/* LunaHorizon design system */
:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --surface-3: #e3e8f0;
  --border: #d7dde8;
  --text: #0f1728;
  --text-2: #465068;
  --text-3: #5d6680;
  --accent: #2a64d6;
  --accent-ink: #ffffff;
  --sun: #e89a00;
  --sun-soft: rgba(232, 154, 0, .16);
  --earth: #2a78d6;
  --earth-soft: rgba(42, 120, 214, .14);
  --both: #1baf7a;
  --both-soft: rgba(27, 175, 122, .15);
  --dsn: #7a8499;
  --relay: #4a3aa7;
  /* text versions of the chart colours, readable (WCAG AA 4.5:1) on their tints and on cards */
  --sun-ink: #8a5a00;
  --earth-ink: #1d5fae;
  --both-ink: #0b7350;
  --relay-ink: #4a3aa7;
  --artemis-ink: #1f52b8;
  --good: #0a7a0a;
  --warn: #c98500;
  --bad: #c03030;
  --grid: rgba(15, 23, 40, .08);
  --shadow: 0 1px 2px rgba(15, 23, 40, .06), 0 4px 16px rgba(15, 23, 40, .06);
  --radius: 14px;
  --radius-s: 9px;
  --pad: 16px;
  --top-h: 58px;
  --tab-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020;
    --surface: #121a2e;
    --surface-2: #19223a;
    --surface-3: #222d49;
    --border: #2a3654;
    --text: #eef2fb;
    --text-2: #b3bdd3;
    --text-3: #8791aa;
    --accent: #5b8cff;
    --accent-ink: #081021;
    --sun: #c98500;
    --sun-soft: rgba(242, 179, 61, .16);
    --earth: #3987e5;
    --earth-soft: rgba(57, 135, 229, .18);
    --both: #199e70;
    --both-soft: rgba(25, 158, 112, .2);
    --dsn: #8791aa;
    --relay: #9085e9;
    --sun-ink: #e0a030;
    --earth-ink: #7ab2f5;
    --both-ink: #45cf98;
    --relay-ink: #aea5f5;
    --artemis-ink: #93b4ff;
    --good: #3ccf5a;
    --bad: #ff7a7a;
    --grid: rgba(255, 255, 255, .07);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #19223a;
  --surface-3: #222d49;
  --border: #2a3654;
  --text: #eef2fb;
  --text-2: #b3bdd3;
  --text-3: #8791aa;
  --accent: #5b8cff;
  --accent-ink: #081021;
  --sun: #c98500;
  --sun-soft: rgba(242, 179, 61, .16);
  --earth: #3987e5;
  --earth-soft: rgba(57, 135, 229, .18);
  --both: #199e70;
  --both-soft: rgba(25, 158, 112, .2);
  --dsn: #8791aa;
  --relay: #9085e9;
  --sun-ink: #e0a030;
  --earth-ink: #7ab2f5;
  --both-ink: #45cf98;
  --relay-ink: #aea5f5;
  --artemis-ink: #93b4ff;
  --good: #3ccf5a;
  --bad: #ff7a7a;
  --grid: rgba(255, 255, 255, .07);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  min-height: 100vh; overflow-x: hidden;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
@media (min-width: 900px) { body { padding-bottom: 0; } }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--text-3); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand svg { stroke: none; }

/* ---------- top bar & tab bar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; gap: 16px; padding: 0 var(--pad);
  padding-left: max(var(--pad), env(safe-area-inset-left)); padding-right: max(var(--pad), env(safe-area-inset-right));
  background: var(--bg);   /* fallback for browsers without color-mix (iOS < 16.2, Chrome < 111) */
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-size: 1.1rem; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 700; }
.mainnav { display: none; gap: 4px; margin-left: 12px; }
.mainnav a { text-decoration: none; color: var(--text-2); padding: 7px 12px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.active { background: var(--surface-3); color: var(--text); }
.topactions { margin-left: auto; display: flex; gap: 4px; }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--text-2); }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg { width: 20px; height: 20px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--text-3); font-size: 11px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent); }
@media (max-width: 380px) { .tabbar a { font-size: 10px; letter-spacing: -0.01em; } }
@media (max-width: 320px) { .tabbar a { font-size: 9px; letter-spacing: -0.02em; } }
@media (min-width: 900px) { .mainnav { display: flex; } .tabbar { display: none; } }
@media (max-width: 339px) { .brand span { display: none; } .topbar { gap: 8px; } .iconbtn { width: 36px; } }

