:root {
  --bg: #0d1210;
  --panel: #141b18;
  --panel2: #1a2420;
  --line: #2a3832;
  --text: #d6e2da;
  --dim: #7f948a;
  --accent: #7cf08a;
  --warn: #ffb020;
  --alert: #ff4d42;
  --dep: #9cc8f0;
  --arr: #e8cf98;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.35 system-ui, "Segoe UI", sans-serif; overflow: hidden; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: #4a6a5a; background: #213029; }
button.on { background: #24402e; border-color: #3f7a52; color: #c8ffd2; }
button.primary { background: #2a5a38; border-color: #48965e; color: #eaffef; font-weight: 600; }
.hidden { display: none !important; }
.dim { color: var(--dim); }

#app { display: grid; grid-template-rows: 40px 1fr clamp(120px, 21vh, 200px); height: 100vh; }

/* top bar */
#topbar { display: flex; align-items: center; gap: 14px; padding: 0 10px; background: #0a0f0d; border-bottom: 1px solid var(--line); font-family: var(--mono); white-space: nowrap; overflow: hidden; }
.tb-pos { font-weight: 700; color: var(--accent); letter-spacing: .5px; }
.tb-item label { color: var(--dim); font-size: 10px; margin-right: 5px; }
.tb-item span { font-weight: 600; }
.tb-spacer { flex: 1; }
.tb-speed button { padding: 3px 8px; margin-left: 2px; }

#main { display: grid; grid-template-columns: clamp(210px, 19vw, 300px) 1fr clamp(240px, 23vw, 380px); min-height: 0; }
#strips { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 6px; }
.bay-title, #alerts-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); padding: 4px 4px 6px; }
.bay { margin-bottom: 10px; }
.bay h4 { margin: 4px 2px; font-size: 11px; font-weight: 600; color: #a8bdb2; text-transform: uppercase; letter-spacing: .6px; display: flex; justify-content: space-between; }
.bay h4 .n { color: var(--dim); }

/* flight progress strips */
.strip { display: grid; grid-template-columns: 1fr auto; gap: 0 6px; font-family: var(--mono); font-size: 11.5px; border-radius: 2px; padding: 4px 6px 4px 9px; margin: 3px 0; cursor: pointer; color: #13201a; position: relative; border: 1px solid rgba(0,0,0,.4); }
.strip::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.strip.dep { background: #c9def0; }
.strip.dep::before { background: #2f6fb0; }
.strip.arr { background: #eedcb4; }
.strip.arr::before { background: #a7792b; }
.strip.other { opacity: .55; }
.strip.sel { outline: 2px solid #ffe066; }
.strip.req { box-shadow: 0 0 0 2px var(--warn) inset; }
.strip.alert { box-shadow: 0 0 0 2px var(--alert) inset; }
.strip .cs { font-weight: 800; font-size: 13px; }
.strip .r { text-align: right; }
.strip .s2 { color: #34463d; }
.strip .st { grid-column: 1 / 3; color: #6a3b00; font-weight: 700; }

#center { position: relative; min-width: 0; min-height: 0; }
#surface { width: 100%; height: 100%; display: block; cursor: crosshair; }
#map-tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; }
#map-tools button { font-family: var(--mono); font-size: 11px; padding: 3px 7px; background: rgba(20,27,24,.85); }

#selpanel { position: absolute; left: 10px; bottom: 10px; right: 10px; max-height: 48%; overflow-y: auto; background: rgba(12,18,15,.94); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: var(--mono); }
#selpanel .hdr { display: flex; gap: 12px; align-items: baseline; margin-bottom: 6px; flex-wrap: wrap; }
#selpanel .hdr b { font-size: 15px; color: #ffe066; }
#selpanel .btns { display: flex; flex-wrap: wrap; gap: 5px; }
#selpanel .btns button { font-family: var(--mono); font-size: 12px; padding: 4px 8px; }
#selpanel .btns button.hot { border-color: var(--warn); color: #ffd890; }
#selpanel .btns .sep { width: 1px; background: var(--line); margin: 0 3px; }
#selpanel .sub { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
#selpanel .sub button { font-size: 11px; padding: 2px 7px; }
#selpanel .hint { color: var(--warn); font-size: 11.5px; margin-top: 5px; }

#toasts { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 5px; align-items: center; pointer-events: none; }
.toast { background: rgba(60,10,8,.94); border: 1px solid var(--alert); color: #ffd6d2; padding: 6px 12px; border-radius: 5px; font-family: var(--mono); font-size: 12.5px; }
.toast.warn { background: rgba(60,40,5,.94); border-color: var(--warn); color: #ffe7b8; }
.toast.good { background: rgba(10,50,20,.94); border-color: #48965e; color: #d6ffe0; }

#right { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#radar-wrap { position: relative; flex: 0 0 auto; height: min(56%, 23vw); border-bottom: 1px solid var(--line); }
#radar { width: 100%; height: 100%; display: block; cursor: crosshair; }
.radar-title { position: absolute; left: 6px; top: 4px; font-family: var(--mono); font-size: 10px; color: #5f8f72; }
#alerts { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 0 6px 6px; font-family: var(--mono); font-size: 11.5px; }
.al { border-left: 3px solid var(--dim); padding: 4px 6px; margin: 3px 0; background: var(--panel2); }
.al.alert { border-color: var(--alert); color: #ffcfca; }
.al.warn { border-color: var(--warn); color: #ffe2a8; }
.al.info { border-color: #4a8fd0; }
.al.good { border-color: #48965e; color: #c7f5d2; }
.al button { margin-top: 4px; font-size: 11px; padding: 2px 8px; }
.al .t { color: var(--dim); margin-right: 4px; }

#bottom { display: grid; grid-template-rows: 1fr auto; border-top: 1px solid var(--line); background: #0a0f0d; min-height: 0; }
#radiolog { overflow-y: auto; padding: 6px 10px; font-family: var(--mono); font-size: 12.5px; }
.tx { padding: 1px 0; }
.tx .t { color: #56685f; margin-right: 8px; }
.tx .who { display: inline-block; min-width: 92px; font-weight: 700; }
.tx.atc .who { color: var(--accent); }
.tx.atc { color: #d8ffe0; }
.tx.pilot .who { color: #9cc8f0; }
.tx.ai .who { color: #8a9a92; }
.tx.ai { color: #93a59b; }
.tx.sys { color: var(--warn); font-style: italic; }
.tx.err .msg { color: #ff9a92; }
.tx .freq { color: #4f6b5c; font-size: 10.5px; margin-right: 6px; }
#cmdline { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; padding: 6px 10px; border-top: 1px solid var(--line); background: #0f1613; position: relative; }
#cmd-target { font-family: var(--mono); font-weight: 800; color: #ffe066; min-width: 70px; }
#cmd { font: 14px var(--mono); background: #060a08; color: #e6ffe9; border: 1px solid #2c4a38; border-radius: 4px; padding: 7px 9px; outline: none; text-transform: uppercase; }
#cmd:focus { border-color: #4fbf6c; }
#cmd-preview { grid-column: 2; font-family: var(--mono); font-size: 11.5px; color: #8fb59c; min-height: 16px; padding-top: 3px; }
#cmd-preview.bad { color: #ff9a92; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(4,8,6,.88); display: flex; align-items: center; justify-content: center; z-index: 50; overflow-y: auto; padding: 20px; }
.menu-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px 26px; width: min(720px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; position: relative; }
.menu-card.wide { width: min(980px, 100%); }
.menu-card h1 { margin: 0 0 2px; font-size: 26px; color: var(--accent); }
.menu-card h2 { color: var(--accent); margin: 18px 0 6px; font-size: 17px; }
.menu-card h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.menu-card .sub { margin: 0; color: var(--dim); }
.menu-card table { border-collapse: collapse; width: 100%; font-size: 12.5px; margin: 6px 0; }
.menu-card td, .menu-card th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.menu-card th { color: var(--dim); font-weight: 600; }
.menu-card code { font-family: var(--mono); color: #c8ffd2; background: #0a110d; padding: 0 4px; border-radius: 3px; }
.modes { display: grid; gap: 8px; }
.mode { display: flex; gap: 10px; align-items: flex-start; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; cursor: pointer; }
.mode:has(input:checked) { border-color: #48965e; background: #1b2e22; }
.mode b { display: block; font-size: 14px; }
.mode span { color: var(--dim); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.opts label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 12px; }
.opts label.chk { grid-column: 1 / 3; flex-direction: row; align-items: center; color: var(--text); font-size: 13px; }
select { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 5px; }
.menu-actions { display: flex; gap: 8px; margin-top: 18px; }
.menu-actions button { padding: 8px 18px; font-size: 14px; }
.credit { color: #5d7066; font-size: 11px; margin-top: 16px; }
.close { position: absolute; right: 12px; top: 10px; font-size: 18px; padding: 0 9px; }
.grade { font-size: 44px; font-weight: 800; color: var(--accent); }
#selpanel .fpl { color: #9fd4ff; font-size: 12px; margin: -2px 0 6px; }
#selpanel .fpl b { color: #e6f4ff; }

/* lessons */
.lessons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lessons button { text-align: left; padding: 10px; display: flex; flex-direction: column; gap: 3px; background: #1b2e22; border-color: #3f7a52; }
.lessons button span { color: var(--dim); font-size: 12px; }
#tutorial { position: absolute; left: 10px; top: 10px; width: min(400px, calc(100% - 20px)); max-height: 60%; overflow-y: auto; z-index: 5;
  background: rgba(14, 22, 30, .96); border: 1px solid #4a8fd0; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5); font-size: 13px; }
#tutorial .tut-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #16324d; border-radius: 8px 8px 0 0; position: sticky; top: 0; }
#tutorial .tut-head b { color: #cfe6ff; }
#tutorial .tut-head span { color: #8fb3d6; font-size: 11px; flex: 1; }
#tutorial .tut-head button { padding: 0 8px; }
#tutorial .tut-body { padding: 8px 12px 10px; }
#tutorial.min .tut-body { display: none; }
#tutorial h4 { margin: 2px 0 6px; color: #ffe066; font-size: 14px; }
#tutorial p { margin: 6px 0; }
#tutorial ul { margin: 4px 0; padding-left: 18px; }
#tutorial li { margin: 2px 0; }
#tutorial code { font-family: var(--mono); color: #c8ffd2; background: #0a110d; padding: 0 4px; border-radius: 3px; }
#tutorial table { border-collapse: collapse; margin: 4px 0; }
#tutorial td { padding: 2px 8px 2px 0; vertical-align: top; }
#tutorial .tut-src { color: #6f8aa3; font-size: 11px; margin-top: 6px; }
#tutorial .tut-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
#tutorial .tut-spacer { flex: 1; }
#tutorial button.ghost { background: transparent; color: #8fb3d6; font-size: 12px; padding: 2px 8px; }
#tutorial .tut-status { font-weight: 700; font-size: 12px; }
#tutorial .tut-status.act { color: #ffe066; }
#tutorial .tut-status.wait { color: #8fd0ff; }
.tut-hl { outline: 2px solid #ffe066 !important; outline-offset: 2px; animation: tutpulse 1.1s ease-in-out infinite; }
@keyframes tutpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,224,102,.0); } 50% { box-shadow: 0 0 0 6px rgba(255,224,102,.35); } }
.tr-link { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; padding: 10px 12px; border: 1px solid #2f5674; border-radius: 6px; background: linear-gradient(135deg, #16324d, #14231c); color: var(--text); text-decoration: none; }
.tr-link span { color: #9fb7cc; font-size: 12.5px; }
.tr-link:hover { border-color: #4a8fd0; }

.tb-click { cursor: pointer; }
.tb-click:hover span { text-decoration: underline; }
.atis-text { font-family: var(--mono); background: #060a08; border: 1px solid #22302a; border-radius: 6px; padding: 12px; line-height: 1.6; }

/* replay debrief */
.menu-card.xwide { width: min(1240px, 100%); }
.rp-row { display: grid; grid-template-columns: 1fr 360px; gap: 10px; }
#rp-canvas { width: 100%; height: 420px; background: #1b2420; border: 1px solid var(--line); border-radius: 6px; display: block; }
.rp-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.rp-explain { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-size: 13px; max-height: 240px; overflow-y: auto; }
.rp-explain h4 { margin: 0 0 6px; color: #ffe066; }
.rp-explain .model { font-family: var(--mono); background: #060a08; border-radius: 4px; padding: 6px 8px; margin-top: 6px; color: #d8ffe0; }
.rp-log { flex: 1; min-height: 120px; max-height: 170px; overflow-y: auto; font-family: var(--mono); font-size: 11.5px; background: #0a0f0d; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.rp-log .atc { color: #d8ffe0; } .rp-log .pilot { color: #9cc8f0; } .rp-log .sys { color: var(--warn); } .rp-log .t { color: #56685f; margin-right: 6px; }
.rp-controls { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.rp-controls input[type=range] { flex: 1; }
.mono { font-family: var(--mono); }
.rp-events { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-events button { font-family: var(--mono); font-size: 11.5px; border-color: #7a3a36; color: #ffcfca; }
.rp-events button.good { border-color: #3f7a52; color: #c7f5d2; }
.rp-events button.sel { outline: 2px solid #ffe066; }
table.prof { width: 100%; border-collapse: collapse; }
table.prof td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.prof .bar { width: 160px; }
#menu-profile { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
#menu-profile h3 { margin: 0 0 6px; }
#menu-profile .weak { color: #ffb020; }
/* coach */
.coach-card { width: min(640px, 100%); border-color: #4a8fd0; }
.coach-tag { color: #8fb3d6; font-size: 11px; letter-spacing: 1px; }
.coach-card h2 { margin: 4px 0 8px; color: #ffe066; }
.coach-event { font-family: var(--mono); color: #ffcfca; background: #2a1412; border-radius: 4px; padding: 6px 10px; }

#cmdline.has-mic { grid-template-columns: auto auto 1fr; }
#cmdline.has-mic #cmd-preview { grid-column: 3; }
#btn-mic { font-size: 16px; padding: 4px 9px; }
#btn-mic.on { background: #5a1a14; border-color: #ff5a4f; }

.atis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.facts-table td { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.tr-input { width: 100%; font: 13px var(--mono); background: #060a08; color: #e6ffe9; border: 1px solid #2c4a38; border-radius: 6px; padding: 8px; outline: none; }
.tr-verdict { font-weight: 800; margin: 8px 0 4px; } .tr-verdict.ok { color: var(--accent); } .tr-verdict.bad { color: #ff8a80; }

.scn-outcome { font-size: 18px; font-weight: 800; padding: 8px 10px; border-radius: 6px; margin-bottom: 8px; }
.scn-outcome.pass { background: #1b3a24; color: #c7f5d2; } .scn-outcome.fail { background: #3a1b18; color: #ffcfca; }
#tutorial .mono { font-family: var(--mono); color: #d8ffe0; }
#tutorial .scn-outcome + ul { margin: 6px 0; }

#scope { width: 100%; height: 100%; display: block; cursor: crosshair; position: absolute; inset: 0; background: #06120c; }
#center { position: relative; }
body.arrival #map-tools #btn-labels, body.arrival #map-tools #btn-fit { display: none; }

#menu .path { color: var(--dim, #9fb4a8); font-size: 12.5px; line-height: 1.45; margin: -4px 0 8px; }

/* checkrides */
table.cr-table { border-collapse: collapse; width: 100%; margin: 8px 0; }
table.cr-table th, table.cr-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
table.cr-table tr.ok td:last-child { color: #9be8a8; } table.cr-table tr.bad td:last-child { color: #ffb4ad; font-weight: 600; }
/* logbook */
#menu-profile h4 { margin: 12px 0 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.lb-next { margin: 2px 0 8px; } .lb-go { color: #c8ffd2; font-weight: 700; }
.lb-path { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.lb-step { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; font-size: 12px; }
.lb-step.ok { border-color: #3f7a52; background: #1b2e22; } .lb-step.cur { border-color: #7cf08a; background: #24402e; font-weight: 600; }
.lb-step:hover { border-color: #7cf08a; } .lb-ic { width: 12px; text-align: center; }
.lb-stats { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 2px; color: var(--dim); } .lb-stats b { color: var(--text); }
.lb-trends { display: flex; flex-wrap: wrap; gap: 10px; }
.lb-fig { margin: 0; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.lb-fig figcaption { font-size: 12px; margin-bottom: 2px; }
.lb-line { fill: none; stroke: #3fae58; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lb-zero { stroke: #3a4a42; stroke-width: 1; }
.lb-ax { fill: var(--dim); font: 9px var(--mono); }
.lb-dot { fill: #3fae58; stroke: var(--panel); stroke-width: 2; } .lb-dot.cr-ok { fill: #7cf08a; } .lb-dot.cr-bad { fill: #ff8a80; }
.lb-hit { fill: transparent; cursor: default; } .lb-pt:hover .lb-dot { r: 6; }
.lb-recent summary { cursor: pointer; color: var(--dim); margin-top: 8px; }
table.lb-table { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 4px; }
table.lb-table th, table.lb-table td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); }

/* ---- installable app and phones ---- */
.phone-only { display: none; }
.menu-install:not(:empty) { margin: 8px 0; }
@media (max-width: 760px) {
  .phone-only { display: block; }
  html, body { overflow: auto; }
  #menu.overlay:not(.hidden) { position: static; padding: 0; display: block; }
  #menu .menu-card { width: 100%; max-width: none; border-radius: 0; border-left: 0; border-right: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); max-height: none; }
  .lessons, .modes { grid-template-columns: 1fr !important; }
  .opts { grid-template-columns: 1fr !important; }
  .opts label { min-width: 0; }
  .opts select { width: 100%; max-width: 100%; min-width: 0; }
  .phone-note .tr-link.daily { background: linear-gradient(135deg, #16324d, #14231c); border-color: #2f5674; }
  .phone-note .tr-link.daily b { font-size: 16px; }
  .lb-fig svg { max-width: 100%; height: auto; }
  .lb-table { display: block; overflow-x: auto; }
  #menu-profile table.prof .bar { width: 80px; }
}

/* ---- sign-in ---- */
#auth { z-index: 100; }
.auth-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 12px; }
.auth-card input { font: 16px system-ui, sans-serif; padding: 9px 10px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.auth-card input:focus { outline: none; border-color: #4fbf6c; }
.auth-err { color: #ff8a80; margin: 0; }
.offline-note { background: #3a2a10; border: 1px solid #7a5a20; color: #ffd9a0; padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; }
.acct-pw summary { cursor: pointer; color: var(--dim); }
