/* ============================================================
   Wayfarer — quiet, map-less walking interface
   No gradients. No large radii. Mobile first.
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #f3f1eb;
  --page-bg: #e9e6de;
  --surface: #fbfaf6;
  --surface-2: #e9e6dd;
  --ink: #191c19;
  --ink-soft: #3f443e;
  --muted: #737a71;
  --line: #d5d2c8;
  --line-strong: #a8a59b;
  --accent: #2e6d51;
  --danger: #8c3e31;
  --trail-remaining: #2f7c59;
  --trail-traveled: #b6b9b2;
  --overlay: rgba(22, 25, 21, 0.42);
  --toast-bg: #191c19;
  --toast-ink: #f3f1eb;
  --font-sans: "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "Consolas", "Liberation Mono",
    monospace;
  --app-width: 442px;
  --pad: 22px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111311;
  --page-bg: #0a0b0a;
  --surface: #191c19;
  --surface-2: #232720;
  --ink: #eceae3;
  --ink-soft: #c7c9c1;
  --muted: #858c82;
  --line: #2a2e2a;
  --line-strong: #4a5047;
  --accent: #79c59d;
  --danger: #d28e80;
  --trail-remaining: #6fc292;
  --trail-traveled: #575e57;
  --overlay: rgba(0, 0, 0, 0.58);
  --toast-bg: #eceae3;
  --toast-ink: #111311;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111311;
    --page-bg: #0a0b0a;
    --surface: #191c19;
    --surface-2: #232720;
    --ink: #eceae3;
    --ink-soft: #c7c9c1;
    --muted: #858c82;
    --line: #2a2e2a;
    --line-strong: #4a5047;
    --accent: #79c59d;
    --danger: #d28e80;
    --trail-remaining: #6fc292;
    --trail-traveled: #575e57;
    --overlay: rgba(0, 0, 0, 0.58);
    --toast-bg: #eceae3;
    --toast-ink: #111311;
  }
}

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

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  transition: background-color 0.24s ease, color 0.24s ease;
}

body.overlay-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------
   Shell
   ------------------------------------------------------------ */

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--app-width);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--pad)
    calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--bg);
  overflow-x: clip;
}

.app[data-ui="trip"],
.app[data-ui="arrived"] {
  height: 100vh;
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}

.app[data-ui="trip"] .topbar,
.app[data-ui="arrived"] .topbar {
  display: none;
}

