/* Colour tokens: light by default, dark via iPhone setting or the theme button. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #7b62d6;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #9085e9;
    --good-text: #0ca30c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #9085e9;
  --good-text: #0ca30c;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .9rem; margin: 0; font-weight: 600; color: var(--text-2); }
small { font-weight: 400; color: var(--muted); }
code { font-size: .9em; background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.topbar {
  position: sticky; overflow: hidden; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
@media (max-width: 480px) { .brand-text { display: none; } .topbar nav a { padding: 6px 8px; } }
.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a { color: var(--text-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.topbar nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.icon-btn { border: 0; background: none; color: var(--text-2); font-size: 1.2rem; padding: 6px; cursor: pointer; }
.topbar nav + .icon-btn { margin-left: 0; }
.topbar .brand + .icon-btn { margin-left: auto; }
.footer { text-align: center; padding-bottom: 32px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 16px 0; box-shadow: var(--shadow);
}
.card.narrow { max-width: 380px; margin: 10vh auto; }
.card.empty { text-align: center; padding: 32px 16px; }
.stack { display: grid; gap: 10px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { margin-top: 24px; }

input, textarea, select {
  font: inherit; font-size: 16px; /* 16px stops iOS zooming into fields */
  color: var(--text); background: var(--page);
  border: 1px solid var(--axis); border-radius: 8px; padding: 10px; width: 100%;
}
select { width: auto; padding: 6px; }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 8px; }
.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--axis);
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn:disabled { opacity: .6; }
.btn.icon { padding: 8px 12px; min-width: 44px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text-2); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--critical); }
.alert.limit { border-left-color: var(--serious); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap;
}
.badge.serious { border-color: var(--critical); color: var(--text); box-shadow: inset 3px 0 0 var(--critical); }
.badge.warning { box-shadow: inset 3px 0 0 var(--warning); }
.badge.limit { box-shadow: inset 3px 0 0 var(--serious); }
.badge.good { box-shadow: inset 3px 0 0 var(--good); }

/* Stat tiles */
.totals, .summary { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 650; }
.summary .stat-value { font-size: 1.15rem; }

