/* Sunnypatch. Layout: drafting-table split. A sticky instrument panel of inputs on the left; the site map first on the right,
   then read-outs for the measuring point: summary, year chart, shade calendar, one day in detail. */
/* Latin subsets from Google Fonts, self-hosted. Archivo and IBM Plex are under the SIL Open Font License 1.1. */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 600 800;
  font-stretch: 62% 100%;
  font-display: swap;
  src: url(fonts/archivo-f1d9f3.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-bc87d8.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/ibm-plex-mono-a80b2c.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-b11e58.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-b11e58.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/ibm-plex-sans-b11e58.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #eceef1;
  --panel: #fbfcfc;
  --ink: #14171c;
  --ink-2: #4a515c;
  --muted: #767c87;
  --line: #dde0e5;
  --axis: #bfc4cb;
  --accent: #1d4f91;
  --accent-ink: #ffffff;
  --accent-wash: rgba(29, 79, 145, 0.08);
  --sun: #e39a00;
  --sunfill: #d48a00;
  --sunlit: #fbe6ad;
  --night: #2f353e;
  --day: rgba(227, 154, 0, 0.14);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --multi: #4a3aa7;
  --danger: #b4232a;
  --font-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013; --panel: #16191e; --ink: #f1f3f5; --ink-2: #b4bac4; --muted: #8a909a;
    --line: #262a31; --axis: #3b4049; --accent: #7eb0ef; --accent-ink: #0e1013; --accent-wash: rgba(126, 176, 239, 0.10);
    --sun: #f4b73a; --sunfill: #e0a41f; --sunlit: #8a6d1f; --night: #07080a; --day: rgba(244, 183, 58, 0.11);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --multi: #9085e9; --danger: #ff7b7b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --panel: #16191e; --ink: #f1f3f5; --ink-2: #b4bac4; --muted: #8a909a;
  --line: #262a31; --axis: #3b4049; --accent: #7eb0ef; --accent-ink: #0e1013; --accent-wash: rgba(126, 176, 239, 0.10);
  --sun: #f4b73a; --sunfill: #e0a41f; --sunlit: #8a6d1f; --night: #07080a; --day: rgba(244, 183, 58, 0.11);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --multi: #9085e9; --danger: #ff7b7b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 0 48px;
}
.app { max-width: 1320px; margin: 0 auto; }

header.top {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px;
  padding-block: 28px 20px;
}
header.top h1 {
  font-family: var(--font-display); font-stretch: 72%; font-weight: 800;
  font-size: clamp(30px, 5vw, 44px); line-height: 1; letter-spacing: -0.01em; margin: 0; text-wrap: balance;
}
header.top p { margin: 6px 0 0; color: var(--ink-2); max-width: 60ch; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { flex: none; border-radius: 10px; }
@media (max-width: 520px) { .brand img { display: none; } }
.top-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.show-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.show-toggle .seg { min-width: 210px; }
#copyLink { padding: 7px 14px; }

.layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; align-items: start; }

