/* Maps — "Legend" chrome (2026-11-14): the controls are drawn the way a
   printed map draws its own legend and collar. Paper boxes with an ink
   keyline, rules between rows instead of drawn buttons, legend squares for
   on/off, one accent (the Atlas trail red), Garamond for names and figures.
   The design sheet it was built from is dev/maps-design/legend.html. */

@font-face {
  font-family: "EB Garamond"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../vendor/eb-garamond/eb-garamond-latin.woff2") format("woff2");
}

:root {
  --paper: #f7f4ec;        /* panels and bars; a shade lighter than the Atlas land */
  --paper-2: #efebdf;      /* selected row, pressed, thumbnails */
  --well: #fffdf7;         /* text inputs only */
  --ink: #23221e;
  --muted: #6c685e;
  --rule: rgba(35, 34, 30, 0.22);
  --red: #c3412b;          /* the Atlas trail color: selected, on, primary progress */
  --accent: var(--red);
  --danger: var(--red);
  --ok: #2f7a45;
  --warn: #a8650a;
  --key: 1px solid var(--ink);                    /* the keyline every box carries */
  --hard: 0 1px 0 rgba(35, 34, 30, 0.25);         /* one hard shadow, no blur */
  --radius: 2px;
  --hud-h: 72px;           /* room the HUD takes at the top (0 when hidden) */
  --bar-h: 62px;           /* room the toolbar takes at the bottom */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --kb: 0px;                /* on-screen keyboard height (set from visualViewport) */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* The page background is also the status bar's colour in the iOS home-screen
   app (it draws a solid band there and starts the page below it). */
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); }
body { font: 15px/1.35 var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* iOS Safari zooms the page when focusing an input under 16px. */
input, textarea, select { font-size: 16px !important; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.ico { display: inline-flex; width: 20px; height: 20px; flex: none; }
.ico svg, [data-icon] svg { width: 100%; height: 100%; display: block; }

#map { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* Zoomed out (map.js), the globe hangs in a night sky with faint stars:
   two star tiles of different sizes so the repeat doesn't show. */
#map.space {
  background-color: #05070c;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='431' height='523'><g fill='%23fff'><circle cx='140' cy='79' r='1.0' fill-opacity='0.27'/><circle cx='354' cy='49' r='0.8' fill-opacity='0.28'/><circle cx='219' cy='20' r='0.7' fill-opacity='0.46'/><circle cx='104' cy='288' r='0.5' fill-opacity='0.66'/><circle cx='53' cy='117' r='1.0' fill-opacity='0.54'/><circle cx='27' cy='306' r='0.5' fill-opacity='0.74'/><circle cx='20' cy='449' r='0.6' fill-opacity='0.46'/><circle cx='233' cy='299' r='0.8' fill-opacity='0.66'/><circle cx='78' cy='304' r='1.0' fill-opacity='0.34'/><circle cx='42' cy='372' r='0.8' fill-opacity='0.28'/><circle cx='89' cy='356' r='0.7' fill-opacity='0.64'/><circle cx='201' cy='483' r='0.6' fill-opacity='0.4'/><circle cx='342' cy='366' r='0.5' fill-opacity='0.29'/><circle cx='129' cy='259' r='0.6' fill-opacity='0.61'/><circle cx='124' cy='513' r='0.5' fill-opacity='0.51'/><circle cx='71' cy='179' r='0.7' fill-opacity='0.46'/><circle cx='415' cy='41' r='0.8' fill-opacity='0.54'/><circle cx='377' cy='164' r='1.0' fill-opacity='0.43'/><circle cx='214' cy='417' r='0.5' fill-opacity='0.67'/><circle cx='407' cy='248' r='1.0' fill-opacity='0.28'/><circle cx='315' cy='162' r='0.8' fill-opacity='0.75'/><circle cx='354' cy='149' r='0.7' fill-opacity='0.69'/></g></svg>"),
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='677' height='719'><g fill='%23fff'><circle cx='235' cy='676' r='0.6' fill-opacity='0.33'/><circle cx='79' cy='42' r='0.6' fill-opacity='0.31'/><circle cx='168' cy='281' r='0.7' fill-opacity='0.29'/><circle cx='304' cy='395' r='0.5' fill-opacity='0.66'/><circle cx='585' cy='200' r='0.7' fill-opacity='0.74'/><circle cx='462' cy='274' r='0.5' fill-opacity='0.33'/><circle cx='119' cy='167' r='0.5' fill-opacity='0.26'/><circle cx='563' cy='131' r='0.6' fill-opacity='0.25'/><circle cx='284' cy='265' r='0.8' fill-opacity='0.41'/><circle cx='85' cy='618' r='0.8' fill-opacity='0.58'/><circle cx='501' cy='328' r='1.0' fill-opacity='0.65'/><circle cx='266' cy='287' r='0.5' fill-opacity='0.49'/><circle cx='271' cy='137' r='0.5' fill-opacity='0.47'/><circle cx='74' cy='432' r='0.5' fill-opacity='0.25'/><circle cx='102' cy='73' r='0.6' fill-opacity='0.56'/><circle cx='48' cy='150' r='0.7' fill-opacity='0.32'/><circle cx='171' cy='250' r='0.6' fill-opacity='0.49'/><circle cx='78' cy='351' r='0.7' fill-opacity='0.49'/><circle cx='211' cy='104' r='1.0' fill-opacity='0.42'/><circle cx='179' cy='596' r='0.5' fill-opacity='0.51'/><circle cx='139' cy='685' r='0.6' fill-opacity='0.32'/><circle cx='368' cy='19' r='0.8' fill-opacity='0.4'/><circle cx='435' cy='65' r='0.6' fill-opacity='0.51'/><circle cx='615' cy='256' r='0.5' fill-opacity='0.52'/><circle cx='527' cy='237' r='0.5' fill-opacity='0.56'/><circle cx='534' cy='545' r='0.5' fill-opacity='0.65'/><circle cx='554' cy='532' r='0.5' fill-opacity='0.35'/><circle cx='334' cy='526' r='0.5' fill-opacity='0.65'/><circle cx='320' cy='139' r='0.8' fill-opacity='0.73'/><circle cx='303' cy='674' r='0.6' fill-opacity='0.73'/></g></svg>");
}
.maplibregl-canvas { outline: none; }

/* Everything that sits over the map is one of these. */
.box { background: var(--paper); color: var(--ink); border: var(--key); border-radius: var(--radius); box-shadow: var(--hard); }

/* A number that changes while you watch it (speed, altitude): each digit in
   its own fixed slot, because this Garamond has no fixed-width figures and
   the readout would shift sideways as digits change (util.js figures()). */
.dg { display: inline-block; width: 0.5em; text-align: center; }

/* Pinching on the fixed chrome must not zoom the whole page (iOS ignores user-scalable=no). */
.hud, .edit-bar, .toolbar, .map-buttons { touch-action: none; }

/* ---- HUD: speed + altitude ---- */
.hud {
  position: fixed; z-index: 20;
  top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px);
  display: grid; grid-template-columns: 1fr 1fr;
  pointer-events: auto;
}
.hud-cell { display: flex; align-items: baseline; gap: 6px; min-width: 0; padding: 7px 12px 8px; border-left: 1px solid var(--rule); }
.hud-cell:first-child { border-left: 0; }
.hud-num { font: 500 38px/1 var(--serif); }
.hud-unit { font-size: 12px; color: var(--muted); }
.hud-ico { display: none; }
.hud .hud-num.dem { color: var(--muted); }

