:root {
  --bg: #0b0f17;
  --card: rgba(16, 22, 35, .90); --card-solid: #101623; /* opaque twin, for elements the panel's content scrolls behind */
  --card-2: #0f1522;
  --line: #22304a;
  --text: #e6ecf5;
  --muted: #8b98b0;
  --accent: #5ac8fa;
  --accent-2: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --starlink: #5ac8fa;
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --panel-w: 360px;
  /* the phone panel's two heights and its bottom offset — read by the app so the map can start moving to the
     new centre at the same moment the panel starts animating, in one motion instead of two */
  --panel-h-tall: 62vh; --panel-h-low: 34vh; --panel-gap: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(90,200,250,.5); }
a:hover { text-decoration-color: var(--accent); }
a:visited { color: var(--accent); }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- 3D world ---------- */
.globe { position: fixed; inset: 0; z-index: 0; background: radial-gradient(ellipse at 50% 60%, #0d1424 0%, #070a10 70%); }
.globe canvas { display: block; }
.labels { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.labels .lbl {
  position: absolute; transform: translate(-50%, -140%); white-space: nowrap; font-size: 11px; line-height: 1;
  padding: 3px 6px; border-radius: 6px; background: rgba(11,15,23,.75); border: 1px solid var(--line); color: var(--text);
}
.labels .lbl.serving { border-color: #fff; color: #fff; font-weight: 700; }
.labels .lbl.hop { border-color: var(--accent-2); color: var(--accent-2); }
.labels .lbl.terminal { border-color: var(--ok); color: var(--ok); }
.labels .lbl.gateway { border-color: var(--warn); color: var(--warn); }
.labels .lbl.pop { border-color: #f472b6; color: #f472b6; }
.labels .lbl.server { border-color: #5ac8fa; color: #5ac8fa; }
.labels .lbl.airport { border-color: #9fb3d0; color: #9fb3d0; }
.labels .lbl.traffic { border-color: rgba(170,180,200,.5); color: #aab4c8; font-size: 10px; padding: 0 4px; opacity: .85; }

.viewchips { position: fixed; top: 12px; right: 14px; z-index: 3; display: flex; gap: 6px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: rgba(15,21,34,.8); color: var(--muted);
  border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover, .chip.on { border-color: var(--accent); color: var(--accent); }

/* ---------- the panel ---------- */
.panel {
  position: fixed; top: 16px; left: 16px; width: var(--panel-w); max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); z-index: 4;
  background: var(--card); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 12px; overflow-y: auto; scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 12px;
  transition: max-height .3s ease;
}
/* The panel is a column flexbox with max-height + overflow-y: without this, an item that contains an
   overflow-x:auto table (Details) can be flex-shrunk and its bottom clipped — the panel then "cannot
   scroll below a certain point". Items must keep their natural height and let the panel scroll. */
.panel > * { flex-shrink: 0; }
.results-wrap { display: flex; flex-direction: column; gap: 8px; }
.again { border-radius: 999px; padding: 6px 16px; font-size: 13px; color: var(--accent); border-color: rgba(90,200,250,.4); background: transparent; }
.brand { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.brand span { color: var(--accent); }
.disclaimer { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; text-align: center; line-height: 1.3; }
.brandrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acct { position: relative; }
.acct-btn { appearance: none; border: 1px solid var(--line); background: rgba(15,21,34,.8); color: var(--muted); border-radius: 999px; width: 34px; height: 34px; padding: 0; line-height: 0; box-sizing: border-box; display: grid; place-items: center; cursor: pointer; position: relative; }
.acct-btn svg { display: block; }
.acct-btn:hover, .acct-btn.open { color: var(--text); border-color: var(--accent); }
.acct-btn.in { color: var(--accent); border-color: rgba(90,200,250,.5); }
.acct-btn .dot { position: absolute; right: -1px; top: -1px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); border: 2px solid var(--bg); box-sizing: content-box; } /* centred on the rim at 45° (a 34 px circle: rim point 5 px from the box edges, dot 12 px wide) */
.acct-menu { position: absolute; right: 0; top: 40px; z-index: 5; min-width: 240px; background: rgba(15,21,34,.98); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13px; }
.acct-menu .mi { display: block; width: 100%; text-align: left; appearance: none; background: none; border: none; color: var(--text); font: inherit; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; }
.acct-menu .mi:hover { background: rgba(255,255,255,.06); }
.acct-menu .mi.owner { color: #e0b060; }
.acct-who { padding: 6px 10px 8px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.acct-who b { color: var(--text); font-weight: 600; }
.acct-form { display: flex; gap: 6px; padding: 4px 8px 6px; }
.acct-form input { flex: 1; min-width: 0; }
.acct-form button { white-space: nowrap; }
.acct-msg { padding: 4px 10px 6px; }

/* connection block */
.conn { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(15,21,34,.6); }
.conn-main { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.conn.pending .dot { animation: pulse 1.2s ease-in-out infinite; }
.conn.starlink { border-color: rgba(90,200,250,.55); background: linear-gradient(180deg, rgba(90,200,250,.10), rgba(15,21,34,.6)); }
.conn.starlink .dot { background: var(--starlink); box-shadow: 0 0 10px var(--starlink); }
.conn.starlink .conn-main { color: #cfeeff; }
.conn.other .dot { background: var(--warn); }
.conn-where { color: var(--text); font-size: 13px; margin-top: 3px; }
.conn-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; word-break: break-all; }
.dtc-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.dtc-hint b { color: #e0b060; }
.conn .tag { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; margin-left: 6px; vertical-align: 1px; }
.pos-line { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); font-size: 12px; }
.model-line { font-size: 12px; color: var(--muted); padding: 2px 12px 0; }
.model-line.cmp { color: var(--text); }
.model-line .cmp-row { display: flex; align-items: baseline; gap: 5px; padding: 1px 0; }
.model-line .cmp-row .k { min-width: 46px; color: var(--muted); }
.model-line .cmp-row b { font-variant-numeric: tabular-nums; }
.model-line .cmp-row .sw { display: inline-block; width: 14px; height: 0; border-top: 2px solid #7dd3fc; align-self: center; }
.model-line .cmp-row .sw.fib { border-top-color: #fb923c; }
.model-line .cmp-row .sw.geo { border-top-color: #c084fc; }
.model-line .cmp-row .geo-show { margin-left: auto; color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.model-line .cmp-row .geo-show input { margin: 0; }
.labels .lbl.geo { border-color: #c084fc; color: #c084fc; }
.report { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 13px; }
.report .cap { font-weight: 600; }
.report label.f { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; }
.report input[type=text], .report input[type=date], .report select { width: 100%; box-sizing: border-box; margin-top: 2px; }
.report .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.report .wifi-opts { display: flex; gap: 14px; margin-top: 8px; }
.report .wifi-opts .chk { color: var(--text); }
.labels .lbl.ref { border-color: rgba(143,176,216,.5); color: #a9c0dc; font-size: 10px; padding: 1px 5px; opacity: .85; }
.model-line .cmp-row.verdict { padding-left: 20px; font-size: 11.5px; }
.model-line .ok { color: var(--ok); }
.seg.mode { display: flex; width: 100%; margin: 2px 0 6px; border: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.seg.mode label { flex: 1; text-align: center; padding: 6px 4px 7px; color: var(--muted); border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.seg.mode label + label { border-left: none; }
.seg.mode label:has(input:checked) { color: var(--text); border-bottom-color: var(--accent); }
.seg.mode input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.pos-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.pos-line #pos-text { flex: 1; min-width: 0; }
.pos-line .flight-chip { padding: 2px 9px; font-size: 11.5px; }
.sim-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sim-row .k { font-size: 12px; font-weight: 600; color: var(--text); min-width: 88px; }
.sim .conn-sub { margin-top: 4px; }
.sim .flight-area .pos-line { border-top: none; padding-top: 0; margin-top: 4px; }
.sim .pos-line #btn-pos, .sim .pos-line #btn-flight { display: none; } /* the card's own chips do that */
/* location card: its first line needs no separator */
.loc .flight-live { border-top: none; margin-top: 0; padding-top: 0; }
.loc .flight-live.hidden + .pos-line, .loc .pos-line:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.conn + .conn { margin-top: 8px; }
.sim-row .chip { padding: 3px 9px; font-size: 12px; }
.sim-row .chip.picking { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.globe.pick canvas { cursor: crosshair !important; }
.pos-line .ok { color: var(--ok); }
.pos-line button.link { font-size: 12px; margin-left: 4px; }
.flight-area { display: flex; flex-direction: column; gap: 4px; }
.flight-area:empty { display: none; }
.flightpath { color: var(--muted); font-size: 11.5px; margin: 0; white-space: nowrap; }
.auto { color: var(--muted); font-size: 12px; margin-top: 4px; justify-content: center; }
.auto input { margin-right: 5px; }
.flightpath input { margin: 0 4px 0 0; }
.flight-chip { color: var(--text); background: rgba(90,200,250,.10); border-color: rgba(90,200,250,.35); white-space: nowrap; flex: none; }
.flight-chip.on { color: var(--accent); }
.flight-live { font-size: 12px; color: var(--ok); min-width: 0; line-height: 1.3; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.flight-live:not(.hidden) + .pos-line { margin-top: 2px; padding-top: 0; border-top: none; } /* the flight line above carries the separator */
.flight-live .muted { color: var(--muted); }
.flight-box { margin-top: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(15,21,34,.5); display: flex; flex-direction: column; gap: 6px; }
.flight-box .wide { width: 100%; }
.flight-box .or { text-align: center; color: var(--muted); font-size: 11px; }
.flight-form { display: flex; gap: 6px; }
.flight-form input { flex: 1; }
.flight-cands { display: flex; flex-direction: column; gap: 4px; }
.flight-cands button { text-align: left; font-size: 12px; padding: 5px 8px; }
.flight-cands button b { color: var(--accent); }
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

/* GO */
.go-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 0; }
.go {
  appearance: none; width: 128px; height: 128px; border-radius: 50%; cursor: pointer;
  border: 3px solid var(--accent); background: radial-gradient(circle at 50% 40%, rgba(90,200,250,.18), rgba(15,21,34,.9) 70%);
  color: var(--accent); font: 800 34px/1 system-ui, sans-serif; letter-spacing: .04em;
  box-shadow: 0 0 0 0 rgba(90,200,250,.35); transition: box-shadow .3s, transform .15s, border-color .3s, color .3s;
}
.go:hover { box-shadow: 0 0 0 10px rgba(90,200,250,.10); transform: scale(1.02); }
.go:active { transform: scale(.98); }
.go:disabled { cursor: default; transform: none; }
.go.running { border-color: var(--accent-2); color: var(--accent-2); animation: goPulse 1.4s ease-in-out infinite; }
.go.running span { font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.go.done { border-color: var(--ok); color: var(--ok); }
.go.done span { font-size: 22px; }
@keyframes goPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(167,139,250,.35) } 50% { box-shadow: 0 0 0 14px rgba(167,139,250,0) } }
.status { min-height: 18px; font-weight: 600; font-size: 13px; text-align: center; color: var(--muted); }
.status.run { color: var(--accent-2); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.err { color: var(--err); }

/* results */
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.metric .v { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric.big .v { font-size: 34px; color: var(--accent); line-height: 1.1; }
.metric .u { color: var(--muted); font-size: 11px; }
.metric .u.model { display: block; margin-top: 2px; color: var(--accent-2); }
.metric .u.model b { color: var(--text); font-weight: 600; }
.metric.small-metric { padding: 5px 12px; }
.metric.small-metric .v { font-size: 16px; }
.center { text-align: center; }
.verdict { text-align: center; color: var(--warn); border: 1px solid rgba(255,190,80,.35); background: rgba(255,190,80,.08); border-radius: 8px; padding: 6px 10px; line-height: 1.35; }
.verdict b { color: var(--text); }
.verdict a { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.verdict code { font-size: 11px; background: rgba(255,255,255,.06); padding: 1px 4px; border-radius: 4px; }
.sat-summary { text-align: center; color: var(--muted); min-height: 0; }
.sat-summary b { color: var(--text); }
.sat-summary .flow { color: var(--accent-2); }

/* details / options */
.more { border-top: 1px solid var(--line); padding-top: 8px; }
.more > summary { cursor: pointer; color: var(--muted); font-size: 13px; text-align: center; list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: '▸ '; }
.more[open] > summary::before { content: '▾ '; }
.more-body { padding-top: 8px; }
.block { border-top: 1px solid var(--line); padding: 8px 0; }
.block > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.block[open] > summary { color: var(--text); margin-bottom: 8px; }
details.sub { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 6px; }
details.sub > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details.sub[open] > summary { color: var(--text); margin-bottom: 6px; }
h3 { font-size: 12px; margin: 8px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- forms ---------- */
label { display: block; color: var(--muted); font-size: 12px; }
.val { font-size: 13px; word-break: break-word; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.badge {
  display: inline-block; background: rgba(90,200,250,.15); color: var(--accent);
  border: 1px solid rgba(90,200,250,.4); border-radius: 999px; padding: 0 8px; font-size: 12px; margin-left: 6px;
}
.badge.warn-badge { background: rgba(251,191,36,.12); color: var(--warn); border-color: rgba(251,191,36,.4); }
button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: #04121c; border-color: var(--accent); font-weight: 700; padding: 8px 18px; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-size: 12px; }
button.ghost { background: none; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { color: var(--text); font-size: 13px; padding: 5px 10px; cursor: pointer; margin: 0; }
.seg label + label { border-left: 1px solid var(--line); }
.seg input { margin-right: 5px; accent-color: var(--accent); }
label.chk { color: var(--text); font-size: 13px; }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); margin-right: 5px; }
input[type=text], input[type=number], input:not([type]), input[type=datetime-local], select {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px;
  padding: 6px 8px; font: inherit; font-size: 13px; width: 100%;
}
input[type=range] { vertical-align: middle; width: 120px; accent-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 10px; margin: 8px 0 0; }
.row label { min-width: 110px; flex: 1 1 110px; }
.row .grow { flex: 1 1 200px; }
/* rows of checkboxes: natural width, aligned on one baseline, no stretching */
.row.chks { align-items: center; gap: 4px 16px; margin-top: 4px; }
.row.chks label { min-width: 0; flex: 0 0 auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.row.chks input { margin: 0 2px 0 0; }
.warn { color: var(--warn); }
pre#log {
  background: #070a10; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 180px; overflow: auto;
  font: 11px/1.4 var(--mono); color: #b7c2d8; white-space: pre-wrap; margin: 0;
}
ol#ookla-list { padding-left: 18px; margin: 6px 0; font-size: 13px; }
ol#ookla-list li { margin: 3px 0; }
ol#ookla-list label { color: var(--text); font-size: 13px; }
code#ookla-cmd { font: 12px var(--mono); background: #070a10; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 160px; }
.tablewrap { overflow-x: auto; }
table#hist, table#sat-cands { border-collapse: collapse; width: 100%; font-size: 12px; }
table#hist th, table#hist td, table#sat-cands th, table#sat-cands td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table#hist th, table#sat-cands th { color: var(--muted); font-weight: 600; }
table#sat-cands tr[data-i] { cursor: pointer; }
table#sat-cands tr[data-i]:hover td { background: rgba(90,200,250,.06); }
table#sat-cands tr.sel td { color: var(--accent); font-weight: 600; }
table#sat-cands tr.noroute td { color: var(--muted); }
ol.sat-hops { padding-left: 16px; margin: 4px 0 6px; font-size: 12px; }
ol.sat-hops li { margin: 2px 0; }
.foot { margin-top: 12px; }
.sat-status { min-height: 18px; font-size: 12px; text-align: left; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* ---------- legend ---------- */
.legend {
  position: fixed; right: 14px; bottom: 12px; z-index: 3; display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted);
  background: rgba(11,15,23,.6); padding: 4px 8px; border-radius: 8px; pointer-events: none;
}
.legend .lbl-toggle { pointer-events: auto; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.legend .lbl-toggle input { margin: 0; }
.labels.off { display: none; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend i.ln { width: 14px; height: 0; border-radius: 0; border-top: 2px solid; vertical-align: 3px; }
.legend i.ln.dash { border-top-style: dashed; }
.legend .sep { width: 1px; height: 12px; background: var(--line); margin: 0 2px; }

/* ---------- responsive: panel becomes a bottom sheet ---------- */
.grab { display: none; }
@media (max-width: 720px) {
  .panel { top: auto; left: 8px; right: 8px; bottom: var(--panel-gap); width: auto; max-width: none; max-height: var(--panel-h-tall); padding: 0 14px 10px; gap: 10px; }
  /* the short position: enough for the connection line, the model row and GO — the map keeps the rest of the screen */
  .panel.low { max-height: var(--panel-h-low); }
  /* full-bleed over the panel's padding and sticky, so the handle stays reachable while the panel's content scrolls
     underneath it (opaque background — the panel itself is translucent) */
  .grab {
    display: block; align-self: stretch; width: auto; height: 22px; padding: 0; margin: 0 -14px 2px; flex-shrink: 0;
    background: var(--card-solid); border: 0; cursor: pointer; touch-action: none;
    position: sticky; top: 0; z-index: 3; border-radius: var(--radius) var(--radius) 0 0;
  }
  .grab::before { content: ''; position: absolute; left: 50%; transform: translateX(-50%); top: 9px; width: 44px; height: 4px; border-radius: 999px; background: var(--line); }
  .grab:hover::before, .panel.low .grab::before { background: var(--accent); }
  .brand { font-size: 18px; }
  .go { width: 96px; height: 96px; font-size: 26px; }
  .metric.big .v { font-size: 28px; }
  .legend { display: none; }
  .viewchips { top: 10px; right: 10px; }
}
