:root {
  --bg: #100a1f;
  --bg-top: #100a1f;
  --bg-mid: #1c1030;
  --bg-low: #3a1a3f;
  --sky-glow: rgba(250, 160, 80, 0.85);
  --sky-mid: rgba(214, 90, 74, 0.7);
  --sky-high: rgba(112, 44, 96, 0.55);
  --sky-corner: rgba(78, 46, 120, 0.55);
  --ink-rgb: 247, 233, 218;
  --glass-rgb: 255, 245, 235;
  --ink: rgb(var(--ink-rgb));
  --ink-2: rgba(var(--ink-rgb), 0.62);
  --ink-3: rgba(var(--ink-rgb), 0.36);
  --amber: #f2a45c;
  --rose: #e8735b;
  --contrast: #2a1633;
  --glass: rgba(var(--glass-rgb), 0.055);
  --edge: rgba(var(--glass-rgb), 0.11);
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter Tight', 'Inter', -apple-system, 'Helvetica Neue', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(90% 55% at 50% 112%, var(--sky-glow) 0%, var(--sky-mid) 28%, var(--sky-high) 55%, transparent 78%),
    radial-gradient(70% 40% at 20% -10%, var(--sky-corner) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 45%, var(--bg-low) 100%);
}
.sky::after {
  content: ''; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: 0.06; mix-blend-mode: overlay;
}

#globe { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

#app {
  position: relative; z-index: 1;
  height: 100dvh; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 14px) 18px calc(env(safe-area-inset-bottom) + 14px);
}

.top { display: flex; align-items: center; justify-content: space-between; }
.wordmark {
  font-family: var(--serif); font-style: italic; font-size: 26px; letter-spacing: 0.01em;
  color: var(--ink); text-decoration: none;
}
.units { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--glass); border: 1px solid var(--edge); }
.units button {
  appearance: none; border: 0; background: transparent; color: var(--ink-2);
  font: 500 12px/1 var(--sans); letter-spacing: 0.06em; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.units button.on { background: var(--ink); color: var(--contrast); }

/* search */
.search { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding-bottom: 14vh; }
.tagline { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 12vw, 54px); line-height: 1.02; margin: 0; letter-spacing: -0.01em; }
.tagline em { color: var(--amber); }
#form { display: flex; gap: 10px; }
#form input {
  flex: 1; min-width: 0; appearance: none; border: 1px solid var(--edge); background: var(--glass);
  color: var(--ink); font: 500 30px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 18px 20px; border-radius: 18px; outline: none; font-variant-numeric: tabular-nums;
  transition: border-color 0.2s, background 0.2s;
}
#form input::placeholder { color: var(--ink-3); }
#form input:focus { border-color: var(--amber); background: rgba(var(--glass-rgb), 0.08); }
#form button {
  appearance: none; border: 0; width: 66px; border-radius: 18px; cursor: pointer;
  background: linear-gradient(160deg, var(--amber), var(--rose)); color: var(--contrast);
  display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.msg { min-height: 1.4em; margin: 0; color: var(--amber); font-size: 14px; }
.recents { display: flex; flex-wrap: wrap; gap: 8px; }
.recents button {
  appearance: none; border: 1px solid var(--edge); background: transparent; color: var(--ink-2);
  font: 500 13px/1 var(--sans); letter-spacing: 0.1em; padding: 9px 13px; border-radius: 999px; cursor: pointer;
}

/* loading */
.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding-bottom: 12vh; }
.loading-ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1.5px solid rgba(var(--ink-rgb), 0.14); border-top-color: var(--amber);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--serif); font-size: 26px; color: var(--ink-2); }
.loading-text span { color: var(--ink); letter-spacing: 0.04em; }

/* flight */
.flight { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; margin-top: 16px; min-height: 0; }
.label { font-size: 11px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); }
.num, .clock, .code, .pct, .ident { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

.ident-row { display: flex; justify-content: space-between; align-items: flex-start; }
.ident { font-size: 30px; font-weight: 500; letter-spacing: 0.04em; line-height: 1; }
.phase { font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); vertical-align: middle; margin-left: 6px; }
.sub { margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.sub span + span::before { content: ' · '; }
.change {
  appearance: none; border: 1px solid var(--edge); background: var(--glass); color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 14px;
}

.route { position: relative; display: flex; justify-content: space-between; padding-bottom: 34px; }
.port .code { font-size: 36px; font-weight: 500; letter-spacing: 0.04em; line-height: 1; }
.port .city { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.port .when { font-size: 13px; color: var(--ink); margin-top: 4px; }
.gate:not(:empty)::before { content: ' · '; color: var(--ink-3); }
.gate { color: var(--ink-2); }
.tz { color: var(--ink-3); font-size: 11px; letter-spacing: 0.06em; margin-left: 4px; }
.port.right { text-align: right; }
.track { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; }
.bar { position: absolute; left: 0; right: 0; top: 12px; height: 2px; background: rgba(var(--ink-rgb), 0.16); border-radius: 2px; }
.fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--rose), var(--amber)); border-radius: 2px; box-shadow: 0 0 12px var(--amber); }
.plane { position: absolute; top: 2px; left: 0%; transform: translateX(-50%) rotate(90deg); color: var(--ink); filter: drop-shadow(0 0 8px var(--amber)); }
.pct { position: absolute; right: 0; top: 18px; font-size: 11px; font-weight: 500; color: var(--ink-2); letter-spacing: 0.06em; }

.hero { text-align: center; padding: 6px 0; }
.clock { display: flex; justify-content: center; align-items: baseline; gap: 2px; margin-top: 8px; line-height: 1; }
#hero-main { font-size: clamp(52px, 17vw, 74px); font-weight: 300; letter-spacing: -0.02em; }
.ms { font-size: clamp(18px, 5.4vw, 24px); color: var(--amber); font-weight: 400; }
.hero-sub { margin-top: 10px; font-size: 13px; color: var(--ink-2); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.stat { min-width: 0; overflow: hidden; background: linear-gradient(0deg, rgba(var(--glass-rgb), 0.085), rgba(var(--glass-rgb), 0.03)); border-radius: 20px; padding: 16px 16px 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.stat .num { margin-top: 8px; font-size: clamp(22px, 6.4vw, 30px); font-weight: 400; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.stat .unit { font-size: 12px; color: var(--ink-2); margin-left: 5px; letter-spacing: 0.06em; }
.trend { color: var(--amber); letter-spacing: 0; }

.foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-2); letter-spacing: 0.04em; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #74d99a; margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 8px #74d99a; animation: pulse 2s ease-in-out infinite; }
.dot.stale { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: none; }
.dot.err { background: var(--rose); box-shadow: none; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.flight.in { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (max-height: 700px) {
  .flight { gap: 8px; margin-top: 8px; }
  #hero-main { font-size: clamp(44px, 14vw, 60px); }
  .port .code { font-size: 30px; }
  .stat { padding: 10px 12px 9px; }
}
