:root {
  --ink: #0b1626;
  --glass: rgba(8, 16, 30, 0.62);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #eef3fb;
  --muted: #9fb0c8;
  --accent: #ffb547;
  --accent-2: #5cc8ff;
  --paper: #fbf7ee;
  --paper-ink: #1d2433;
  --band: #0f2a55;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #02060d; color: var(--text); overscroll-behavior: none; }
body { -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

#world, #cabin { position: fixed; inset: 0; width: 100%; height: 100%; }
#world .cesium-viewer-bottom, #world .cesium-widget-credits { display: none !important; }
#cabin { touch-action: none; cursor: grab; }
#cabin.dragging { cursor: grabbing; }
#credits { position: fixed; left: 8px; bottom: calc(4px + var(--safe-bottom)); font-size: 9px; opacity: 0.5; z-index: 3; max-width: 40vw; pointer-events: auto; }
#credits img { max-height: 12px; vertical-align: middle; }
#credits a { color: #cfd8e6; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ---------------- Telemetry ---------------- */
.telemetry { position: fixed; top: calc(14px + var(--safe-top)); left: 14px; padding: 12px 14px; min-width: 230px; z-index: 5; }
.status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #888; box-shadow: 0 0 0 0 rgba(80, 255, 140, 0.6); }
.dot.live { background: #46e27f; animation: pulse 1.8s infinite; }
.dot.est { background: var(--accent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(70, 226, 127, 0.55); } 70% { box-shadow: 0 0 0 9px rgba(70, 226, 127, 0); } 100% { box-shadow: 0 0 0 0 rgba(70, 226, 127, 0); } }
.phase { font-size: 18px; font-weight: 650; margin: 4px 0 8px; }
.tele-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.tele-grid label, .pass label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.tele-grid b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sky { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------------- Boarding pass ---------------- */
.pass {
  position: fixed; top: calc(14px + var(--safe-top)); right: 14px; z-index: 6;
  display: flex; width: 440px; max-width: calc(100vw - 28px);
  color: var(--paper-ink); filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.45));
  transform-origin: top right; animation: pass-in 0.7s cubic-bezier(.2, .9, .25, 1.15);
}
@keyframes pass-in { from { transform: translateY(-30px) rotate(3deg); opacity: 0; } to { transform: none; opacity: 1; } }
.pass-main, .pass-stub { background: var(--paper); position: relative; }
.pass-main {
  flex: 1; border-radius: 14px 0 0 14px; overflow: hidden; min-width: 0;
  -webkit-mask: radial-gradient(circle 9px at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat,
                radial-gradient(circle 9px at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat;
          mask: radial-gradient(circle 9px at 100% 0, transparent 98%, #000) top right / 100% 51% no-repeat,
                radial-gradient(circle 9px at 100% 100%, transparent 98%, #000) bottom right / 100% 51% no-repeat;
}
.pass-stub {
  width: 104px; border-radius: 0 14px 14px 0; padding: 40px 10px 10px; border-left: 2px dashed rgba(29, 36, 51, 0.28);
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  -webkit-mask: radial-gradient(circle 9px at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat,
                radial-gradient(circle 9px at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat;
          mask: radial-gradient(circle 9px at 0 0, transparent 98%, #000) top left / 100% 51% no-repeat,
                radial-gradient(circle 9px at 0 100%, transparent 98%, #000) bottom left / 100% 51% no-repeat;
}
.pass-stub::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 32px; background: var(--band); }
.pass-top { display: flex; justify-content: space-between; align-items: center; background: var(--band); color: #fff; padding: 7px 14px; height: 32px; }
.pass-airline { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 13px; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass-logo { color: var(--accent); }
.pass-kind { font-size: 10px; letter-spacing: 0.18em; opacity: 0.85; white-space: nowrap; }
.pass-route { display: flex; align-items: center; padding: 10px 14px 4px; gap: 10px; }
.pass-ap { min-width: 0; }
.pass-ap.right { text-align: right; }
.pass-code { font-size: 32px; font-weight: 800; letter-spacing: 0.02em; line-height: 1; }
.pass-city { font-size: 11px; color: #5b6477; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; margin-top: 2px; }
.pass-line { flex: 1; min-width: 60px; text-align: center; }
.pass-track { position: relative; height: 18px; }
.pass-track::before { content: ''; position: absolute; left: 0; right: 0; top: 9px; border-top: 2px dotted rgba(29, 36, 51, 0.35); }
.pass-progress { position: absolute; left: 0; top: 8px; height: 3px; width: 0; background: var(--band); border-radius: 2px; transition: width 1s linear; }
.pass-plane { position: absolute; top: -2px; left: 0; transform: translateX(-50%) rotate(0deg); font-size: 17px; color: var(--band); transition: left 1s linear; }
.pass-dur { font-size: 10px; color: #5b6477; margin-top: 2px; }
.pass-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 10px; padding: 8px 14px 12px; }
.pass-grid .wide { grid-column: span 2; }
.pass label { color: #7a8396; font-size: 9px; }
.pass-grid b, .stub-seat b { font-size: 13px; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stub-seat b { font-size: 22px; }
.stub-flight { font-weight: 700; font-size: 12px; }
.barcode { width: 100%; height: 54px; margin-top: auto; background: repeating-linear-gradient(90deg, #1d2433 0 2px, transparent 2px 4px); }
.pass-toggle { display: none; position: absolute; right: 8px; bottom: -14px; width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--band); color: #fff; font-size: 13px; }

/* ---------------- Controls ---------------- */
.controls {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-bottom)); z-index: 5;
  display: flex; gap: 8px; padding: 8px; align-items: center; max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none;
}
.controls::-webkit-scrollbar { display: none; }
.seg { display: flex; background: rgba(255, 255, 255, 0.06); border-radius: 11px; padding: 3px; flex-shrink: 0; }
.seg button, .controls .icon { border: none; background: transparent; padding: 8px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text); }
.seg button.on { background: #fff; color: var(--ink); }
.controls .icon { background: rgba(255, 255, 255, 0.06); flex-shrink: 0; }
.controls .icon.on { background: rgba(92, 200, 255, 0.25); }
.controls .icon.accent { background: var(--accent); color: #1c1203; }
.controls button:hover { filter: brightness(1.15); }

.hint { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.5); padding: 10px 16px; border-radius: 999px; font-size: 14px; pointer-events: none; transition: opacity 1s; z-index: 4; }
.hint.gone { opacity: 0; }
.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-bottom)); transform: translateX(-50%) translateY(10px); background: rgba(0, 0, 0, 0.75); padding: 9px 16px; border-radius: 999px; font-size: 13px; opacity: 0; transition: all 0.3s; pointer-events: none; z-index: 8; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.banner { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + var(--safe-top)); background: rgba(255, 181, 71, 0.95); color: #1c1203; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; z-index: 7; max-width: 46vw; text-align: center; }

/* ---------------- Picker ---------------- */
.picker { position: fixed; inset: 0; z-index: 20; display: flex; background: #050b16; }
.picker-map { flex: 1; height: 100%; background: #0a1322; }
.picker-panel { width: 400px; height: 100%; display: flex; flex-direction: column; background: #0b1424; border-left: 1px solid rgba(255, 255, 255, 0.08); }
.brand { display: flex; gap: 12px; align-items: center; padding: 18px 18px 10px; position: relative; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.close-picker { position: absolute; right: 14px; top: 16px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.08); }
.search { display: flex; gap: 8px; padding: 6px 18px 10px; }
.search input { flex: 1; min-width: 0; padding: 11px 13px; border-radius: 11px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.05); color: var(--text); font-size: 14px; outline: none; }
.search input:focus { border-color: var(--accent-2); }
.search button { padding: 0 16px; border-radius: 11px; border: none; background: var(--accent); color: #1c1203; font-weight: 700; }
.chips { display: flex; gap: 6px; padding: 0 18px 10px; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.chips button { border: 1px solid rgba(255, 255, 255, 0.14); background: transparent; padding: 5px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; color: var(--muted); }
.chips button:hover { color: #fff; border-color: #fff; }
.lists { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.list-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 12px 8px 6px; display: flex; justify-content: space-between; }
.list-empty { color: var(--muted); padding: 18px 10px; font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.row:hover, .row.sel { background: rgba(255, 255, 255, 0.07); }
.row .cs { font-weight: 700; min-width: 74px; }
.row .meta { color: var(--muted); font-size: 12px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .alt { font-variant-numeric: tabular-nums; font-size: 12px; }
.row .arrow { font-size: 14px; }
.up { color: #59e38d; } .down { color: #ffb547; }
.selected { margin: 0 14px 6px; padding: 14px; border-radius: 14px; background: linear-gradient(135deg, #13284d, #0e1d36); border: 1px solid rgba(92, 200, 255, 0.25); }
.selected h3 { margin: 0; font-size: 20px; display: flex; justify-content: space-between; gap: 8px; }
.selected .sub { color: var(--muted); font-size: 13px; margin: 3px 0 10px; }
.selected .route { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.selected .stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.selected .stats b { color: var(--text); }
.board { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.board button { border: none; padding: 11px 6px; border-radius: 11px; background: #fff; color: var(--ink); font-weight: 700; font-size: 13px; }
.board button.primary { background: var(--accent); }
.picker-foot { padding: 10px 18px calc(12px + var(--safe-bottom)); font-size: 10.5px; color: #6b7a92; border-top: 1px solid rgba(255, 255, 255, 0.06); }

/* aircraft markers */
.ac-icon { width: 26px; height: 26px; display: grid; place-items: center; }
.ac-icon svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8)); transition: transform 0.4s; }
.ac-icon.sel svg { width: 30px; height: 30px; }
.leaflet-container { background: #0a1322; font: inherit; }
.leaflet-control-attribution { background: rgba(0, 0, 0, 0.5) !important; color: #8a97ab !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #b8c4d8 !important; }

/* boot */
.boot { position: fixed; inset: 0; z-index: 40; background: #050b16; display: grid; place-content: center; text-align: center; color: var(--muted); transition: opacity 0.6s; }
.boot.done { opacity: 0; pointer-events: none; }
.spinner { width: 38px; height: 38px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Mobile ---------------- */
@media (max-width: 760px) {
  .telemetry { top: auto; bottom: calc(74px + var(--safe-bottom)); left: 10px; min-width: 0; padding: 8px 11px; border-radius: 13px; }
  .telemetry .phase { font-size: 14px; margin: 2px 0 4px; }
  .tele-grid { grid-template-columns: repeat(4, auto); gap: 2px 12px; }
  .tele-grid b { font-size: 13px; }
  .sky { display: none; }
  .pass { top: calc(8px + var(--safe-top)); right: 8px; left: 8px; width: auto; max-width: none; }
  .pass-stub { width: 78px; padding-top: 38px; }
  .stub-seat b { font-size: 18px; }
  .barcode { height: 40px; }
  .pass-code { font-size: 26px; }
  .pass.collapsed .pass-grid, .pass.collapsed .barcode, .pass.collapsed .stub-flight { display: none; }
  .pass.collapsed .pass-stub { padding-bottom: 8px; }
  .pass-toggle { display: block; }
  .pass.collapsed .pass-toggle { transform: none; }
  .pass:not(.collapsed) .pass-toggle { transform: rotate(180deg); }
  .controls { left: 8px; right: 8px; transform: none; bottom: calc(8px + var(--safe-bottom)); border-radius: 14px; padding: 6px; gap: 6px; }
  .seg button, .controls .icon { padding: 8px 10px; font-size: 12px; }
  .controls .icon span { display: none; }
  .controls .icon.accent span { display: inline; }
  .hide-sm { display: none !important; }
  .banner { top: auto; bottom: calc(150px + var(--safe-bottom)); max-width: 90vw; }
  .toast { bottom: calc(150px + var(--safe-bottom)); }
  .picker { flex-direction: column; }
  .picker-map { flex: none; height: 46%; }
  .picker-panel { width: 100%; flex: 1; min-height: 0; border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.08); }
  .brand { padding: 12px 14px 6px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 12px; }
  .search { padding: 4px 14px 8px; }
  .chips { padding: 0 14px 6px; }
}
@media (max-width: 760px) and (orientation: landscape) {
  .picker { flex-direction: row; }
  .picker-map { height: 100%; flex: 1; }
  .picker-panel { width: 46%; border-top: none; }
  .pass { left: auto; width: 330px; }
  .telemetry { bottom: calc(64px + var(--safe-bottom)); }
}
