:root {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #17223a;
  --line: #24314d;
  --text: #e6ecf7;
  --muted: #8b99b5;
  --accent: #38bdf8;
  --accent-ink: #04121f;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; font-size: 14px; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- header / search ---------- */
.top {
  display: flex; align-items: center; gap: 20px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.logo { color: var(--accent); }
.search { display: flex; align-items: stretch; gap: 8px; flex: 1; flex-wrap: wrap; }
.field {
  position: relative; flex: 1 1 180px; min-width: 150px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px;
}
.field:focus-within { border-color: var(--accent); }
.field label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input { width: 100%; border: 0; outline: 0; background: transparent; padding: 2px 40px 2px 0; font-size: 15px; }
.field.date { flex: 0 1 160px; min-width: 140px; }
.field.date input { padding-right: 0; }
.field .code { position: absolute; right: 12px; bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.swap {
  align-self: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); margin: 0 -4px; z-index: 1;
}
.swap:hover { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; padding: 0 4px; }
.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 0 24px; font-weight: 700; min-height: 44px;
}
.primary:hover { filter: brightness(1.1); }
.suggest {
  position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); z-index: 1000;
  list-style: none; margin: 0; padding: 4px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px #0008;
  max-height: 320px; overflow: auto;
}
.suggest:empty { display: none; }
.suggest li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggest li.active, .suggest li:hover { background: var(--line); }
.suggest small { color: var(--muted); }
.suggest b { color: var(--accent); font-size: 12px; }
.suggest .ap { padding-left: 24px; }