/* Controls */
.controls {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px);
  max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 16px 16px; display: flex; flex-direction: column;
}
.controls fieldset { border: 0; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 10px; min-width: 0; }
.controls fieldset:last-child { border-bottom: 0; padding-bottom: 0; }
.controls legend {
  font-family: var(--font-display); font-stretch: 85%; font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); padding: 0; margin-bottom: 2px; float: left; width: 100%;
}
.field { display: grid; gap: 4px; min-width: 0; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.hint:empty { display: none; }
.search { display: flex; min-width: 0; }
.search input {
  flex: 1; min-width: 0; font: 14px var(--font-body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--axis); border-right: 0; border-radius: 6px 0 0 6px; padding: 7px 10px;
}
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.search button { border-radius: 0 6px 6px 0; }
.search .locate-icon { display: none; border-radius: 0; border-right: 0; padding: 0 12px; place-items: center; }
.icon-text { display: inline-flex; align-items: center; gap: 6px; }
.exact-head { display: none; }
details.more summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--accent); width: fit-content; }
details.more summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.more-body { display: grid; gap: 10px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.empty { margin: 0; font-size: 13px; color: var(--ink-2); }
.unit { display: flex; align-items: center; border: 1px solid var(--axis); border-radius: 6px; background: var(--bg); overflow: hidden; min-width: 0; }
.unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.unit input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); font: 500 14px var(--font-mono); padding: 7px 8px; outline: none; }
.unit span { font: 12px var(--font-mono); color: var(--muted); padding-right: 9px; white-space: nowrap; }
select {
  width: 100%; font: 14px var(--font-body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--axis); border-radius: 6px; padding: 7px 8px;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

button {
  font: 500 13px var(--font-body); color: var(--accent); background: transparent;
  border: 1px solid var(--accent); border-radius: 6px; padding: 6px 14px; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--accent-wash); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; background: transparent; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
button.ghost { border-color: transparent; padding: 4px 6px; color: var(--ink-2); }
button.ghost:hover { color: var(--accent); background: var(--accent-wash); }
button.ghost.danger:hover { color: var(--danger); background: transparent; }

.chip { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; display: inline-block; }

/* Wall list */
.wall-list { display: grid; gap: 8px; }
.wall-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.wall-row.sel { border-color: var(--accent); background: var(--accent-wash); }
.wall-meta { display: grid; min-width: 0; }
.wall-name {
  width: 100%; min-width: 0; margin: -2px 0 0 -5px; padding: 1px 4px;
  font: 600 14px var(--font-body); color: var(--ink); background: transparent;
  border: 1px solid transparent; border-radius: 4px; text-overflow: ellipsis;
}
.wall-name::placeholder { color: var(--ink); opacity: 1; }
.wall-name:hover { border-color: var(--axis); cursor: text; }
.wall-name:focus { outline: none; border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px var(--accent-wash); }
.wall-name:focus::placeholder { color: var(--muted); }
.wall-meta span { font: 12px var(--font-mono); color: var(--muted); }
.wall-row .unit { grid-column: 2 / 3; }
.wall-row .danger { grid-column: 3; grid-row: 1; }

/* Point distances */
.pt-list { display: grid; gap: 10px; }
.pt-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 84px auto; gap: 4px 8px; align-items: center; }
.pt-row label { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-row .side { font-family: var(--font-mono); font-size: 12px; padding: 4px 6px; }
.pt-note { grid-column: 2 / -1; margin: -2px 0 0; font-size: 12px; color: var(--muted); }
.pt-note:empty { display: none; }
.coords { font: 12px var(--font-mono); color: var(--muted); margin: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--axis); border-radius: 6px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { text-align: center; padding: 7px 4px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); }
.seg label + input + label { border-left: 1px solid var(--axis); }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -4px; }

/* Read-outs */
main { display: grid; gap: 20px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; margin-bottom: 12px; }
.panel h2 { font-family: var(--font-display); font-stretch: 80%; font-weight: 700; font-size: 20px; margin: 0; line-height: 1.2; text-wrap: balance; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* Result cards fold away from their title. */
.card-toggle {
  all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: inline-flex; align-items: center; gap: 10px;
  font: inherit; color: inherit; border-radius: 4px;
}
.card .panel-head h2 { flex: 1 1 auto; }
.card-toggle::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-top: -4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
}
.card-toggle[aria-expanded="false"]::after { transform: rotate(-45deg); margin-top: 0; }
.card-toggle:hover::after { border-color: var(--accent); }
.card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card.folded { padding-block: 14px; }
.card.folded .panel-head { margin-bottom: 0; }
.card.folded .panel-head p { display: none; }