/* Flights per month (single series, bars anchored to the baseline) */
.month-chart { display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.month-col { flex: 1 0 18px; max-width: 48px; display: flex; flex-direction: column; align-items: stretch; outline: none; }
.month-plot { height: 150px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  border-bottom: 1px solid var(--axis); padding-top: 18px; }
.month-bar { width: 70%; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; position: relative; }
.month-n { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 2px;
  font-size: .75rem; color: var(--text-2); visibility: hidden; font-variant-numeric: tabular-nums; }
.month-col:hover .month-n, .month-col:focus .month-n { visibility: visible; }
.month-col:hover .month-bar, .month-col:focus .month-bar { filter: brightness(1.15); }
.month-label { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.2; padding-top: 4px; min-height: 2.4em; }
.table-view summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; margin-top: 8px; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--grid); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Records */
.records { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.record { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.record-value { font-size: 1.5rem; font-weight: 650; margin: 2px 0; }
.record-meta { font-size: .8rem; color: var(--muted); margin: 0; }
.record-link { font-size: .85rem; margin-top: 6px; }

/* Flight list */
.flight-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.flight-row {
  display: grid; gap: 4px; padding: 12px 14px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.flight-date { font-weight: 600; }
.flight-stats { display: flex; gap: 14px; color: var(--text-2); font-size: .9rem; font-variant-numeric: tabular-nums; }
.flight-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.flight-badges:empty { display: none; }
@media (min-width: 720px) {
  .flight-row { grid-template-columns: 1.3fr 1.5fr 1fr; align-items: center; }
}

/* Upload results */
.results { list-style: none; padding: 0; display: grid; gap: 8px; }
.result { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.result-name { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; }

/* Flight page */
.pager { display: flex; gap: 6px; }
.map { height: 48vh; min-height: 280px; border-radius: var(--radius); border: 1px solid var(--border); margin: 12px 0 0; z-index: 0; }
:root[data-theme="dark"] .map .osm-tiles { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .map .osm-tiles { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
}
.leaflet-container { background: var(--surface-2); font: inherit; }
.player {
  position: sticky; bottom: 0; z-index: 900;
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); margin: 8px 0 16px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .08);
}
.player input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
.readout { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.readout b { color: var(--text); font-weight: 600; }

.events { list-style: none; padding: 0; margin: 0; max-height: 320px; overflow-y: auto; }
.events li { border-bottom: 1px solid var(--grid); }
.events button {
  width: 100%; text-align: left; background: none; border: 0; font: inherit; color: var(--text);
  padding: 8px 4px; display: grid; grid-template-columns: 30px 44px 1fr; gap: 8px; align-items: start; cursor: pointer;
}
.events button:hover, .events button:focus-visible { background: var(--surface-2); }
.events .ev-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; }
.events .ev-msg { font-size: .9rem; }
.events li.serious .ev-msg { font-weight: 650; }
.events li.serious { background: color-mix(in srgb, var(--critical) 10%, transparent); }
.events li[hidden] { display: none; }

.charts { display: grid; gap: 12px; }
@media (min-width: 900px) { .charts { grid-template-columns: 1fr 1fr; } }
.chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px 4px; min-width: 0; }
.chart h3 { padding: 0 6px 4px; }
.chart .legend-row { display: flex; gap: 12px; padding: 0 6px 4px; font-size: .8rem; color: var(--text-2); }
.chart .swatch { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.chart .swatch.limit { background: none; border-top: 2px dashed var(--critical); height: 0; }
.chart .missing { color: var(--muted); font-size: .85rem; padding: 12px 6px; }
.u-legend { display: none; }
.share-url { font-family: ui-monospace, monospace; font-size: .85rem; }
.drone-marker { background: var(--accent); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--accent); }
.home-marker { background: var(--surface); color: var(--text); border: 2px solid var(--text); border-radius: 6px; font-size: 12px; font-weight: 700; text-align: center; line-height: 18px; }

/* ---------- Meters (app/graphics.py) ---------- */
.gfx { display: block; width: 100%; height: auto; overflow: visible; }
.gfx .g-track { fill: var(--surface-2); }
.gfx .g-track-stroke { fill: none; stroke: var(--surface-2); stroke-width: 9; stroke-linecap: round; }
.gfx .g-fill { fill: var(--series-1); }
.gfx .g-fill-stroke { fill: none; stroke: var(--series-1); stroke-width: 9; stroke-linecap: round; }
.gfx .g-warm { fill: var(--series-2); }
.gfx .g-needle { stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.gfx .g-hub, .gfx .g-marker { fill: var(--text); }
.gfx .g-tick { fill: var(--muted); font: 8px system-ui, -apple-system, sans-serif; }
.gfx .g-tickline { stroke: var(--axis); stroke-width: 1; }
.gfx .g-limit { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 4 3; }
.gfx .g-limit-text { fill: var(--critical); }
.gfx .g-outline { fill: none; stroke: var(--text-2); stroke-width: 3; }
.gfx .g-outline-fill { fill: var(--text-2); }
.gfx .g-good { fill: var(--good); }
.gfx .g-warn { fill: var(--warning); }
.gfx .g-crit { fill: var(--critical); }
.gfx.dial { max-width: 180px; margin: 4px auto 0; }
.gfx.bar { max-width: 240px; margin: 10px auto 0; }
.gfx.column, .gfx.thermo { max-width: 130px; height: 110px; margin: 4px auto 0; }
.gfx.battery { max-width: 110px; margin: 8px auto 0; }
.record-gfx { padding: 4px 0 2px; }
.record { text-align: center; }
.record h3 { text-align: left; }
.record .record-meta, .record .record-link { text-align: center; }

.summary.with-gfx { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.summary.with-gfx .stat { text-align: center; }
.summary.with-gfx .stat-label { text-align: left; }
.stat-gfx { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4px 0; }
.stat-gfx .gfx.column, .stat-gfx .gfx.thermo { height: 90px; }
.stat-gfx .gfx.dial { max-width: 130px; }

/* ---------- Home: weather + recent flights ---------- */
.home-top { display: grid; gap: 16px; margin-top: 16px; }
.home-top .card { margin: 0; }
@media (min-width: 860px) { .home-top { grid-template-columns: 1.2fr 1fr; } }
.tiny { font-size: .75rem; margin: 10px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 9px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; border: 0; background: none; color: var(--text-2); padding: 6px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border-left: 5px solid var(--good); margin: 8px 0 12px; }
.verdict.caution { border-left-color: var(--warning); }
.verdict.no { border-left-color: var(--critical); }
.verdict-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-weight: 800; font-size: .8rem; color: #fff; background: var(--good); }
.verdict.caution .verdict-icon { background: var(--warning); color: #111; }
.verdict.no .verdict-icon { background: var(--critical); }
.verdict-why { flex-basis: 100%; font-size: .85rem; color: var(--text-2); }
.wx-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.wx-tile { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.wx-value { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.wx-arrow { display: inline-block; font-weight: 700; color: var(--accent); }
.wx-hours { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(78px, 1fr); gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.wx-hour { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--border); border-radius: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.dot.caution { background: var(--warning); }
.dot.no { background: var(--critical); }

.recent-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.recent-row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; text-decoration: none; color: var(--text);
  padding: 6px; border-radius: 10px; }
.recent-row:hover, .recent-row:focus-visible { background: var(--surface-2); }
.thumb { width: 96px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--surface-2); pointer-events: none; }
.recent-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-date { font-weight: 600; }
@media (max-width: 520px) {
  .records { grid-template-columns: 1fr 1fr; gap: 8px; }
  .record { padding: 10px; }
  .record h3 { font-size: .8rem; }
  .record-value { font-size: 1.15rem; }
  .record-link { font-size: .78rem; }
  .gfx.column, .gfx.thermo { height: 90px; }
}

/* Gradient stops for meters (cool = aqua→blue→violet, warm = amber→orange→red) */
:root { --gc1: #1baf7a; --gc2: #2a78d6; --gc3: #4a3aa7; --gw1: #eda100; --gw2: #eb6834; --gw3: #d03b3b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --gc1: #199e70; --gc2: #3987e5; --gc3: #9085e9; --gw1: #c98500; --gw2: #d95926; --gw3: #e66767; }
}
:root[data-theme="dark"] { --gc1: #199e70; --gc2: #3987e5; --gc3: #9085e9; --gw1: #c98500; --gw2: #d95926; --gw3: #e66767; }
.gfx .g-cool1 { stop-color: var(--gc1); } .gfx .g-cool2 { stop-color: var(--gc2); } .gfx .g-cool3 { stop-color: var(--gc3); }
.gfx .g-warm1 { stop-color: var(--gw1); } .gfx .g-warm2 { stop-color: var(--gw2); } .gfx .g-warm3 { stop-color: var(--gw3); }
.gfx .g-good1 { stop-color: #0a8f0a; } .gfx .g-good2 { stop-color: #0ca30c; } .gfx .g-good3 { stop-color: #1baf7a; }
.gfx.icon { max-width: 70px; margin: 6px auto 0; }
.home-marker { background: #fff; border: 2px solid #111; border-radius: 7px; box-shadow: 0 2px 4px rgba(0,0,0,.4); display: grid; place-items: center; }
.home-marker svg { width: 16px; height: 16px; }

/* ---------- Events table + map pins ---------- */
.events { max-height: 420px; }
.ev-filters { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.ev-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.ev-meta { flex-basis: 100%; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.events li.current { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ev-mark { display: flex; justify-content: center; padding-top: 2px; }
.badge.mode { box-shadow: inset 3px 0 0 var(--series-1); }
.badge.battery { box-shadow: inset 3px 0 0 var(--good); }
.badge.signal { box-shadow: inset 3px 0 0 var(--gc3); }

/* Pin colours: gradient per kind, like AirData's markers */
.map-pin, .pin-dot { --p1: #6da7ec; --p2: #2a78d6; }
.map-pin.serious, .pin-dot.serious { --p1: #f07a7a; --p2: #b82e2e; }
.map-pin.warning, .pin-dot.warning { --p1: #ffd36b; --p2: #e09600; }
.map-pin.limit, .pin-dot.limit { --p1: #f6a37f; --p2: #d9541f; }
.map-pin.signal, .pin-dot.signal { --p1: #b3a9f2; --p2: #5b4bc4; }
.map-pin.mode, .pin-dot.mode { --p1: #86b6ef; --p2: #256abf; }
.map-pin {
  background: none; border: 0;
}
.map-pin .pin-shape {
  position: absolute; left: 1px; top: 0; width: 24px; height: 24px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: linear-gradient(90deg, var(--p1), var(--p2));
  border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .45); box-sizing: border-box;
}
.map-pin b {
  position: absolute; left: 0; top: 0; width: 26px; height: 24px; display: grid; place-items: center;
  color: #fff; font: 700 11px/1 system-ui, sans-serif; text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.map-pin.warning b { color: #111; text-shadow: none; }
.pin-dot {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px;
  background: linear-gradient(135deg, var(--p1), var(--p2)); color: #fff; font: 700 11px/1 system-ui, sans-serif;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
}
.pin-dot.warning { color: #111; text-shadow: none; }
.mini-batt { position: relative; display: inline-block; width: 22px; height: 11px; border: 1.5px solid var(--text-2);
  border-radius: 3px; padding: 1px; vertical-align: middle; }
.mini-batt::after { content: ""; position: absolute; right: -4px; top: 2.5px; width: 2px; height: 4px; background: var(--text-2); border-radius: 0 1px 1px 0; }
.mini-batt i { display: block; height: 100%; border-radius: 1px; background: linear-gradient(90deg, #0ca30c, #1baf7a); }
.batt-pin { background: none; border: 0; white-space: nowrap; }
.batt-pin .mini-batt { background: #fff; border-color: #222; }
.batt-pin .mini-batt::after { background: #222; }
.batt-pin b { margin-left: 6px; font: 700 12px system-ui, sans-serif; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 2px #000; }

/* Shortcut page */
.steps { padding-left: 1.3em; display: grid; gap: 10px; }
.steps ul { padding-left: 1.1em; display: grid; gap: 6px; margin-top: 6px; }
.key-box { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.key-box input { flex: 1; min-width: 0; }
.sample { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; font-size: .9rem; white-space: pre-wrap; }
.alert.good-alert { border-left-color: var(--good); }

/* Efficiency gauges (minutes / miles per battery) */
.gfx.gauge { width: 100%; max-width: 220px; height: auto; display: block; margin: 0 auto; }
.gfx .g-zone { fill: none; stroke-width: 7; }
:root { --zone1: var(--critical); --zone2: var(--gw2); --zone3: var(--warning); --zone4: var(--good); }
.gfx .g-tickmajor { stroke: var(--text-2); stroke-width: 1.5; }
.gfx .g-needle-red { stroke: var(--critical); stroke-width: 3; }
.efficiency { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; align-items: center; }
@media (min-width: 720px) { .efficiency { grid-template-columns: 1fr minmax(150px, 200px) 1fr; } }
.eff-dial { text-align: center; }
.eff-dial h3 { margin: 4px 0 0; }
.eff-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 0; }
.eff-mid { display: grid; gap: 8px; }
@media (max-width: 719px) {
  .eff-mid { grid-template-columns: repeat(3, 1fr); grid-column: 1 / -1; order: 3; }
  .eff-mid .stat-value { font-size: 1.05rem; }
  .eff-value { font-size: 1.3rem; }
  .eff-dial h3 { font-size: .85rem; }
}
.eff-mid .stat { text-align: center; }
.chart { position: relative; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: .8rem; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); font-variant-numeric: tabular-nums; }
.chart-tip b { font-weight: 700; }
.chart-tip .swatch { margin-right: 4px; }
#reprocess progress { display: block; width: 100%; margin-top: 6px; accent-color: var(--series-1); }

/* Record leaderboards */
.record-title { color: inherit; text-decoration: none; }
.record-title:hover { text-decoration: underline; }
.record-top { font-size: .8rem; margin-top: 2px; color: var(--muted); }
.seg a { font-size: .85rem; color: var(--text-2); padding: 6px 12px; text-decoration: none; }
.seg a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.leaderboard { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 10px; align-items: center; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.lb-row:hover { border-color: var(--axis); }
.lb-rank { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--surface-2); font-variant-numeric: tabular-nums; font-size: .9rem; }
.lb-top1 { background: linear-gradient(135deg, #f6d365, #d4a017); color: #3a2a00; }
.lb-top2 { background: linear-gradient(135deg, #e6e9ee, #a7adb7); color: #22262c; }
.lb-top3 { background: linear-gradient(135deg, #f0b98a, #b9733f); color: #3a1d06; }
.lb-main { display: grid; gap: 3px; min-width: 0; }
.lb-value { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.lb-go { white-space: nowrap; }
@media (max-width: 480px) { .seg a { padding: 6px 8px; } .page-head .seg { margin-top: 6px; } }

/* Upload page: live processing panel and upload progress */
.work-block { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); }
.work-block:first-of-type { border-top: 0; padding-top: 0; }
.work-line { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.work-current { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; display: grid; gap: 4px; }
.work-name { font-weight: 600; overflow-wrap: anywhere; }
.work progress, .upload-progress progress { display: block; width: 100%; height: 10px; accent-color: var(--series-1); }
.work progress.stage { height: 6px; }
.work-queue summary { cursor: pointer; font-size: .85rem; color: var(--text-2); }
.work-queue ol { margin: 6px 0 0; padding-left: 1.4em; font-size: .85rem; color: var(--text-2); }
.work-queue li { overflow-wrap: anywhere; }
.upload-progress { display: grid; gap: 4px; }
[hidden] { display: none !important; }
.work-line > .muted { white-space: nowrap; }
.work-queue li.muted { list-style: none; margin-left: -1.4em; }

/* Flights: filters and selection */
.filters summary { cursor: pointer; }
.filter-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: 10px; }
.filter-form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px 10px; margin: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-form legend { font-size: .85rem; font-weight: 600; padding: 0 4px; }
.filter-form label { display: grid; gap: 2px; font-size: .8rem; color: var(--text-2); }
.filter-form input, .filter-form select { font: inherit; font-size: .95rem; width: 100%; min-width: 0; padding: 6px 8px;
  border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--text); }
.filter-form select { grid-column: 1 / -1; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filter-form > p { grid-column: 1 / -1; margin: 0; }
.select-bar { position: sticky; top: var(--topbar-h, 58px); z-index: 10; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; padding: 8px 12px; margin: 12px 0 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.flight-list.selectable li { display: grid; grid-template-columns: 40px 1fr; align-items: stretch; }
.pick { display: grid; place-items: center; cursor: pointer; }
.pick input { width: 20px; height: 20px; }
.flight-list li.picked .flight-row { border-color: var(--series-1); }
.list-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 4px 0 12px; font-size: .9rem; }
.list-tools select { font: inherit; padding: 5px 8px; margin-left: 4px; border: 1px solid var(--axis); border-radius: 6px;
  background: var(--surface); color: var(--text); }

/* Batteries (home page) */
.batteries { display: grid; gap: 12px; }
.battery-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.battery-head h3 { margin: 0; overflow-wrap: anywhere; }
.battery-head p { margin: 2px 0 0; }
.battery-icon { width: 64px; flex: none; }
.battery-icon .gfx { width: 100%; height: auto; display: block; }
.battery-stats { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.battery-stats .stat-value { font-size: 1.15rem; }

/* Photos / videos, heading arrow, path colouring, GPS table */
.map-pin.rth, .pin-dot.rth { --p1: #7fd1b0; --p2: #13865c; }
.media-pin { display: grid; place-items: center; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.media-pin svg { width: 14px; height: 14px; }
.media-pin.photo, .pin-dot.photo { background: linear-gradient(135deg, #3fa0ff, #1f5fbf); }
.media-pin.video, .pin-dot.video { background: linear-gradient(135deg, #ff7a6b, #c6352a); }
.pin-dot.photo, .pin-dot.video { display: inline-grid; place-items: center; }
.pin-dot.photo svg, .pin-dot.video svg { width: 12px; height: 12px; }
.badge.rth { box-shadow: inset 3px 0 0 #13865c; }
.badge.photo { box-shadow: inset 3px 0 0 #1f5fbf; }
.badge.video { box-shadow: inset 3px 0 0 #c6352a; }
.drone-marker { position: relative; }
.drone-heading { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }
.drone-heading::before { content: ""; position: absolute; left: -6px; top: -22px; border: 6px solid transparent;
  border-bottom: 12px solid var(--accent); border-top: 0; filter: drop-shadow(0 0 1px #fff); }
.path-mode { background: var(--surface); color: var(--text); padding: 4px 8px; font-size: .8rem; }
.path-mode select { font: inherit; margin-left: 4px; background: var(--surface); color: var(--text); border: 1px solid var(--axis); border-radius: 4px; }
.path-legend { background: var(--surface); color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: .75rem;
  display: grid; gap: 2px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.path-legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.gps-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.details-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.details-grid .stat-value { font-size: 1.05rem; overflow-wrap: anywhere; }
.rth-list { margin: 8px 0 0; padding-left: 1.2em; }

/* Weather: sunrise/sunset and wind by height */
.wx-sun { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 10px; font-size: .9rem; }
.sun-icon { color: #e8a200; }
.sun-icon.set { color: #d9541f; }
.wx-aloft { margin-top: 10px; font-size: .9rem; }
.wx-aloft caption { text-align: left; font-weight: 600; padding-bottom: 4px; }
.wx-aloft td, .wx-aloft th { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.wx-aloft .dot { display: inline-block; }

/* Flying: airfield weather and logbook */
.metar-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.metar-box code { flex: 1; font: 600 .95rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.metar-box .btn { padding: 6px 10px; }
.fly-top { display: grid; gap: 12px; align-items: start; }
@media (min-width: 640px) { .fly-top { grid-template-columns: 180px 1fr; } }
.rwy-diagram { width: 100%; max-width: 180px; margin: 0 auto; display: block; }
.rwy-ring { fill: var(--surface-2); stroke: var(--border); }
.rwy-tick { font-size: 9px; fill: var(--muted); font-weight: 600; }
.rwy-strip { fill: var(--text-2); }
.rwy-num { font-size: 7px; fill: var(--surface); font-weight: 700; }
.rwy-wind { stroke: var(--accent); stroke-width: 3.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fly-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.small-value { font-size: .95rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fly-hours td, .fly-hours th { white-space: nowrap; }
.logbook-table { font-size: .85rem; }
.logbook-table td, .logbook-table th { white-space: nowrap; vertical-align: top; }
.logbook-table td.remarks { white-space: normal; min-width: 160px; color: var(--text-2); }
.logbook-table tr:target { background: var(--surface-2); }
.logbook-table tfoot td { font-weight: 650; border-top: 2px solid var(--axis); }
.lb-form { display: grid; gap: 12px; }
.lb-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; margin: 0;
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.lb-form legend { font-weight: 650; padding: 0 4px; }
.lb-form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--text-2); }
.lb-form label.wide { grid-column: 1 / -1; }
.lb-form label.check { flex-direction: row; align-items: center; gap: 8px; }
.lb-form select { width: 100%; padding: 10px; font-size: 16px; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 650; background: var(--surface-2); }
.status-pill.good { box-shadow: inset 3px 0 0 var(--good); }
.status-pill.no { box-shadow: inset 3px 0 0 var(--critical); }
.fly-hours .dot { display: inline-block; vertical-align: middle; }
.official { margin-bottom: 16px; }
.official h3 { margin: 0 0 6px; }
.official-head { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; }
.metar-box code.taf { white-space: pre-wrap; }
.status-pill.cat-vfr { box-shadow: inset 3px 0 0 var(--good); }
.status-pill.cat-mvfr { box-shadow: inset 3px 0 0 var(--accent); }
.status-pill.cat-ifr { box-shadow: inset 3px 0 0 var(--critical); }
.status-pill.cat-lifr { box-shadow: inset 3px 0 0 #b03ab0; }

/* Server status */
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 6px 0; }
.meter span { display: block; height: 100%; background: var(--good); border-radius: 4px; transition: width .4s ease; }
.meter span.warm { background: var(--warning); }
.meter span.hot { background: var(--critical); }
.srv-log { max-height: 360px; overflow: auto; background: var(--surface-2); border-radius: 10px; padding: 10px 12px;
  font: .8rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
