/* SimAirport — Popsicle (personal-app house system).
   Every colour is a token; nothing below hardcodes a hex outside :root blocks,
   so both themes and the L/D/A toggle come for free. */

:root {
  --bg: #f6f5fa;
  --surface: #ffffff;
  --surface-2: #efedf8;
  --border: #e2def0;
  --ink: #241f33;
  --muted: #6f6885;
  --accent: #e2570e;
  --accent-ink: #ffffff;
  --teal: #0a9d90;
  --grape: #6b4de6;
  --danger: #d64545;
  --gold: #e0a400;
  --warn: #e0a400;
  --glass: rgba(255, 255, 255, .82);
  --shadow: 0 6px 22px rgba(36, 31, 51, .12);
  --shadow-lg: 0 14px 40px rgba(36, 31, 51, .18);
  --radius: 15px;
  --radius-sm: 10px;
  --chrome-pad: 10px;
}

:root[data-theme="dark"] {
  --bg: #191625;
  --surface: #241f33;
  --surface-2: #2e2840;
  --border: #3b3352;
  --ink: #f2eef9;
  --muted: #a69dba;
  --accent: #ff8a3d;
  --accent-ink: #2a1206;
  --teal: #2fd4c4;
  --grape: #ab8dff;
  --danger: #ff6b78;
  --gold: #e0b24d;
  --warn: #e0b24d;
  --glass: rgba(36, 31, 51, .80);
  --shadow: 0 10px 26px rgba(0, 0, 0, .42);
  --shadow-lg: 0 18px 46px rgba(0, 0, 0, .55);
}

/* The `hidden` attribute is only a UA-stylesheet rule, so ANY author
   `display:` on the same element outranks it and the element stays on screen
   while every test asserting `el.hidden === true` still passes. This one line
   is why panels in this app actually hide. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* The page itself never scrolls — this is an app, not a document. Anything
     that overflows scrolls inside its own container. */
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", Nunito, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { position: fixed; inset: 0; touch-action: none; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
/* Desktop only: an open hand when a drag would move the map, a closed one while
   it is being dragged. Touch devices have no cursor, which is exactly why they
   get the visible hand BUTTON instead. */
#stage.can-pan { cursor: grab; }
#stage.panning { cursor: grabbing; }

/* ============================ Boot splash ============================ */
#boot {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .45s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
.boot-card { text-align: center; padding: 24px; max-width: 82vw; }
.boot-logo { font-size: clamp(44px, 10vw, 74px); line-height: 1; }
.boot-title { font-size: clamp(22px, 5vw, 32px); font-weight: 700; margin-top: 10px; letter-spacing: -.02em; }
.boot-sub { color: var(--muted); margin-top: 8px; font-size: 15px; }
.boot-rescue { margin-top: 22px; }
.boot-rescue p { color: var(--muted); font-size: 14px; }

/* ============================ Shared bits ============================ */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); border-radius: var(--radius-sm); padding: 9px 14px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.96); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn[disabled] { opacity: .45; cursor: default; }

.icon-btn {
  appearance: none; border: 1px solid var(--border); background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--ink); border-radius: 12px; width: 38px; height: 38px;
  font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: transform .08s ease, background .15s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }

/* ============================ Top bar ============================ */
#topbar {
  position: fixed; z-index: 20;
  top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + var(--chrome-pad))
           calc(env(safe-area-inset-right, 0px) + var(--chrome-pad))
           var(--chrome-pad)
           calc(env(safe-area-inset-left, 0px) + var(--chrome-pad));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; }
.tb-mid { display: flex; align-items: center; gap: 8px; margin: 0 auto; }

.brand {
  display: flex; align-items: center; gap: 8px;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 7px 12px; box-shadow: var(--shadow);
}
.brand-mark { font-size: 17px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }

.clock-chip, .funds-chip {
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px 12px; display: flex; align-items: baseline; gap: 8px;
  font-variant-numeric: tabular-nums;
}
.clock-time { font-weight: 700; font-size: 16px; }
.clock-day { font-size: 12px; color: var(--muted); }
.funds-chip { font-weight: 700; font-size: 15px; color: var(--teal); }

