/* Parked — warm white, graphite, one accent. */

:root {
  color-scheme: light dark;

  --bg: #f6f3ec;
  --surface: #fffdf8;
  --sunken: #ece8df;
  --ink: #1e2124;
  --ink-2: #565b62;
  --line: rgba(30, 33, 36, 0.14);
  --accent: #c8401c;
  --accent-deep: #a93313;
  --accent-ink: #ffffff;
  --accent-wash: rgba(200, 64, 28, 0.14);
  --chip-ink: #a93313;
  --solid: #1e2124;
  --solid-ink: #f6f3ec;
  --shadow: 0 1px 2px rgba(30, 33, 36, 0.06), 0 12px 32px rgba(30, 33, 36, 0.1);

  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;

  --gutter: 24px;
  --radius: 18px;
  --tap: 52px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191b;
    --surface: #212427;
    --sunken: #101213;
    --ink: #f3efe7;
    --ink-2: #a9a69f;
    --line: rgba(243, 239, 231, 0.16);
    --accent: #ff7a4d;
    --accent-deep: #e9602f;
    --accent-ink: #1b0e08;
    --accent-wash: rgba(255, 122, 77, 0.18);
    --chip-ink: #ffb59a;
    --solid: #f3efe7;
    --solid-ink: #17191b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.4);
  }
}

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

html {
  /* Follows the iOS Dynamic Type setting; everything below is sized in rem. */
  font: -apple-system-body;
  font-family: var(--font-text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
  /* The page itself never scrolls or bounces. */
  overflow: hidden;
  overscroll-behavior: none;
}

@supports not (font: -apple-system-body) {
  html {
    font-size: 17px;
    line-height: 1.4;
  }
}

body {
  /* Pinned to the screen: there is nothing to scroll and nothing to rubber-band. */
  position: fixed;
  inset: 0;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* No page panning, no pinch zoom, no double-tap zoom. Sheets and maps opt back in to what they need. */
  touch-action: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

h1,
h2,
p,
dl,
dd,
ul,
ol {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ views */

.view {
  /* Exactly the height of the screen. Contents flex to fit instead of overflowing. */
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + var(--gutter))
    calc(env(safe-area-inset-bottom) + 20px) calc(env(safe-area-inset-left) + var(--gutter));
  max-width: 560px;
  margin: 0 auto;
  /*
   * Last resort only: at the very largest accessibility text sizes the content can be taller than
   * the screen, and a button must never become unreachable. When everything fits (the normal case)
   * this element has nothing to scroll and does not move.
   */
  overflow: hidden auto;
  overscroll-behavior: none;
  touch-action: pan-y;
  scrollbar-width: none;
}

.view::-webkit-scrollbar {
  display: none;
}

.view:not([hidden]) {
  animation: view-in 0.32s var(--ease);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.masthead {
  flex: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* EN / DE switch. */
.language {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--sunken);
}

.language button {
  min-width: 44px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.18s, color 0.18s;
}

.language button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}

.language button:disabled {
  opacity: 0.45;
  cursor: default;
}

.wordmark {
  font-family: var(--font-round);
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.wordmark::before {
  content: "";
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin-right: 0.5em;
  border-radius: 50%;
  background: var(--accent);
}

/* ------------------------------------------------------------------- home */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3.2dvh, 28px);
  padding-top: clamp(10px, 6dvh, 72px);
}

/* Push the main control into the lower, thumb-reachable part of the screen. */
.stage > .orb {
  margin-top: auto;
  margin-bottom: clamp(14px, 7dvh, 88px);
}

/* Where buttons follow the orb, they supply the spacing instead. */
#home-saved > .orb,
#home-saving > .orb {
  margin-bottom: 4px;
}

.stage-text {
  align-items: stretch;
}

.stage-text > .stack {
  margin-top: auto;
}

.lede {
  align-self: stretch;
}