/* ---- edit bar (replaces the HUD while drawing): stats + live profile ---- */
.edit-bar {
  position: fixed; z-index: 21;
  top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px);
  padding: 8px 12px 6px;
  display: flex; flex-direction: column; gap: 4px;
}
.edit-stats { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font: 500 14px/1.2 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; }
.edit-stats .es-dist { font: 500 22px/1 var(--serif); }
.edit-stats span:empty { display: none; }
.edit-hint { font-size: 12.5px; line-height: 1.3; color: var(--muted); text-align: center; padding-bottom: 2px; }
.edit-profile { display: block; width: 100%; height: 56px; }
.seg { display: inline-flex; border: var(--key); border-radius: var(--radius); overflow: hidden; flex: none; }
.seg button { height: 34px; min-width: 40px; padding: 0 10px; border: 0; background: transparent; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 13px; }
.seg button + button { border-left: var(--key); }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg button .ico { width: 18px; height: 18px; }
/* Drawing controls take the toolbar's place. */
body.editing #toolbar { display: none; }
.edit-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 6px; }
.edit-tools .tool { border: 0; width: 40px; padding: 10px; }
.edit-tools .seg button { min-width: 34px; padding: 0 7px; }
.tool:disabled { opacity: 0.35; }
.edit-tools .tool.done { background: var(--ink); color: var(--paper); width: 48px; height: 34px; padding: 7px; border-radius: var(--radius); }