/* First-visit steps. */
/* Shown only on a first visit: html.first-visit is set by the inline script in <head>. */
.intro {
  display: none; gap: 6px; margin-bottom: 12px; padding: 12px 14px;
  border: 1px solid var(--accent); border-radius: 6px; background: var(--accent-wash); font-size: 13px;
}
html.first-visit .intro { display: grid; }
.intro p { margin: 0; }
.intro ol { margin: 0; padding-left: 20px; display: grid; gap: 2px; }
.intro button { justify-self: start; margin-left: -6px; color: var(--accent); font-weight: 600; }

/* Site map. The stage holds the Leaflet map and the controls that float on it. */
.map-wrap { position: relative; }
.map-stage { position: relative; height: 480px; border-radius: 6px; overflow: hidden; background: var(--bg); }
#mapBox { position: absolute; inset: 0; z-index: 0; }
#mapBox.drawing, #mapBox.drawing .leaflet-interactive { cursor: crosshair; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.map-ctl { position: absolute; z-index: 10; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.map-btn {
  background: var(--panel); color: var(--ink); border: 1px solid var(--axis); font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); padding: 7px 14px;
}
.map-btn:hover { background: var(--panel); border-color: var(--accent); }
.map-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.map-btn[aria-pressed="true"]:not(#fullBtn) { border-color: var(--accent); color: var(--accent); }
.map-btn.icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; }
.map-btn svg { display: block; }
.map-btn .done-lbl { display: none; }
.map-wrap.full #fullBtn { width: auto; padding: 0 16px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.map-wrap.full #fullBtn .ico-open { display: none; }
.map-wrap.full #fullBtn .done-lbl { display: inline; }
.map-panel {
  display: grid; gap: 10px; width: 220px; padding: 12px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--axis); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.map-panel .field span { font-weight: 500; }

/* The drawing prompt sits on dark glass over the imagery, so it uses fixed colours. */
.map-coach {
  position: absolute; z-index: 10; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 130px);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; border-radius: 22px;
  background: rgba(20, 23, 28, 0.9); color: #ffffff; font-size: 14px; font-weight: 600; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.map-coach button { color: #ffffff; border-color: rgba(255, 255, 255, 0.5); border-radius: 18px; padding: 5px 12px; }
.map-coach button:hover { background: rgba(255, 255, 255, 0.15); }