.main {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: -10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.brand-word {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  line-height: 1;
}

.brand-mark {
  display: grid;
  width: 12px;
  height: 12px;
  place-items: center;
  opacity: 0.55;
}

.brand-mark svg {
  display: block;
  width: 12px;
  height: 12px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.icon-button:hover {
  background: var(--surface-2);
}

.icon-button:active {
  background: var(--line);
}

.icon-button svg {
  display: block;
}

.icon-button-small {
  width: 36px;
  height: 36px;
}

/* ------------------------------------------------------------
   Setup
   ------------------------------------------------------------ */

.screen {
  animation: screen-in 0.38s var(--ease-out) both;
}

.screen-setup {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding-top: clamp(12px, 3vh, 28px);
}

.hero {
  margin-bottom: clamp(20px, 3.4vh, 30px);
}

.kicker {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.24em;
  line-height: 1.4;
}

.display {
  margin: 0 0 16px;
  font-size: clamp(26px, 7.4vw, 34px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.lede {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  line-height: 1.8;
}

.field {
  margin-bottom: clamp(16px, 2.6vh, 22px);
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.field-head h2 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  line-height: 1.4;
}

.field-meta {
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.distance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.choice {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
  transition: border-color 0.18s ease, background-color 0.18s ease,
    color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.choice:hover {
  border-color: var(--line-strong);
}

.choice:active {
  background: var(--surface-2);
}

.choice[aria-checked="true"],
.choice[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.choice[aria-checked="true"]:active,
.choice[aria-pressed="true"]:active {
  background: var(--ink-soft);
}

.choice-type::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--line-strong);
  transform: translateY(-50%);
}

.choice-type[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--surface-2);
  color: var(--ink);
}

.choice-type[aria-pressed="true"]::after {
  border-color: var(--ink);
  background: var(--ink);
}

.choice-type[aria-pressed="true"] .choice-index {
  color: var(--ink);
  opacity: 1;
}

.choice-type[aria-pressed="true"]:active {
  background: var(--surface);
}

.choice-type {
  min-height: 46px;
  justify-content: flex-start;
  gap: 11px;
  padding: 0 13px;
  text-align: left;
}

.choice-index {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1;
}

.choice[aria-pressed="true"] .choice-index {
  color: var(--bg);
  opacity: 0.6;
}

.choice.choice-type[aria-pressed="true"] .choice-index {
  color: var(--ink);
  opacity: 1;
}

.choice-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paused-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.paused-copy {
  min-width: 0;
}

.paused-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1.4;
}

.paused-copy p {
  overflow: hidden;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paused-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
}

.setup-actions {
  display: grid;
  gap: 7px;
  margin-top: 2px;
}

.button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 0;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-align: center;
  transition: background-color 0.18s ease, border-color 0.18s ease,
    color 0.18s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.button:active {
  transform: translateY(1px);
}

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

.button-primary:hover {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
}

.button-quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.button-quiet:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.button-side {
  position: absolute;
  right: 16px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

#home-button {
  position: relative;
}

.button-compact {
  min-height: 42px;
  padding: 0 14px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.button-retry {
  margin-top: 2px;
}

.mode-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.mode-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent);
}

.text-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 4px 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
}

.text-button:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.text-button-inline {
  min-height: 28px;
  padding: 2px 0;
  font-size: 10.5px;
}

.text-button-danger {
  color: var(--danger);
  text-decoration-color: var(--danger);
}

.footnote {
  margin: auto 0 0;
  padding-top: 22px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  line-height: 1.9;
}

/* ------------------------------------------------------------
   Trip screen
   ------------------------------------------------------------ */

.screen-trip {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  animation: screen-in 0.34s var(--ease-out) both;
}

.trip-topbar {
  display: grid;
  flex-shrink: 0;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 48px;
  margin: 0 -10px;
}

.trip-topbar > :first-child {
  justify-self: start;
}

.trip-topbar > :last-child {
  justify-self: end;
}

.trip-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  line-height: 1;
}

.trip-status-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: status-pulse 2.8s ease-in-out infinite;
}

.trip-status-dot.is-weak {
  background: var(--danger);
  animation: none;
}

.trip-stage {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.trip-footer {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.trip-footer-item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Arrow mode */

.arrow-panel {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 2vh, 20px) 0 10px;
}

.arrow-field {
  display: grid;
  width: min(70vw, 282px);
  aspect-ratio: 1 / 1;
  margin-bottom: clamp(12px, 2.4vh, 24px);
  place-items: center;
  transition: transform 0.5s var(--ease-out);
}

.arrow-panel.is-aligned .arrow-field {
  transform: scale(1.035);
}

.arrow-rotor {
  width: 100%;
  height: 100%;
  will-change: transform;
}

.arrow-rotor svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.arrow-shaft,
.arrow-tip {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.4;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transition: stroke 0.32s ease;
}

.arrow-panel.is-aligned .arrow-shaft,
.arrow-panel.is-aligned .arrow-tip {
  stroke: var(--accent);
}

.readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.readout-value {
  font-size: clamp(42px, 13vw, 58px);
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1;
}

.readout-unit {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
}

.readout-label {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.2em;
  line-height: 1.4;
}

.trip-hint {
  min-height: 18px;
  margin: clamp(16px, 3vh, 26px) 0 0;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  line-height: 1.75;
  text-align: center;
}

/* Polyline mode */

.trail-panel {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  margin-inline: calc(var(--pad) * -1);
}

.trail-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.trail-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: center;
}

.trail-overlay-text {
  max-width: 260px;
  line-height: 1.7;
}