/* ---- floating map buttons: search, compass, status ---- */
.map-buttons {
  position: fixed; right: calc(var(--safe-r) + 10px); top: calc(var(--safe-t) + var(--hud-h) + 10px); z-index: 15;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none;
}
.map-buttons > * { pointer-events: auto; }
body.no-hud { --hud-h: 0px; }   /* sheet height, buttons and toasts move up */
body.editing { --hud-h: var(--edit-h, 112px); }   /* the edit bar's measured height (draw.js) */
body.no-hud:not(.editing) .toasts { top: calc(var(--safe-t) + 62px); }   /* clear of the search box */
.round-btn { width: 40px; height: 40px; display: grid; place-items: center; padding: 9px; }
body.editing #btn-search { display: none; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: var(--radius); border: 0; background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 600; }
.status-badge .ico { width: 15px; height: 15px; }
.status-badge.warn { background: var(--red); }

/* ---- bottom toolbar: one strip, cells split by rules ---- */
.toolbar {
  position: fixed; z-index: 20; height: 46px;
  left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px); bottom: calc(var(--safe-b) + 10px);
}
.tool { width: 46px; height: 44px; padding: 11px; border: 0; background: transparent; color: var(--ink); display: grid; place-items: center; flex: none; }
.tool.on { background: var(--ink); color: var(--paper); }
.tool.follow { color: var(--red); }                                   /* following your position */
.tool.heading { background: var(--red); color: var(--paper); }        /* and turning the map with you */
/* Layers + location on the left, the scale in the middle, drawing + routes
   on the right (Thomas, 2026-11-14). */