.map-bottom {
  position: absolute; z-index: 10; left: 10px; right: 10px; bottom: calc(var(--credit-h, 18px) + 6px);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none;
}
.map-bottom > * { pointer-events: auto; }
.map-result {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; max-width: 100%; padding: 8px 14px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--axis); border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); text-align: left; white-space: normal; font-weight: 400;
}
.map-result:hover { background: var(--panel); border-color: var(--accent); }
.map-result small { display: block; font: 10px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.map-result b { font-family: var(--font-display); font-stretch: 85%; font-size: 18px; font-weight: 600; line-height: 1.1; }
.map-result .rc-word { font-weight: 600; font-size: 13px; }
.map-result .rc-go { color: var(--accent); font-weight: 600; font-size: 13px; }

.wall-sheet {
  width: 100%; max-width: 400px; display: grid; gap: 10px; padding: 12px 14px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--axis); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.ws-head { display: flex; align-items: center; gap: 10px; }
.ws-title { display: grid; flex: 1; min-width: 0; }
.ws-title b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-title span { font: 12px var(--font-mono); color: var(--muted); }
.ws-close { padding: 4px 10px; font-size: 15px; }
.ws-note { margin: 0; font-size: 12px; color: var(--ink-2); }
.ws-label { font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: -4px; }
.ws-heights { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-heights button { min-width: 50px; padding: 6px 10px; font-family: var(--font-mono); color: var(--ink); border-color: var(--axis); }
.ws-heights button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ws-heights button:last-child { font-family: var(--font-body); }
.ws-name {
  width: 100%; font: 14px var(--font-body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--axis); border-radius: 6px; padding: 7px 10px;
}
.ws-name:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.ws-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.danger-btn { color: var(--danger); border-color: var(--danger); }
.danger-btn:hover { background: transparent; filter: brightness(1.15); }

/* Full screen: the map fills the window above the floating time bar. */
body.map-full { overflow: hidden; }
.map-wrap.full { position: fixed; z-index: 2000; inset: 0 0 var(--tb-h, 0px) 0; display: flex; flex-direction: column; background: var(--bg); }
.map-wrap.full .map-stage { flex: 1; height: auto; min-height: 0; max-height: none; border-radius: 0; }
.map-wrap.full .map-status {
  margin: 0; min-height: 0; max-width: 100%; padding: 6px 12px; border-radius: 8px;
  background: rgba(20, 23, 28, 0.88); color: #ffffff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.map-wrap.full .map-status:empty, .map-wrap.full .map-status.stale { display: none; }
.map-wrap.full .ov-legend {
  position: absolute; z-index: 11; top: 118px; left: 10px; margin: 0; padding: 8px 10px; grid-template-columns: minmax(0, 180px);
  background: var(--panel); border: 1px solid var(--axis); border-radius: 8px;
}
.leaflet-container { font-family: var(--font-body); }
.map-fallback { padding: 24px; color: var(--ink-2); }
.map-status { margin: 8px 0 0; font-size: 13px; color: var(--ink); min-height: 1.5em; }
.time-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 10px 20px; align-items: end; margin-top: 12px; }
@media (max-width: 640px) { .time-row { grid-template-columns: minmax(0, 1fr); } }
.time-row label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 500; }
.time-row output { font-family: var(--font-mono); color: var(--ink-2); font-weight: 400; }
.play-ico { display: none; }
/* On phones, and in full screen, the date and time float in a bar at the bottom of the window. */
.time-row.floating {
  position: fixed; z-index: 2100; left: 0; right: 0; bottom: 0; margin: 0;
  grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; align-items: center;
  padding: 6px max(16px, calc((100% - 860px) / 2)) calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.14);
}
.time-row.floating .field { grid-column: 1; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 10px; }
.time-row.floating .tl-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.time-row.floating output { color: var(--ink); font-weight: 500; }
.time-row.floating #play { grid-column: 2; grid-row: 1 / span 2; width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 15px; }
.time-row.floating .play-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.time-row.floating .play-ico { display: inline; }
body.typing .time-row.floating { display: none; }
.ov-legend { display: grid; grid-template-columns: auto minmax(0, 240px); gap: 12px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.scale-bar { height: 10px; border-radius: 2px; }
.scale-ticks { display: flex; justify-content: space-between; font: 11px var(--font-mono); color: var(--muted); margin-top: 3px; }
/* Map overlays sit on photo imagery in both themes, so they use fixed colours.
   The handle and pin boxes are the grab area (bigger on touch screens); the dots are drawn inside. */
.wall-handle { cursor: grab; }
.wall-handle::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; box-sizing: border-box;
  background: #ffffff; border: 3px solid #14171c; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.wall-tag span {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  color: #ffffff; font: 700 11px var(--font-display); border: 2px solid #ffffff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.pin { cursor: grab; }
.pin::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; box-sizing: border-box;
  border-radius: 50%; background: #ffffff; border: 3px solid #14171c;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55), 0 2px 6px rgba(0, 0, 0, 0.5);
}
.pin::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #d0263a; }
.map-hint {
  position: absolute; z-index: 1000; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none;
  padding: 10px 16px; border-radius: 8px; background: rgba(20, 23, 28, 0.82); color: #ffffff; font-size: 15px; font-weight: 500;
  opacity: 0; transition: opacity 0.2s;
}
.map-hint.show { opacity: 1; }