.speed-pill, .theme-pill {
  display: flex; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow);
}
.speed-pill button, .theme-pill button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 8px 10px; min-width: 34px; transition: background .15s ease, color .15s ease;
}
.speed-pill button.on, .theme-pill button.on { background: var(--accent); color: var(--accent-ink); }

/* Narrow phones: the three top-bar clusters do not fit on one row at 390 px —
   measured, the right-hand cluster started at x=442 on a 390 px viewport, which
   puts the SETTINGS BUTTON off-screen entirely with no way to reach it. Rather
   than shrink everything, the least-used controls leave the bar: the theme
   pill is already in Settings > Appearance, and the speed pill moves to a
   thumb-reachable column on the left, mirroring the camera controls. */
@media (max-width: 640px) {
  .brand-name { display: none; }
  .brand { padding: 7px 11px; }
  .clock-day { display: none; }
  #theme-pill { display: none; }
  #speed-pill {
    position: fixed;
    left: calc(env(safe-area-inset-left, 0px) + var(--chrome-pad));
    bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    flex-direction: column;
  }
  #speed-pill button { padding: 9px 8px; min-width: 40px; }
  /* The hint bar sits between the two thumb columns, so keep it clear of both. */
  #hintbar { max-width: calc(100vw - 124px); }
}

/* ============================ Hint bar ============================ */
#hintbar {
  position: fixed; z-index: 18;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  max-width: min(94vw, 620px);
  display: flex; align-items: center; gap: 9px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
  padding: 8px 15px; font-size: 13.5px; color: var(--muted);
}
#hintbar.bad { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); color: var(--danger); }
.hint-icon { font-size: 15px; }
.hint-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint-cost { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
#hintbar.bad .hint-cost { color: var(--danger); }

/* ============================ Toolbar ============================ */
/* Narrow screens: a bottom rail. Wide screens: a left column. Either way the
   palette scrolls INSIDE ITSELF and never scrolls the page. */
#toolbar {
  position: fixed; z-index: 19;
  left: calc(env(safe-area-inset-left, 0px) + var(--chrome-pad));
  right: calc(env(safe-area-inset-right, 0px) + var(--chrome-pad));
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--chrome-pad));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.tool-scroll {
  display: flex; gap: 6px; padding: 7px;
  max-width: 100%; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  scroll-snap-type: x proximity;
}
.tool-scroll::-webkit-scrollbar { display: none; }

.tool {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  font: inherit; cursor: pointer; border-radius: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 9px; min-width: 62px; scroll-snap-align: center;
  transition: background .15s ease, transform .08s ease;
}
.tool:active { transform: scale(.94); }
.tool .t-icon { font-size: 19px; line-height: 1.1; }
.tool .t-label { font-size: 10.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tool.on { background: var(--accent); }
.tool.on .t-label { color: var(--accent-ink); }
.tool.on .t-icon { filter: saturate(0) brightness(3); }

.tool-variants {
  display: flex; gap: 5px; padding: 5px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow);
}
.variant {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; padding: 6px 12px;
  border-radius: 9px; cursor: pointer;
}
.variant.on { background: var(--grape); color: #fff; }

@media (min-width: 860px) {
  #toolbar {
    top: calc(env(safe-area-inset-top, 0px) + 72px);
    bottom: auto; right: auto;
    align-items: flex-start;
  }
  .tool-scroll {
    flex-direction: column; max-height: min(64vh, 560px);
    overflow-x: hidden; overflow-y: auto;
  }
  .tool { flex-direction: row; gap: 9px; min-width: 148px; justify-content: flex-start; padding: 9px 11px; }
  .tool .t-label { font-size: 12.5px; }
  .tool-variants { flex-direction: column; }
  #hintbar { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--chrome-pad)); }
}

/* ============================ Camera controls ============================ */
#camctl {
  position: fixed; z-index: 19;
  right: calc(env(safe-area-inset-right, 0px) + var(--chrome-pad));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
  display: flex; flex-direction: column; gap: 6px;
}
.cam-btn {
  appearance: none; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--ink); font-size: 17px; cursor: pointer; box-shadow: var(--shadow);
  display: grid; place-items: center; transition: transform .08s ease, background .15s ease;
}
.cam-btn:active { transform: scale(.9); }
.cam-btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
@media (min-width: 860px) {
  #camctl { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--chrome-pad)); flex-direction: row; }
}

