/* Bearings. TG Studios ink and peach in dark, cream and rust in light,
   a yellow on black high contrast choice, system colours in Windows contrast
   themes. The theme follows the computer unless Settings picks one
   (html[data-theme]). Relative units throughout so the page reflows to one
   column at 320 CSS px (400 percent zoom) with no horizontal scroll. */

:root {
  color-scheme: dark;
  --bg: #16171a;
  --surface: #1e2024;
  --surface-2: #282b31;
  --text: #ececea;
  --muted: #c4c4bd;       /* 10:1 on --bg */
  --border: #8a8a84;      /* 5:1 on --bg and --surface */
  --accent: #ff9e6b;      /* peach, 8.8:1 on --bg */
  --accent-text: #16171a;
  --link: #ffb48c;
  --danger: #ff8a80;
  --focus: #ff9e6b;
  --focus-halo: #16171a;
  --radius: 0.5rem;
  --gap: clamp(0.75rem, 2vw, 1.5rem);
  --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;

  /* Map colours. The canvas draws from the palettes in src/ui/mappalette.js; these
     properties are only for the page around it (map frame, route panel) and, in a
     Windows contrast theme, for the canvas itself (see the forced-colors block). */
  --map-bg: #16171a;
  --map-route: #4fc3ff;
}

/* Light: the system asks for it, Settings does not override, and no Windows contrast theme is on */
@media (prefers-color-scheme: light) and (forced-colors: none) {
  :root:not([data-theme="dark"]):not([data-theme="yellow"]) {
    color-scheme: light;
    --bg: #fdfdfc; --surface: #f2f1ec; --surface-2: #e6e4dc; --text: #1a1a18; --muted: #45453f; --border: #6b6b64;
    --accent: #8a3a12; --accent-text: #ffffff; --link: #8a3a12; --danger: #a3160c; --focus: #8a3a12; --focus-halo: #fdfdfc;
    --map-bg: #fdfdfc; --map-route: #0057d9;
  }
  :root[data-map="contrast"]:not([data-theme="dark"]):not([data-theme="yellow"]) { --map-bg: #ffffff; --map-route: #b000a0; }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fdfdfc; --surface: #f2f1ec; --surface-2: #e6e4dc; --text: #1a1a18; --muted: #45453f; --border: #6b6b64;
  --accent: #8a3a12; --accent-text: #ffffff; --link: #8a3a12; --danger: #a3160c; --focus: #8a3a12; --focus-halo: #fdfdfc;
  --map-bg: #fdfdfc; --map-route: #0057d9;
}
:root[data-map="contrast"]:not([data-theme="yellow"]) { --map-bg: #000000; --map-route: #ff66ff; }
:root[data-map="contrast"][data-theme="light"] { --map-bg: #ffffff; --map-route: #b000a0; }

/* Yellow on black, high contrast */
:root[data-theme="yellow"] {
  color-scheme: dark;
  --bg: #000000; --surface: #000000; --surface-2: #1a1a00; --text: #ffff00; --muted: #ffff00; --border: #ffff00;
  --accent: #ffff00; --accent-text: #000000; --link: #00ffff; --danger: #ff8080; --focus: #ffffff; --focus-halo: #000000;
  --map-bg: #000000; --map-route: #ff66ff;
}

/* Windows contrast themes: only system colours. The canvas reads these (mapview.js). */
@media (forced-colors: active) {
  :root, :root[data-theme], :root[data-map] {
    --focus: Highlight;
    --map-bg: Canvas; --map-grid: Canvas; --map-major: CanvasText; --map-major-line: Canvas; --map-street: CanvasText; --map-minor: GrayText;
    --map-path: CanvasText; --map-blocked: GrayText; --map-building: Canvas; --map-building-edge: CanvasText; --map-building-hatch: GrayText;
    --map-water: Canvas; --map-water-edge: LinkText; --map-park: Canvas; --map-park-edge: CanvasText; --map-area: Canvas;
    --map-route: Highlight; --map-route-halo: Canvas; --map-route-arrow: Canvas; --map-route-done: GrayText;
    --map-dest: Highlight; --map-start: CanvasText; --map-you: CanvasText; --map-you-ring: Canvas;
    --map-place: CanvasText; --map-marker: LinkText; --map-pin: CanvasText; --map-text: CanvasText; --map-street-text: CanvasText; --map-halo: Canvas;
  }
}

@media (prefers-contrast: more) {
  /* !important: the light rules above are more specific and would win (Jim 0.4, L2). */
  :root { --muted: var(--text) !important; --border: var(--text) !important; }
  .panel, #map, input[type="text"], input[type="email"], textarea, select { border-width: 0.125rem; }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 112.5%; /* 18px when the browser default is 16 */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  overflow-wrap: break-word;
}

.wrap {
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); letter-spacing: -0.01em; font-family: var(--serif); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 0.75em; }

a { color: var(--link); text-underline-offset: 0.15em; }

/* ---------- focus: thick, two-tone, never removed ---------- */
:focus-visible {
  outline: 0.1875rem solid var(--focus);
  outline-offset: 0.1875rem;
  box-shadow: 0 0 0 0.375rem var(--focus-halo);
}
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
h2[tabindex="-1"]:focus, h3[tabindex="-1"]:focus {
  outline: 0.1875rem solid var(--focus);
  outline-offset: 0.35rem;
  border-radius: 0.25rem;
}
#help-body:focus, #help-body:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: -0.1875rem; box-shadow: none; }
/* The ring on a primary button must not be the button's own colour */
button.primary:focus-visible { outline-color: var(--text); }

/* ---------- utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 10;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}
.skip:focus { top: 1rem; }

/* ---------- buttons and fields ---------- */
button {
  font: inherit;
  font-weight: 650;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  border: 0.125rem solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--text); }
button:disabled { opacity: 0.55; cursor: default; } /* simply dimmer (Priya: dashed read as an old form) */
button:disabled:hover { border-color: var(--border); }
/* Busy (Send while it sends): dimmer and no pointer, but it keeps focus, unlike disabled (Jim 0.4, M2). */
button[aria-disabled="true"] { opacity: 0.55; cursor: progress; }
button[aria-disabled="true"]:hover { filter: none; border-color: var(--border); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: var(--danger); }
button[aria-pressed="true"] { border-color: var(--accent); border-style: double; border-width: 0.3rem; box-shadow: inset 0 0 0 0.125rem var(--accent); }

input[type="text"], input[type="email"], textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 0.125rem solid var(--border);
  border-radius: var(--radius);
  min-height: 2.75rem;
  padding: 0.4rem 0.7rem;
  width: 100%;
  max-width: 100%;
}

