/* Schuylkill Scramble design system (see Scramble-Website brand-design skill):
   pine / rust / parchment, Arvo + Lora + Space Mono, square-ish corners,
   patch framing. Light only — the brand has no dark palette. */
:root {
  --pine-dark: #17241a;
  --pine: #2e4a22;
  --rust: #c1703d;
  --cream: #f4efdf;
  --ink: #20301c;
  --white: #ffffff;
  --rule: rgba(46, 74, 34, 0.18);
  --muted: rgba(32, 48, 28, 0.62);
  --radius: 4px;
  --display: "Arvo", Georgia, serif;
  --body: "Lora", Georgia, serif;
  --mono: "Space Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font: 17px/1.45 var(--body);
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.label {
  font: 700 11px/1.3 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--rust);
}
:focus-visible { outline: 3px solid var(--rust); outline-offset: 2px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--pine-dark);
  color: var(--cream);
  border-bottom: 3px solid var(--rust);
}
.bar-text { flex: 1; min-width: 0; }
.bar-title { font: 700 19px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-status { font-size: 12px; letter-spacing: 0.04em; opacity: 0.85; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: transparent; color: var(--cream);
  border: 1.5px solid rgba(244, 239, 223, 0.35); border-radius: var(--radius);
}
.icon-btn[aria-pressed="true"] { background: var(--rust); border-color: var(--rust); }

/* ---------- banner ---------- */
.banner {
  margin: 12px 16px 0;
  padding: 10px 14px;
  background: var(--white);
  border: 2px solid var(--rust);
  border-radius: var(--radius);
  font-size: 15px;
}
.banner strong { font-family: var(--display); }
.banner button { background: none; border: 0; padding: 0; text-decoration: underline; color: var(--pine); font-weight: 600; }

/* ---------- chips ---------- */
.chips {
  display: flex; gap: 8px;
  padding: 12px 16px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--rule);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 12px;
  background: transparent;
  border: 1.5px solid var(--rule); border-radius: var(--radius);
  color: var(--muted);
}
.chip svg.i { width: 18px; height: 18px; }
.chip .n { font: 700 13px var(--mono); }
.chip[aria-pressed="true"] { background: var(--white); border-color: var(--pine); color: var(--ink); }
.chip[aria-pressed="true"] .n { color: var(--rust); }

/* ---------- list ---------- */
main { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.row {
  width: 100%;
  display: grid; grid-template-columns: 48px minmax(56px, auto) 1fr; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: none; border: 0; border-bottom: 1px solid var(--rule);
  text-align: left;
}
.row:active { background: rgba(193, 112, 61, 0.08); }
.badge {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 50%;
  background: var(--pine); color: var(--cream);
  box-shadow: 0 0 0 2px var(--cream), 0 0 0 3.5px var(--rust);
}
.dist { text-align: right; line-height: 1; }
.dist b { display: block; font: 700 30px/1 var(--display); color: var(--ink); letter-spacing: -0.02em; }
.dist small { font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.what { min-width: 0; }
.what .name { font-weight: 600; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.what .meta { margin-top: 3px; font: 400 12px/1.4 var(--mono); color: var(--muted); letter-spacing: 0.02em; }
.what .meta .cat { color: var(--rust); font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; }
.row.next .badge { background: var(--rust); box-shadow: 0 0 0 2px var(--cream), 0 0 0 3.5px var(--pine); }
.row.behind { opacity: 0.55; }
.row.behind .dist b { font-size: 22px; }

.here {
  position: sticky; top: calc(67px + env(safe-area-inset-top)); z-index: 2;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 16px;
  background: var(--pine);
  color: var(--cream);
  font: 700 17px var(--display);
}
.here .mono { font-size: 13px; letter-spacing: 0.08em; }

.empty { padding: 32px 16px; text-align: center; }
.patch.prompt { margin: 16px; }
.empty p { margin: 8px auto 20px; max-width: 34ch; color: var(--muted); }
.more { display: block; margin: 16px auto; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 12px 20px;
  border-radius: var(--radius);
  font: 700 17px var(--body);
  text-decoration: none;
}
.btn-primary { background: var(--rust); color: var(--cream); border: 0; }
.btn-primary:hover { filter: brightness(0.88); }
.btn-primary:disabled { opacity: 0.55; }
.btn-outline { background: transparent; border: 1.5px solid var(--pine); color: var(--ink); }
.btn-outline:hover { border-color: var(--rust); color: var(--rust); }
.btn.inline { width: auto; display: inline-flex; }

/* ---------- sheets (detail + setup) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 10;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--cream);
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}
.sheet-bar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--pine-dark); color: var(--cream);
  border-bottom: 3px solid var(--rust);
}
.sheet-bar h2 { margin: 0; font: 700 19px var(--display); flex: 1; }
.sheet-body { padding: 20px 16px; max-width: 640px; margin: 0 auto; }

.detail-cat { display: flex; align-items: center; gap: 10px; }
.detail-cat .badge { width: 40px; height: 40px; }
.detail-cat .badge svg.i { width: 20px; height: 20px; }
.sheet-body h1 { font: 700 30px/1.15 var(--display); color: var(--pine); margin: 12px 0 18px; overflow-wrap: anywhere; }
.stats { display: flex; gap: 32px; margin-bottom: 20px; }
.stats b { display: block; font: 700 40px/1 var(--display); color: var(--ink); }
.stats span { font: 400 12px var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
dl.facts { margin: 0 0 24px; border-top: 1px solid var(--rule); }
dl.facts div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
dl.facts dt { font: 700 11px/1.8 var(--mono); text-transform: uppercase; letter-spacing: 0.16em; color: var(--rust); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: grid; gap: 12px; }
.coords { margin-top: 16px; font: 13px var(--mono); color: var(--muted); user-select: all; }

/* patch framing: rust outer rule, pine inner rule */
.patch { border: 2px solid var(--rust); padding: 4px; border-radius: var(--radius); margin-bottom: 20px; background: var(--white); }
.patch > .in { border: 1px solid var(--pine); padding: 16px; border-radius: 2px; }
.patch h3 { font: 700 20px/1.2 var(--display); color: var(--pine); margin: 6px 0 10px; }
.patch p { margin: 0 0 12px; }
.small { font-size: 14px; color: var(--muted); }

.route-opt {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; background: none; border: 0; border-bottom: 1px solid var(--rule); text-align: left;
}
.route-opt:last-of-type { border-bottom: 0; }
.route-opt .nm { font-weight: 600; }
.route-opt .sub { font: 12px var(--mono); color: var(--muted); }
.route-opt[aria-current="true"] .nm { color: var(--rust); }
.route-opt[aria-current="true"] .nm::after { content: " ✓"; }
.file-btn { position: relative; margin-top: 12px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.seg { display: inline-flex; border: 1.5px solid var(--pine); border-radius: var(--radius); overflow: hidden; }
.seg button { min-height: 40px; padding: 0 16px; background: none; border: 0; font: 700 13px var(--mono); }
.seg button[aria-pressed="true"] { background: var(--pine); color: var(--cream); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.setting + .setting { border-top: 1px solid var(--rule); }
input[type="range"] { width: 100%; accent-color: var(--rust); min-height: 44px; }
.progress { font: 13px var(--mono); color: var(--pine); margin-top: 10px; }

@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: rise 0.3s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } }
}