/* ============================ Inspector ============================ */
#inspector {
  position: fixed; z-index: 21;
  right: calc(env(safe-area-inset-right, 0px) + var(--chrome-pad));
  top: calc(env(safe-area-inset-top, 0px) + 66px);
  width: min(300px, calc(100vw - 2 * var(--chrome-pad)));
  max-height: min(52vh, 440px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
}
.insp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px;
}
.insp-body { padding: 12px 14px 14px; overflow-y: auto; font-size: 13.5px; }
.insp-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.insp-row span:first-child { color: var(--muted); }
.insp-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.insp-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================ Settings drawer ============================ */
#scrim { position: fixed; inset: 0; z-index: 29; background: rgba(20, 16, 30, .42); }
#settings-panel {
  position: fixed; z-index: 30; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.sp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 17px;
}
/* The settings body is the ONE region allowed to scroll — the native-app
   fallback, with the header pinned. */
.sp-body { overflow-y: auto; padding: 10px 14px 24px; -webkit-overflow-scrolling: touch; }

/* Collapsed-by-default sections, so this never becomes a wall of cards. */
.sp-body details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
}
.sp-body summary {
  cursor: pointer; padding: 13px 15px; font-weight: 700; font-size: 14.5px;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.sp-body summary::-webkit-details-marker { display: none; }
.sp-body summary::after { content: "⌄"; color: var(--muted); transition: transform .2s ease; }
.sp-body details[open] summary::after { transform: rotate(180deg); }
.sp-body details > *:not(summary) { padding-left: 15px; padding-right: 15px; }
.sp-body details > *:last-child { padding-bottom: 14px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; font-size: 14px;
}
.row + .row { border-top: 1px solid var(--border); }
.row select, .row input[type="time"] {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--ink); border-radius: 9px; padding: 7px 10px; font: inherit; font-size: 13.5px;
}
.row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

.sp-group { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding-top: 4px; }
.stat {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px;
}
.stat .s-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s-lab { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sp-note { font-size: 13px; color: var(--muted); padding-top: 4px; padding-bottom: 8px; }
.sp-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 8px; }
.keys { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--muted); line-height: 1.75; }
.keys b { color: var(--ink); }

/* ============================ Flights & ops ============================ */
#flights-panel {
  position: fixed; z-index: 30; top: 0; right: 0; bottom: 0;
  width: min(430px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.ops-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 10px 14px 4px;
}
.ops-cell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 9px; }
.ops-cell .o-val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ops-cell .o-lab { font-size: 10px; color: var(--muted); margin-top: 1px; }
.ops-cell.good .o-val { color: var(--teal); }
.ops-cell.warn .o-val { color: var(--warn); }
.ops-cell.bad .o-val { color: var(--danger); }

.board-tabs { display: flex; gap: 6px; padding: 8px 14px 10px; }
.board-tabs button {
  flex: 1; appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
  padding: 8px 6px; border-radius: var(--radius-sm); cursor: pointer;
}
.board-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.flight-row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); margin-bottom: 6px;
}
.flight-row .f-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.flight-row .f-time small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; text-decoration: line-through; }
.flight-row .f-code { font-weight: 700; font-size: 13.5px; }
.flight-row .f-city { font-size: 12px; color: var(--muted); }
.flight-row .f-right { text-align: right; }
.flight-row .f-gate { font-weight: 700; font-size: 13px; }
.flight-row .f-status { font-size: 10.5px; color: var(--muted); text-transform: capitalize; }
.flight-row.late { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.flight-row.late .f-status { color: var(--danger); }
.flight-row.boarding .f-status { color: var(--teal); font-weight: 700; }
.flight-row .f-bar { width: 3px; height: 30px; border-radius: 2px; }

.prob-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--surface); margin-bottom: 6px; font-size: 13px;
}
.prob-row .p-n { font-weight: 700; color: var(--danger); font-variant-numeric: tabular-nums; }
.log-row { font-size: 12.5px; color: var(--muted); padding: 5px 2px; border-bottom: 1px solid var(--border); }
.log-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.board-empty { color: var(--muted); font-size: 13.5px; padding: 16px 2px; }

