/* Magnetic Field Check. Colours are the other tools' tokens, so the platform
   reads as one; the charts' series are the validated blue, orange and aqua,
   and the map's scale runs from blue through a neutral grey to red. */

:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f2ee;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --border: rgba(11, 11, 11, 0.10);
  --good-ink: #006300; --warning-ink: #8a5a00; --critical-ink: #b3261e; --critical: #d03b3b;
  --accent: #2a78d6; --focus: #2a78d6;
  --grid: #e1e0d9; --axis: #c3c2b7; --series-1: #2a78d6; --series-2: #eb6834;
  --series-3: #1baf7a; --div-neg: #184f95; --div-mid: #f0efec; --div-pos: #9c2424;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 2px 8px rgba(11, 11, 11, 0.04);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --border: rgba(255, 255, 255, 0.10);
    --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #e66767;
    --accent: #3987e5; --focus: #6da7ec;
    --grid: #2c2c2a; --axis: #383835; --series-1: #3987e5; --series-2: #d95926; --shadow: none;
    --series-3: #199e70; --div-neg: #86b6ef; --div-mid: #383835; --div-pos: #f08f8a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --border: rgba(255, 255, 255, 0.10);
  --good-ink: #0ca30c; --warning-ink: #fab219; --critical-ink: #e66767;
  --accent: #3987e5; --focus: #6da7ec;
  --grid: #2c2c2a; --axis: #383835; --series-1: #3987e5; --series-2: #d95926; --shadow: none;
    --series-3: #199e70; --div-neg: #86b6ef; --div-mid: #383835; --div-pos: #f08f8a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font);
             font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
body.loading .layout { visibility: hidden; }
a { color: var(--accent); }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
          flex-wrap: wrap; padding: 10px 20px; background: var(--surface);
          border-bottom: 1px solid var(--border); }
.back { color: var(--accent); text-decoration: none; white-space: nowrap; }
.back:hover { text-decoration: underline; }
.brand h1 { font-size: 16px; font-weight: 650; margin: 0; }
.subtitle { margin: 0; color: var(--ink-2); font-size: 13px; }
.actions { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; border: 1px solid var(--border);
       background: var(--surface); border-radius: 8px; padding: 5px 11px; cursor: pointer;
       white-space: nowrap; text-decoration: none; color: inherit; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

.layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px;
          padding: 16px 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 12px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 6px; }