label { font-weight: 600; }

/* ---------- header ---------- */
.site-header {
  border-bottom: 0.0625rem solid var(--border);
  background: var(--surface);
}
.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand .mark { width: 2rem; height: 2rem; color: var(--accent); flex: none; }
.header-row h1 { margin: 0; }
.header-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
@media (max-width: 30em) {
  .header-actions button { padding: 0.45rem 0.75rem; }
}
@media (max-width: 22em) {
  .header-actions button { padding: 0.45rem 0.6rem; font-size: 0.95rem; }
  .header-row { padding-top: 0.4rem; padding-bottom: 0.4rem; }
  .brand .mark { display: none; }
  .header-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
}
#mute[aria-pressed="true"] { border-color: var(--danger); color: var(--danger); box-shadow: none; border-style: double; border-width: 0.3rem; }

/* ---------- intro: the hero before Start, a slim line after ---------- */
main { padding-top: var(--gap); padding-bottom: calc(var(--gap) * 2); }
.intro { margin-bottom: var(--gap); max-width: 52rem; }
.eyebrow { font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.lead {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem);
  font-weight: 700;
  line-height: 1.25;
  max-width: 24em;
  text-wrap: balance;
}
.start-help { color: var(--muted); max-width: 46rem; }
#start { font-size: 1.3rem; padding: 0.85rem 2rem; min-height: 3.5rem; }
.limits {
  margin-top: 1rem;
  max-width: 46rem;
  padding: 0.6rem 0.9rem;
  border-left: 0.25rem solid var(--border);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* After Start the onboarding has done its job: the map comes first (the limits stay in Help). */
body.started .intro { display: none; }
#start { margin: 0.25rem 0 0.75rem; }
.start-sr { font-size: 0.95rem; }

/* Short windows (300 and 400 percent zoom): Start within the first screen (Dorothy 11). */
@media (max-height: 34em) {
  .header-row { padding-top: 0.35rem; padding-bottom: 0.35rem; gap: 0.35rem 0.75rem; }
  .header-row h1 { font-size: 1.35rem; }
  .brand .mark { width: 1.5rem; height: 1.5rem; }
  .intro .eyebrow { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .lead { font-size: 1.15rem; margin-bottom: 0.4rem; }
  main { padding-top: 0.5rem; }
  /* Before Start, Start comes straight after the header; the words follow it */
  body:not(.started) .intro { display: flex; flex-direction: column; }
  body:not(.started) #start { order: -1; margin-top: 0; font-size: 1.2rem; min-height: 3rem; padding: 0.5rem 1.5rem; align-self: flex-start; }
}
@media (max-height: 34em) and (max-width: 22em) {
  .header-actions { display: flex; flex-wrap: wrap; width: auto; gap: 0.35rem; }
  .header-actions button { padding: 0.3rem 0.5rem; font-size: 0.9rem; }
}

/* ---------- status line: the caption track, a fixed height so nothing jumps ---------- */
.status-line {
  font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem);
  font-weight: 650;
  line-height: 1.35;
  background: var(--surface);
  border-left: 0.375rem solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 var(--gap);
  min-height: calc(2 * 1.35em + 1.5rem);
  display: flex;
  align-items: center;
}
@media (max-width: 40em) { .status-line { min-height: calc(3 * 1.35em + 1.5rem); } }
/* 0.3.1 (Priya 2): after Start the line has a fixed height and scrolls inside, so nothing below it
   ever moves while the words change. On a phone it is not shown at all: the one copy is the
   caption under the map (Priya 10); it stays in the page for a screen reader's browse mode. */
body.started .status-line { height: calc(2 * 1.35em + 1.5rem); min-height: 0; overflow-y: auto; align-items: flex-start; }
@media (max-width: 40em) {
  body.started .status-line { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; padding: 0; }
}
/* Short screens (400 percent zoom): a fixed height, so a long line never pushes the map
   off screen. The whole line is also under the map and in the message history. */
@media (max-height: 34em) {
  body.started .status-line { height: calc(2 * 1.35em + 1.5rem); min-height: 0; overflow-y: auto; align-items: flex-start; font-size: 1.05rem; }
}
.loading {
  color: var(--muted);
  font-weight: 600;
  margin: calc(var(--gap) * -0.5) 0 var(--gap);
}

/* Before Start: no empty boxes. The status line only repeats the button. */
body:not(.started) .status-line { display: none; }
body:not(.started) .layout { display: none; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
}
@media (min-width: 46em) {
  .layout { grid-template-columns: minmax(0, 1.5fr) minmax(16rem, 1fr); align-items: start; }
}
.side-col { display: grid; gap: var(--gap); min-width: 0; }
.map-col { min-width: 0; }

.panel {
  background: var(--surface);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
}
.hint { color: var(--muted); }

/* ---------- map surface ---------- */
.map-frame { position: relative; }
/* While the map waits (focus is elsewhere), one large Carry on on the map itself (Dorothy 1) */
.map-resume {
  /* along the bottom of the map, never over the traveller in the middle (Priya 11) */
  position: absolute;
  left: 50%;
  bottom: calc(3 * 1.4em + 2rem);
  transform: translateX(-50%);
  z-index: 3;
  font-size: 1.4rem;
  min-height: 3.5rem;
  padding: 0.6rem 1.75rem;
  white-space: nowrap;
  box-shadow: 0 0 0 0.3rem var(--bg), 0 0 0 0.45rem var(--text);
}
.map-resume[hidden] { display: none; }
.map-frame.is-waiting #map-canvas { opacity: 0.75; }
/* The preview's state on the map: a plate along the top, a bar for how far it has gone */
.map-banner {
  position: absolute;
  left: 3.25rem;
  right: 0.5rem;
  top: 0.5rem;
  z-index: 2;
  display: grid;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg);
  color: var(--text);
  border: 0.125rem solid var(--text);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  pointer-events: none;
}
.map-banner[hidden] { display: none; }
.map-banner progress { width: 100%; height: 0.6rem; accent-color: var(--map-route); }
#map {
  position: relative;
  border: 0.125rem solid var(--border);
  border-radius: var(--radius);
  background: var(--map-bg);
  overflow: hidden;
}
#map:focus-visible, #map:focus {
  outline: 0.25rem solid var(--focus);
  outline-offset: 0.1875rem;
  box-shadow: 0 0 0 0.5rem var(--focus-halo);
}
#map-canvas {
  display: block;
  width: 100%;
  height: clamp(16rem, calc(100dvh - 17rem), 44rem);
  cursor: crosshair;
}
@media (max-width: 40em) {
  /* leave room for the latest message under the map at 400 percent */
  /* a phone: the map and the walking buttons fit one screen together (Priya 6) */
  #map-canvas { height: clamp(11rem, min(80vw, 40dvh), 26rem); }
}
.map-state {
  margin: 0;
  /* a fixed three lines: the buttons under the map never slide (Priya 1 and 2). A longer line is cut
     with an ellipsis; the whole line is in the message history (not a scroller: that would be an
     unnamed Tab stop). */
  height: calc(3 * 1.4em + 0.9rem);
  overflow: hidden;
  line-height: 1.4;
  padding: 0.45rem 0.75rem;
  border-top: 0.125rem solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}