.tool.locked { opacity: .45; }
.tool.locked .t-label { text-decoration: line-through; }
.variant.locked { opacity: .5; }

.ops-strip { grid-template-columns: repeat(3, 1fr); }
.sect { font-weight: 700; font-size: 13px; margin: 14px 0 7px; }
.wx-row {
  display: flex; align-items: center; gap: 10px; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.wx-ico { font-size: 19px; }

.star-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.star-big { font-size: 19px; color: var(--warn); letter-spacing: 2px; }
.star-dim { opacity: .22; }
.star-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.need {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 9px; align-items: center;
  font-size: 12px; color: var(--muted); padding: 3px 0;
}
.need-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.need-bar i { display: block; height: 100%; background: var(--accent); }
.need.ok .need-bar i { background: var(--teal); }
.need-n { font-variant-numeric: tabular-nums; }

.led {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--border);
}
.led small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.led .pos { color: var(--teal); font-weight: 700; font-variant-numeric: tabular-nums; }
.led .neg { color: var(--danger); font-weight: 700; font-variant-numeric: tabular-nums; }
.led.total { border-bottom: 0; border-top: 2px solid var(--border); margin-top: 4px; padding-top: 9px; font-weight: 700; }

.air-row {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; margin-bottom: 6px; font-size: 13px;
}
.air-row small { display: block; color: var(--muted); font-size: 11px; }
.air-bar { width: 4px; height: 28px; border-radius: 2px; }
.air-rel { font-weight: 700; font-variant-numeric: tabular-nums; }
.air-rel.expanding { color: var(--teal); }
.air-rel.leaving { color: var(--danger); }
.air-rel.unhappy { color: var(--warn); }

.board-tabs { overflow-x: auto; scrollbar-width: none; }
.board-tabs::-webkit-scrollbar { display: none; }
.board-tabs button { flex: 0 0 auto; padding: 8px 12px; }

.icon-btn.attention { position: relative; }
.icon-btn.attention::after {
  content: ''; position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}