.lede h2 {
  font-family: var(--font-round);
  font-size: 2.1rem;
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lede h2:focus {
  outline: none;
}

.lede p {
  margin-top: 10px;
  font-size: 1.06rem;
  color: var(--ink-2);
  text-wrap: pretty;
}

.fineprint {
  font-size: 0.82rem;
  line-height: 1.38;
  color: var(--ink-2);
  text-align: center;
  text-wrap: pretty;
}

.steps {
  margin: 16px 0 0 1.3em;
  color: var(--ink);
  display: grid;
  gap: 8px;
}

/* The one big control. */
.orb {
  --size: min(62vw, 34dvh, 248px);
  position: relative;
  /* Shrinks before anything is pushed off the screen; the width follows through the aspect ratio. */
  flex: 0 1 auto;
  height: var(--size);
  width: auto;
  aspect-ratio: 1;
  min-height: 124px;
  /* Lets the label size itself from the button, so it still fits when the button is small. */
  container-type: inline-size;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 18px 40px -14px var(--accent);
  transition: transform 0.18s var(--ease), background-color 0.18s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* A hairline halo: the "subtle compass treatment" carried onto the home screen. */
.orb::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  pointer-events: none;
}

button.orb:active {
  transform: scale(0.96);
  background: var(--accent-deep);
}

.orb-label {
  font-family: var(--font-round);
  font-size: min(2.1rem, 16cqi);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  padding: 0 14px;
  text-align: center;
}

.orb-label-medium {
  font-size: min(1.5rem, 12.5cqi);
}

.orb-label-small {
  font-size: min(1.25rem, 11cqi);
  font-variant-numeric: tabular-nums;
}

.orb-glyph {
  width: min(44px, 20cqi);
  height: min(44px, 20cqi);
  fill: currentColor;
}

.orb-busy {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: default;
}

.orb-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.orb-ring circle {
  fill: none;
  stroke-width: 5;
}

.orb-ring-track {
  stroke: var(--line);
}

.orb-ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.orb-check {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 46%;
  height: 46%;
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  opacity: 0;
}

.orb-busy.is-done {
  background: var(--accent);
  animation: orb-pop 0.5s var(--ease);
}

.orb-busy.is-done .orb-label,
.orb-busy.is-done .orb-ring {
  opacity: 0;
}

.orb-busy.is-done .orb-check {
  opacity: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.36s 0.08s ease-out;
}

@keyframes orb-pop {
  0% {
    transform: scale(0.94);
  }
  55% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s var(--ease), opacity 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.button:active {
  transform: scale(0.98);
  opacity: 0.82;
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

.button-primary {
  background: var(--solid);
  color: var(--solid-ink);
}

.button-secondary {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.button-quiet {
  color: var(--ink-2);
}

.button-small {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.94rem;
  border-radius: 14px;
}

.button-chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.94rem;
  color: var(--chip-ink);
  background: var(--accent-wash);
  align-self: flex-start;
}

.button-bar {
  min-height: 44px;
  padding: 8px 4px;
  gap: 2px;
  font-weight: 500;
  color: var(--ink);
}

.button-bar svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-strong {
  font-weight: 700;
  color: var(--accent);
}

.stack {
  display: grid;
  gap: 10px;
}

.stack-tight {
  gap: 4px;
  justify-items: start;
}

.row {
  align-self: stretch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row .button {
  padding-inline: 8px;
}

/* -------------------------------------------------------------- spot card */

.spot {
  align-self: stretch;
  text-align: left;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}

.spot-photo {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--sunken);
  cursor: pointer;
}

.spot-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.spot-facts {
  flex: 1 1 160px;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.spot-facts div {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.spot-facts dt {
  flex: none;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  min-width: 3.4em;
}

.spot-facts dd {
  font-size: 1.12rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.spot-compact {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------- guidance */

.guide {
  padding-top: calc(env(safe-area-inset-top) + 4px);
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  margin: 0 -6px;
}

.guide-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.6dvh, 14px);
  padding: 4px 0 12px;
}

/*
 * The dial takes whatever height is left once the text and buttons have what they need, so extra
 * advice makes the dial smaller instead of making the page longer. The auto margins centre the
 * dial and readout together when there is room to spare, and can never push anything off screen.
 */
.dial {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  max-height: min(340px, 80vw);
  aspect-ratio: 1;
  width: auto;
  max-width: 100%;
  margin-top: auto;
}

/* Too little room to draw a readable dial (set by ui/guide.ts): leave the space empty instead. */
.dial[data-tiny] {
  visibility: hidden;
}

.dial svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.dial-top {
  fill: var(--ink-2);
}

.dial-circle {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
}

.dial-tick {
  stroke: var(--ink-2);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.45;
}

.dial-tick-major {
  stroke: var(--ink);
  stroke-width: 2;
  opacity: 0.8;
}

.dial-north {
  font-family: var(--font-round);
  font-size: 17px;
  font-weight: 700;
  fill: var(--ink-2);
}

.dial-arrow-a {
  fill: var(--accent);
}

.dial-arrow-b {
  fill: var(--accent-deep);
}

.dial-arrow-a,
.dial-arrow-b {
  stroke-linejoin: round;
  stroke-width: 6;
}

.dial-arrow-a {
  stroke: var(--accent);
}

.dial-arrow-b {
  stroke: var(--accent-deep);
}

.dial-spread {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.38;
}

.dial-near-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.55;
}

.dial-near-ring-2 {
  opacity: 0.25;
}

.dial-near-dot {
  fill: var(--accent);
}

.dial-off-ring {
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 2;
  stroke-dasharray: 3 9;
  stroke-linecap: round;
  opacity: 0.7;
}

/* Which layers show in which mode. */
.dial-arrow,
.dial-near,
.dial-off,
.dial-north,
#dial-ticks {
  transition: opacity 0.25s;
}

.dial:not([data-mode="arrow"]) .dial-arrow,
.dial:not([data-mode="near"]) .dial-near,
.dial[data-mode="arrow"] .dial-off,
.dial[data-mode="near"] .dial-off {
  opacity: 0;
}

.dial:not([data-north]) .dial-north {
  opacity: 0;
}

.dial:not([data-north]) #dial-ticks {
  opacity: 0.5;
}

/* A wide uncertainty arc is shown as an outline arrow: visibly a rough direction. */
.dial[data-rough] .dial-arrow-a,
.dial[data-rough] .dial-arrow-b {
  fill: transparent;
  stroke: var(--accent);
  stroke-width: 3;
}

.dial-caption {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 24%;
  text-align: center;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink-2);
  text-wrap: balance;
  pointer-events: none;
}

.dial[data-mode="arrow"] .dial-caption,
.dial[data-mode="near"] .dial-caption {
  display: none;
}

.dial-sim {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.readout {
  flex: none;
  margin-bottom: auto;
  align-self: stretch;
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.distance {
  font-family: var(--font-round);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.12em;
  min-height: 3.6rem;
}

.distance-value {
  font-size: 3.6rem;
}

.distance-unit {
  font-size: 1.5rem;
  color: var(--ink-2);
  letter-spacing: 0;
}

.distance.is-phrase .distance-value {
  font-size: 1.8rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

.distance.is-stale .distance-value {
  color: var(--ink-2);
}

.distance-caption {
  font-size: 0.98rem;
  color: var(--ink-2);
  min-height: 1.4em;
  text-wrap: pretty;
}

.signals {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-top: 4px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-2);
}

.signals li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.meter {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.meter i {
  width: 4px;
  border-radius: 1px;
  background: var(--line);
}

.meter i:nth-child(1) {
  height: 5px;
}

.meter i:nth-child(2) {
  height: 8.5px;
}

.meter i:nth-child(3) {
  height: 12px;
}

[data-level="1"] .meter i:nth-child(-n + 1),
[data-level="2"] .meter i:nth-child(-n + 2),
[data-level="3"] .meter i:nth-child(-n + 3) {
  background: var(--ink);
}

[data-level="1"] .meter i:nth-child(1) {
  background: var(--accent);
}

.advice {
  align-self: stretch;
  margin-top: 6px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--sunken);
  display: grid;
  gap: 10px;
  justify-items: center;
  font-size: 0.94rem;
  text-wrap: pretty;
}

.guide-actions {
  flex: none;
  display: grid;
  gap: 10px;
}

.guide-actions .fineprint {
  margin-bottom: 4px;
}

/* Keeps the long Apple Maps label on one line at the default text size. */
.guide-actions .button {
  font-size: 0.96rem;
  padding-inline: 12px;
}

/* Short screens (a Safari tab with its toolbars showing): tighten up so the dial keeps its room. */
@media (max-height: 700px) {
  .spot-compact {
    margin-top: 0;
    padding-top: 10px;
  }

  .spot-compact .spot-photo {
    width: 48px;
    height: 48px;
    border-radius: 11px;
  }

  .spot-compact dd {
    font-size: 1rem;
  }

  .advice {
    margin-top: 2px;
    padding: 10px 14px;
    gap: 8px;
  }

  .distance {
    min-height: 3rem;
  }

  .distance-value {
    font-size: 3rem;
  }

  .guide-actions {
    gap: 8px;
  }

  .guide-actions .button {
    min-height: 46px;
    padding-block: 8px;
  }
}

/* Landscape phone: dial on the left, everything else on the right. */
@media (orientation: landscape) and (max-height: 520px) {
  .guide {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    column-gap: 24px;
  }

  .guide .bar {
    grid-column: 1 / -1;
  }

  .guide-body {
    display: contents;
  }

  .dial {
    grid-column: 1;
    grid-row: 2 / 4;
    width: min(42vw, 66dvh);
    height: auto;
    max-height: none;
    margin: 0;
    align-self: center;
    justify-self: center;
  }

  .readout {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    align-self: center;
  }

  .guide-actions {
    grid-column: 2;
    grid-row: 3;
    grid-template-columns: 1fr 1fr;
  }

  .guide-actions .fineprint {
    grid-column: 1 / -1;
  }

  /* Advice sits beside its button, and the note makes way for it, so the buttons stay on screen. */
  .advice {
    grid-template-columns: 1fr auto;
    align-items: center;
    justify-items: start;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.86rem;
  }

  .distance {
    min-height: 2.6rem;
  }

  .distance-value {
    font-size: 2.6rem;
  }

  .advice:not([hidden]) ~ .spot-compact {
    display: none;
  }

  .view {
    padding-top: calc(env(safe-area-inset-top) + 4px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
  }

  .home {
    max-width: none;
  }

  .stage {
    padding-top: 2px;
    gap: 8px;
  }

  .lede h2 {
    font-size: 1.5rem;
  }

  .lede p {
    margin-top: 2px;
    font-size: 0.94rem;
  }

  .spot-photo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }

  .orb {
    --size: min(40dvh, 200px);
    min-height: 84px;
  }

  .stage > .orb {
    margin-bottom: 4px;
  }

  .row .button {
    min-height: 44px;
    padding-block: 6px;
  }
}

/* ----------------------------------------------------------------- sheets */

dialog.sheet {
  width: 100%;
  max-width: 560px;
  /* --viewport-height and --keyboard-inset are set by ui/viewport.ts while the keyboard is up. */
  max-height: calc(var(--viewport-height, 100dvh) - env(safe-area-inset-top) - 16px);
  margin: auto auto var(--keyboard-inset, 0px);
  padding: 10px calc(env(safe-area-inset-right) + var(--gutter)) calc(env(safe-area-inset-bottom) + 22px)
    calc(env(safe-area-inset-left) + var(--gutter));
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* A sheet may scroll its own content vertically; it still cannot be zoomed. */
  touch-action: pan-y;
}

dialog.sheet[open] {
  animation: sheet-in 0.34s var(--ease);
}

dialog.sheet::backdrop {
  background: rgba(16, 18, 19, 0.42);
  animation: fade-in 0.25s ease-out;
}

/* The grabber: a familiar hint that this is a sheet. */
dialog.sheet::before {
  content: "";
  display: block;
  width: 38px;
  height: 5px;
  margin: 0 auto 6px;
  border-radius: 3px;
  background: var(--line);
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.sheet form {
  display: grid;
  gap: 16px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.sheet h2 {
  font-family: var(--font-round);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sheet-note {
  color: var(--ink-2);
  font-size: 0.94rem;
  text-wrap: pretty;
}

.sheet-error {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.94rem;
}

.sheet-confirm h2 {
  font-size: 1.5rem;
  margin-top: 8px;
}

.sheet-confirm p {
  color: var(--ink-2);
  text-wrap: pretty;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.field input[type="text"] {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sunken);
  color: var(--ink);
  font: inherit;
  /* 16px minimum stops iOS zooming the page when the field is focused. */
  font-size: max(1.06rem, 16px);
  box-shadow: inset 0 0 0 1.5px transparent;
}

.field input[type="text"]:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.field input::placeholder {
  color: var(--ink-2);
  opacity: 0.7;
}

.photo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.photo-row img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--sunken);
}

dialog.sheet-map[open] {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(var(--viewport-height, 100dvh) - env(safe-area-inset-top) - 16px);
}

.map-frame {
  position: relative;
  flex: 1;
  min-height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sunken);
}

.map {
  position: absolute;
  inset: 0;
}

.map-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 52px;
  /* The tip of the pin, not its centre, marks the spot. */
  transform: translate(-50%, -96%);
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
  pointer-events: none;
  z-index: 500;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
}

.map-crosshair circle {
  fill: #fff;
  stroke: none;
}

.map-car,
.map-me {
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.map-car {
  background: #c8401c;
}

.map-me {
  background: #1e2124;
}

dialog.sheet-photo[open] {
  display: grid;
  gap: 14px;
}

.sheet-photo img {
  width: 100%;
  max-height: 68dvh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--sunken);
}

.sheet-photo form {
  display: grid;
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 10px);
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(92vw, 480px);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--solid);
  color: var(--solid-ink);
  font-size: 0.94rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
}

/* ------------------------------------------------------------- simulation */

.sim {
  flex: none;
  max-height: 46dvh;
  overflow-y: auto;
  touch-action: pan-y;
  z-index: 900;
  font-size: 13px;
  line-height: 1.3;
  color: #1b1300;
  background: #ffd23f;
  background-image: repeating-linear-gradient(135deg, transparent 0 14px, rgba(0, 0, 0, 0.08) 14px 28px);
  padding: calc(env(safe-area-inset-top) + 6px) 12px 8px;
}

.sim strong {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sim details {
  margin-top: 4px;
}

.sim summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 28px;
}

.sim-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 6px 0 2px;
  max-width: 520px;
}

.sim-grid input[type="range"] {
  width: 100%;
}

.sim-grid output {
  font-variant-numeric: tabular-nums;
  min-width: 4.5em;
  text-align: right;
}

.sim-toggles {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

/* ---------------------------------------------------------- reduce motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  ::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