.map-state .when-active { display: none; color: var(--text); }
#map:focus .map-state .when-active, #map:focus-within .map-state .when-active { display: inline; }
#map:focus .map-state .when-paused, #map:focus-within .map-state .when-paused { display: none; }
#map:focus-within { border-color: var(--focus); }
.map-latest { color: var(--text); }
.map-state > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.map-state .when-active { display: none; }
#map:focus .map-state .when-active, #map:focus-within .map-state .when-active { display: -webkit-box; }
#map:focus .map-state .when-paused, #map:focus-within .map-state .when-paused { display: none; }

/* Magnifier focus target (Settings, off by default): focus lands on your marker, not the whole map */
.map-focus {
  position: absolute;
  width: 6rem;
  height: 6rem;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}
.map-focus:focus, .map-focus:focus-visible { outline: 0.25rem solid var(--focus); outline-offset: 0.5rem; box-shadow: 0 0 0 0.9rem var(--focus-halo); }

html[data-big-cursor="true"] #map-canvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cg fill='none' stroke-linecap='round'%3E%3Cpath d='M24 3v16M24 29v16M3 24h16M29 24h16' stroke='%23000' stroke-width='7'/%3E%3Ccircle cx='24' cy='24' r='9' stroke='%23000' stroke-width='7'/%3E%3Cpath d='M24 3v16M24 29v16M3 24h16M29 24h16' stroke='%23fff' stroke-width='3'/%3E%3Ccircle cx='24' cy='24' r='9' stroke='%23fff' stroke-width='3'/%3E%3C/g%3E%3C/svg%3E") 24 24, crosshair;
}

