/* Radio Link Planner. Colours are the other tools' tokens, so the platform reads
   as one; the chosen radio's line is the validated blue, the other rates grey. */

: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;
  --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; --shadow: none;
  }
}
: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; --shadow: none;
}


* { 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 { min-width: 0; }
.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; gap: 6px; 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); }
.btn:disabled { opacity: .55; cursor: default; }

.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; } }
#copter-bar { margin-bottom: 12px; }
h3.section { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2);
             margin: 18px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
fieldset { border: 0; margin: 10px 0 0; padding: 0; min-width: 0; }
legend, label { font-weight: 600; font-size: 13px; padding: 0; }
legend { margin-bottom: 2px; }
fieldset.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
fieldset.two label { display: block; }
fieldset.two .span { grid-column: 1 / -1; }
input:not([type=checkbox]):not([type=range]):not([type=file]), select {
  width: 100%; margin-top: 4px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); }
input:disabled, select:disabled { color: var(--muted); background: var(--surface-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.row input[type=number] { width: 120px; flex: none; }
#pwr { width: 140px; flex: none; }
.form h2 { margin-top: 14px; }
.readout { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.invalid { border-color: var(--critical) !important; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.gloss { color: var(--ink-2); font-size: 12px; margin: 2px 0 0; }
.gloss:empty { display: none; }
.status { font-size: 12.5px; margin: 6px 0 0; color: var(--ink-2); }
.status.bad { color: var(--critical-ink); }
.status.good { color: var(--good-ink); }
.muted { color: var(--ink-2); margin: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 99px;
            padding: 2px 9px; cursor: pointer; font-size: 12.5px; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.error-box { margin-top: 10px; padding: 8px 10px; border-radius: 8px; color: var(--critical-ink);
             border: 1px solid var(--critical); }

/* the headline numbers */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 4px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; min-width: 0; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 22px; font-weight: 650; line-height: 1.2; }
.tile .sub { color: var(--muted); font-size: 12px; }
.tile.good .value { color: var(--good-ink); }
.tile.warn .value { color: var(--warning-ink); }
.tile.bad .value { color: var(--critical-ink); }

.findings { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.findings > li { display: grid; grid-template-columns: 22px 1fr; gap: 2px 6px; align-items: baseline; }
.findings .icon { font-weight: 700; text-align: center; }
.findings .good .icon { color: var(--good-ink); }
.findings .warn .icon { color: var(--warning-ink); }
.findings .bad .icon { color: var(--critical-ink); }
.findings .info .icon { color: var(--muted); }
.findings ul { grid-column: 2; margin: 2px 0 0; padding-left: 18px; color: var(--ink-2); }
.findings ul li { margin: 1px 0; }
.findings .fix-title { grid-column: 2; color: var(--ink-2); font-size: 13px; }

.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table th, .table td { text-align: left; vertical-align: top; padding: 6px 8px;
                       border-bottom: 1px solid var(--border); }
.table th { color: var(--ink-2); font-weight: 600; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.chosen td { background: var(--surface-2); }
.table tr.chosen td:first-child { box-shadow: inset 3px 0 0 var(--series-1); }
.table.modes { min-width: 660px; }
.table.budget { min-width: 340px; }
.modes .pick { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer;
               font-weight: 600; text-align: left; }
.modes .pick:hover { text-decoration: underline; }
.modes .sub, .budget .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.budget td.op { width: 1.5em; color: var(--muted); text-align: center; }
.budget tr.total td { font-weight: 650; border-top: 2px solid var(--border); }
.mono { font-family: var(--mono); }
.good-ink { color: var(--good-ink); }
.warn-ink { color: var(--warning-ink); }
.bad-ink { color: var(--critical-ink); }
.sources ul { margin: 4px 0 0; padding-left: 18px; }
.sources li { margin: 3px 0; }

/* charts */
.chart { margin: 4px 0 0; min-width: 0; }
.chart figcaption { font-size: 13px; margin-bottom: 4px; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin: 4px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--series-1); }
.legend i.thin { border-top-width: 1px; }
.legend i.grey { border-top: 1px solid var(--muted); }
.legend i.ref { border-top: 1px dashed var(--warning-ink); }
.legend i.band { height: 10px; border: 0; background: color-mix(in srgb, var(--series-1) 16%, transparent); }
.legend i.ground { height: 10px; border: 0; background: var(--ground); }
.legend i.bad { border-top: 3px solid var(--critical); }
.legend i.warn { border-top: 3px solid var(--warning-ink); }
.legend i.curve { border-top: 1px dotted var(--ink-2); }
svg.plot { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
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 { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.plot .label { fill: var(--ink-2); font-size: 11px; }
svg.plot .label.strong { fill: var(--ink); font-weight: 600; }
svg.plot .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
svg.plot .series { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.plot .series.thin { stroke-width: 1.25; opacity: .55; }
svg.plot .other { fill: none; stroke: var(--muted); stroke-width: 1; }
svg.plot .ref { stroke: var(--warning-ink); stroke-width: 1; stroke-dasharray: 5 4; }
svg.plot .zero { stroke: var(--axis); stroke-width: 1.5; }
svg.plot .mark { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
svg.plot .leader { stroke: var(--muted); stroke-width: .75; }
svg.plot .ground { fill: var(--ground); stroke: var(--ground-edge); stroke-width: 1; }
svg.plot .curve { fill: none; stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 1.5 2.5; }
svg.plot .band { fill: var(--series-1); fill-opacity: .12; stroke: none; }
svg.plot .band-edge { fill: none; stroke: var(--series-1); stroke-width: 1; stroke-dasharray: 4 3; opacity: .8; }
svg.plot .hit-bad { fill: none; stroke: var(--critical); stroke-width: 3; stroke-linecap: round; }
svg.plot .hit-warn { fill: none; stroke: var(--warning-ink); stroke-width: 3; stroke-linecap: round; }
svg.plot .mast { stroke: var(--ink-2); stroke-width: 1.5; }
svg.plot .you { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.plot .dot-bad { fill: var(--critical); stroke: var(--surface); stroke-width: 2; }
svg.plot .wp { stroke: var(--ink-2); stroke-width: 1; }
svg.plot .crosshair { stroke: var(--axis); stroke-width: 1; }
svg.plot .hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.plot .hit { fill: transparent; cursor: crosshair; }
.tooltip { position: fixed; z-index: 30; pointer-events: none; background: var(--surface);
           border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12.5px;
           box-shadow: var(--shadow); font-variant-numeric: tabular-nums; max-width: 300px; }
.tooltip div + div { color: var(--ink-2); }

:root { --ground: #e6e1d3; --ground-edge: #b9b09a; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) { --ground: #34312a; --ground-edge: #5f584a; }
}
:root[data-theme="dark"] { --ground: #34312a; --ground-edge: #5f584a; }

.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; }

/* On a phone the tables keep their columns and scroll inside their box. */
@media (max-width: 600px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .card { padding: 12px; }
  .tile .value { font-size: 19px; }
}