#toolbar { display: grid; grid-template-columns: auto 1fr auto; }
.tb-side, .tb-mid { display: flex; align-items: stretch; min-width: 0; }
.tb-mid { justify-content: center; border-left: 1px solid var(--rule); }
.tb-side > * + *, .tb-side.end > :first-child { border-left: 1px solid var(--rule); }
/* The scale, as a printed map draws it: a bar in alternating blocks. */
.scale { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; }
.scale-label { font-size: 10.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.scale-bar { height: 5px; width: 80px; border: var(--key); background: linear-gradient(90deg, var(--ink) 0 25%, transparent 25% 50%, var(--ink) 50% 75%, transparent 75%); }

/* MapLibre's attribution, tucked above the toolbar. */
/* Settings → Credits (there is no attribution control on the map). */
.credits h3 { font-size: 11px; font-weight: 400; color: var(--muted); margin: 16px 0 4px; }
.credits .note { margin: 3px 0; }
.credits a { color: inherit; }

/* ---- the panel: a box above the toolbar on a phone, a column on a desktop ---- */
.sheet {
  position: fixed; z-index: 18;
  left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px); bottom: max(calc(var(--safe-b) + var(--bar-h)), var(--kb));
  background: var(--paper); color: var(--ink); border: var(--key); border-radius: var(--radius); box-shadow: var(--hard);
  display: flex; flex-direction: column;
  height: var(--sheet-h, 42vh); max-height: calc(var(--vh, 100dvh) - var(--safe-t) - var(--hud-h) - 18px - max(calc(var(--safe-b) + var(--bar-h)), var(--kb)));
  /* the keyboard term: with it up the panel sits on the keyboard, and a
     full-height panel ran off the top of the screen, search box and all */
  transition: height 0.22s ease;
  touch-action: pan-y;
}
/* the second, faint keyline a legend box has just inside its edge */
.sheet::before { content: ""; position: absolute; inset: 3px; border: 1px solid var(--rule); pointer-events: none; z-index: 3; }
.sheet.dragging { transition: none; }
.sheet[data-size="peek"] { --sheet-h: auto; }
.sheet-grip { flex: none; height: 16px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet-grip span { width: 28px; height: 2px; background: var(--rule); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 14px 12px; margin: 0 4px 4px; }
.sheet[data-size="peek"] .sheet-body { max-height: 46vh; }

/* panel content */
.view-head { display: flex; align-items: baseline; gap: 10px; padding: 2px 0 8px; position: sticky; top: 0; background: var(--paper); z-index: 2; }
.view-head h2 { flex: 1; margin: 0; font: 500 21px/1.15 var(--serif); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-head h2 small { display: block; font: 400 12px/1.3 var(--font); color: var(--muted); margin-top: 2px; }
.icon-btn { width: 32px; height: 32px; align-self: center; border: var(--key); border-radius: var(--radius); background: transparent; color: var(--ink); display: grid; place-items: center; padding: 6px; flex: none; }
.icon-btn.on { background: var(--ink); color: var(--paper); }
/* Close and Back are written as the word (their aria-label), not drawn as a glyph. */
.icon-btn.plain { width: auto; height: auto; min-height: 32px; border: 0; padding: 0 2px; color: var(--muted); font-size: 12.5px; text-transform: lowercase; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.icon-btn.plain > * { display: none; }
.icon-btn.plain::after { content: attr(aria-label); }

/* Actions: the one that matters is ink-filled; the rest are links. */
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin: 8px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 1px; border: 0; border-radius: var(--radius); background: none;
  color: var(--ink); font-size: 13.5px;
  text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px;
}
.btn .ico { display: none; }
.btn.primary, .btn.accent { min-height: 36px; padding: 0 14px; background: var(--ink); color: var(--paper); font-weight: 600; text-decoration: none; }
.btn.primary .ico, .btn.accent .ico { display: inline-flex; width: 16px; height: 16px; }
.btn.primary.grow, .btn.accent.grow { flex: 0 1 auto; }
@media (hover: hover) { .btn:hover { text-decoration-color: var(--ink); } .btn.primary:hover, .btn.accent:hover { background: #3a3832; } }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: 0.45; }
a.btn.primary, a.btn.accent { text-decoration: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin: 8px 0 12px; padding: 10px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stats > div { min-width: 0; }
.stats b { display: block; font: 500 23px/1.1 var(--serif); white-space: nowrap; }
.stats > div > span { font-size: 11px; color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.err { color: var(--red); font-size: 13.5px; margin: 6px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); min-height: 46px; }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; display: flex; align-items: center; gap: 10px; }
.row-text { min-width: 0; flex: 1; }
.row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.row.hidden-route .row-title, .row.hidden-route .swatch, .row.hidden-route .route-thumb { opacity: 0.45; }
.route-thumb { width: 34px; height: 34px; flex: none; background: var(--paper-2); border: 1px solid var(--rule); }
.route-thumb path { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.swatch { width: 14px; height: 14px; flex: none; border: 1px solid rgba(35, 34, 30, 0.45); }
.folder-ico { width: 20px; height: 20px; color: var(--muted); flex: none; }
.crumbs { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 14px; }
.search { width: 100%; height: 40px; border: var(--key); border-radius: var(--radius); background: var(--well); padding: 0 11px; font: inherit; margin-bottom: 8px; caret-color: var(--red); }
.search:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--red); outline-offset: 1px; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field label, .field .label { font-size: 11px; color: var(--muted); }
.field input[type=text], .field textarea, .field select { font: inherit; border: var(--key); border-radius: var(--radius); background: var(--well); padding: 8px 10px; color: var(--ink); caret-color: var(--red); }
.field textarea { min-height: 70px; resize: vertical; }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 28px; height: 28px; border: 1px solid rgba(35, 34, 30, 0.45); border-radius: 0; }
.colors button.on { outline: 2px solid var(--ink); outline-offset: 2px; }

/* On/off is a legend square, in front of what it switches. */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); min-height: 44px; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row:has(.switch) { flex-direction: row-reverse; justify-content: flex-end; gap: 10px; cursor: pointer; }
.toggle-row .s { font-size: 12px; color: var(--muted); }
.toggle-row .slider { flex: 0 1 48%; min-width: 120px; accent-color: var(--ink); }
.toggle-row select {
  -webkit-appearance: none; appearance: none; font: inherit; color: var(--ink); max-width: 58%;
  border: var(--key); border-radius: var(--radius); padding: 6px 26px 6px 9px;
  background: var(--well) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2323221e' stroke-width='1.4'/%3E%3C/svg%3E") right 9px center / 9px no-repeat;
}
.switch { position: relative; width: 14px; height: 14px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border: var(--key); }
.switch input:checked + span { background: var(--red); border-color: var(--red); box-shadow: inset 0 0 0 2px var(--paper); }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Base map: three swatches; the chosen one is outlined in red. */
.base-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 2px 0 10px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.base-pick button { border: 0; background: none; padding: 0; font-size: 13px; text-align: left; display: flex; flex-direction: column; gap: 5px; white-space: nowrap; }
.base-pick button.on { font-weight: 600; }
.base-pick i { height: 30px; border: var(--key); display: block; }
.base-pick button.on i { outline: 2px solid var(--red); outline-offset: 1px; }
.base-pick .b-atlas { background: linear-gradient(135deg, #c5d9b3 0 42%, #f5f2eb 42% 47%, #c3412b 47% 52%, #f5f2eb 52% 58%, #a8d0e0 58%); }
.base-pick .b-satellite { background: linear-gradient(135deg, #4c5237, #7b7455 55%, #39413a); }
.base-pick .b-topo { background: repeating-linear-gradient(160deg, #f1ead6 0 5px, #b79b6c 5px 6px); }

/* profile chart */
.profile { position: relative; margin: 4px 0 6px; touch-action: pan-y; }  /* vertical swipes still scroll the panel */
.profile canvas { width: 100%; height: 150px; display: block; }
.profile-readout { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-size: 12px; line-height: 1.2; font-variant-numeric: tabular-nums; padding: 3px 7px; border-radius: var(--radius); white-space: nowrap; pointer-events: none; }
.progress { font-size: 13px; color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule); padding: 7px 10px; margin: 0 0 10px; }
.progress b { font-variant-numeric: tabular-nums; }
.range-line { font-size: 13px; color: var(--ink); margin: -4px 0 10px; }

/* directions (directions.js): From and To, with the swap beside them */
.dir-ends { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.dir-ends .list { flex: 1; min-width: 0; }
.dir-ends .row-sub { font-size: 11px; }
/* choosing a point on the map: the panel steps aside until the tap */
body.picking .sheet { display: none; }

/* long-press / place cards */
.card-title { font: 500 21px/1.15 var(--serif); margin: 0 0 2px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.slope { margin: -4px 0 2px; font-size: 14.5px; color: var(--ink); }
.hours-open { color: var(--ok); font-weight: 600; }
.hours-soon { color: var(--warn); font-weight: 600; }
.hours-closed { color: var(--red); font-weight: 600; }
button.link, .kv a { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.hours .link { margin-left: 6px; }
.hours-week { margin: 6px 0 2px; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.hours-week td { padding: 1px 14px 1px 0; vertical-align: top; }
.hours-week tr.today { font-weight: 700; }
.hours-note { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.hero { display: flex; align-items: baseline; gap: 5px; margin: 0 0 8px; }
.hero b { font: 500 40px/1 var(--serif); }
.hero span { font-size: 15px; line-height: 1; color: var(--muted); }
.facts { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; padding: 10px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.fact { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink); }
.fact > .ico { width: 16px; height: 16px; color: var(--muted); }
.fact > span { display: inline-flex; align-items: center; gap: 6px; }
.needle { width: 17px; height: 17px; color: var(--ink); flex: none; }
.quiet-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 4px 0 2px; }
.quiet { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; color: var(--muted); font: 400 12.5px/1.2 var(--font); font-variant-numeric: tabular-nums; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; cursor: pointer; }
.quiet .ico { width: 14px; height: 14px; }
@media (hover: hover) { .quiet:hover { color: var(--ink); } }
.photo { width: 100%; max-height: 220px; object-fit: cover; margin: 6px 0; background: var(--paper-2); border: 1px solid var(--rule); }

/* progress bars (downloads) */
.bar { height: 6px; border: var(--key); background: transparent; overflow: hidden; margin: 6px 0; }
.bar > i { display: block; height: 100%; background: var(--ink); width: 0; transition: width 0.2s; }

/* passing messages */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + var(--hud-h) + 12px); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--radius); font-size: 13.5px; display: flex; gap: 12px; align-items: center; }
.toast.error { background: var(--red); }
.toast button { background: none; border: 0; color: var(--paper); font-weight: 600; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

/* menu (action list) */
.menu { position: fixed; z-index: 50; inset: 0; background: rgba(35, 34, 30, 0.28); display: flex; align-items: flex-end; justify-content: center; padding: 10px 10px calc(max(var(--safe-b), var(--kb)) + 10px); }
.menu-box { width: min(100%, 420px); background: var(--paper); border: var(--key); border-radius: var(--radius); box-shadow: var(--hard); padding: 0 14px; max-height: 80dvh; overflow-y: auto; }
.menu-title { padding: 12px 0 8px; font: 500 19px/1.2 var(--serif); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 0; border: 0; background: none; text-align: left; font-size: 14.5px; border-top: 1px solid var(--rule); }
.menu-item .ico { width: 18px; height: 18px; color: var(--muted); }
.menu-item.danger { color: var(--red); }
.menu-item.danger .ico { color: var(--red); }
.menu-item.cancel { justify-content: center; color: var(--muted); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.menu-box .field, .menu-box .btn-row { padding-left: 0 !important; padding-right: 0 !important; }
@media (min-width: 900px) { .menu { align-items: center; } }

.fatal { position: fixed; inset: 0; z-index: 100; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.fatal h1 { font: 500 24px/1.2 var(--serif); margin: 0 0 8px; }
.fatal p { color: var(--muted); max-width: 420px; }
.fatal button { margin-top: 12px; padding: 9px 16px; border-radius: var(--radius); border: 0; background: var(--ink); color: var(--paper); font-weight: 600; }

/* style tuning panel (?tune) */
.tune { position: fixed; z-index: 60; right: 8px; top: calc(var(--safe-t) + 8px); width: 290px; max-height: 80dvh; overflow-y: auto; background: var(--paper); border: var(--key); padding: 10px; font-size: 12px; }
.tune label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 3px 0; }
.tune input[type=color] { width: 38px; height: 22px; padding: 0; border: 0; }
.tune input[type=range] { width: 120px; }
.tune textarea { width: 100%; height: 90px; font: 11px ui-monospace, monospace; }

/* Elevation under the pointer (hover.js), beside the scale; desktop only. */
.hover-elev { display: flex; align-items: center; gap: 6px; padding: 0 10px; white-space: nowrap; min-width: 86px; }
.hover-elev b { font: 500 16px/1 var(--serif); }
.hover-elev [data-icon] { width: 15px; height: 15px; color: var(--muted); }

/* Map key (key.js) */
.key-sec { margin: 4px 0 16px; }
.key-sec h3 { font-size: 11px; font-weight: 400; color: var(--muted); margin: 0 0 8px; }
.key-sec h3 small { font-size: 11px; }
.key-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 14px; }
.key-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; line-height: 1.25; min-width: 0; }
.key-sw { flex: none; }
.key-bands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.kb { display: flex; align-items: center; gap: 7px; }
.kb i { width: 22px; height: 14px; flex: none; border: 1px solid rgba(35, 34, 30, 0.3); }
.key-img { width: 24px; height: 18px; flex: none; object-fit: contain; }

/* ---- phone: swiped away (bars.js). The top bar (HUD or search) slides up
   off the screen, the toolbar down; the panel and the map's attribution take
   the room. A long press on the map brings them back. ---- */
@media (max-width: 899px) {
  .hud, .map-buttons, #toolbar { transition: transform 0.25s ease; }
  body.top-away:not(.editing) { --hud-h: 0px; }
  body.top-away:not(.editing) .hud,
  body.top-away:not(.editing) .map-buttons { transform: translateY(calc(-100% - var(--safe-t) - var(--hud-h) - 24px)); pointer-events: none; }
  body.top-away:not(.editing) .toasts { top: calc(var(--safe-t) + 12px); }
  body.bottom-away:not(.editing) { --bar-h: 10px; }
  body.bottom-away:not(.editing) #toolbar { transform: translateY(calc(100% + var(--safe-b) + 24px)); pointer-events: none; }
}


/* ---- phone, resting: search is a labelled box across the top, as on the sheet ---- */
@media (max-width: 899px) {
  body.no-hud:not(.editing) .map-buttons { left: calc(var(--safe-l) + 10px); flex-direction: row; align-items: flex-start; }
  body.no-hud:not(.editing) #btn-search { flex: 1; display: flex; justify-content: flex-start; gap: 8px; padding: 0 11px; color: var(--muted); font-size: 14px; }
  body.no-hud:not(.editing) #btn-search > span { width: 17px; height: 17px; }
  body.no-hud:not(.editing) #btn-search::after { content: attr(aria-label); }
}

/* ---- desktop: the panel is a full-height column with one rule on its map
   side; the toolbar is a single strip centered over the map that is left.
   (Thomas: "for desktop the menu bar should go on top? bottom for mobile,
   certainly".) While drawing, the drawing controls take the toolbar's place
   and the stats + profile sit at the bottom. ---- */
@media (min-width: 900px) {
  :root { --bar-h: 0px; --panel-w: 390px; --map-cx: 50vw; }
  body, body.editing, body.no-hud { --hud-h: 0px; }
  body.sheet-open { --map-cx: calc(var(--panel-w) + (100vw - var(--panel-w)) / 2); }

  .sheet {
    left: 0; right: auto; top: 0; bottom: 0; width: var(--panel-w);
    height: auto !important; max-height: none;
    border-width: 0 1px 0 0; border-radius: 0; box-shadow: 1px 0 0 rgba(35, 34, 30, 0.2);
    padding-left: var(--safe-l);
  }
  .sheet::before { display: none; }
  .sheet-grip { display: none; }
  .sheet-body, .sheet[data-size="peek"] .sheet-body { padding: 14px 16px; margin: 0; max-height: none; }

  .hud, .edit-bar, .toolbar { left: var(--map-cx); right: auto; transform: translateX(-50%); transition: left 0.2s ease; }
  .toolbar { top: 10px; bottom: auto; height: 36px; }
  #toolbar { grid-template-columns: auto auto auto; }
  .tool { width: 36px; height: 34px; padding: 8px; }
  @media (hover: hover) { .tool:not(.on):not(.heading):not(.done):hover { background: var(--paper-2); } }
  .scale { flex: none; width: 104px; padding: 0 10px; }
  .edit-tools { gap: 8px; padding: 0 4px; }
  .edit-tools .tool.done { height: 28px; width: 46px; }
  .seg button { height: 28px; }
  .hud { top: 56px; grid-template-columns: auto auto; }
  .hud-cell { padding: 5px 14px 6px; }
  .hud-num { font-size: 30px; }
  .edit-bar { top: auto; bottom: 12px; width: min(600px, calc(100vw - var(--panel-w) - 40px)); }
  body:not(.sheet-open) .edit-bar { width: min(600px, calc(100vw - 40px)); }
  .edit-profile { height: 48px; }
  .map-buttons { top: 10px; right: 10px; }
  .round-btn { width: 36px; height: 36px; padding: 8px; }
  .toasts, body.editing .toasts { left: var(--map-cx); top: 58px; }
  .menu-box { width: min(100%, 320px); }
}

/* ---- desktop with a mouse: denser. The phone sizes are for thumbs; with a
   pointer the same controls can be smaller. Same parts, tighter metrics.
   (Thomas, of the earlier desktop chrome: "it's to big and bubbly".) ---- */
@media (min-width: 900px) and (pointer: fine) {
  :root { --panel-w: 344px; }
  body { font-size: 13.5px; }
  .sheet-body, .sheet[data-size="peek"] .sheet-body { padding: 12px 14px; }
  .view-head { padding: 0 0 8px; }
  .view-head h2 { font-size: 20px; }
  .icon-btn { width: 26px; height: 26px; padding: 5px; }
  .icon-btn.plain { min-height: 24px; }
  .btn { min-height: 30px; font-size: 13px; }
  .btn.primary, .btn.accent { min-height: 30px; padding: 0 12px; }
  .btn-row { margin: 6px 0; }
  .search { height: 32px; font-size: 13.5px !important; }
  .hero b { font-size: 32px; }
  .facts { gap: 4px; margin-bottom: 10px; padding: 8px 0; }
  .fact { font-size: 13px; gap: 7px; }
  .stats { gap: 8px 10px; margin: 6px 0 10px; padding: 8px 0; }
  .stats b { font-size: 20px; }
  .row { min-height: 36px; padding: 4px 0; gap: 8px; }
  .route-thumb { width: 28px; height: 28px; }
  .toggle-row { padding: 6px 0; min-height: 34px; }
  .base-pick i { height: 26px; }
  .field input[type=text], .field textarea, .field select { padding: 6px 9px; font-size: 13.5px !important; }
  .profile canvas { height: 120px; }
  .key-item { font-size: 12.5px; gap: 8px; }
  .key-grid { gap: 6px 12px; }
  .kb { font-size: 12px; }
  .menu-item { padding: 8px 0; font-size: 13.5px; }
  .toast { font-size: 13px; padding: 6px 11px; }
}