/* Map key */
.map-key { margin-top: 0.6rem; }
.map-key summary { font-weight: 700; min-height: 2.75rem; display: flex; align-items: center; cursor: pointer; }
.key-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.4rem 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.key-list li { display: flex; align-items: center; gap: 0.6rem; }
.key-swatch { flex: none; width: 4.5rem; height: 1.75rem; border: 0.0625rem solid var(--border); border-radius: 0.25rem; }
@media (forced-colors: active) { .key-swatch { forced-color-adjust: none; } }

.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.map-tools button { padding: 0.4rem 0.9rem; }
.map-tip { margin: 0 0 0 auto; color: var(--muted); font-size: 0.95rem; }

.pin-menu, .tour-ask { margin-top: 0.6rem; }
.pin-menu[hidden], .tour-ask[hidden], .route-quick[hidden], #tour-bar[hidden] { display: none; }
/* The route's buttons directly under the map (Dorothy 7: they were 6 to 21 screens down) */
.route-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.route-quick button { padding: 0.45rem 0.9rem; }
.touchpad-tip { margin: 0.35rem 0 0; font-size: 0.95rem; }
.touchpad-tip[hidden] { display: none; }
.pin-title { font-weight: 700; margin-bottom: 0.5rem; }
.pin-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Large on-screen buttons for phones: the map only answers a keyboard otherwise */
.touchpad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.touchpad[hidden] { display: none; }
.touchpad button { min-height: 3.75rem; font-size: 1.1rem; padding: 0.4rem; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
/* Arrows beside the words (Priya: every button looked the same); the alternative text after the
   slash keeps them out of the accessible name */
.touchpad [data-action="turnLeft"]::before { content: "\2190\00a0" / ""; }
.touchpad [data-action="forward"]::before { content: "\2191\00a0" / ""; }
.touchpad [data-action="turnRight"]::after { content: "\00a0\2192" / ""; }
.touchpad [data-action="turnAround"]::before { content: "\21BB\00a0" / ""; }
/* Everything you can touch is at least 44 by 44 CSS pixels (Priya 12) */
.choice { min-height: 2.75rem; align-items: center; }
.choice input { margin-top: 0; }
.choice label { padding: 0.5rem 0; flex: 1 1 auto; }
.note-btn { min-height: 2.75rem; }
@media (pointer: coarse) {
  .site-footer a { display: inline-block; padding: 0.6rem 0.1rem; }
}
/* Settings on a small screen: one Close, at the top, always in view (Priya 13) */
@media (max-width: 40em), (max-height: 34em) {
  #settings .dialog-foot { display: none; }
  #settings .dialog-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-bottom: 0.5rem; border-bottom: 0.0625rem solid var(--border); }
}

/* ---------- search ---------- */
.search-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.combo { position: static; flex: 1 1 8rem; min-width: 0; }
#search-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 18rem;
  overflow-y: auto;
  background: var(--bg);
  border: 0.125rem solid var(--text);
  border-radius: var(--radius);
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.5);
}
#search-list [role="option"] {
  padding: 0.55rem 0.7rem;
  border-radius: 0.3rem;
  cursor: pointer;
}
#search-list [role="option"]:hover { background: var(--surface-2); }
#search-list [role="option"][aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-text);
  outline: 0.125rem solid var(--text);
}
.search-tip { font-size: 0.95rem; margin: 0.5rem 0 0; }
.search-status { color: var(--muted); margin: 0.5rem 0 0; }
.search-status:empty { display: none; }
#search:has(#search-results:not([hidden])) .search-status { display: none; }
#search-results { margin: 1rem 0.35rem 0; }
#search-back { margin-top: 0.75rem; }