.dilemma {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 12px;
}
.dl-head { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.dl-text { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.dl-opt {
  display: block; width: 100%; text-align: left; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; font: inherit; cursor: pointer;
  color: var(--ink);
}
.dl-opt b { font-size: 13.5px; }
.dl-opt small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.dl-opt:active { transform: scale(.99); }
.dl-opt[disabled] { opacity: .5; }

.scen {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px;
}
.scen.offer { border-color: color-mix(in srgb, var(--teal) 50%, var(--border)); }
.sc-head { font-weight: 700; font-size: 14.5px; display: flex; justify-content: space-between; gap: 10px; }
.sc-days { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.sc-days.urgent { color: var(--danger); }
.sc-brief { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 7px 0 10px; }
.sc-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.obj { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; padding: 5px 0; }
.obj em { color: var(--danger); font-style: normal; font-size: 11px; }
.obj small { display: block; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.obj-tick { color: var(--muted); font-weight: 700; }
.obj.done .obj-tick { color: var(--teal); }
.obj.done { color: var(--muted); }

.staff {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 13px; margin-bottom: 8px;
}
.staff.hired { border-color: color-mix(in srgb, var(--teal) 40%, var(--border)); }
.st-top { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.st-role { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 600; }
.st-role.vacant { color: var(--warn); }
.st-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.st-quirk { font-size: 12px; margin-top: 7px; line-height: 1.45; }
.st-blurb { font-size: 12px; color: var(--muted); margin: 6px 0 9px; line-height: 1.45; }
.cand {
  display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 5px; font: inherit; cursor: pointer; color: var(--ink);
  text-align: left;
}
.cand:active { transform: scale(.99); }
.cd-name { font-size: 13px; font-weight: 600; }
.cd-name small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.cd-pay { font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============================ Crisis strip ============================ */
#crisis {
  position: fixed; z-index: 22;
  left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 62px);
  max-width: min(94vw, 640px);
  display: flex; align-items: center; gap: 9px;
  padding: 8px 15px; border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--border));
  color: var(--danger); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); cursor: pointer;
}
#crisis .c-more { color: var(--muted); font-weight: 600; }

/* ============================ Cinematic ============================ */
#cine { position: fixed; inset: 0; z-index: 24; pointer-events: none; }
.cine-bar {
  position: absolute; left: 0; right: 0; height: 8vh; background: #000;
  animation: cine-in .5s ease both;
}
.cine-bar.top { top: 0; }
.cine-bar.bottom { bottom: 0; }
@keyframes cine-in { from { height: 0; } }
.cine-caption {
  position: absolute; left: 0; right: 0; bottom: calc(8vh + 18px);
  text-align: center; color: #fff; font-size: 14px; font-weight: 700;
  letter-spacing: .04em; text-shadow: 0 2px 10px rgba(0, 0, 0, .8);
}
.cine-actions {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(8vh + 52px); display: flex; gap: 8px; pointer-events: auto;
}

/* ============================ Onboarding ============================ */
#tut {
  position: fixed; z-index: 23;
  left: calc(env(safe-area-inset-left, 0px) + var(--chrome-pad));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 160px);
  width: min(330px, calc(100vw - 2 * var(--chrome-pad)));
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 13px 15px;
}
.tut-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#tut-title { font-weight: 700; font-size: 14.5px; }
.tut-step { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tut-body { font-size: 13px; color: var(--muted); line-height: 1.55; margin-top: 6px; }
.tut-body b { color: var(--ink); }
.tut-hint {
  margin-top: 9px; font-size: 12px; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-radius: var(--radius-sm); padding: 7px 10px;
}
.tut-actions { display: flex; gap: 8px; margin-top: 11px; justify-content: flex-end; }

@media (max-width: 640px) {
  #tut { bottom: calc(env(safe-area-inset-bottom, 0px) + 168px); left: 50%; transform: translateX(-50%); }
}

/* ============================ Toasts ============================ */
#toasts {
  position: fixed; z-index: 40;
  left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 64px + var(--crisis-h, 0px));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow-lg);
  padding: 9px 17px; font-size: 13.5px; font-weight: 600;
  animation: toast-in .22s ease both;
}
.toast.warn { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); color: var(--danger); }
.toast.ok { border-color: color-mix(in srgb, var(--teal) 55%, var(--border)); color: var(--teal); }
.toast.out { animation: toast-out .25s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===================== Phase 6 — advice, goals, charts ===================== */
/* Everything here lives inside the flights panel's own scroll container or the
   inspector's, so none of it can make the page itself scroll sideways or down. */

/* --- the advisor ------------------------------------------------------- */
.adv {
  border: 1px solid var(--border); background: var(--surface);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
}
.adv-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; }
.adv-ico { font-size: 15px; line-height: 1; }
.adv-text { font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.adv.bad { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.adv.warn { border-left-color: var(--gold, #e0a400); }
.adv.info { border-left-color: var(--grape); }
.adv.good { border-left-color: var(--teal); }

/* --- things waiting on a decision -------------------------------------- */
.ask {
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
}
.ask.partner {
  background: color-mix(in srgb, var(--firm, var(--grape)) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--firm, var(--grape)) 50%, var(--border));
}
.ask-head { font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ask-title { font-weight: 700; font-size: 14.5px; margin: 6px 0 4px; }
.ask-text { font-size: 13px; line-height: 1.5; }
.ask-foot { font-size: 11.5px; color: var(--muted); margin-top: 7px; }

.firm { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.firm-logo { display: block; line-height: 0; flex: 0 0 auto; }
.firm-id b { display: block; font-size: 13.5px; }
.firm-id small { display: block; font-size: 11.5px; color: var(--muted); font-style: italic; }

.claims { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 2px; }
.claim {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 16%, var(--surface)); color: var(--teal);
}
.split {
  display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 9px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.split .mine { color: var(--ink); font-weight: 700; }

/* --- airline requests --------------------------------------------------- */
.req {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
}
.req-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.req-bar { width: 4px; height: 15px; border-radius: 2px; flex: 0 0 auto; }
.req-why { font-size: 12.5px; color: var(--muted); margin: 5px 0 8px; line-height: 1.45; }
.req .need { grid-template-columns: 1fr 70px auto; }
.req-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* --- collapsible history (see §17: collapse by default) ----------------- */
.fold { margin-top: 12px; }
.fold > summary {
  cursor: pointer; font-weight: 700; font-size: 13px; padding: 8px 2px;
  list-style: none; display: flex; align-items: center; gap: 7px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: '▸'; color: var(--muted); }
.fold[open] > summary::before { content: '▾'; }
.log-row.impressed b, .log-row.impressed { color: var(--teal); }
.log-row.poor { color: var(--danger); }

/* --- goals -------------------------------------------------------------- */
.goal-top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 13px; padding: 2px 2px 12px;
}
.goal-top span { color: var(--muted); font-size: 12px; }
.goal {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 7px;
}
.goal-ico { font-size: 16px; line-height: 1.2; text-align: center; }
.goal-main b { display: block; font-size: 13.5px; }
.goal-main small { display: block; font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; line-height: 1.4; }
.goal-main .need-bar { height: 5px; }
.goal-best { margin: 5px 0 0 !important; }
.goal-right { text-align: right; }
.goal-right b { display: block; font-size: 12.5px; color: var(--teal); font-variant-numeric: tabular-nums; }
.goal-right small { display: block; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.goal.done { opacity: .62; }
.goal.done .goal-ico { color: var(--teal); }
.goal.expired { opacity: .45; }
.goal.expired .goal-right b { color: var(--muted); }

/* --- charts ------------------------------------------------------------- */
.chartwrap { display: flex; flex-direction: column; gap: 10px; }
.chart {
  display: block; width: 100%; height: 64px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* --- spot advice, inside the inspector ---------------------------------- */
.spot { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.spot-head { font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.spot-facts { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 7px 0 9px; }
.spot-facts span {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums;
}
.spot-idea {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 10px; margin-bottom: 7px; background: var(--surface);
}
.spot-idea.blocked { opacity: .6; }
.si-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 12.5px; }
.si-cost { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; flex: 0 0 auto; }
.si-why { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; margin-top: 8px; }

/* Incidents (v0.8.0) */
.ask.incident {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 48%, var(--border));
}

/* Follow a passenger (v0.9.0) */
#follow-marker {
  position: fixed; z-index: 18; left: -14px; top: -14px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--accent); pointer-events: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  animation: follow-pulse 1.6s ease-in-out infinite;
}
@keyframes follow-pulse {
  0%, 100% { transform-origin: center; scale: 1; opacity: .95; }
  50% { scale: 1.25; opacity: .55; }
}
#follow-chip {
  position: fixed; z-index: 22; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--toolbar-h, 92px) + 14px);
  display: flex; align-items: center; gap: 9px;
  max-width: min(560px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow-lg);
  padding: 8px 10px 8px 14px; font-size: 13px;
}
#follow-face { font-size: 19px; line-height: 1; flex: 0 0 auto; }
#follow-chip .fc-main { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#follow-chip b { font-weight: 700; }

/* ============================ Version badge ============================
   Filled by index.html from version.js; shows BUILD. Top-left, in the top bar's 10px
   --chrome-pad above the brand chip: measured live, every top-bar chip and button starts at
   y>=10 (brand at x=10), so an 8px box at the top edge covers no control or HUD number.
   z-index 95: above the boot splash (90), panels (30) and toasts (40). The top bar is
   see-through over the 3D airfield, so the badge carries its own --bg backing and is
   measured on that: light --muted #6f6885 4.85:1 on #f6f5fa, dark --muted #a69dba 6.89:1
   on #191625. Fail: light #b83232 5.47:1 (--danger #d64545 is only 4.0:1), dark --danger
   #ff6b78 6.45:1. */
.app-version {
  position: fixed; z-index: 95; pointer-events: none;
  top: env(safe-area-inset-top, 0px); left: calc(env(safe-area-inset-left, 0px) + 10px);
  padding: 0 3px; border-radius: 0 0 3px 3px; background: var(--bg);
  font: 500 9px/8px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .2px; color: var(--muted); white-space: nowrap;
}
.app-version.fail { color: #b83232; font-weight: 700; }
:root[data-theme="dark"] .app-version.fail { color: var(--danger); }
