/* ===== Display view ===== */
#app {
  position: relative;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--text);
}

/* ---- Themes ---- */
#app[data-theme='departure'] {
  --bg: #0a0a0b; --panel: #141414; --card: #131313;
  --text: #ffb000; --muted: #b07e2e; --dim: #6d5320;
  --accent: #ffb000; --accent2: #ff7a00;
  --line: rgba(255, 176, 0, 0.16); --radar-line: rgba(255, 176, 0, 0.22);
  --num-font: var(--mono);
}
#app[data-theme='radar'] {
  --bg: #001103; --panel: #04220a; --card: #05230b;
  --text: #34ff6a; --muted: #1f9e46; --dim: #147a34;
  --accent: #34ff6a; --accent2: #6dffa0;
  --line: rgba(52, 255, 106, 0.18); --radar-line: rgba(52, 255, 106, 0.28);
  --num-font: var(--mono);
}
#app[data-theme='minimal'] {
  --bg: #0e1116; --panel: #161b22; --card: #161b22;
  --text: #e6edf3; --muted: #8b949e; --dim: #545d68;
  --accent: #4ea1ff; --accent2: #7cc3ff;
  --line: rgba(255, 255, 255, 0.09); --radar-line: rgba(255, 255, 255, 0.16);
  --num-font: var(--mono);
}
#app[data-theme='radar']::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px);
  opacity: 0.5;
}