.result-list { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.75rem; }
.result { border-bottom: 0.0625rem solid var(--surface-2); padding-bottom: 0.75rem; }
.result-name { font-weight: 700; margin-bottom: 0.4rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.result-actions button { text-align: left; }

.button-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; }
.button-list button { width: 100%; text-align: left; font-weight: 550; }
.plain-list { margin: 0 0 0.75rem; padding-left: 1.4rem; }
.plain-list li { padding: 0.2rem 0; }

/* ---------- route panel ---------- */
.route-panel { border-left: 0.375rem solid var(--map-route); }
.route-ends { font-weight: 700; margin-bottom: 0.25rem; }
.route-length { color: var(--muted); font-weight: 600; }
.route-overview { font-weight: 600; }
.route-pace { margin-top: -0.25rem; font-size: 0.95rem; }
.route-check { margin-bottom: 0.25rem; }
.step-item { display: grid; gap: 0.2rem; }
.step-crossings { margin: 0; padding-left: 3.2rem; font-size: 0.95rem; }
.step-note-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; padding-left: 2.3rem; }
.step-note { margin: 0; font-weight: 600; }
.note-btn { min-height: 2.25rem; padding: 0.2rem 0.7rem; font-size: 0.9rem; font-weight: 550; }
.route-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.route-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.5rem; }
.route-row select { width: auto; flex: 1 1 10rem; }
.route-state { min-height: 1.5em; color: var(--muted); font-weight: 600; margin: 0 0 0.25rem; }
.steps-h { margin-top: 0.5rem; }
.route-steps { list-style: none; margin: 0 0 0.75rem; padding: 0.2rem; display: grid; gap: 0.35rem; }
@media (min-width: 46em) { .route-steps { max-height: 24rem; overflow-y: auto; } }
.step-btn {
  width: 100%;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  text-align: left;
  font-weight: 550;
  padding: 0.45rem 0.6rem;
}
.step-num {
  flex: none;
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: 0.125rem solid var(--map-route);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}
.step-btn[aria-current="step"] { border-color: var(--map-route); background: var(--surface); box-shadow: inset 0.375rem 0 0 var(--map-route); }
.step-btn[aria-current="step"] .step-num { background: var(--map-route); color: var(--bg); }