.trail-readout {
  position: absolute;
  bottom: 18px;
  left: 50%;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 10px;
  background: var(--bg);
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.trail-readout-value {
  font-size: 27px;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
}

.trail-readout-unit {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  line-height: 1;
}

.trail-readout-label {
  margin-left: 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.14em;
  line-height: 1.4;
}

/* ------------------------------------------------------------
   Loading
   ------------------------------------------------------------ */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: var(--bg);
  animation: fade-in 0.24s ease both;
}

.loading-panel {
  display: flex;
  max-width: 320px;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  text-align: center;
}

.loading-title {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.loading-detail {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
  line-height: 1.8;
}

.loading-panel .text-button {
  margin-top: 4px;
}

.loader-line {
  position: relative;
  display: block;
  width: 120px;
  height: 1px;
  overflow: hidden;
  background: var(--line);
}

.loader-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: translateX(-100%);
  animation: loader-sweep 1.3s var(--ease) infinite;
}

/* ------------------------------------------------------------
   Toast
   ------------------------------------------------------------ */

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%;
  z-index: 95;
  max-width: min(520px, calc(100vw - 36px));
  padding: 11px 15px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  line-height: 1.6;
  transform: translateX(-50%);
  animation: toast-in 0.28s var(--ease-out) both;
}

/* ------------------------------------------------------------
   Overlays, sheet, modals
   ------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  background: var(--overlay);
  animation: fade-in 0.22s ease both;
  backdrop-filter: blur(2px);
}

.overlay-sheet {
  align-items: flex-end;
  justify-content: center;
}

.overlay-modal {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sheet {
  display: flex;
  width: 100%;
  max-width: var(--app-width);
  max-height: min(88vh, 88svh);
  flex-direction: column;
  border-top: 1px solid var(--line-strong);
  background: var(--bg);
  animation: sheet-in 0.4s var(--ease-out) both;
}

.sheet:focus,
.modal:focus {
  outline: none;
}

.sheet-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.sheet-body {
  overflow-y: auto;
  padding: 0 22px calc(env(safe-area-inset-bottom, 0px) + 24px);
  overscroll-behavior: contain;
}

.sheet-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.sheet-section:last-child {
  border-bottom: 0;
}

.sheet-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.sheet-section-head h3 {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.sheet-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  line-height: 1.75;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.segment {
  display: flex;
  min-height: 74px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  transition: border-color 0.18s ease, background-color 0.18s ease,
    color 0.18s ease;
}

.segment:hover {
  border-color: var(--line-strong);
}

.segment[aria-checked="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.segment:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.segment-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.segment-desc {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.segment[aria-checked="true"] .segment-desc {
  color: var(--bg);
  opacity: 0.65;
}

.home-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.coord-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.coord-form .button {
  grid-column: 1 / -1;
}

.coord-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coord-field span {
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  line-height: 1.4;
}

.coord-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.01em;
  outline: none;
  appearance: textfield;
}

.coord-field input:focus {
  border-color: var(--ink);
}

.coord-field input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.history-list {
  display: flex;
  flex-direction: column;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.history-list li:first-child {
  border-top: 0;
}

.history-name {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
}

.history-meta {
  flex-shrink: 0;
  padding-top: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.01em;
  line-height: 1.6;
  text-align: right;
  white-space: pre-line;
}

.history-empty {
  padding: 4px 0 12px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  line-height: 1.7;
}

.sheet-section-meta {
  padding-bottom: 8px;
}

.meta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 6px;
}

.modal {
  width: min(100%, 400px);
  padding: 26px 24px 22px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  animation: modal-in 0.46s var(--ease-out) both;
}

.modal-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.26em;
  line-height: 1.4;
}

.arrival-name {
  margin: 9px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(26px, 7.4vw, 34px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
  animation: name-in 0.7s var(--ease-out) 0.08s both;
}

.arrival-rule {
  width: 38px;
  height: 1px;
  margin: 19px 0 14px;
  background: var(--ink);
  transform-origin: left center;
  animation: rule-in 0.55s var(--ease-out) 0.18s both;
}

.arrival-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.01em;
  line-height: 1.85;
  white-space: pre-line;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 24px;
}

.modal-actions-single {
  grid-template-columns: 1fr;
}

.modal .button {
  min-height: 46px;
  font-size: 12px;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.modal-text {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.85;
  white-space: pre-line;
}

.modal-compact {
  padding: 24px 22px 20px;
}

/* ------------------------------------------------------------
   Developer panel
   ------------------------------------------------------------ */

