:root {
  --bg: #f6f1e7;
  --fg: #2c2a26;
  --muted: #5e5952;
  --surface: #fffdf8;
  --primary: #5e6d57;
  --primary-fg: #f6f1e7;
  --gold: #c4a574;
  --sage: #a8b5a2;
  --sage-soft: #e4ebdf;
  --line: #e3dac8;
  --stage: #d5dece;
  --ink: #2c2a26;
  --danger: #a33b2b;
  --radius: 1.25rem;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

html.dark {
  --bg: #161814;
  --fg: #f3efe6;
  --muted: #c2bbb0;
  --surface: #22261f;
  --primary: #c5d1bf;
  --primary-fg: #1a1c18;
  --gold: #d4b896;
  --sage: #a8b5a2;
  --sage-soft: #2a3126;
  --line: #34392f;
  --stage: #0e100d;
  --ink: #1a1c18;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--stage);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
img { display: block; max-width: 100%; }
a { color: inherit; }

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

::selection { background: var(--sage-soft); color: var(--fg); }

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

.app {
  margin: 0 auto;
  width: 100%;
  max-width: 28rem;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}
@media (min-width: 48rem) {
  .app { box-shadow: 0 0 0 1px var(--line); }
}

.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1rem;
}

.footer-actions {
  flex-shrink: 0;
  padding: 0.75rem 1.5rem calc(1rem + env(safe-area-inset-bottom));
  display: grid;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin: 1rem 0 0;
  font-family: var(--font-serif);
  font-weight: 560;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.15;
  text-wrap: balance;
}
h2 {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 560;
}
.lede {
  margin: 1.25rem 0 0;
  max-width: 20rem;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 0.875rem; line-height: 1.5; }

.center-stack {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  width: 100%;
  padding: 0 1.5rem;
  border-radius: 999px;
  font-size: 1.125rem;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-soft { background: var(--sage-soft); color: var(--fg); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-row { display: grid; gap: 0.5rem; }
.btn-sm { min-height: 2.75rem; font-size: 1rem; width: auto; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.chip {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  color: var(--fg);
}
.chip[aria-pressed="true"] {
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-top: 0.75rem;
}
.card-title { margin: 0; font-weight: 600; }
.card-line { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.95rem; }

.field { margin-top: 1rem; display: grid; gap: 0.4rem; }
.field label { font-size: 0.9rem; color: var(--muted); }
.field textarea, .field input[type="text"], .field input[type="time"] {
  width: 100%;
  min-height: 2.75rem;
  border-radius: 0.9rem;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.75rem 0.9rem;
  resize: vertical;
}
.field textarea { min-height: 5rem; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.step { margin: 0; color: var(--muted); font-size: 0.85rem; }

.nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 95%, transparent);
  backdrop-filter: blur(10px);
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
}
.nav button {
  display: grid;
  place-items: center;
  gap: 0.15rem;
  min-height: 3.25rem;
  font-size: 0.7rem;
  color: var(--muted);
  border-radius: 0.75rem;
}
.nav button[aria-current="page"] { color: var(--fg); background: var(--sage-soft); }
.nav svg { width: 1.25rem; height: 1.25rem; }

.script {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
}
.script p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--fg);
}
.script p.is-active {
  background: var(--sage-soft);
  border-radius: 0.9rem;
  padding: 0.75rem 0.85rem;
}

.action-box {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--sage-soft);
}
.action-box strong { display: block; margin-bottom: 0.35rem; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-top: 1rem;
}
.calendar .dow { text-align: center; font-size: 0.7rem; color: var(--muted); }
.day {
  aspect-ratio: 1;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.75rem;
}
.day.done { background: var(--gold); color: var(--ink); border-color: transparent; }
.day.partial { background: var(--sage-soft); border-color: var(--primary); }
.day.today { box-shadow: 0 0 0 2px var(--gold); }

.list { display: grid; gap: 0.65rem; margin-top: 1rem; }
.list article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.list time { color: var(--muted); font-size: 0.8rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 20;
  max-width: calc(100% - 2rem);
}

.rise { animation: rise 0.45s both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .rise { animation: none; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.player {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}
.player .btn { width: auto; min-width: 7rem; }
.status-dot {
  width: 0.55rem; height: 0.55rem; border-radius: 999px;
  background: var(--gold); display: inline-block; margin-right: 0.4rem;
}
