/* Roman Forum & Palatine walking tour
 * Three display modes, set on <html data-mode>:
 *   stone — warm daylight default (travertine + terracotta)
 *   dark  — evening / low light
 *   sun   — high-brightness outdoor: near-black on near-white, heavier weights,
 *           no low-contrast greys, no translucency. Built for 100k lux.
 */

:root {
  --ink:        #241a14;
  --ink-soft:   #5a4638;
  --ink-faint:  #8a7263;
  --paper:      #f6efe4;
  --paper-2:    #efe5d6;
  --paper-3:    #e5d8c4;
  --line:       #d6c6ad;
  --terra:      #a8452a;
  --terra-deep: #7b3f2b;
  --terra-soft: #f0ded4;
  --gold:       #9a7233;
  --green:      #4a6b3f;
  --shadow:     0 2px 10px rgba(60, 40, 25, .16);
  --shadow-lg:  0 -6px 28px rgba(60, 40, 25, .26);
  --radius:     14px;

  --fs-body:    17.5px;
  --fs-lede:    19px;
  --lh-body:    1.62;
  --w-body:     400;
  --w-strong:   650;

  --bar-h: 58px;
  --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);
}

html[data-mode='dark'] {
  --ink:        #f2e7da;
  --ink-soft:   #c3b2a1;
  --ink-faint:  #93826f;
  --paper:      #191412;
  --paper-2:    #221b17;
  --paper-3:    #2c231d;
  --line:       #3d3128;
  --terra:      #d97a55;
  --terra-deep: #b8563a;
  --terra-soft: #33211a;
  --gold:       #c9a24f;
  --green:      #86ac74;
  --shadow:     0 2px 10px rgba(0, 0, 0, .5);
  --shadow-lg:  0 -6px 28px rgba(0, 0, 0, .6);
}

html[data-mode='sun'] {
  --ink:        #000000;
  --ink-soft:   #1c1c1c;
  --ink-faint:  #333333;
  --paper:      #ffffff;
  --paper-2:    #ffffff;
  --paper-3:    #f0f0f0;
  --line:       #000000;
  --terra:      #9c1f00;
  --terra-deep: #7a1800;
  --terra-soft: #ffe9e0;
  --gold:       #6b4a00;
  --green:      #14481f;
  --shadow:     0 2px 0 rgba(0, 0, 0, .9);
  --shadow-lg:  0 -3px 0 rgba(0, 0, 0, .9);
  --radius:     10px;
  --fs-body:    19.5px;
  --fs-lede:    21px;
  --lh-body:    1.55;
  --w-body:     560;
  --w-strong:   800;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* .sheet sets display:flex, which would otherwise beat the UA [hidden] rule. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  /* dvh tracks Safari's collapsing toolbar; the 100% above is the fallback. */
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font: var(--w-body) var(--fs-body)/var(--lh-body)
        ui-serif, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .ui { font-family: ui-sans-serif, -apple-system, 'Helvetica Neue', Arial, sans-serif; }

/* ─────────────────────────── header ─────────────────────────── */

.bar {
  flex: 0 0 auto;
  padding: calc(var(--safe-t) + 9px) 12px 9px;
  min-height: var(--bar-h);
  background: var(--terra-deep);
  color: #fff5ea;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 900;
  box-shadow: var(--shadow);
}
html[data-mode='sun'] .bar { background: #000; color: #fff; }

.bar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: .01em;
  line-height: 1.15;
}
.bar-sub {
  margin: 2px 0 0;
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  opacity: .82;
  letter-spacing: .02em;
}
html[data-mode='sun'] .bar-sub { opacity: 1; }
.bar-main { flex: 1 1 auto; min-width: 0; }

.icon-btn {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border: 2px solid rgba(255, 245, 234, .45);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
html[data-mode='sun'] .icon-btn { border-color: #fff; }
.icon-btn:active { background: rgba(255, 255, 255, .18); }

/* ───────────────────── practical card ───────────────────── */

.practical-toggle {
  flex: 0 0 auto;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--terra-soft);
  color: var(--terra-deep);
  font: var(--w-strong) 15.5px/1.3 ui-sans-serif, -apple-system, sans-serif;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  z-index: 880;
}
html[data-mode='sun'] .practical-toggle { border-bottom-width: 3px; }
.pt-left { display: flex; align-items: center; gap: 9px; }
.pt-glyph {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: grid;
  place-items: center;
}
.pt-chev { font-size: 15px; transition: transform .18s ease; }
.practical-toggle[aria-expanded='true'] .pt-chev { transform: rotate(180deg); }

.practical {
  flex: 0 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper-2);
  border-bottom: 2px solid var(--line);
  max-height: 62dvh;
  z-index: 870;
}
.practical-inner { padding: 12px 12px 18px; display: grid; gap: 11px; }

.pcard {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
  padding: 13px 15px;
}
html[data-mode='sun'] .pcard { border-width: 2px; border-left-width: 7px; }
.pcard-key { border-left-color: var(--terra); background: var(--terra-soft); }
.pcard-note { border-left-color: var(--green); }

.pcard h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--terra-deep);
}
html[data-mode='sun'] .pcard h2 { color: #000; }
.pcard ul { margin: 0; padding-left: 20px; }
.pcard li { margin: 0 0 7px; }
.pcard li:last-child { margin-bottom: 0; }
.pcard p { margin: 0 0 8px; }
.pcard p:last-child { margin-bottom: 0; }
.pcard b { font-weight: var(--w-strong); }

/* ─────────────────────────── map ─────────────────────────── */

#map {
  flex: 1 1 auto;
  min-height: 180px;
  background: var(--paper-3);
  z-index: 1;
}