.results { display: grid; gap: 16px; min-width: 0; }
.form { position: sticky; top: 70px; max-height: calc(100vh - 86px); overflow: auto; }
@media (max-width: 900px) { .form { position: static; max-height: none; } }
fieldset { border: 0; margin: 12px 0 0; padding: 0; min-width: 0; }
legend, label { font-weight: 600; font-size: 13px; padding: 0; }
fieldset.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset.two label { display: block; }
input:not([type=checkbox]):not([type=range]), select {
  width: 100%; margin-top: 4px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input[type=number] { width: 90px; flex: none; }
.row input[type=range] { flex: 1; min-width: 120px; accent-color: var(--accent); }
.invalid { border-color: var(--critical) !important; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.caution { color: var(--warning-ink); font-size: 12.5px; margin: 6px 0 0; }
.muted { color: var(--ink-2); margin: 0; }
.error-box { margin-top: 10px; padding: 8px 10px; border-radius: 8px; color: var(--critical-ink);
             border: 1px solid var(--critical); }


.check { display: flex; gap: 8px; align-items: baseline; margin-top: 8px; cursor: pointer; }
.check input { transform: translateY(2px); }
fieldset > label:not(.check) { display: block; margin-top: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.two label { display: block; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input[type=number] { width: 72px; }
.row.nowrap select { flex: 1; min-width: 0; }
fieldset > legend { font-size: 14px; font-weight: 650; margin-bottom: 2px; }
fieldset { border-top: 1px solid var(--border); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; margin-top: 10px; color: var(--ink-2); }
textarea { width: 100%; margin-top: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
           background: var(--surface); color: inherit; font: 12px/1.4 var(--mono); resize: vertical; }
.drop { border: 1.5px dashed var(--axis); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }
.drop p { margin: 0 0 8px; color: var(--ink-2); font-size: 13px; }
.drop.over { border-color: var(--accent); background: var(--surface-2); }
.loaded { margin: 8px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.loaded .tag { margin-left: 6px; }
.problems { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--warning-ink); }
.problems.bad { color: var(--critical-ink); }
.problems li { margin: 2px 0; }
.file-actions { display: flex; align-items: flex-end; }
.file-actions .btn { width: 100%; justify-content: center; }
fieldset .row { margin-top: 8px; }
.params { display: grid; gap: 8px; margin-top: 8px; }
.param { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 2px 8px; align-items: center; }
.param .pname { font-family: var(--mono); font-weight: 600; font-size: 12.5px; overflow-wrap: anywhere; }
.param .unit { color: var(--muted); font-weight: 400; font-family: var(--font); font-size: 12px; margin-left: 4px; }
.param .gloss { grid-column: 1 / -1; color: var(--muted); font-size: 12px; margin-top: -2px; }
.param input { margin-top: 0 !important; }
.param .from { color: var(--good-ink); font-size: 11.5px; font-weight: 400; font-family: var(--font); margin-left: 4px; }
.param .bad { grid-column: 1 / -1; color: var(--critical-ink); font-size: 12px; }

.tag { font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 99px; padding: 0 7px;
       white-space: nowrap; font-weight: 500; }
.tag.warn { color: var(--warning-ink); }
.tag.bad { color: var(--critical-ink); }

.verdict { display: grid; gap: 10px; }
.verdict .head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.verdict .status { font-size: 26px; font-weight: 750; letter-spacing: 0.02em; }
.verdict .status::before { margin-right: 8px; }
.verdict.unknown .status { color: var(--warning-ink); }
.verdict.unknown .status::before { content: "?"; }
.verdict .reason { font-size: 14.5px; margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.tile .k { color: var(--ink-2); font-size: 12px; }
.tile .v { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: 12px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 8px; }
.chart { margin: 0; min-width: 0; }
.chart figcaption { font-size: 13px; margin-bottom: 4px; }
svg.plot { width: 100%; height: auto; display: block; overflow: visible; }
svg.plot .grid { stroke: var(--grid); stroke-width: 1; }
svg.plot .axis { stroke: var(--axis); stroke-width: 1; }
svg.plot .tick, svg.plot .axis-label, svg.plot .label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.plot .label.ink { fill: var(--ink-2); }
svg.plot .series { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.plot .series.s2 { stroke: var(--series-2); }
svg.plot .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.plot .dot.s2 { fill: var(--series-2); }
svg.plot .ref { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg.plot .mark { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
svg.plot .crosshair { stroke: var(--axis); stroke-width: 1; }
svg.plot .hit { fill: transparent; cursor: crosshair; }
.map svg .wp { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; }
.map svg .home rect { fill: var(--ink); }
.map svg .home text { fill: var(--surface); font-size: 11px; font-weight: 700; }
.map svg .scale line { stroke: var(--ink-2); stroke-width: 2; }
.map svg .scale text, .map svg .north text { fill: var(--ink-2); font-size: 11px; }
.map svg .north path { fill: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 28px; height: 10px; }
.legend svg line { stroke-width: 2.5; }
.legend .l1 { stroke: var(--series-1); }
.legend svg.dotkey { width: 10px; height: 10px; }
.tooltip { position: fixed; z-index: 30; pointer-events: none; background: var(--surface); max-width: 300px;
           border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12.5px;
           box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.table th, .table td { text-align: left; vertical-align: top; padding: 5px 7px; border-bottom: 1px solid var(--border); }
.table th { color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.notes { margin: 4px 0 0; padding-left: 18px; }
.notes li { margin: 5px 0; }
.notes li.warn::marker { color: var(--warning-ink); }
.model code, .notes code, .hint code, .reason code, .table code, .loaded code { font-family: var(--mono); font-size: 0.95em; }

.about { padding: 4px 20px 24px; color: var(--muted); font-size: 12.5px; }
.about a { color: var(--ink-2); }
@media (max-width: 900px) { .about { padding: 4px 12px 20px; } }
.actions select { width: auto; margin-top: 0; padding: 5px 8px; }
@media (max-width: 420px) {
  .topbar { padding: 8px 12px; }
  .card { padding: 12px; }
  .verdict .status { font-size: 22px; }
}

.model ul { margin: 4px 0 0; padding-left: 18px; }
.model li { margin: 6px 0; }
.verdict.quiet .status { color: var(--good-ink); }
.verdict.quiet .status::before { content: "✓"; }
.verdict.watch .status { color: var(--warning-ink); }
.verdict.watch .status::before { content: "!"; }
.verdict.bad .status { color: var(--critical-ink); }
.verdict.bad .status::before { content: "✕"; }
.verdict .examples { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.tile .v small { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.tile.over .v { color: var(--critical-ink); }
.tile.near .v { color: var(--warning-ink); }

.layer-row { margin: 2px 0 8px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg .btn { padding: 3px 10px; font-size: 13px; }
.seg .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.map svg .route { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.map svg .route-halo { fill: none; stroke: var(--surface); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
.map svg .wp { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.map svg .num text { fill: var(--ink); font-size: 10.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.map svg .worst { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3 3; }
.map svg .worst-label { fill: var(--ink); font-size: 11.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.map svg .hover { fill: none; stroke: var(--ink); stroke-width: 1.5; pointer-events: none; }
.map svg .scale text, .map svg .north text { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.map svg .north path { stroke: var(--surface); stroke-width: 1; }
.scalebar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.scalebar .ramp { width: 180px; height: 10px; border-radius: 3px; border: 1px solid var(--border); }
.scalebar .nodata { display: inline-block; width: 14px; height: 10px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); margin-left: 10px; }
.legend .l1 { stroke: var(--series-1); }
.legend .l2 { stroke: var(--series-2); }
.legend .l3 { stroke: var(--series-3); }
.legend .lref { stroke: var(--critical); stroke-dasharray: 5 4; stroke-width: 1.5; }
.legend .lroute { stroke: var(--ink); }
svg.plot .series.s3 { stroke: var(--series-3); }
svg.plot .zero { stroke: var(--axis); stroke-width: 1.5; }
svg.plot .end-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
svg.plot .wpmark { stroke: var(--grid); stroke-width: 1; }
#along-card .chart + .chart { margin-top: 18px; }
#along-card svg.plot { max-width: 860px; }
.points td { white-space: nowrap; }
.points tr.flag td.turn { color: var(--warning-ink); font-weight: 650; }
.points tr.hl td { background: var(--surface-2); }
.table td.over { color: var(--critical-ink); font-weight: 650; }
.table td.near { color: var(--warning-ink); font-weight: 650; }
.table td small { color: var(--muted); }
.param select { margin-top: 0 !important; }
.param.wide { grid-template-columns: minmax(0, 1fr); }
input[type=date] { max-width: 180px; }

/* The map: the anomaly, the outlines and the cities on a canvas, the route in
   an SVG over it, the zoom buttons in its corner. */
.map-frame { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); line-height: 0;
             user-select: none; -webkit-user-select: none; }
.map-frame canvas { width: 100%; aspect-ratio: 720 / 470; display: block; }
.map-frame svg.plot { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; overflow: hidden; }
.map-frame svg.plot:active { cursor: grabbing; }
.map-frame.drawing svg.plot { cursor: crosshair; touch-action: none; }
.map-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; line-height: 1.45; }
.map-tools .btn { width: 30px; height: 30px; padding: 0; justify-content: center; font-size: 17px; box-shadow: var(--shadow); }
.map svg .wp.handle { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.draw-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 210px; overflow: auto; font-size: 12.5px; }
.draw-list li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.draw-list .coords { font-variant-numeric: tabular-nums; flex: 1; }
.draw-list .tag { min-width: 2.6em; text-align: center; }
.btn.x { padding: 0 7px; line-height: 1.5; color: var(--ink-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
#draw-box > label:not(.check) { display: block; margin-top: 10px; }
#draw-alt { max-width: 120px; }
#draw-kept:empty { display: none; }
/* while a route is drawn the verdict keeps its room, so the map under it stays where it is */
.verdict.steady { min-height: 236px; align-content: start; }