/* Point summary */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stats div { border-top: 1px solid var(--line); padding-top: 6px; min-width: 0; }
.stats dt { font: 11px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stats dd { margin: 2px 0 0; font-family: var(--font-display); font-stretch: 85%; font-weight: 600; font-size: 24px; line-height: 1.1; }
.stats dd small { display: block; font: 11px var(--font-mono); color: var(--muted); font-weight: 400; margin-top: 2px; }
.share { margin-top: 16px; display: grid; gap: 6px; }
.share h3 { margin: 0; font-size: 13px; font-weight: 600; }
.share-bar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; gap: 2px; background: var(--line); }
.share-bar i { display: block; height: 100%; background: var(--c); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend b { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.sw-area { width: 14px; height: 12px; border-radius: 2px; background: var(--day); border-top: 2px solid var(--sun); }
.foot { margin: 12px 0 0; font-size: 13px; color: var(--ink-2); }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.card-actions .hint { flex: 1 1 240px; }

.viz { display: block; width: 100%; overflow: visible; }
.viz text { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.viz .grid { stroke: var(--line); }
.viz .base { stroke: var(--axis); }
#yearChart { margin-top: 8px; }
#calCanvas { display: block; width: 100%; cursor: crosshair; touch-action: pan-y; margin-top: 8px; }

details.tbl { margin-top: 10px; }
details.tbl summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 500; }
details.tbl summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font: 500 11px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
td { font-family: var(--font-mono); }
td.dim { color: var(--muted); }
th.state, td.state { text-align: left; font-family: var(--font-body); }
td.state .chip { margin-right: 6px; vertical-align: -1px; }
tr.now td { background: var(--accent-wash); }

.day-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 14px; margin: 0 0 14px; }
.day-stats div { border-top: 1px solid var(--line); padding-top: 5px; }
.day-stats dt { font: 11px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.day-stats dd { margin: 1px 0 0; font-family: var(--font-mono); font-size: 14px; }
.hour-wrap { max-height: 360px; overflow: auto; }

.prose { color: var(--ink-2); font-size: 14px; }
.prose .card-body { max-width: 75ch; }
.prose h3 { margin: 16px 0 4px; font-size: 14px; font-weight: 600; color: var(--ink); }
.prose h3:first-child { margin-top: 0; }
.prose p { margin: 0; }
.prose ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.prose a, .site-foot a { color: var(--accent); }

.site-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.site-foot p { margin: 0; max-width: 90ch; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; }
.noscript { margin: 16px auto; max-width: 60ch; padding: 12px 16px; border: 1px solid var(--danger); border-radius: 6px; color: var(--ink); background: var(--panel); }

#tip {
  position: fixed; z-index: 1000; pointer-events: none; display: none;
  background: var(--panel); color: var(--ink); border: 1px solid var(--axis); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14); padding: 8px 10px; font-size: 12px; line-height: 1.45; max-width: 280px;
}
#tip b { font-weight: 600; }
#tip .k { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
#tip .mono { font-family: var(--font-mono); }
/* Phones and narrow windows: one column in the order people use it. A search bar, the map (with its
   results strip), the results, then the exact measurements folded away, then the FAQ. */