/* ---------- layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 1fr 440px; min-height: 0; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0a0f1a; }
.panel { display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); min-height: 0; }

.map-status, .legend {
  position: absolute; z-index: 500; background: #0b1220e6; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--muted); backdrop-filter: blur(6px);
}
.map-status { top: 12px; left: 56px; display: flex; align-items: center; gap: 8px; }
.map-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.map-status.ok .dot { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
.map-status.err .dot { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #34d39988; } 70% { box-shadow: 0 0 0 8px #34d39900; } 100% { box-shadow: 0 0 0 0 #34d39900; } }
.legend { bottom: 24px; left: 12px; display: flex; align-items: center; gap: 6px; }
.legend .grad { width: 90px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #fb923c, #facc15, #4ade80, #38bdf8, #a78bfa); }
.legend small:last-child { margin-left: -2px; }

/* aircraft markers */
.ac-icon { background: none; border: 0; }
.ac-icon svg { width: 22px; height: 22px; display: block; filter: drop-shadow(0 1px 2px #000a); transition: transform .4s; }
.ac-icon.sel svg { width: 30px; height: 30px; margin: -4px; filter: drop-shadow(0 0 6px #fff); }
.ac-icon.dim { opacity: .35; }
.ap-icon { background: var(--accent); border: 3px solid var(--bg); border-radius: 50%; box-shadow: 0 0 0 2px var(--accent); }
.leaflet-tooltip.ap-label { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font-weight: 600; box-shadow: none; }
.leaflet-tooltip.ap-label::before { display: none; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { background: #0b1220b0 !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }

/* plane card */
.plane-card {
  position: absolute; z-index: 600; right: 12px; bottom: 24px; width: 340px; max-width: calc(100% - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 16px 40px #000a;
}
.pc-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.pc-head h3 { margin: 0; font-size: 20px; }
.pc-head p { margin: 2px 0 0; color: var(--muted); }
.pc-close { background: none; border: 0; font-size: 22px; color: var(--muted); line-height: 1; padding: 0 4px; }
.pc-route { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin: 14px 0 6px; }
.pc-route .ap b { display: block; font-size: 22px; }
.pc-route .ap small { color: var(--muted); }
.pc-route .ap:last-child { text-align: right; }
.pc-route .mid { color: var(--accent); font-size: 18px; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.progress i { display: block; height: 100%; background: var(--accent); }
.pc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-grid div { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.pc-grid small { display: block; color: var(--muted); font-size: 11px; }
.pc-grid b { font-size: 14px; }
.pc-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  text-align: center; text-decoration: none; color: var(--text);
}
.btn:hover, .btn.on { border-color: var(--accent); color: var(--accent); }

/* ---------- panel ---------- */
.tabs { display: flex; padding: 8px 8px 0; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; background: none; border: 0; padding: 10px 6px; border-bottom: 2px solid transparent;
  color: var(--muted); font-weight: 600;
}
.tabs button.active { color: var(--text); border-color: var(--accent); }
.tabs b { font-size: 11px; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 7px; margin-left: 4px; font-weight: 600; }
.tabs b:empty { display: none; }
.tab-body { flex: 1; overflow: auto; padding: 14px; min-height: 0; }
.privacy { font-size: 11px; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--line); line-height: 1.45; }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; line-height: 1.5; }
.empty h4 { color: var(--text); margin: 0 0 6px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
.chip:hover, .chip.on { border-color: var(--accent); color: var(--accent); }
.note {
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 12px 14px; color: var(--muted); line-height: 1.5; margin-bottom: 12px;
}
.note b { color: var(--text); }
.note code { color: var(--accent); }
.note .btn { display: inline-block; margin-top: 8px; }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--bad); }

/* price calendar */
.cal { margin-bottom: 14px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-head b { text-transform: capitalize; }
.cal-head button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; width: 30px; height: 28px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 80px; }
.bar {
  flex: 1; min-width: 0; background: var(--line); border: 0; border-radius: 3px 3px 0 0; padding: 0;
  position: relative;
}
.bar.has { background: #38bdf855; }
.bar.min { background: var(--good); }
.bar.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.bar:hover { background: var(--accent); }
.cal-days { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; margin-top: 4px; }
.cal-hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.cal-hint b { color: var(--good); }

.sort { display: flex; gap: 6px; margin-bottom: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.sort .chip { padding: 4px 10px; font-size: 12px; }

.ticket {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px;
}
.ticket:hover { border-color: #38bdf888; }
.t-airline { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.t-airline img { width: 24px; height: 24px; border-radius: 6px; background: #fff; }
.t-times { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.t-times b { font-size: 18px; }
.t-times span { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.tag.good { background: #34d39922; color: var(--good); }
.t-price { text-align: right; }
.t-price b { display: block; font-size: 20px; margin-bottom: 6px; }
.t-price a {
  display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 700;
  text-decoration: none; border-radius: 8px; padding: 6px 14px; font-size: 13px;
}
.best { border-color: var(--good); }
.best .t-price b { color: var(--good); }

/* board */
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; background: none; border: 0; padding: 7px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--line); color: var(--text); }
.board-row {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.board-row .tm b { display: block; font-size: 15px; }
.board-row .tm s { color: var(--muted); font-size: 11px; }
.board-row .tm em { display: block; font-style: normal; color: var(--warn); font-size: 12px; }
.board-row .dest b { display: block; }
.board-row .dest small { color: var(--muted); }
.st { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.st.ok { background: #34d39922; color: var(--good); }
.st.warn { background: #fbbf2422; color: var(--warn); }
.st.bad { background: #f8717122; color: var(--bad); }
.st.air { background: #38bdf822; color: var(--accent); }
.board-row.past { opacity: .5; }

/* sky list */
.filter {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; outline: 0; margin-bottom: 8px;
}
.filter:focus { border-color: var(--accent); }
.sky-list { list-style: none; margin: 0; padding: 0; }
.sky-list li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 9px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.sky-list li:hover, .sky-list li.sel { background: var(--surface-2); }
.sky-list li b { font-size: 14px; }
.sky-list li small { color: var(--muted); }
.sky-list .alt { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; }

.privacy a { color: var(--accent); }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .top { gap: 10px; padding: 10px 12px; }
  .search { gap: 6px; }
  .field { flex: 1 1 40%; min-width: 0; }
  .swap { display: none; }
  .field.date { flex: 1 1 30%; }
  .check { font-size: 12px; }
  .primary { flex: 0 0 auto; padding: 0 18px; }
  .brand { display: none; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 45vh auto; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .tab-body { overflow: visible; }
  body { height: auto; }
  html, body { height: auto; }
  .plane-card { left: 12px; right: 12px; width: auto; bottom: 12px; }
  .legend { display: none; }
}

/* ---------- terms page ---------- */
body.doc { height: auto; min-height: 100%; }
.doc .top { justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.doc .brand { color: var(--text); text-decoration: none; display: block; }
.doc .back { flex: 0 0 auto; padding: 8px 14px; }
.doc-body { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; line-height: 1.65; font-size: 15px; }
.doc-body h1 { font-size: 30px; margin: 0 0 4px; }
.doc-body h2 { font-size: 19px; margin: 32px 0 8px; scroll-margin-top: 80px; }
.doc-body p { margin: 0 0 10px; color: #c9d3e6; }
.doc-body ul { margin: 0 0 10px; padding-left: 22px; color: #c9d3e6; }
.doc-body li { margin-bottom: 4px; }
.doc-body b { color: var(--text); }
.doc-body code { color: var(--accent); }
.doc-date { color: var(--muted) !important; font-size: 13px; }
.doc-callout {
  margin: 20px 0; padding: 16px 18px; border-radius: var(--radius);
  background: #38bdf814; border: 1px solid #38bdf855; color: #c9d3e6;
}
.doc-toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 16px; margin-bottom: 8px; }
.doc-toc a { color: var(--accent); text-decoration: none; font-size: 14px; }
.doc-toc a:hover { text-decoration: underline; }
.doc-foot { margin-top: 36px; }
.doc-foot .primary { display: inline-flex; align-items: center; text-decoration: none; }
@media (max-width: 900px) { .doc .brand { display: block; } }