/* Sun mode: drop saturation and darken slightly. Brightening blows the pale
 * parchment palette out to flat white — a darker map is what actually reads in
 * glare, because the UI chrome and pins then have something to sit against. */
html[data-mode='sun'] .leaflet-tile { filter: saturate(.35) contrast(1.18) brightness(.9); }
/* Inverting the warm parchment straight goes muddy olive; desaturating most of
 * the way first leaves a neutral charcoal the pins sit cleanly on top of. */
html[data-mode='dark'] .leaflet-tile { filter: invert(1) grayscale(.72) brightness(.78) contrast(1.12); }

.leaflet-container {
  background: var(--paper-3);
  font-family: ui-sans-serif, -apple-system, sans-serif;
}
/* Sit the credit just above the floating buttons rather than under them. */
.leaflet-bottom.leaflet-right { bottom: calc(var(--safe-b) + 80px); }
.leaflet-control-attribution {
  font-size: 10.5px;
  white-space: nowrap;
  border-radius: 5px 0 0 5px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, .85) !important;
  color: #4a4a4a !important;
}
.leaflet-control-attribution a { color: #4a4a4a !important; }
html[data-mode='sun'] .leaflet-control-attribution {
  background: #fff !important;
  color: #000 !important;
  border: 1px solid #000;
}
html[data-mode='dark'] .leaflet-control-attribution {
  background: rgba(25, 20, 18, .85) !important;
  color: #b5a595 !important;
}
html[data-mode='dark'] .leaflet-control-attribution a { color: #b5a595 !important; }
.leaflet-bar a {
  width: 44px !important; height: 44px !important;
  line-height: 44px !important;
  font-size: 21px !important;
  color: var(--ink) !important;
  background: var(--paper) !important;
}
html[data-mode='sun'] .leaflet-bar a { border: 2px solid #000 !important; font-weight: 800; }

/* numbered pins */
.pin {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  border: 3px solid var(--paper);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  display: grid;
  place-items: center;
  font: 800 18px/1 ui-sans-serif, -apple-system, sans-serif;
  transition: transform .12s ease;
}
.pin.palatine { background: var(--gold); }
.pin.done { background: var(--green); }
.pin.done::after { content: '✓'; position: absolute; font-size: 19px; }
.pin.done .pin-n { visibility: hidden; }
.pin.active { transform: scale(1.28); box-shadow: 0 0 0 5px rgba(168, 69, 42, .38), 0 3px 8px rgba(0, 0, 0, .45); }

/* Badge standing in for a run of stops too close together to tap separately. */
.pin.cluster {
  width: 58px;
  border-radius: 22px;
  font-size: 15.5px;
  letter-spacing: .01em;
  background: var(--terra-deep);
  border-style: dashed;
}
html[data-mode='sun'] .pin.cluster { background: #000; border-style: solid; }
html[data-mode='sun'] .pin { border-color: #fff; border-width: 4px; box-shadow: 0 0 0 2px #000; font-size: 19px; }

.endpin {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--terra-deep);
  display: grid;
  place-items: center;
  font-size: 17px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
html[data-mode='sun'] .endpin { border-color: #000; }

.mepin {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #1470d6;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(20, 112, 214, .55), 0 2px 6px rgba(0, 0, 0, .4);
}

/* ───────────────────── floating controls ───────────────────── */

.map-controls {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(var(--safe-b) + 12px);
  display: flex;
  gap: 10px;
  z-index: 800;
  pointer-events: none;
}
.fab {
  pointer-events: auto;
  flex: 1 1 0;
  min-height: 62px;
  border: 2px solid var(--terra-deep);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font: var(--w-strong) 16px/1.2 ui-sans-serif, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  padding: 8px 10px;
}
html[data-mode='sun'] .fab { border-color: #000; border-width: 3px; }
.fab:active { background: var(--paper-3); transform: translateY(1px); }
.fab-glyph { font-size: 22px; line-height: 1; }
.fab-locate .fab-glyph { color: #1470d6; }
.fab.tracking { background: var(--terra); color: #fff; border-color: var(--terra-deep); }
.fab.tracking .fab-glyph { color: #fff; }
.fab-label b { font-weight: 800; }

/* ───────────────────────── sheets ───────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 12, .5);
  z-index: 950;
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 960;
  background: var(--paper);
  border-top: 3px solid var(--terra-deep);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
  animation: rise .22s cubic-bezier(.2, .8, .3, 1);
}
html[data-mode='sun'] .sheet { border-top-color: #000; border-top-width: 4px; }
@keyframes rise { from { transform: translateY(14%); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.listview { top: 0; border-radius: 0; max-height: 100dvh; padding-top: var(--safe-t); }

.sheet-grab {
  width: 44px; height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 9px auto 0;
  flex: 0 0 auto;
}

.sheet-head {
  flex: 0 0 auto;
  padding: 13px 14px 11px;
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.sheet-head h2 { margin: 0; font-size: 21px; font-weight: 780; line-height: 1.2; }

.stop-title { flex: 1 1 auto; display: flex; gap: 11px; align-items: flex-start; min-width: 0; }
.stop-num {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  display: grid;
  place-items: center;
  font: 800 20px/1 ui-sans-serif, -apple-system, sans-serif;
}
.stop-num.palatine { background: var(--gold); }
.stop-it {
  margin: 3px 0 0;
  font-style: italic;
  font-size: 15.5px;
  color: var(--ink-soft);
}

.close-btn {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}
html[data-mode='sun'] .close-btn { border-color: #000; }

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  overscroll-behavior: contain;
}

.sheet-foot {
  flex: 0 0 auto;
  padding: 11px 12px calc(var(--safe-b) + 12px);
  border-top: 2px solid var(--line);
  background: var(--paper-2);
  display: flex;
  gap: 9px;
  align-items: center;
}

/* ─────────────────── stop detail contents ─────────────────── */

.dates {
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 12px;
}
html[data-mode='sun'] .dates { color: #000; }

.looking {
  margin: 0 0 15px;
  padding: 12px 14px;
  background: var(--paper-2);
  border-left: 5px solid var(--terra);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--fs-lede);
  line-height: 1.5;
}
.looking-label {
  display: block;
  font: 800 12px/1 ui-sans-serif, -apple-system, sans-serif;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--terra-deep);
  margin-bottom: 6px;
}
html[data-mode='sun'] .looking-label { color: #000; }

.myth {
  margin: 0 0 15px;
  padding: 13px 15px;
  background: var(--terra-soft);
  border: 2px solid var(--terra);
  border-radius: var(--radius);
}
.myth h3 {
  margin: 0 0 7px;
  font-size: 16px;
  font-weight: 800;
  color: var(--terra-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}
html[data-mode='sun'] .myth h3 { color: #000; }
.myth h3::before {
  content: '✕';
  width: 22px; height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  font-size: 13px;
  display: grid;
  place-items: center;
}
.myth p { margin: 0; }

.access {
  margin: 0 0 15px;
  padding: 11px 14px;
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  font-size: 15.5px;
  color: var(--ink-soft);
}
html[data-mode='sun'] .access { color: #000; border-color: #000; }

/* ── stop photographs ── */

.shot {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
}
html[data-mode='sun'] .shot { border-width: 2px; border-color: #000; }

.shot img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: var(--paper-3);
}
html[data-mode='sun'] .shot img { filter: contrast(1.08) saturate(.9); }
html[data-mode='dark'] .shot img { filter: brightness(.86); }

.shot figcaption {
  padding: 10px 13px 11px;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}
html[data-mode='sun'] .shot figcaption { color: #000; border-top-color: #000; }

.shot .credit {
  display: block;
  margin-top: 6px;
  font: 500 11.5px/1.35 ui-sans-serif, -apple-system, sans-serif;
  color: var(--ink-faint);
  letter-spacing: .01em;
}
html[data-mode='sun'] .shot .credit { color: #333; font-weight: 600; }

.history p { margin: 0 0 13px; }
.history p:last-child { margin-bottom: 0; }

.nextleg {
  margin: 18px 0 0;
  padding: 13px 15px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
html[data-mode='sun'] .nextleg { border-width: 2px; }
.nextleg.climb { border-left: 5px solid var(--terra); }
.nextleg.last  { border-left: 5px solid var(--green); }
.nextleg h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--terra-deep);
}
html[data-mode='sun'] .nextleg h3 { color: #000; }
.nextleg p { margin: 0; }
.walktime {
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-weight: 800;
  font-size: 24px;
  color: var(--terra);
  display: block;
  margin-bottom: 4px;
}
html[data-mode='sun'] .walktime { color: #000; }

.shade-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 13px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font: 800 13.5px/1 ui-sans-serif, -apple-system, sans-serif;
  letter-spacing: .03em;
}

/* footer buttons */
.nav-btn {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
html[data-mode='sun'] .nav-btn { border-color: #000; }
.nav-btn:disabled { opacity: .3; }

.check-btn {
  flex: 1 1 auto;
  min-height: 56px;
  border: 2px solid var(--terra-deep);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: var(--w-strong) 16.5px/1.2 ui-sans-serif, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}
html[data-mode='sun'] .check-btn { border-color: #000; border-width: 3px; }
.cb-box {
  width: 24px; height: 24px;
  border: 2.5px solid currentColor;
  border-radius: 6px;
  flex: 0 0 auto;
}
.check-btn.on { background: var(--green); color: #fff; border-color: var(--green); }
.check-btn.on .cb-box { background: #fff; color: var(--green); position: relative; }
.check-btn.on .cb-box::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
  color: var(--green);
}

.ghost-btn {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  font: 700 15px ui-sans-serif, -apple-system, sans-serif;
  cursor: pointer;
}
html[data-mode='sun'] .ghost-btn { color: #000; border-color: #000; }

/* ───────────────────────── list view ───────────────────────── */

.listrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  margin-bottom: 9px;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-body);
}
html[data-mode='sun'] .listrow { border-width: 2px; }
.listrow.done { background: var(--paper-2); }
.listrow.done .lr-name { text-decoration: line-through; color: var(--ink-faint); }
html[data-mode='sun'] .listrow.done .lr-name { color: #333; }

.lr-num {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  display: grid;
  place-items: center;
  font: 800 17px/1 ui-sans-serif, -apple-system, sans-serif;
}
.lr-num.palatine { background: var(--gold); }
.lr-num.done { background: var(--green); }
.lr-text { flex: 1 1 auto; min-width: 0; }
.lr-name { font-weight: var(--w-strong); line-height: 1.28; }
.lr-it { font-size: 14px; font-style: italic; color: var(--ink-soft); margin-top: 2px; }
html[data-mode='sun'] .lr-it { color: #333; }
.lr-check {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
  display: grid;
  place-items: center;
  font-size: 21px;
  color: transparent;
  cursor: pointer;
}
html[data-mode='sun'] .lr-check { border-color: #000; }
.lr-check.on { background: var(--green); border-color: var(--green); color: #fff; }

.list-sep {
  margin: 18px 0 10px;
  font: 800 12.5px/1 ui-sans-serif, -apple-system, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 2px solid var(--line);
  padding-bottom: 7px;
}
html[data-mode='sun'] .list-sep { color: #000; }
.list-sep:first-child { margin-top: 0; }

/* ───────────────────────── toast ───────────────────────── */

.toast {
  position: fixed;
  left: 14px; right: 14px;
  bottom: calc(var(--safe-b) + 86px);
  z-index: 940;
  padding: 13px 16px;
  background: var(--terra-deep);
  color: #fff5ea;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font: 650 15.5px/1.4 ui-sans-serif, -apple-system, sans-serif;
  text-align: center;
}
html[data-mode='sun'] .toast { background: #000; color: #fff; border: 2px solid #fff; }

/* ─────────────── phone in landscape ───────────────
 * Rotating a phone leaves ~390px of height. Everything vertical shrinks so the
 * map keeps a usable share, and the notch insets move in from the side. */
@media (orientation: landscape) and (max-height: 520px) {
  .bar { padding: calc(var(--safe-t) + 5px) calc(12px + var(--safe-r)) 5px calc(12px + var(--safe-l)); min-height: 0; }
  .bar h1 { font-size: 17px; }
  .bar-sub { font-size: 11px; }
  .icon-btn { width: 42px; height: 42px; font-size: 19px; }

  .practical-toggle { min-height: 42px; padding: 8px calc(14px + var(--safe-r)) 8px calc(14px + var(--safe-l)); font-size: 14px; }
  .practical { max-height: 56dvh; }
  .practical-inner { padding-left: calc(12px + var(--safe-l)); padding-right: calc(12px + var(--safe-r)); }

  .map-controls { bottom: calc(var(--safe-b) + 8px); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); }
  .fab { min-height: 50px; font-size: 15px; }

  .sheet { max-height: 97dvh; }
  .sheet-grab { margin-top: 5px; }
  .sheet-head { padding: 9px calc(14px + var(--safe-r)) 8px calc(14px + var(--safe-l)); }
  .sheet-head h2 { font-size: 19px; }
  .sheet-body { padding: 11px calc(14px + var(--safe-r)) 11px calc(14px + var(--safe-l)); }
  .sheet-foot { padding: 8px calc(12px + var(--safe-r)) calc(var(--safe-b) + 8px) calc(12px + var(--safe-l)); }
  .nav-btn { width: 52px; height: 50px; }
  .check-btn { min-height: 50px; }
  .stop-num { width: 36px; height: 36px; font-size: 18px; }
  /* In landscape there is only ~250px of panel body. Cap the photo so the text
   * under it is visible without scrolling first. */
  .shot img { aspect-ratio: 21 / 9; max-height: 32dvh; }
  .shot figcaption { padding: 8px 12px 9px; font-size: 14.5px; }
}

/* wider screens: keep it a phone-shaped column */
@media (min-width: 720px) {
  .sheet { left: 50%; transform: translateX(-50%); width: min(600px, 100%); }
  @keyframes rise { from { transform: translateX(-50%) translateY(14%); opacity: .4; } to { transform: translateX(-50%); opacity: 1; } }
  .map-controls { left: 50%; transform: translateX(-50%); width: min(600px, calc(100% - 20px)); right: auto; }
  .toast { left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); right: auto; }
}
