:root {
  --bg: #eaf2f4;
  --paper: #ffffff;
  --ink: #10232b;
  --ink2: #34505a;
  --line: #9fb6bf;
  --rule: #10232b;
  --accent: #9c165f;
  --accent-ink: #ffffff;
  --btn: #ffffff;
  --btn-line: #7d98a2;
  --focus: #c4237a;
  --err: #a3201a;
  --err-bg: #fbe9e7;
  --info-bg: #dde9ee;
  --flash: #fbe3f0;
  --head: "Bahnschrift", "DIN Alternate", "DIN Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f191d;
    --paper: #16252b;
    --ink: #e3eef1;
    --ink2: #b4c9d0;
    --line: #3d5761;
    --rule: #b4c9d0;
    --accent: #f08cc4;
    --accent-ink: #2a0718;
    --btn: #1c3038;
    --btn-line: #56737e;
    --focus: #ff9fd3;
    --err: #ff9b8f;
    --err-bg: #3a1a17;
    --info-bg: #1d3139;
    --flash: #4a1e36;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--body); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* chart neatline: a heavy rule with a thin one under it */
.mast { background: var(--paper); border-bottom: 4px solid var(--rule); box-shadow: 0 3px 0 var(--paper), 0 4px 0 var(--rule); margin-bottom: 20px; }
.mast .wrap { padding-top: 18px; padding-bottom: 16px; }
h1, h2 { font-family: var(--head); font-weight: 700; letter-spacing: 0.01em; line-height: 1.15; }
h1 { font-size: clamp(30px, 6vw, 44px); margin: 0 0 6px; }
.lede { margin: 0; color: var(--ink2); max-width: 62ch; }
h2 { font-size: 24px; margin: 0 0 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  font: 600 16px/1.2 var(--body); color: var(--ink); background: var(--btn); border: 1px solid var(--btn-line); border-radius: 2px; cursor: pointer; text-align: center; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--err); border-color: var(--err); color: var(--paper); }
.link { background: none; border: 0; padding: 4px 0; min-height: 44px; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }

.openbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.openbar label.btn:has(+ input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.note { padding: 10px 12px; border-radius: 2px; background: var(--info-bg); margin: 0 0 12px; overflow-wrap: anywhere; }
.note p { margin: 0 0 6px; }
.note.err, .note.warn { background: var(--err-bg); color: var(--err); }
.drop { border: 2px dashed var(--btn-line); padding: 36px 20px; background: var(--paper); }
.drop p { margin: 0 0 6px; font-size: 18px; }
.drop .sub { color: var(--ink2); font-size: 16px; margin: 0; }
.tool.dragging .drop, .tool.dragging .mapbox { outline: 3px dashed var(--accent); outline-offset: 4px; }

.work { display: grid; gap: 20px; }
@media (min-width: 900px) {
  .work { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
  .mapcol { position: sticky; top: 12px; }
}
.mapbox { position: relative; width: 100%; max-width: calc(72vh * var(--ar, 2)); aspect-ratio: var(--ar, 2); background: var(--paper);
  border: 1px solid var(--rule); background-image: linear-gradient(45deg, #d6dde0 25%, transparent 25%, transparent 75%, #d6dde0 75%), linear-gradient(45deg, #d6dde0 25%, transparent 25%, transparent 75%, #d6dde0 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.mapbox canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#grid { cursor: crosshair; touch-action: manipulation; }
.busy { position: absolute; left: 8px; top: 8px; background: var(--paper); color: var(--ink); padding: 4px 10px; border: 1px solid var(--rule); font-weight: 600; pointer-events: none; }
.maptools { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; margin: 8px 0 4px; }
.check { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.hint { color: var(--ink2); }
.mapname { margin: 4px 0 0; color: var(--ink2); overflow-wrap: anywhere; }

.reshead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 12px; border-bottom: 2px solid var(--rule); margin-bottom: 4px; }
.reshead h2 { margin-bottom: 4px; }
.surface { margin: 0 0 4px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.colors { list-style: none; margin: 0; padding: 0; }
.crow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 44px; gap: 4px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.crow.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--flash); } to { background: transparent; } }
.sw { width: 44px; height: 44px; border: 1px solid var(--rule); background: var(--c, #888); position: relative; cursor: pointer; }
.sw input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.sw:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
input[type="text"], select { font: 16px/1.3 var(--body); color: var(--ink); background: var(--paper); border: 1px solid var(--btn-line); border-radius: 2px; min-height: 44px; padding: 8px 10px; width: 100%; }
.crow select { width: auto; }
.x, .dismiss { width: 44px; height: 44px; background: none; border: 1px solid transparent; color: var(--ink2); font-size: 24px; line-height: 1; cursor: pointer; border-radius: 2px; }
.x:hover, .dismiss:hover { border-color: var(--btn-line); color: var(--ink); }
.cres { grid-column: 2 / -1; margin: 0; font-variant-numeric: tabular-nums; }
.cres b { margin-right: 6px; }
.cres span { color: var(--ink2); }
.cres .cmp { display: block; color: var(--ink); }
.crow.stale .cres { opacity: 0.55; }
.empty { color: var(--ink2); margin: 12px 0; }
.totals { margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.totals dt { font-weight: 600; }
.totals dd { margin: 0; text-align: right; }
.totals dd span { color: var(--ink2); margin-left: 6px; }
.tip { margin: 8px 0 0; color: var(--ink2); }
.guess { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; margin: 0; padding: 2px 0 2px 12px; background: var(--info-bg); border-radius: 2px; }
.guess > span { flex: 1 1 14em; padding: 8px 0; }
.guess .dismiss { flex: none; margin-left: auto; }
.chint { grid-column: 1 / -1; }
#water-hint { margin: 12px 0 0; }

.set { border: 0; border-top: 2px solid var(--rule); padding: 10px 0 0; margin: 18px 0 0; min-width: 0; }
.set legend, .set summary { font: 700 20px/1.2 var(--head); padding: 0; }
.set legend { float: left; width: 100%; margin-bottom: 2px; }
.set legend + * { clear: both; }
.set summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.lab { display: block; font-weight: 600; margin: 12px 0 4px; }
.pair { display: flex; gap: 8px; }
.pair input { flex: 1 1 auto; min-width: 0; }
.pair select { flex: 0 0 auto; width: auto; }
.pair .unit-short { align-self: center; font-weight: 600; }
.echo { margin: 6px 0 0; color: var(--ink2); font-variant-numeric: tabular-nums; }
.echo.flash { animation: flash 1.2s ease-out; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); }
output { font-weight: 400; color: var(--ink2); margin-left: 6px; }

.maps { margin: 28px 0 0; border-top: 2px solid var(--rule); padding-top: 6px; }
.maps summary { font: 700 20px/1.2 var(--head); cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.maps-list { list-style: none; margin: 0; padding: 0; }
.maps-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 12px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.maps-list .mi { min-width: 0; overflow-wrap: anywhere; }
.maps-list .mi span { display: block; color: var(--ink2); }
.maps-list .row { margin: 6px 0; }
.maps-list .confirm { flex-basis: 100%; }
.open-now { color: var(--ink2); padding: 0 8px; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--paper); padding: 8px 16px; border-radius: 2px; z-index: 20; pointer-events: none; overflow-wrap: anywhere; }
.toast .link { color: var(--paper); pointer-events: auto; font-weight: 700; margin-left: 8px; }
/* on phones the results sit low on the screen, so the toast goes at the top */
@media (max-width: 600px) { .toast { left: 16px; right: 16px; top: 16px; bottom: auto; transform: none; width: auto; max-width: none; } }

.prose { margin-top: 44px; }
.prose h2 { margin-top: 32px; }
.prose p { max-width: 70ch; }
.formula { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 16px; background: var(--paper); border-left: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 12px; overflow-wrap: anywhere; }
#faq details { border-bottom: 1px solid var(--line); max-width: 75ch; }
#faq summary { cursor: pointer; font-weight: 600; padding: 10px 0; min-height: 44px; }
#faq details p { margin: 0 0 12px; }

.site-foot { margin-top: 56px; border-top: 4px solid var(--rule); background: var(--paper); padding: 20px 0 28px; color: var(--ink2); font-size: 16px; }
.sb-footer p { margin: 0 0 10px; }
.sb-more { line-height: 1.8; }
.sb-footer a { color: var(--ink); }
.sb-credit a, .sb-privacy a { color: var(--accent); }

#print-root { display: none; }

@media (max-width: 360px) {
  .crow { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .crow select { grid-column: 2; grid-row: 2; justify-self: start; }
  .crow .x { grid-column: 3; grid-row: 1; }
  .crow .cres { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .crow.flash, .echo.flash { animation: none; } }

@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font: 10.5pt/1.35 var(--body); }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root h1 { font: 700 18pt/1.2 var(--head); margin: 0 0 4pt; }
  .p-meta { margin: 0 0 8pt; }
  .p-thumb { display: block; width: auto; height: auto; max-width: 100%; max-height: 92mm; border: 0.75pt solid #000; margin: 0 0 10pt; break-inside: avoid; }
  .p-table { width: calc(100% - 2px); margin-left: 1px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  .p-table th, .p-table td { border-bottom: 0.5pt solid #777; padding: 3pt 5pt; text-align: left; vertical-align: top; }
  .p-table thead th { border-bottom: 1pt solid #000; font-weight: 700; }
  .p-tot { break-inside: avoid; }
  .p-tot th, .p-tot td { border-bottom: 0 !important; }
  .p-tot tr:first-child th, .p-tot tr:first-child td { border-top: 1pt solid #000; }
  .p-tot tr:last-child th, .p-tot tr:last-child td { font-weight: 700; }
  .p-table .n { text-align: right; white-space: nowrap; }
  .p-table tr { break-inside: avoid; }
  .p-sw { width: 16pt; }
  .sw-p { display: inline-block; width: 12pt; height: 12pt; border: 0.5pt solid #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-foot { margin-top: 8pt; font-size: 9.5pt; }
  .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