/* ---------- layout */
main { outline: none; }
.page { max-width: 1440px; margin: 0 auto; padding: 18px var(--pad) 40px; padding-left: max(var(--pad), env(safe-area-inset-left)); padding-right: max(var(--pad), env(safe-area-inset-right)); animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } * { transition: none !important; } }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 16px; }
.pagehead h1 { font-size: clamp(1.35rem, 3vw, 1.9rem); margin: 0; }
.pagehead p { margin: 4px 0 0; color: var(--text-2); max-width: 70ch; }
.pagehead .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr; }
@media (min-width: 1100px) { .cols-2 { grid-template-columns: minmax(0, 1fr) 360px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card > header h2, .card > header h3 { margin: 0; }
.card > header .spacer { flex: 1; }
.card.flush > header { padding: 12px 16px 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hr { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; user-select: none; -webkit-user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); min-height: 30px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 600; min-width: 0; }
.field > span { display: flex; justify-content: space-between; gap: 8px; }
.field output { color: var(--text); font-family: var(--font); font-variant-numeric: tabular-nums; }
input[type="text"], input[type="number"], input[type="datetime-local"], input[type="date"], input[type="search"], select {
  min-height: 38px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0; width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); font-weight: 500; cursor: pointer; }
.formgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); min-height: 32px;
}
.chip:hover { border-color: var(--text-3); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .6; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--surface-3); color: var(--text-2); vertical-align: middle; }
.tag.artemis { background: rgba(91, 140, 255, .18); color: var(--artemis-ink); }
.tag.clps { background: var(--both-soft); color: var(--both-ink); }
.tag.custom { background: var(--sun-soft); color: var(--sun-ink); }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.sun { color: var(--sun-ink); background: var(--sun-soft); }
.pill.earth { color: var(--earth-ink); background: var(--earth-soft); }
.pill.both { color: var(--both-ink); background: var(--both-soft); }
.pill.relay { color: var(--relay-ink); background: var(--surface-2); background: color-mix(in srgb, var(--relay) 16%, transparent); }
.pill.off { color: var(--text-3); background: var(--surface-2); }
.pill.off::before { background: transparent; border: 2px solid currentColor; width: 6px; height: 6px; }

