:root {
  color-scheme: light;
  --bg: #f7f1e8;
  --paper: #fffdf8;
  --ink: #23383b;
  --muted: #637376;
  --line: #d9ddd7;
  --accent: #365b61;
  --accent-soft: #e2ecea;
  --warm: #a85d45;
  --warm-soft: #f5e7df;
  --moss: #69765b;
  --moss-soft: #e9ede3;
  --focus: #1c6e78;
  --radius: 14px;
  font: 17px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button, select, input[type="range"] { min-height: 44px; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--paper);
  color: var(--ink);
}
.skip-link:focus { top: 10px; }

.app-header, .tabs, main {
  width: min(100% - 28px, 760px);
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: max(22px, env(safe-area-inset-top)) 0 14px;
}

h1, h2, h3 {
  font-family: Georgia, "Iowan Old Style", serif;
  line-height: 1.15;
}
h1 { margin: 2px 0 3px; font-size: 2rem; font-weight: 500; }
h2 { margin: 0; font-size: 1.45rem; font-weight: 500; }
h3 { margin: 0; font-size: 1.08rem; font-weight: 600; }
p { margin: 0; }

.eyebrow {
  color: var(--warm);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .11em;
}
.muted { color: var(--muted); }
.small { font-size: .86rem; }

.chapter-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 8px 12px;
  text-align: right;
}
.chapter-chip span, .chapter-chip strong { display: block; }
.chapter-chip span { color: var(--muted); font-size: .72rem; }
.chapter-chip strong { color: var(--accent); font-size: .9rem; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 10px;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 13px;
}
.tabs button[aria-current="page"] {
  background: var(--accent);
  color: white;
}

main { padding: 20px 0 calc(48px + env(safe-area-inset-bottom)); }
.view { display: grid; gap: 18px; }
.section-heading { display: grid; gap: 5px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 16px;
}
.card.subtle { background: color-mix(in srgb, var(--paper) 72%, var(--accent-soft)); }
.card.warm { background: var(--warm-soft); border-color: #dfc7ba; }
.card.moss { background: var(--moss-soft); border-color: #cdd5c3; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.time {
  color: var(--warm);
  font-size: .82rem;
  font-weight: 700;
}
.suggestion { margin: 8px 0 14px; font-size: 1.03rem; }
.detail { margin-top: 10px; color: var(--muted); font-size: .9rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.actions button, .button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 13px;
}
.actions .primary, button.primary, .button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.actions .quiet, button.quiet { background: transparent; }
button.complete {
  border-color: var(--moss);
  background: var(--moss);
  color: white;
}
button[disabled] { cursor: default; opacity: .58; }

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}
.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--moss);
  font-size: .9rem;
  font-weight: 650;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.check-list { display: grid; gap: 9px; margin-top: 10px; }
.check-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
}
.grocery-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  color: var(--ink);
}
.check-row input { width: 21px; height: 21px; margin: 2px 0 0; accent-color: var(--accent); }
.low-button {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: var(--warm-soft);
  color: var(--warm);
  padding: 3px 9px;
  font-size: .75rem;
}
.low-button[aria-pressed="true"] { background: var(--warm); color: white; }

label { display: grid; gap: 5px; font-size: .9rem; color: var(--muted); }
select, input[type="text"], input[type="number"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 12px;
}
textarea { min-height: 92px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.range-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.range-row output { min-width: 1.5rem; color: var(--accent); font-weight: 750; text-align: center; }

.restaurant-order { display: grid; gap: 10px; margin-top: 12px; }
.caution {
  border-left: 3px solid var(--warm);
  padding-left: 11px;
  color: var(--muted);
  font-size: .88rem;
}

.category-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.category-buttons button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 7px 12px;
}
.category-buttons button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.steps { counter-reset: step; display: grid; gap: 12px; }
.step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
}
.step::before {
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 750;
}

.clue-list { display: grid; gap: 9px; }
.clue {
  border-left: 2px solid var(--line);
  padding: 3px 0 3px 12px;
}
.clue.latest { border-color: var(--warm); }
.choice-set { display: grid; gap: 8px; }
.choice-set button {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 11px;
}
.choice-set button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.notice {
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  padding: 12px 14px;
}
.notice strong { display: block; margin-bottom: 3px; }

.quote-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--moss-soft);
  padding: 16px 18px;
}
.quote-text {
  margin: 8px 0 8px;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.22rem;
  line-height: 1.35;
  color: var(--ink);
}
.quote-attribution {
  color: var(--muted);
  font-size: .84rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 520px);
  border-radius: 11px;
  background: var(--ink);
  color: white;
  padding: 12px 15px;
  text-align: center;
}

dialog {
  width: min(calc(100% - 32px), 520px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: rgb(20 32 34 / .55); }
.dialog-body { display: grid; gap: 14px; padding: 22px; }

.danger-zone { border-top: 1px solid var(--line); padding-top: 18px; }
.danger { color: #8a352d; border-color: #d6aaa5 !important; }

@media (max-width: 600px) {
  :root { font-size: 16px; }
  .app-header { align-items: center; }
  .chapter-chip { padding: 7px 10px; }
  .grid.two, .field-grid { grid-template-columns: 1fr; }
  .actions > button { flex: 1 1 42%; }
  .actions > button.primary { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
