:root {
  --paper: #f3ecdf;
  --paper-2: #e7decd;
  --card: rgba(255, 251, 245, 0.92);
  --ink: #1c1712;
  --ink-soft: #6d6256;
  --line: rgba(48, 34, 20, 0.12);
  --cinnabar: #c4482d;
  --cinnabar-deep: #8e2f1c;
  --pine: #234237;
  --pine-soft: #e4efe8;
  --gold: #8d6432;
  --shadow: 0 16px 40px rgba(62, 38, 16, 0.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "STSong", "Noto Serif SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --mono: "SF Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.topbar > [hidden] {
  display: inline-flex !important;
  visibility: hidden;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 500px at 50% -10%, #fbf6ee, transparent 60%),
    #e5dccb;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

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

button { cursor: pointer; }

.app {
  width: min(100%, 430px);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.55), transparent 220px),
    var(--paper);
  position: relative;
  box-shadow: 0 0 0 1px rgba(48, 34, 20, 0.05);
}

.app > main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr 72px;
  align-items: center;
  height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  text-align: center;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.18em;
}

.icon-btn, .text-btn {
  border: 0;
  background: transparent;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-btn {
  justify-content: flex-end;
  padding-right: 6px;
  color: var(--cinnabar-deep);
  font-size: 14px;
}

.screen {
  padding: 8px 20px calc(28px + var(--safe-bottom));
}

.app.has-tabs .screen {
  padding-bottom: 28px;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  flex: none;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(16px);
  padding-bottom: var(--safe-bottom);
  z-index: 6;
}

.tab {
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.on {
  color: var(--cinnabar);
}

.kicker {
  margin: 8px 0 0;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.16em;
}

h1 {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 560;
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.screen.home {
  container-type: inline-size;
}

h1.home-title {
  font-size: clamp(22px, 8.1cqi, 32px);
  line-height: 1.28;
}

h1.home-title span {
  display: block;
}

.lede {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.section-label {
  margin: 28px 0 10px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.14em;
}

.btn {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 15px 18px;
  background: var(--ink);
  color: #f8f2e8;
  font-size: 16px;
}

.btn:disabled {
  background: #c9c0b2;
  color: #f7f3ec;
}

.btn.secondary {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-row { margin-top: 22px; display: grid; gap: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.trip-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px;
}

.trip-open,
.drive-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.drive-link {
  width: auto;
  margin-top: 12px;
  color: var(--cinnabar);
  font-size: 13px;
}

.trip-card .where {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.3;
}

.meta {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 13px;
}

.resume {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--cinnabar-deep);
  font-size: 14px;
}

.route-spine {
  height: 56px;
  margin-top: 12px;
}

.field-stack { margin-top: 22px; display: grid; gap: 12px; }

.field {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.field label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  justify-self: center;
  background: var(--pine);
  box-shadow: 0 0 0 4px var(--pine-soft);
}

.dot.end { background: var(--cinnabar); box-shadow: 0 0 0 4px #f6e2db; }

.field input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 17px;
}

.field small {
  grid-column: 2;
  color: var(--ink-soft);
  font-size: 12px;
}

.map-card { padding: 12px 12px 4px; overflow: hidden; }

.map-card svg { width: 100%; height: auto; display: block; }

.map-note {
  margin: 8px 4px 10px;
  color: var(--ink-soft);
  font-size: 12px;
}

.route-list { display: grid; gap: 10px; margin-top: 14px; }

.route-option {
  width: 100%;
  text-align: left;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.route-option.selected {
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.route-option .name { font-size: 16px; }

.route-option .stat {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.route-option .badge {
  grid-row: span 2;
  align-self: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--pine);
}

.pref-list { display: grid; gap: 8px; margin-top: 16px; }

.pref {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
}

.pref .name { font-size: 16px; }
.pref .hint { color: var(--ink-soft); font-size: 12px; }

.switch {
  width: 42px;
  height: 26px;
  border-radius: 999px;
  background: #d9d0c2;
  align-self: center;
  position: relative;
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.18s ease;
}

.pref.on .switch { background: var(--pine); }
.pref.on .switch i { transform: translateX(16px); }

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
  padding: 4px;
  border-radius: 14px;
  background: var(--paper-2);
}

.seg button, .voice-grid button {
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 10px 8px;
}

.seg button.selected, .voice-grid button.selected {
  background: var(--card);
  box-shadow: 0 4px 14px rgba(62, 38, 16, 0.06);
}

.voice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.voice-grid button {
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--card);
}

.voice-grid .name { display: block; font-size: 15px; }
.voice-grid small { color: var(--ink-soft); }

.steps { margin-top: 22px; display: grid; gap: 0; }

.step {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  min-height: 58px;
}

.step .rail { position: relative; }

.step .rail::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: -8px;
  width: 1px;
  background: var(--line);
}

.step:last-child .rail::before { display: none; }

.step .mark {
  width: 13px;
  height: 13px;
  margin-top: 4px;
  border-radius: 50%;
  border: 1.5px solid #b7ad9e;
  background: var(--paper);
  position: relative;
  z-index: 1;
}

.step.done .mark { background: var(--pine); border-color: var(--pine); }
.step.now .mark { border-color: var(--cinnabar); box-shadow: 0 0 0 4px #f6e1da; }
.step .title { font-size: 15px; }
.step .desc { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.step.wait .title { color: var(--ink-soft); }

.progress-num {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1;
}

.progress-num span { font-size: 16px; color: var(--ink-soft); margin-left: 4px; }

.progress-track {
  margin-top: 14px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-track i {
  display: block;
  height: 100%;
  background: var(--cinnabar);
}

.step.bad .mark { background: var(--cinnabar); border-color: var(--cinnabar); }
.step.bad .title { color: var(--cinnabar); }

.chapter-head .where {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.2;
  margin-top: 6px;
}

.mode-row { display: flex; justify-content: flex-end; margin-top: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.chip {
  border: 0;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.chip.on {
  background: var(--ink);
  color: #f6f0e6;
  box-shadow: none;
}

.route-map {
  position: relative;
  height: 460px;
  margin-top: 14px;
  border-radius: 16px;
  background: var(--paper-2);
  overflow: hidden;
}

.route-map svg { width: 100%; height: 100%; display: block; }

.map-pin {
  width: 36px;
  height: 54px;
  border: 0;
  background: transparent;
  padding: 0;
  display: block;
  cursor: pointer;
}

.route-map > .map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
}

.map-pin img { width: 36px; height: 54px; display: block; pointer-events: none; }
.map-pin.spent,
.map-pin.spent img { width: 22px; height: 33px; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend img { width: 28px; height: 42px; display: block; }

.chapters { margin: 16px 0 0; padding: 0; list-style: none; }

.chapter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.chapter-row:last-child { border-bottom: 1px solid var(--line); }

.chapter {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 14px 0;
  border: 0;
  background: transparent;
}

.tts {
  border: 0;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--cinnabar-deep);
  white-space: nowrap;
}

.tts.ready,
.tts:disabled {
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-row.tight { margin-top: 14px; }

.chapter .km {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gold);
  padding-top: 4px;
}

.chapter .title {
  display: block;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
}

.chapter .sub {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.chapter .time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-soft);
  padding-top: 4px;
}

.chapter.pending { color: #8a8176; }
.chapter.pending .title { color: #8a8176; }
.chapter.current .title { color: var(--cinnabar-deep); }

.player-kicker {
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 13px;
}

.player h1 { font-size: 32px; }

.hook {
  margin: 12px 0 0;
  font-size: 15px;
  color: #3f372f;
}

.position {
  margin-top: 18px;
  padding: 12px 12px 10px;
  border-radius: 14px;
  background: var(--paper-2);
}

.position .cap {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-soft);
}

.track {
  position: relative;
  height: 28px;
  margin-top: 6px;
}

.track .line {
  position: absolute;
  left: 0;
  right: 0;
  top: 13px;
  height: 2px;
  background: rgba(48, 34, 20, 0.18);
}

.track .pin {
  position: absolute;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cinnabar);
  transform: translateX(-50%);
}

.controls {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 64px 84px 64px;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.controls .side, .play {
  border: 0;
  background: transparent;
}

.controls .side {
  height: 48px;
  color: var(--ink);
  font-size: 13px;
}

.controls .side:disabled { color: #b3a898; }

.play {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--cinnabar);
  color: white;
  box-shadow: 0 12px 24px rgba(196, 72, 45, 0.28);
}

.play svg, .mini svg { width: 28px; height: 28px; fill: currentColor; }

.scrub { margin-top: 8px; }

.scrub input {
  width: 100%;
  accent-color: var(--cinnabar);
}

.times {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}

.block { margin-top: 22px; }

.block h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.script {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
}

.source {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.source b { font-weight: 560; }
.source span { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }

.legend {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f6e7c8;
  color: #7a5620;
  font-size: 11px;
  font-style: normal;
}

.setting {
  width: 100%;
  text-align: left;
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.setting .name { font-size: 16px; }
.setting .value { color: var(--ink-soft); font-size: 14px; }

.footnote {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.notice {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.banner {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8e6e1;
  color: #8e2f1c;
  font-size: 13px;
  line-height: 1.5;
}

.empty {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

@media (min-width: 800px) {
  body { padding: 28px 0; }
  .app {
    height: calc(100dvh - 56px);
    max-height: calc(100dvh - 56px);
    border-radius: 28px;
    overflow: hidden;
  }
}