/* KPI tiles */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px 12px; min-width: 0; position: relative; }
.kpi .k { font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v small { font-size: .7em; font-weight: 600; }
.kpi .s { font-size: 12px; color: var(--text-2); }
.kpi .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.kpi.wide { grid-column: 1 / -1; }

/* charts */
.chart { position: relative; width: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart canvas { display: block; width: 100%; height: 100%; }
.pano { height: clamp(240px, 38vh, 380px); background: #03050b; border-radius: var(--radius) var(--radius) 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; line-height: 1.45; display: none;
}
.tooltip b { font-weight: 700; }
.tooltip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* time bar */
.timebar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.timebar .when { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; min-width: 0; }
.timebar input[type="datetime-local"] { width: auto; max-width: 100%; }
.timebar .grp { display: flex; gap: 4px; align-items: center; }
.timebar .spacer { flex: 1; }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-s); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.data th { font-size: 12px; color: var(--text-3); font-weight: 700; background: var(--surface); }
table.data th[aria-sort] { cursor: pointer; user-select: none; }
table.data th.sorted { color: var(--text); }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
.bar { position: relative; display: inline-block; min-width: 56px; }
.bar > i { position: absolute; left: 0; bottom: -3px; height: 3px; border-radius: 2px; }
td.best { font-weight: 800; }
td.best::after { content: " ★"; color: var(--sun); font-size: 11px; }

/* site list */
.sitelist { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.siteitem { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--surface-2); text-decoration: none; color: var(--text); border: 1px solid transparent; cursor: pointer; text-align: left; width: 100%; }
.siteitem:hover { border-color: var(--border); background: var(--surface-3); }
.siteitem .nm { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.siteitem .co { font-size: 12px; color: var(--text-3); flex: none; }
.evlist .siteitem { flex-wrap: wrap; row-gap: 2px; }
.evlist .siteitem .nm { white-space: normal; }
.evlist .siteitem .co { flex-basis: 100%; padding-left: 20px; }

/* home */
.hero { position: relative; overflow: hidden; border-radius: 20px; background: radial-gradient(120% 140% at 80% 0%, #1d2a50 0%, #0b1020 55%, #05070f 100%); color: #eef2fb; padding: clamp(20px, 5vw, 44px); min-height: 280px; isolation: isolate; }
.hero h1 { color: #fff; max-width: 18ch; }
.hero p { color: #c6cee2; max-width: 56ch; font-size: 1.05rem; }
.hero > canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.hero .row .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.hero .row .btn.primary { background: #5b8cff; border-color: #5b8cff; color: #061022; }
.features { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.feature { text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px; transition: transform .15s, border-color .15s; }
.feature:hover { transform: translateY(-2px); border-color: var(--accent); }
.feature .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.feature .ic svg { width: 22px; height: 22px; }
.feature h2 { font-size: 1rem; margin: 0; }
.feature p { color: var(--text-2); margin: 0; font-size: 14px; }
.livegrid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }

/* install tip */
.installtip { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; margin-bottom: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.installtip .ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--surface-2); color: var(--accent); }
.installtip .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); line-height: 1.4; }
.installtip .tx b { color: var(--text); font-size: 14px; }
.installtip .act { display: flex; align-items: center; gap: 2px; flex: none; }
/* Offline: top-bar pill, save panel */
.netpill { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; margin-right: 4px; border-radius: 999px; align-self: center;
  background: #6b4a00; color: #fff; font-size: 12px; font-weight: 700; }
.netpill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; }
.netpill[hidden] { display: none; }
@media (max-width: 400px) { .netpill { width: 32px; padding: 0; justify-content: center; } .netpill span { display: none; } }
.is-offline #btn-install { display: none; }        /* installing needs a connection: the Offline pill takes its place */
.offpanel { display: flex; flex-direction: column; gap: 10px; }
.offbar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.offbar > span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
/* Install button (top bar), dialog steps */
.installbtn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 10px; margin-right: 4px; border-radius: 999px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; align-self: center; }
.installbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.installbtn:hover, .installbtn.ready { background: var(--accent); color: var(--accent-ink); }
.installbtn[hidden] { display: none; }
@media (max-width: 400px) { .installbtn { padding: 0; width: 36px; justify-content: center; margin-right: 0; } .installbtn span { display: none; } }
.isteps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); }
.isteps svg { fill: none; stroke: currentColor; stroke-width: 2; }
.allplat summary { cursor: pointer; font-weight: 700; }
.allplat dl { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.allplat dt { font-weight: 700; } .allplat dd { margin: 0; color: var(--text-2); }
@media (max-width: 520px) { .allplat dl { grid-template-columns: 1fr; gap: 2px; } .allplat dd { margin-bottom: 8px; } }
@media (max-width: 420px) { .installtip { flex-wrap: wrap; } .installtip .act { width: 100%; justify-content: space-between; padding-left: 52px; } }

/* map */
.mapwrap { position: relative; height: clamp(380px, calc(100vh - 220px), 900px); background: #000; border-radius: var(--radius); overflow: hidden; touch-action: none; }
.mapwrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.maptools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.maptools > * { pointer-events: auto; }
.mapzoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.mapzoom .btn { width: 40px; padding: 0; background: rgba(18, 26, 46, .9); color: #fff; border-color: rgba(255, 255, 255, .15); }
.maplegend { position: absolute; left: 10px; bottom: 10px; background: rgba(8, 12, 24, .85); color: #dfe5f3; border-radius: 10px; padding: 8px 10px; font-size: 12px; max-width: calc(100% - 80px); }
.maplegend .ramp { height: 10px; width: 180px; max-width: 100%; border-radius: 3px; margin: 4px 0 2px; }
.maplegend .ends { display: flex; justify-content: space-between; }
.mapcard { position: absolute; z-index: 6; width: min(310px, calc(100% - 20px)); }
.maptools .seg, .seg.dark { background: rgba(8, 12, 24, .85); border-color: rgba(255, 255, 255, .15); }
.maptools .seg button, .seg.dark button { color: #b3bdd3; }
.maptools .seg button.on, .seg.dark button.on { background: #5b8cff; color: #061022; }

/* 3D controls: compact on phones so the terrain stays visible */
@media (max-width: 600px) {
  .hud3d { gap: 6px !important; }
  .hud3d .seg { padding: 2px; }
  .hud3d .seg button { font-size: 12px; padding: 3px 7px; min-height: 26px; }
  .hud3d select { font-size: 13px; min-height: 30px; padding: 2px 6px; max-width: 46vw; }
}
/* 3D labels */
.g3 { transform: translate(-50%, -50%); color: #eef2fb; font: 600 12px/1.2 system-ui, sans-serif; white-space: nowrap; text-shadow: 0 0 3px #000, 0 0 6px #000; display: flex; align-items: center; gap: 5px; }
.g3-site { transform: translate(-6px, -50%); opacity: .9; }
.g3-site.on { color: #ffd46b; font-size: 13px; opacity: 1; }
.g3-pin { width: 8px; height: 8px; border-radius: 50%; background: #5b8cff; border: 1.5px solid #fff; flex: none; }
.g3-site.on .g3-pin { background: #f2b33d; }
.g3-sun { width: 18px; height: 18px; border-radius: 50%; background: #fff4d6; box-shadow: 0 0 14px 6px rgba(255, 212, 107, .7); }
.g3-earth { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #9fd0ff, #2a78d6 60%, #123e7a); box-shadow: 0 0 8px rgba(120, 180, 255, .6); }

/* calendar heatmap */
.heat { position: relative; }
.heat canvas { display: block; width: 100%; }

/* dialog */
dialog { border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
/* browsers without <dialog>.showModal (iOS < 15.4) get a fixed panel */
dialog.fallback[open] { position: fixed; inset: 20px 0 auto; margin: 0 auto; z-index: 90; overflow: auto; }
dialog::backdrop { background: rgba(3, 6, 14, .55); backdrop-filter: blur(3px); }
dialog .dlg-h { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog .dlg-h h2 { margin: 0; flex: 1; }
dialog .dlg-b { padding: 16px 18px; display: flex; flex-direction: column; gap: 18px; }
dialog fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 0; }
dialog legend { font-weight: 700; padding: 0 6px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { #toast { bottom: 24px; } }

/* busy */
.busy { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 14px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--text-3); }

/* prose (learn) */
.prose { max-width: 76ch; }
.prose h2 { margin-top: 1.2em; }
.prose p, .prose li { color: var(--text-2); }
.prose li { margin-bottom: .35em; }
.callout { border-left: 4px solid var(--accent); background: var(--surface-2); padding: 10px 14px; border-radius: 0 10px 10px 0; margin: 12px 0; color: var(--text-2); }
dl.gloss dt { font-weight: 700; margin-top: 10px; }
dl.gloss dd { margin: 2px 0 0; color: var(--text-2); }

/* utility */
@media (min-width: 700px) { .kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { text-align: center; color: var(--text-3); padding: 30px 10px; }
.warnbox { border: 1px solid var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: var(--surface-2); background: color-mix(in srgb, var(--warn) 10%, transparent); padding: 10px 12px; border-radius: 10px; font-size: 13px; color: var(--text-2); }
.ok { color: var(--good); font-weight: 700; }
.no { color: var(--bad); font-weight: 700; }
