/* XC Coach v4 — aeronautical-chart palette
   paper/ink for the page, ICAO route magenta for everything belonging to the
   task, airspace blue for the flight itself, lift/sink only where a vario value
   is meant. */
:root {
  --paper: #F4F6F7;
  --sheet: #FFFFFF;
  --ink: #16212B;
  --ink-2: #4A5866;
  --ink-3: #7A8794;
  --rule: #D3DAE0;
  --rule-2: #E6EBEF;
  --route: #B0246F;
  --route-wash: #F7E4EE;
  --flight: #1F5DA6;
  --flight-wash: #E3ECF7;
  --lift: #1E8A5A;
  --lift-wash: #DFF1E7;
  --sink: #C4432B;
  --sink-wash: #F8E3DE;
  --wave: #2D7F9A;
  --warn: #9A6A00;
  --warn-wash: #FBF0D3;
  --display: 'Barlow Semi Condensed', 'Arial Narrow', sans-serif;
  --text: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --r-s: 6px;
  --r-m: 10px;
  --w: 1120px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--text); font-size: 16px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.005em; }
p { margin: 0 0 0.8em; }
a { color: var(--flight); }
:focus-visible { outline: 2px solid var(--flight); outline-offset: 2px; }
.num, td, .readout-value, .kv dd { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* top bar */
.topbar { max-width: var(--w); margin: 0 auto; padding: 18px 20px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-logo { display: block; flex: none; line-height: 0; }
.brand-logo img { height: 48px; width: auto; display: block; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; padding-left: 16px; border-left: 1px solid var(--rule); white-space: nowrap; }
.topnav { display: flex; align-items: center; gap: 10px; flex: none; }
.btn-home { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.btn-home svg { width: 17px; height: 17px; }
.btn-home:hover { color: #fff; }

.btn { font: 600 15px/1 var(--text); border-radius: var(--r-s); padding: 11px 16px; cursor: pointer; border: 1px solid var(--ink); background: var(--ink); color: #fff; }
.btn:hover { background: #24323f; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-quiet:hover { background: var(--sheet); border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: default; }

main { max-width: var(--w); margin: 0 auto; padding: 0 20px 48px; }

/* landing */
.landing { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; padding: 56px 0 40px; }
.landing h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 700; margin-bottom: 18px; }
.lede { font-size: 18px; color: var(--ink-2); max-width: 36em; }
.path { font-family: var(--display); font-weight: 600; color: var(--ink); white-space: nowrap; }
.landing-list { margin: 20px 0 0; padding: 0; list-style: none; }
.landing-list li { padding: 8px 0 8px 22px; border-top: 1px solid var(--rule-2); position: relative; color: var(--ink-2); }
.landing-list li::before { content: ''; position: absolute; left: 2px; top: 17px; width: 9px; height: 2px; background: var(--route); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; min-height: 300px; padding: 32px; background: var(--sheet); border: 1.5px dashed var(--ink-3); border-radius: var(--r-m); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--route); background: #fff; }
.dropzone.drag { background: var(--route-wash); }
.dz-icon { width: 96px; color: var(--flight); margin-bottom: 8px; }
.dz-title { font-family: var(--display); font-size: 26px; font-weight: 600; }
.dz-or { color: var(--ink-2); }
.dz-note { margin-top: 14px; font-size: 13px; color: var(--ink-3); max-width: 26em; }
.progress { grid-column: 1 / -1; position: relative; height: 34px; background: var(--rule-2); border-radius: var(--r-s); overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--flight-wash); transition: width .2s; }
.progress span { position: relative; display: block; padding: 6px 12px; font-size: 14px; color: var(--ink-2); }
.error { grid-column: 1 / -1; background: var(--sink-wash); color: #7a2414; padding: 12px 14px; border-radius: var(--r-s); }

/* report scaffolding */
.section { padding: 36px 0 8px; border-top: 1px solid var(--rule); }
.section:first-child { border-top: 0; }
.section > h2 { font-size: 28px; margin-bottom: 4px; }
.section-intro { color: var(--ink-2); margin: 0 0 18px; max-width: 46em; }
.sub-h { font-family: var(--display); font-size: 19px; font-weight: 600; margin: 26px 0 10px; }
.note { font-size: 13px; color: var(--ink-3); }

/* hero: the result board */
.hero { padding: 34px 0 28px; }
.hero-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; }
.hero-pilot { font-family: var(--display); font-size: 34px; font-weight: 700; }
.hero-task { font-size: 17px; color: var(--ink-2); }
.status { display: inline-block; font: 600 13px/1 var(--text); padding: 6px 10px; border-radius: 999px; }
.status-done { background: var(--lift-wash); color: #12603e; }
.status-open { background: var(--warn-wash); color: #6b4a00; }
.status-none { background: var(--rule-2); color: var(--ink-2); }
.board { margin-top: 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 3px solid var(--route); background: var(--sheet); border-radius: 0 0 var(--r-m) var(--r-m); box-shadow: 0 1px 0 var(--rule); }
.readout { padding: 18px 22px 20px; border-left: 1px solid var(--rule-2); }
.readout:first-child { border-left: 0; }
.readout-label { font-size: 14px; color: var(--ink-3); }
.readout-value { font-family: var(--display); font-weight: 700; font-size: clamp(40px, 6vw, 64px); line-height: 1.02; letter-spacing: -0.01em; }
.readout-unit { font-size: .42em; font-weight: 600; color: var(--ink-2); margin-left: 4px; }
.readout-foot { font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; margin-top: 18px; border-top: 1px solid var(--rule-2); }
.fact { padding: 10px 14px 10px 0; border-bottom: 1px solid var(--rule-2); }
.fact dt { font-size: 13px; color: var(--ink-3); }
.fact dd { margin: 0; font-weight: 500; }

/* key-value metric grid */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); background: var(--sheet); border: 1px solid var(--rule-2); border-radius: var(--r-m); overflow: hidden; margin: 0 0 8px; }
.kv > div { padding: 12px 14px; border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); margin: 0 -1px -1px 0; }
.kv dt { font-size: 13px; color: var(--ink-3); }
.kv dd { margin: 2px 0 0; font-family: var(--display); font-size: 26px; font-weight: 600; line-height: 1.1; }
.kv dd small { font-family: var(--text); font-size: 13px; font-weight: 400; color: var(--ink-2); display: block; margin-top: 2px; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule-2); border-radius: var(--r-m); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: right; font-weight: 600; color: var(--ink-2); padding: 10px 10px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: #FAFBFC; }
table.data td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
table.data th:first-child, table.data td:first-child, table.data .l { text-align: left; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.missed td { color: var(--ink-3); }
table.data tfoot td { font-weight: 600; border-top: 1px solid var(--rule); background: #FAFBFC; }
.role { display: inline-block; min-width: 46px; font-weight: 600; color: var(--route); }
.zone { color: var(--ink-2); }
.dir-R, .dir-L, .dir-LR { font-weight: 600; }
.dir-R { color: var(--flight); } .dir-L { color: #6a4fb3; } .dir-LR { color: var(--ink-2); }
.good { color: var(--lift); } .bad { color: var(--sink); } .muted { color: var(--ink-3); }
.tag { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 999px; background: var(--rule-2); color: var(--ink-2); margin-left: 6px; }
.tag-lift { background: var(--lift-wash); color: #12603e; }
.tag-wave { background: #DDEFF4; color: #1d5a6e; }

.checks { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.checks li { font-size: 14px; padding: 6px 10px; border-radius: var(--r-s); background: var(--sheet); border: 1px solid var(--rule-2); }
.checks li.ok::before { content: '✓ '; color: var(--lift); font-weight: 700; }
.checks li.fail { border-color: #E9B8AD; background: var(--sink-wash); }
.checks li.fail::before { content: '✕ '; color: var(--sink); font-weight: 700; }

/* time breakdown bar */
.split { display: flex; height: 38px; border-radius: var(--r-s); overflow: hidden; margin: 6px 0 8px; background: var(--rule-2); }
.split > div { display: flex; align-items: center; padding: 0 10px; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; }
.split .s-circ { background: var(--lift); }
.split .s-wave { background: var(--wave); }
.split .s-glide { background: var(--flight); }
.split .s-other { background: var(--ink-3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* highlights */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin: 4px 0 6px; }
.insight { background: var(--sheet); border: 1px solid var(--rule-2); border-left: 3px solid var(--lift); border-radius: var(--r-s); padding: 12px 14px; }
.insight.watch { border-left-color: var(--warn); }
.insight h3 { font-family: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.insight p { margin: 0; color: var(--ink-2); font-size: 15px; }

/* replay */
.replay { background: var(--sheet); border: 1px solid var(--rule-2); border-radius: var(--r-m); overflow: hidden; }
#map { height: 480px; background: #E9EEF1; }
.rp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; border-bottom: 1px solid var(--rule-2); }
.rp-tabs, .seg-group { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-s); overflow: hidden; }
.rp-tabs button, .seg-group button { font: 600 13px/1 var(--text); padding: 9px 12px; border: 0; border-left: 1px solid var(--rule); background: var(--sheet); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.rp-tabs button:first-child, .seg-group button:first-child { border-left: 0; }
.rp-tabs button { padding: 9px 18px; font-size: 14px; }
.rp-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.seg-group button[aria-pressed="true"] { background: var(--flight-wash); color: var(--flight); }
.seg-group button:disabled { color: var(--rule); cursor: default; }
.rp-tabs button:focus-visible, .seg-group button:focus-visible { outline: 2px solid var(--flight); outline-offset: -2px; }
.v3d-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.v3d { position: relative; height: 520px; background: #a9cbe3; overflow: hidden; }
.v3d canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.v3d canvas:active { cursor: grabbing; }
.v3d-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl3d { position: absolute; transform: translate(-50%, -100%); background: var(--ink); color: #fff; font: 600 12px/1 var(--text); padding: 4px 6px; border-radius: 4px; white-space: nowrap; box-shadow: 0 1px 3px rgba(22,33,43,.3); }
.lbl3d span { font-weight: 500; opacity: .75; margin-left: 6px; }
.lbl3d.tp { background: var(--sheet); color: var(--route); border: 1.5px solid var(--route); }
.lbl3d.tp.below { transform: translate(-50%, 6px); }
.v3d-note { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); background: rgba(22,33,43,.86); color: #fff; font-size: 13px; padding: 7px 12px; border-radius: var(--r-s); text-align: center; }
.v3d-help { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: #16212B; background: rgba(255,255,255,.72); padding: 3px 7px; border-radius: 4px; pointer-events: none; }
.map-overlay { position: absolute; z-index: 500; }
.profile { position: relative; height: 210px; border-top: 1px solid var(--rule-2); cursor: crosshair; touch-action: none; }
.profile svg { display: block; width: 100%; height: 100%; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; border-top: 1px solid var(--rule-2); }
.play { width: 44px; height: 40px; padding: 0; display: grid; place-items: center; }
.speeds { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-s); overflow: hidden; }
.speeds button { font: 600 13px/1 var(--text); padding: 10px 10px; border: 0; background: var(--sheet); color: var(--ink-2); cursor: pointer; border-left: 1px solid var(--rule); }
.speeds button:first-child { border-left: 0; }
.speeds button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.scrub { flex: 1 1 260px; accent-color: var(--route); }
.clock { font-family: var(--display); font-size: 22px; font-weight: 600; min-width: 92px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.hud { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--rule-2); }
.hud div { padding: 8px 12px; border-left: 1px solid var(--rule-2); }
.hud div:first-child { border-left: 0; }
.hud dt { font-size: 12px; color: var(--ink-3); }
.hud dd { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 600; }
.glider-icon { width: 26px; height: 26px; }
.tp-label { background: var(--sheet); border: 1.5px solid var(--route); color: var(--route); font: 600 12px/1 var(--text); padding: 4px 6px; border-radius: 4px; white-space: nowrap; box-shadow: 0 1px 2px rgba(22,33,43,.18); }
.leaflet-container { font-family: var(--text); }

/* exercises */
.exercise { display: grid; grid-template-columns: 96px 1fr; gap: 0 18px; padding: 18px 0; border-top: 1px solid var(--rule-2); }
.exercise:first-of-type { border-top: 0; }
.ex-num { font-family: var(--display); font-size: 30px; font-weight: 700; color: var(--route); line-height: 1; white-space: nowrap; }
.ex-theme { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.exercise h3 { font-size: 22px; margin-bottom: 6px; }
.ex-why { color: var(--ink); margin-bottom: 8px; }
.ex-drill { color: var(--ink-2); background: var(--sheet); border: 1px solid var(--rule-2); border-radius: var(--r-s); padding: 10px 12px; margin: 0; }
.ex-drill b { color: var(--ink); }
.ex-soft { font-size: 13px; color: var(--warn); margin-left: 8px; font-family: var(--text); font-weight: 500; }

/* AI debrief */
.coach-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.coach-bar select { font: 500 15px var(--text); padding: 9px 10px; border-radius: var(--r-s); border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); }
.coach-text { background: var(--sheet); border: 1px solid var(--rule-2); border-radius: var(--r-m); padding: 20px 22px; font-size: 17px; line-height: 1.6; max-width: 46em; }
.coach-text p:last-child { margin-bottom: 0; }
.coach-loading { color: var(--ink-3); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 26px 0 0; }

.footer { max-width: var(--w); margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--rule); }

@media (max-width: 860px) {
  .landing { grid-template-columns: 1fr; gap: 28px; padding-top: 32px; }
  .dropzone { min-height: 220px; }
  .board { grid-template-columns: 1fr; }
  .readout { border-left: 0; border-top: 1px solid var(--rule-2); }
  .readout:first-child { border-top: 0; }
  .hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hud div:nth-child(4) { border-left: 0; }
  #map { height: 360px; }
  .v3d { height: 420px; }
  .v3d-help { display: none; }
  .exercise { grid-template-columns: 1fr; }
  .ex-num { font-size: 26px; margin-bottom: 4px; }
  #btn-new { display: none; }
}
@media (max-width: 520px) {
  .topbar { padding: 12px 16px 10px; gap: 10px; }
  .brand { gap: 10px; }
  .brand-logo img { height: 34px; }
  .brand-name { font-size: 19px; padding-left: 10px; }
  .btn-home { padding: 9px 11px; }
}
@media (max-width: 360px) { .brand-logo img { height: 28px; } .brand-name { font-size: 17px; } .btn-home { padding: 8px 9px; font-size: 14px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .topnav, .actions, .controls, .coach-bar { display: none !important; } }
