:root {
  --bg: #0f0d12;
  --panel: #1a1620;
  --panel-2: #241e2b;
  --ink: #efe6d3;
  --ink-dim: #b9ae9a;
  --amber: #e9a94a;
  --amber-ink: #2a1a05;
  --line: #3a3142;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", -apple-system, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
h1 { font-size: 2rem; line-height: 1.1; }
h2 { font-size: 1.35rem; line-height: 1.2; }
p { margin: 0; }
button { font: inherit; }
.loading, .muted { color: var(--ink-dim); }
.eyebrow { font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }

/* Route picker */
.app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 48px); }
.routes { display: grid; gap: 12px; margin-top: 20px; }
.route-card { display: block; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: inherit; text-decoration: none; }
.route-card .meta { color: var(--ink-dim); margin-top: 6px; font-size: 0.95rem; }
.route-card.soon { opacity: 0.55; }
.foot { margin-top: 32px; color: var(--ink-dim); font-size: 0.9rem; display: grid; gap: 8px; }

/* Walk screen: top strip, map, sheet, bar. The app is pinned to the real
   viewport edges, so an installed app and a browser tab fill the screen the
   same way, with no gap under the bar. */
body.walk { overflow: hidden; }
body.walk .app {
  max-width: none;
  padding: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* never wider than the screen */
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.top { min-height: 60px; }
.top .back { color: var(--ink); text-decoration: none; font-size: 1.8rem; line-height: 1; padding: 0 8px 6px 4px; display: flex; align-items: center; }
.top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.top-name { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { color: var(--ink-dim); font-size: 0.8rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status:empty { display: none; } /* an empty status would hold a blank row and push the title up */
.locate {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
}
.locate.on { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }

.map-wrap { position: relative; min-height: 0; }
.map {
  position: absolute;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
  background: #141216;
  cursor: grab;
}
.map::-webkit-scrollbar { display: none; }
.map.dragging { cursor: grabbing; }
.map .canvas { position: relative; width: 100%; }
.map img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.map .pins { position: absolute; inset: 0; }
.map-fallback { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; color: var(--ink-dim); }
.zooms { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 6px; z-index: 2; }
.zoom {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(26, 22, 32, 0.92);
  color: var(--ink);
  font-weight: 600;
  font-size: 1.3rem;
  cursor: pointer;
  touch-action: manipulation;
}
.pin {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--amber);
  color: var(--amber-ink);
  border: 2px solid var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.pin.extra { background: var(--panel-2); color: var(--ink); border-color: var(--amber); }
.pin.sel { background: #fff; color: var(--amber-ink); box-shadow: 0 0 0 4px rgba(233, 169, 74, 0.45); z-index: 1; }
.pin.near { box-shadow: 0 0 0 4px rgba(95, 179, 255, 0.5); }
.pin.playing { background: #fff; }
.me {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #5fb3ff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(95, 179, 255, 0.3);
  pointer-events: none;
}

/* Player drawer */
/* The bottom padding only clears the home indicator on an installed app;
   the full safe-area inset read as empty space. */
.bar { background: var(--panel); border-top: 1px solid var(--line); padding: 12px 16px max(8px, calc(var(--safe-bottom) - 14px)); }
.bar-info { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 0; color: var(--ink); text-align: left; cursor: pointer; }
.bar-num { flex: 0 0 auto; align-self: center; font-family: var(--serif); font-weight: 600; font-size: 2.4rem; line-height: 1; color: var(--amber); min-width: 1.2em; text-align: center; }
.bar-text { min-width: 0; }
.bar-name { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sub { color: var(--ink-dim); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-dir { margin-top: 10px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; color: var(--ink-dim); font-size: 0.85rem; line-height: 1.35; }
.bar-dir .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bar-prog { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; }
.bar-t { font-size: 0.75rem; color: var(--ink-dim); font-variant-numeric: tabular-nums; min-width: 2.6em; }
.bar-t:last-child { text-align: right; }
.bar-track { flex: 1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--amber); transition: width 0.25s linear; }
.bar-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bar-nav { flex: 1; min-width: 0; min-height: 52px; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: 0.95rem; text-align: left; cursor: pointer; touch-action: manipulation; padding: 0; display: grid; gap: 2px; }
.bar-nav.right { text-align: right; }
.bar-nav small { font-weight: 400; color: var(--ink-dim); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-nav[disabled] { opacity: 0.35; }
.bar-play { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--amber); color: var(--amber-ink); font-size: 1.3rem; cursor: pointer; touch-action: manipulation; }

/* The sheet that expands from the bar */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 18%;
  z-index: 5;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
}
body.sheet-open .bar { position: relative; z-index: 6; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 0 16px; }
.tabs { display: flex; gap: 6px; }
.tab { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--ink-dim); font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.tab.on { background: var(--panel-2); color: var(--ink); }
.sheet-close { width: 44px; height: 44px; border: 0; background: none; color: var(--ink-dim); font-size: 1.4rem; cursor: pointer; }
.sheet-body { overflow: auto; padding: 8px 16px calc(var(--safe-bottom) + 220px); -webkit-overflow-scrolling: touch; }
.sheet-story h2 { font-size: 1.5rem; }
.sheet-story .addr { color: var(--ink-dim); font-size: 0.95rem; margin: 4px 0 12px; }
.sheet-story .next { padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; color: var(--ink-dim); font-size: 0.95rem; margin-bottom: 14px; }
.sheet-story .text { font-family: var(--serif); font-size: 1.2rem; line-height: 1.55; }
.sheet-story .src { color: var(--ink-dim); font-size: 0.85rem; margin-top: 16px; }
.sheet-story .src a { color: var(--ink-dim); }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-list .sep { color: var(--amber); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 14px 0 6px; }
.sheet-list .row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 0; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); text-align: left; cursor: pointer; }
.sheet-list .num { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; background: var(--amber); color: var(--amber-ink); font-weight: 600; display: flex; align-items: center; justify-content: center; }
.sheet-list .num.extra { background: var(--panel-2); color: var(--ink); border: 1px solid var(--amber); }
.sheet-list .row-text { min-width: 0; display: grid; }
.sheet-list b { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; }
.sheet-list small { color: var(--ink-dim); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