/* ---------- you are here ---------- */
.here { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.here li {
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 0.0625rem solid color-mix(in srgb, var(--border) 45%, transparent);
}
.here li:last-child { border-bottom: 0; }
.here .k { color: var(--muted); font-weight: 600; }
.here .v { font-weight: 600; }
@media (max-width: 22em) {
  .here li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* ---------- log ---------- */
.log {
  margin: 0;
  padding-left: 1.6rem;
  max-height: 16rem;
  overflow-y: auto;
  color: var(--muted);
}
.log li { padding: 0.15rem 0; }
.log li:first-child { color: var(--text); font-weight: 600; }
.log-panel:has(.log:empty) { display: none; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 0.0625rem solid var(--border);
  padding: 1rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.footer-row p { margin: 0 0 0.35rem; }

/* ---------- dialogs ---------- */
dialog {
  width: min(44rem, calc(100vw - 1rem));
  max-height: calc(100dvh - 1rem);
  padding: 0;
  border: 0.125rem solid var(--text);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  display: none;
  flex-direction: column;
}
dialog[open] { display: flex; }
dialog::backdrop { background: rgb(0 0 0 / 0.7); }
.dialog-head { padding: 1rem 1.25rem 0; }
.dialog-head h2 { margin-bottom: 0.25rem; }
.dialog-foot {
  padding: 0.75rem 1.25rem 1rem;
  border-top: 0.0625rem solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}
#list-items, #list-empty { margin: 0.75rem 1.25rem; padding: 0.5rem; overflow-y: auto; }
#list-items.plain-list { padding-left: 2rem; }
.choice-buttons { border-top: 0; justify-content: flex-start; }
/* The first question: two answers of the same weight, one above the other, whole words */
.choice-buttons.stacked { flex-direction: column; align-items: stretch; }
.choice-buttons.stacked button { text-align: left; }
#choice-h[tabindex="-1"]:focus { outline: 0.1875rem solid var(--focus); outline-offset: 0.35rem; border-radius: 0.25rem; }
.head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.5rem 1rem; }
.settings-nav ul { list-style: none; margin: 0.5rem 0 0.25rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.settings-nav button { padding: 0.35rem 0.8rem; }
.settings-form h3[tabindex="-1"]:focus { outline: 0.1875rem solid var(--focus); outline-offset: 0.35rem; border-radius: 0.25rem; }
#settings-h[tabindex="-1"]:focus { outline: 0.1875rem solid var(--focus); outline-offset: 0.35rem; border-radius: 0.25rem; }
.summary-top { margin: 0.25rem 0 0.5rem; }
.summary-handout { flex: 1 1 100%; }
.prompt-form { display: flex; flex-direction: column; min-height: 0; }
/* The body scrolls between a fixed heading and fixed buttons, so Send and Cancel are always on screen (Jim 0.4, B1). */
.prompt-form > .dialog-head, .prompt-form > .dialog-foot { flex: none; }
.prompt-body { padding: 0.75rem 1.25rem 1rem; display: grid; gap: 0.35rem; overflow-y: auto; min-height: 0; grid-auto-rows: max-content; scroll-padding-block: 1rem; }
.prompt-body > label:not(:first-child) { margin-top: 0.75rem; }

.settings-form { overflow-y: auto; padding: 0.5rem 1.25rem 1rem; }
.settings-form h3 { font-size: 1.35rem; margin: 0.5rem 0 0.75rem; }
.settings-form section { border-bottom: 0.125rem solid var(--border); padding: 1rem 0; }
.settings-form section:last-of-type { border-bottom: 0; }
.field { margin: 0 0 1rem; }
fieldset.field {
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem 0.6rem;
  min-width: 0;
}
legend { font-weight: 700; padding: 0 0.35rem; }
.choice { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.25rem 0; }
.choice label { font-weight: 500; cursor: pointer; }
.choice input { width: 1.35rem; height: 1.35rem; margin: 0.15rem 0 0; flex: none; accent-color: var(--accent); }
.subgroup { border-left: 0.25rem solid var(--surface-2); padding-left: 0.9rem; margin-bottom: 1rem; }
.range label { display: block; margin-bottom: 0.2rem; }
.range-row { display: flex; align-items: center; gap: 0.75rem; }
.range-row input[type="range"] { flex: 1 1 auto; min-width: 0; height: 2.75rem; accent-color: var(--accent); }
.range-row output { min-width: 6.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.help-body { overflow-y: auto; padding: 1rem 1.25rem; }
.help-body h3 { margin-top: 1.25rem; }
.help-tour { font-weight: 700; border-left: 0.25rem solid var(--accent); padding-left: 0.6rem; }
.help-body h4 { margin-top: 1rem; color: var(--accent); }
.keys { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.keys th, .keys td {
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 0.6rem;
  border-bottom: 0.0625rem solid var(--surface-2);
}
.keys thead th { border-bottom: 0.125rem solid var(--border); }
.keys tbody th { font-weight: 700; width: 38%; }
@media (max-width: 30em) {
  .keys, .keys tbody, .keys tr, .keys th, .keys td { display: block; width: auto; }
  .keys thead { display: none; }
  .keys tbody th { border-bottom: 0; padding-bottom: 0; width: auto; }
}

.summary-body { overflow-y: auto; padding: 0.5rem 1.25rem 1rem; }
.summary-steps { margin: 0; padding-left: 1.8rem; font-size: 1.15rem; }
.summary-steps li { padding: 0.3rem 0; }
.summary-steps ul { margin: 0.2rem 0 0; padding-left: 1.2rem; font-size: 1rem; }
.summary-overview { font-weight: 650; }
.summary-note { color: var(--muted); margin-top: 1rem; }

.learn-body { overflow-y: auto; padding: 0.5rem 1.25rem 1rem; }
.learn-body h3 { margin-top: 1rem; }
.learn-part { font-size: 1.3rem; border-top: 0.125rem solid var(--border); padding-top: 1rem; }
.sound-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.4rem; }
.sound-btn { width: 100%; text-align: left; font-weight: 550; }

.print-area { display: none; }

/* Privacy on the start page */
.privacy { margin-top: 1.5rem; max-width: 46rem; }
.privacy h2 { font-size: 1.2rem; }
.forget-confirm { border-left: 0.25rem solid var(--danger); padding: 0.5rem 0.75rem; margin-bottom: 1rem; }
.forget-done { font-weight: 650; border-left: 0.25rem solid var(--accent); padding-left: 0.6rem; }
/* 0.4: Send feedback and About */
textarea { resize: vertical; line-height: 1.4; }
/* Read only: no grip, a dashed edge and a filled ground, so it does not look like a field to type in (Jim L9). */
textarea[readonly] { background: var(--surface-2); color: var(--text); resize: none; border-style: dashed; }
textarea[aria-invalid="true"], input[aria-invalid="true"] { border-color: var(--danger); border-width: 0.1875rem; }
/* The focus ring on a field in error is the text colour, so ring and error border never share a colour (Jim L1). */
textarea[aria-invalid="true"]:focus, textarea[aria-invalid="true"]:focus-visible,
input[aria-invalid="true"]:focus, input[aria-invalid="true"]:focus-visible { outline-color: var(--text); }
.field-error { color: var(--danger); font-weight: 650; margin: 0; border-left: 0.25rem solid var(--danger); padding-left: 0.6rem; }
.field-error::before { content: "Error: "; }
.feedback-status { font-weight: 650; border-left: 0.25rem solid var(--accent); padding-left: 0.6rem; margin: 0.5rem 0 0; }
/* Sent and not sent differ by more than colour: a solid bar against a thick double bar and a frame. */
.feedback-status.is-sent { border-left: 0.25rem solid var(--accent); }
.feedback-status.is-failed { border: 0.125rem dashed var(--danger); border-left: 0.5rem double var(--danger); padding: 0.4rem 0.6rem; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); column-gap: 1rem; }
/* Buttons inside text line up with the text (Jim M6). */
button.linkish { min-height: 2.75rem; padding: 0.4rem 0; border-width: 0; background: none; color: var(--link); text-decoration: underline; font-weight: inherit; }
button.linkish:hover { text-decoration-thickness: 0.15em; }
.footer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; }
.footer-actions a { padding: 0.6rem 0; }
/* A link with the box of a secondary button (About: Get Bearings for Windows, Jim M7). */
a.button-link {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 1.1rem;
  border-radius: var(--radius); border: 0.125rem solid var(--border); background: var(--surface-2);
  color: var(--text); font-weight: 650; text-decoration: none;
}
a.button-link:hover { border-color: var(--text); text-decoration: underline; }
a.button-link[hidden] { display: none; }
.about-version { font-weight: 650; font-size: 1.15rem; }
/* The page behind an open dialog stays put (Jim M5). Two rules: one for browsers with :has(), and a
   class the page sets for the rest; a browser that cannot read :has() drops only that one rule. */
html.dialog-open { overflow: hidden; }
html:has(dialog[open]) { overflow: hidden; }
.help-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Dialogs on short screens (400 percent zoom): the whole dialog scrolls, not a sliver of it */
@media (max-height: 34em) {
  dialog { overflow-y: auto; }
  dialog > *, .prompt-form > * { flex: none; }
  .settings-form, .help-body, .summary-body, .learn-body, #list-items, .prompt-body { overflow: visible; }
  .dialog-head { padding-top: 0.6rem; }
  .dialog-foot { padding: 0.5rem 1rem; }
}

/* ---------- motion ---------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
html[data-reduced-motion="true"] { scroll-behavior: auto; }
html[data-reduced-motion="true"] *, html[data-reduced-motion="true"] *::before, html[data-reduced-motion="true"] *::after {
  transition: none !important;
  animation: none !important;
}

/* ---------- forced colours ---------- */
@media (forced-colors: active) {
  button, input[type="text"], input[type="email"], textarea, a.button-link, select, .panel, #map, dialog, .status-line { border-color: CanvasText; }
  button.primary { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  button.primary:focus-visible { outline-color: CanvasText; }
  #search-list [role="option"][aria-selected="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .step-btn[aria-current="step"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  button[aria-pressed="true"], #mute[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: HighlightText; }
  button:disabled { color: GrayText; border-color: GrayText; }
  :focus-visible, #map:focus { outline-color: Highlight; box-shadow: none; }
  .brand .mark { color: CanvasText; }
}

/* ---------- 0.3.1: touch targets last, so they win (Priya 12) ---------- */
.choice { min-height: 2.75rem; align-items: center; }
.choice input { margin-top: 0; }
.choice label { padding: 0.5rem 0; flex: 1 1 auto; }
.note-btn { min-height: 2.75rem; }
.route-check { min-height: 2.75rem; }