.dev-fab {
  position: fixed;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 55;
  display: grid;
  width: 42px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

.dev-fab:hover {
  opacity: 1;
}

.dev-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  width: min(400px, 100vw);
  overflow-y: auto;
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 22px);
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.55;
  animation: panel-in 0.3s var(--ease-out) both;
}

.dev-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.dev-head strong {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.dev-close {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.dev-section {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.dev-section h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.dev-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.dev-row:last-child {
  margin-bottom: 0;
}

.dev-row label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
}

.dev-row input[type="number"],
.dev-row input[type="text"],
.dev-row select {
  min-height: 28px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
}

.dev-row input[type="range"] {
  width: 140px;
  accent-color: var(--accent);
}

.dev-btn {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.dev-btn:hover {
  border-color: var(--line-strong);
  background: var(--bg);
}

.dev-btn.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.dev-btn.is-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.dev-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.dev-state {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------------------------
   Utility / noscript
   ------------------------------------------------------------ */

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  margin: 0;
  background: var(--bg);
  padding: 24px;
  font-size: 13px;
}

/* ------------------------------------------------------------
   Animations
   ------------------------------------------------------------ */

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes rule-in {
  from {
    opacity: 0;
    transform: scaleX(0);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

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

@keyframes loader-sweep {
  0% {
    transform: translateX(-100%);
  }
  55%,
  100% {
    transform: translateX(100%);
  }
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

@media (min-width: 760px) {
  body {
    padding: 0;
  }

  .app {
    max-width: 460px;
    --pad: 30px;
    padding-right: 30px;
    padding-left: 30px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  .screen-setup {
    padding-top: 44px;
  }

  .overlay-sheet {
    align-items: center;
  }

  .sheet {
    max-height: 82vh;
    border: 1px solid var(--line-strong);
  }

  .arrow-field {
    width: min(46vw, 260px);
  }

  .trail-panel {
    margin: 0 -4px;
  }
}

@media (max-height: 700px) {
  .hero {
    margin-bottom: 22px;
  }

  .display {
    font-size: clamp(24px, 6.8vw, 31px);
  }

  .lede {
    line-height: 1.75;
  }

  .field {
    margin-bottom: 17px;
  }

  .arrow-field {
    width: min(52vw, 200px);
    margin-bottom: 10px;
  }

  .trip-hint {
    margin-top: 12px;
  }

  .footnote {
    padding-top: 20px;
  }
}

@media (max-width: 359px) {
  :root {
    --pad: 17px;
  }

  .choice {
    font-size: 11px;
    padding: 0 4px;
  }

  .choice-type {
    padding: 0 10px;
    gap: 8px;
  }

  .readout-value {
    font-size: 40px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .app[data-ui="trip"],
  .app[data-ui="arrived"] {
    padding-top: calc(env(safe-area-inset-top, 0px) + 4px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
  }

  .trip-topbar {
    min-height: 40px;
  }

  .arrow-panel {
    padding-top: 0;
    padding-bottom: 2px;
  }

  .arrow-field {
    width: min(38vh, 168px);
    margin-bottom: 2px;
  }

  .readout-value {
    font-size: 34px;
  }

  .readout-label {
    display: none;
  }

  .trip-hint {
    margin-top: 8px;
    font-size: 9.5px;
    line-height: 1.5;
  }

  .trip-footer {
    margin-top: 4px;
    padding-top: 6px;
  }

  .trail-readout {
    bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