@media (max-width: 940px) {
  body { padding-bottom: calc(var(--tb-h, 0px) + 24px); }
  header.top { padding-block: 18px 12px; }
  header.top p { font-size: 13px; }
  .top-right { width: 100%; flex-wrap: nowrap; justify-content: space-between; }
  .show-toggle .seg { min-width: 0; }
  #copyLink { flex: none; width: 44px; padding: 0; justify-content: center; }
  #copyLink .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .layout { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
  .controls, main { display: contents; }
  .controls > fieldset {
    order: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  }
  .controls > fieldset legend, #locate, #zoneHint { display: none; }
  .search .locate-icon { display: inline-grid; }
  main > #siteSec { order: 2; }
  #siteSec .panel-head p { display: none; }
  .map-stage { height: 62vh; height: 62svh; min-height: 340px; max-height: 560px; }
  main > section { order: 5; }
  .exact { order: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
  .exact-head { display: block; margin: 0; font-family: var(--font-display); font-stretch: 80%; font-weight: 700; font-size: 20px; line-height: 1.2; }
  .exact:not(.open) .exact-body { display: none; }
  main > section.prose { order: 7; }
  .wall-sheet { max-width: none; }
}

/* Guide pages (guides/): one readable column of text, with the same tokens, fonts and tables as the tool. */
body.guide { font-size: 17px; line-height: 1.6; }
.guide .app { max-width: 720px; }
.guide a { color: var(--accent); }
.guide-top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding-block: 18px; border-bottom: 1px solid var(--line);
}
.guide-top .home {
  display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
  font-family: var(--font-display); font-stretch: 72%; font-weight: 800; font-size: 26px; line-height: 1;
}
.guide-top .home img { border-radius: 7px; }
.guide-top nav { display: flex; align-items: center; gap: 16px; font-size: 15px; font-weight: 500; }
.guide a.btn {
  display: inline-flex; align-items: center; font: 600 15px var(--font-body); color: var(--accent-ink); background: var(--accent);
  border-radius: 6px; padding: 8px 16px; text-decoration: none;
}
.guide a.btn:hover { filter: brightness(1.1); }
.guide a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
body.guide main { display: block; padding-block: 26px 8px; }
.guide .crumb { margin: 0 0 10px; font-size: 14px; }
.guide h1 {
  font-family: var(--font-display); font-stretch: 80%; font-weight: 800; font-size: clamp(30px, 6vw, 42px);
  line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 14px; text-wrap: balance;
}
.guide h2 { font-family: var(--font-display); font-stretch: 80%; font-weight: 700; font-size: 25px; line-height: 1.2; margin: 38px 0 10px; text-wrap: balance; }
.guide h3 { font-size: 17px; font-weight: 600; margin: 22px 0 4px; }
.guide main p, .guide main ul, .guide main ol { margin: 0 0 14px; }
.guide main ul, .guide main ol { padding-left: 22px; }
.guide main li { margin-bottom: 4px; }
.guide .lede { font-size: 19px; }
.guide .note { font-size: 14px; color: var(--ink-2); }
.guide .table-wrap { margin: 0 0 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.guide table { font-size: 14px; }
.guide caption { caption-side: top; text-align: left; padding: 12px 10px 8px; font-weight: 600; white-space: normal; }
.guide th, .guide td { padding: 7px 10px; }
.guide tbody tr:last-child td { border-bottom: 0; }
.guide td:first-child { font-family: var(--font-body); white-space: normal; min-width: 150px; }
.guide td small { display: block; color: var(--muted); font-size: 12px; }
.guide td.state { white-space: normal; min-width: 200px; }
.guide .try { margin: 30px 0; padding: 18px 20px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-wash); }
.guide .try h2 { margin-top: 0; font-size: 21px; }
.guide .try > :last-child { margin-bottom: 0; }
.guide .links { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0; list-style: none; }
.guide .calc {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 14px; padding: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.guide .calc .stats { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.guide .calc .hint { grid-column: 1 / -1; }
@media (max-width: 520px) { .guide .calc { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.guide-list { display: grid; gap: 12px; padding: 0 !important; list-style: none; }
.guide-list li { margin: 0; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.guide-list a { font-family: var(--font-display); font-stretch: 85%; font-weight: 700; font-size: 20px; line-height: 1.25; }
.guide-list p { margin: 4px 0 0 !important; font-size: 15px; color: var(--ink-2); }
.guide .more { margin-top: 38px; padding-top: 18px; border-top: 1px solid var(--line); }
.guide .more h2 { margin-top: 0; font-size: 19px; }
.guide .site-foot { font-size: 13px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Touch screens: 44px targets, and 16px text in fields so iPhone Safari doesn't zoom in on focus. */
@media (pointer: coarse) {
  button, .card-toggle, .guide a.btn { min-height: 44px; }
  .seg label { display: flex; align-items: center; justify-content: center; min-height: 44px; }
  .unit input, select, .search input, .wall-name, .ws-name { font-size: 16px; }
  .unit input, select { padding-block: 10px; }
  input[type="range"] { height: 32px; }
  details.more summary, details.tbl summary { padding-block: 10px; }
  .check input { width: 22px; height: 22px; }
  .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; font-size: 22px; }
}