/* ---- Header ---- */
#hdr {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: clamp(0.5rem, 1.6vh, 1.1rem) clamp(0.8rem, 2vw, 1.6rem);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: 0.18em; font-size: clamp(0.9rem, 1.8vw, 1.4rem); }
.brand .logo { color: var(--accent2); margin-right: 0.35em; }
.ctx { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); min-width: 0; }
.ctx .home { font-size: clamp(0.8rem, 1.5vw, 1.15rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.right { display: flex; align-items: center; gap: 0.7rem; }
.clock { font-family: var(--num-font); font-size: clamp(1rem, 2.4vw, 1.8rem); font-weight: 700; letter-spacing: 0.06em; }
.fs { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; width: 2rem; height: 2rem; line-height: 1; font-size: 1rem; }
.fs:hover { color: var(--text); border-color: var(--accent); }

/* ---- Main layout ---- */
#main {
  flex: 1; min-height: 0; display: grid; gap: clamp(0.5rem, 1.4vw, 1.2rem);
  grid-template-columns: minmax(0, 1fr) clamp(240px, 32vw, 480px);
  padding: clamp(0.5rem, 1.4vh, 1.1rem) clamp(0.8rem, 2vw, 1.6rem);
}
#app.no-side #main { grid-template-columns: minmax(0, 1fr); }

/* ---- Board + cards ---- */
.board { min-height: 0; display: flex; flex-direction: column; gap: clamp(0.4rem, 1vh, 0.8rem); overflow: hidden; }
.flight {
  flex: 1 1 0; min-height: 0; overflow: hidden; container-type: size;
  display: flex; align-items: center; gap: clamp(0.4rem, 1.1vw, 1.1rem);
  padding: clamp(0.4rem, 1.1vh, 1rem) clamp(0.7rem, 1.6vw, 1.3rem);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  border-left: 4px solid var(--fc, var(--accent));
}
/* Card contents scale to each card's own height (cqh) so any row count fits. */
.ac-col { flex: 0 0 auto; width: clamp(48px, 6vw, 92px); display: flex; flex-direction: column; align-items: center; gap: 0.25em; min-width: 0; }
.ac-icon { width: clamp(24px, 44cqh, 56px); height: clamp(24px, 44cqh, 56px); opacity: 0.95; }
.ac-icon svg { width: 100%; height: 100%; display: block; }
.ac-model { font-family: var(--num-font); font-size: clamp(0.5rem, min(12cqh, 1vw), 0.82rem); line-height: 1.05; color: var(--muted); text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }

.ident { flex: 1 1 auto; min-width: 0; }
.flightno {
  font-family: var(--num-font); font-weight: 800; letter-spacing: 0.04em;
  font-size: clamp(0.95rem, min(24cqh, 2.4vw), 2.4rem); line-height: 1.05;
  display: flex; align-items: baseline; gap: 0.5em; overflow: hidden;
}
.flightno .cs { flex: 0 0 auto; } /* callsign never truncates */
.flightno .cs.cs-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-family: system-ui, sans-serif; } /* airline-name title can shrink */
.flightno .airline { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: system-ui, sans-serif; font-weight: 600; font-size: 0.46em; color: var(--muted); letter-spacing: 0; }
.flightno .emerg { flex: 0 0 auto; font-size: 0.42em; color: #ff4d4d; border: 1px solid #ff4d4d; border-radius: 4px; padding: 0 0.3em; text-transform: uppercase; }
.seen-badge { flex: 0 0 auto; font-family: system-ui, sans-serif; font-weight: 700; font-size: 0.4em; letter-spacing: 0.02em; color: var(--accent2); border: 1px solid var(--accent2); border-radius: 999px; padding: 0.05em 0.55em; white-space: nowrap; }
.route { margin-top: 0.2em; font-size: clamp(0.72rem, min(15cqh, 1.4vw), 1.3rem); color: var(--text); display: flex; align-items: baseline; gap: 0.4em; white-space: nowrap; overflow: hidden; }
.route .ap { font-family: var(--num-font); font-weight: 700; letter-spacing: 0.05em; }
.route .arrow { color: var(--accent2); }
.route .cities { color: var(--muted); font-size: 0.72em; overflow: hidden; text-overflow: ellipsis; }
.route.muted { color: var(--muted); }
.route.owner { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.subline { display: flex; align-items: center; gap: 0.5em; min-width: 0; margin-top: 0.22em; }
.subline .route { margin-top: 0; min-width: 0; flex: 1 1 auto; }
.airline-pill {
  flex: 0 0 auto; min-width: 0; max-width: 58%;
  padding: 0.12em 0.7em; border-radius: 999px;
  font-family: system-ui, sans-serif; font-weight: 700;
  font-size: clamp(0.6rem, min(13cqh, 1.15vw), 1rem); line-height: 1.45;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.airline-pill.private { background: transparent; border: 1px solid var(--fc); color: var(--fc); font-weight: 600; }

.metrics { flex: 0 0 auto; display: flex; gap: clamp(0.3rem, 0.85vw, 0.95rem); align-items: center; }
.metric { display: flex; flex-direction: column; align-items: flex-start; }
.metric label { font-size: clamp(0.5rem, min(7cqh, 0.7vw), 0.72rem); letter-spacing: 0.1em; color: var(--dim); text-transform: uppercase; }
.metric span { font-family: var(--num-font); font-weight: 700; font-size: clamp(0.75rem, min(15cqh, 1.25vw), 1.4rem); white-space: nowrap; }

.tail { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: clamp(50px, 6.3vw, 116px); }
.logo-box { width: 100%; height: clamp(30px, 60cqh, 104px); display: flex; align-items: center; justify-content: center; }
.logo-img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px; }
.logo-box svg { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* not-found tracked flight */
.flight.not-found { opacity: 0.72; justify-content: space-between; border-left-color: var(--dim); }
.flight .await { font-family: var(--num-font); color: var(--muted); letter-spacing: 0.14em; font-size: clamp(0.8rem, 16cqh, 1.2rem); }

/* ---- Empty states ---- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.6rem; color: var(--muted); }
.empty .big { font-size: clamp(1.4rem, 4vw, 3rem); font-weight: 800; letter-spacing: 0.08em; color: var(--text); }
.empty .sub { font-size: clamp(0.9rem, 1.8vw, 1.3rem); }
.empty .url { font-family: var(--mono); color: var(--accent); margin-top: 0.4rem; }

/* ---- Cycle mode (single flight, auto-cycling) ---- */
#app[data-layout='cycle'] #main { grid-template-columns: minmax(0, 1fr); }
.cycle {
  height: 100%; display: flex; flex-direction: column; justify-content: center;
  gap: clamp(1rem, 4vh, 3rem); padding: clamp(0.5rem, 3vw, 3rem);
  animation: cyc-in 0.45s ease;
}
@keyframes cyc-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.cyc-head { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2.5rem); min-width: 0; }
.cyc-icon { flex: 0 0 auto; width: clamp(48px, min(15vh, 13vw), 170px); height: clamp(48px, min(15vh, 13vw), 170px); }
.cyc-icon svg { width: 100%; height: 100%; display: block; }
.cyc-title { flex: 1 1 auto; min-width: 0; }
.cyc-name { font-family: var(--num-font); font-weight: 800; font-size: clamp(1.8rem, min(9vh, 7vw), 6rem); line-height: 1; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: baseline; gap: 0.35em; }
.cyc-sub { display: flex; align-items: center; gap: 0.6em; margin-top: 0.4em; font-size: clamp(0.9rem, min(3.6vh, 2.6vw), 2.4rem); min-width: 0; }
.cyc-sub .route { font-size: 1em; min-width: 0; }
.cyc-sub .airline-pill { font-size: 0.62em; }
.cyc-model { margin-top: 0.35em; color: var(--muted); font-family: var(--num-font); font-size: clamp(0.8rem, 2.2vh, 1.5rem); }
.cyc-logo { flex: 0 0 auto; display: flex; align-items: center; }
.cyc-logo .logo-box { height: clamp(48px, 13vh, 140px); }
.cyc-logo .logo-img { background: #fff; border-radius: 10px; padding: 6px; max-height: 100%; max-width: clamp(90px, 18vw, 240px); object-fit: contain; }
.cyc-logo svg { max-height: clamp(48px, 13vh, 140px); border-radius: 12px; }
.cyc-metrics { display: flex; justify-content: space-between; gap: clamp(0.5rem, 2vw, 2rem); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: clamp(0.8rem, 3vh, 2rem) 0; }
.cyc-metric { display: flex; flex-direction: column; gap: 0.3em; min-width: 0; }
.cyc-metric label { font-size: clamp(0.55rem, 1.6vh, 1rem); letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; }
.cyc-metric span { font-family: var(--num-font); font-weight: 700; font-size: clamp(1rem, min(5vh, 3.4vw), 3.2rem); white-space: nowrap; }
.cyc-progress { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.cyc-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--line); }
.cyc-dot.on { background: var(--fc, var(--accent)); }

/* ---- Side panel: map / radar ---- */
.side { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-height: 0; }
.map { position: absolute; inset: 0; background: #0b1020; }
.leaflet-container { background: #0b1020; font: inherit; }
.leaflet-control-attribution { font-size: 9px; background: rgba(0,0,0,0.5); color: #888; }
.leaflet-control-attribution a { color: #aaa; }
.radar-canvas { position: absolute; inset: 0; margin: auto; aspect-ratio: 1 / 1; max-width: 100%; max-height: 100%; }
.range { position: absolute; bottom: 0.5rem; right: 0.7rem; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; color: var(--muted); z-index: 400; }

/* ---- Map plane markers ---- */
.plane-div { background: none !important; border: none !important; }
.pm { position: relative; width: 42px; height: 42px; }
.pm-ico { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)); }
.pm-ico svg { width: 26px; height: 26px; }
.pm-lbl { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 1px; font: 700 9px/1 var(--mono); color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; }

/* ---- Appearance alert ---- */
.alert {
  position: absolute; left: 50%; bottom: 9%; transform: translate(-50%, 24px);
  display: flex; align-items: center; gap: 0.5em; z-index: 30;
  background: var(--accent); color: #06121f;
  padding: 0.7em 1.4em; border-radius: 999px; font-weight: 800;
  font-size: clamp(0.9rem, 2vw, 1.4rem); letter-spacing: 0.01em;
  box-shadow: 0 10px 34px rgba(0,0,0,0.55); opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.alert.show { opacity: 1; transform: translate(-50%, 0); }
.alert-ico { font-size: 1.1em; }

/* ---- Footer ---- */
#foot {
  display: flex; align-items: center; gap: 1.2rem;
  padding: clamp(0.3rem, 1vh, 0.7rem) clamp(0.8rem, 2vw, 1.6rem);
  border-top: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); font-size: clamp(0.65rem, 1.3vw, 0.9rem); letter-spacing: 0.06em;
}
#foot .count { margin-left: auto; }
.status .dot { margin-right: 0.4em; }

/* ---- ATC audio ---- */
.audio-bar { display: flex; align-items: center; gap: 0.9rem; min-width: 0; overflow: hidden; }
.ach { display: inline-flex; align-items: center; gap: 0.35em; white-space: nowrap; }
.audio-gate {
  position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); z-index: 25;
  background: var(--accent); color: #06121f; border: none; cursor: pointer;
  padding: 0.7em 1.4em; border-radius: 999px; font-weight: 800;
  font-size: clamp(0.9rem, 2vw, 1.3rem); box-shadow: 0 10px 34px rgba(0,0,0,0.55);
}
.audio-gate:hover { filter: brightness(1.06); }

/* ---- Kiosk ---- */
body.idle #app { cursor: none; }
body.idle .fs { opacity: 0; }

/* ---- Narrow (portrait / small screens) ---- */
@media (max-width: 820px) {
  #main, #app.no-side #main { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .flight { flex-wrap: wrap; gap: 0.3rem 0.8rem; }
  .metrics { flex-wrap: wrap; }
  .tail { flex-direction: row; gap: 0.5em; }
}

/* ---- Flight Wall modern live board ---- */
#app[data-theme='departure'] {
  --bg: #09121b; --panel: #0d1823; --card: #121f2b;
  --text: #edf5fa; --muted: #a5b6c3; --dim: #718594;
  --accent: #49d6c5; --accent2: #82eee0;
  --line: rgba(151, 183, 200, 0.18); --radar-line: rgba(73, 214, 197, 0.27);
  --num-font: var(--mono);
}
.flight {
  gap: clamp(0.6rem, 1.3vw, 1.35rem);
  padding: clamp(0.55rem, 1.2vh, 1.1rem) clamp(0.7rem, 1.4vw, 1.4rem);
  background: linear-gradient(115deg, color-mix(in srgb, var(--fc) 8%, var(--card)), var(--card) 48%);
  border: 1px solid var(--line);
  border-left: 5px solid var(--fc, var(--accent));
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.ac-col { width: clamp(58px, 7vw, 104px); }
.ac-icon { width: clamp(42px, 52cqh, 72px); height: clamp(42px, 52cqh, 72px); }
.ident { min-width: 0; overflow: hidden; }
.flight-head { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; min-width: 0; }
.flightno { font-size: clamp(1.3rem, min(27cqh, 2.6vw), 2.8rem); gap: 0.4em; }
.flightno .cs { color: var(--text); }
.airline-name { flex: 0 1 auto; min-width: 0; max-width: 42%; padding: 0.26em 0.75em; border-radius: 999px; background: color-mix(in srgb, var(--fc) 76%, #10202a); color: #fff; font: 700 clamp(0.76rem, min(14cqh, 1.15vw), 1.08rem)/1.2 system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.registration { margin-top: 0.22em; color: var(--muted); font: 600 clamp(0.7rem, min(13cqh, 1vw), 0.98rem)/1.3 system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.registration span { color: var(--dim); padding: 0 0.2em; }
.route { margin-top: 0.28em; display: flex; align-items: center; gap: 0.55em; white-space: normal; overflow: visible; color: var(--text); font-size: clamp(0.78rem, min(15cqh, 1.15vw), 1.12rem); }
.airport { display: inline-flex; align-items: baseline; gap: 0.35em; min-width: 0; }
.airport .ap { flex: 0 0 auto; font-size: 1em; }
.airport-name { min-width: 0; color: var(--muted); font: 500 0.88em/1.2 system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route .arrow { flex: 0 0 auto; color: var(--accent2); font-size: 1.2em; }
.owner-line { color: var(--muted); font-size: 0.82em; margin-top: 0.1em; }
.special-badge { flex: 0 0 auto; font: 800 clamp(0.48rem, min(9cqh, 0.68vw), 0.68rem)/1 system-ui, sans-serif; letter-spacing: 0.08em; border-radius: 999px; padding: 0.38em 0.65em; }
.heli-badge { color: #0b1a1c; background: #8ce9c1; }
.gov-badge { color: #fff; background: #a84557; }
.approach { display: flex; align-items: baseline; gap: 0.55em; margin-top: 0.32em; color: var(--accent2); font-family: var(--mono); white-space: nowrap; }
.approach-kicker { color: var(--muted); font: 700 clamp(0.48rem, min(8cqh, 0.62vw), 0.65rem)/1 system-ui, sans-serif; letter-spacing: 0.09em; }
.approach strong { font-size: clamp(0.8rem, min(15cqh, 1.2vw), 1.16rem); }
.approach-distance { color: var(--muted); font-size: clamp(0.57rem, min(10cqh, 0.75vw), 0.78rem); }
.metrics { gap: clamp(0.32rem, 0.7vw, 0.75rem); }
.metric label { color: var(--dim); font-size: clamp(0.46rem, min(7cqh, 0.58vw), 0.62rem); }
.metric span { color: #c7d4dc; font-size: clamp(0.64rem, min(12cqh, 0.92vw), 0.98rem); }
.tail { width: clamp(56px, 7vw, 104px); }
.logo-box { height: clamp(42px, 54cqh, 76px); }
.logo-img { padding: 5px; border-radius: 10px; }
.flight.highlight-heli { border-color: rgba(140, 233, 193, 0.56); border-left-color: #8ce9c1; }
.flight.highlight-government { border-color: rgba(222, 109, 129, 0.58); border-left-color: #de6d81; }
.flight.highlight-heli.highlight-government { border-left-color: #f2be68; }
.side { background: #e9edf0; border-color: rgba(255, 255, 255, 0.4); }
.map, .leaflet-container { background: #e9edf0; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,0.86); color: #29333a; }
.leaflet-control-attribution a { color: #176b94; }
.pm { width: 54px; height: 54px; }
.pm-ico svg { width: 38px; height: 38px; }
.pm-lbl { font-size: 11px; }

@media (max-width: 1100px) {
  .metrics { gap: 0.3rem; }
  .metric label { font-size: 0.48rem; }
  .metric span { font-size: 0.68rem; }
  .tail { display: none; }
}
@media (max-width: 820px) {
  .flight { flex-wrap: nowrap; }
  .ac-col { width: 56px; }
  .ac-icon { width: 46px; height: 46px; }
  .metrics { display: none; }
  .airline-name { max-width: 48%; }
  .route { flex-wrap: wrap; }
  .airport-name { white-space: normal; }
}

