:root {
  --bg: #f5ead9;
  --card: #ffffff;
  --ink: #3a2a1d;
  --ink-soft: #6b5643;
  --accent: #a9642f;
  --accent-dark: #8b5e34;
  --line: #e8d9c2;
  --good: #4c7a4c;
  --warn: #b5502e;
  --shadow: 0 2px 10px rgba(60, 40, 20, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201810;
    --card: #2b2119;
    --ink: #f2e6d5;
    --ink-soft: #c9b9a3;
    --accent: #e2a15c;
    --accent-dark: #d99148;
    --line: #40332580;
    --good: #7fbf7f;
    --warn: #e2836a;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 16px calc(env(safe-area-inset-bottom, 16px) + 24px);
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 2px 16px;
}
.header h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
}
.header .gear {
  background: none;
  border: none;
  font-size: 1.3rem;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--ink-soft);
}

.card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
}

.now-card {
  border: 2px solid var(--accent);
}
.now-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--accent-dark);
  font-weight: 700;
  margin-bottom: 4px;
}
.now-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 6px;
  line-height: 1.2;
}
.now-action {
  color: var(--ink-soft);
  font-size: 0.98rem;
  margin: 0 0 16px;
  line-height: 1.4;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 4px 0 2px;
}
.timer.overdue { color: var(--warn); }
.timer-sub {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.progress-track {
  height: 8px;
  background: var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.3s ease;
}

.btn-row {
  display: flex;
  gap: 10px;
}
button {
  font-family: inherit;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
}
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary {
  background: var(--line);
  color: var(--ink);
  flex: 0 0 auto;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px;
  text-decoration: underline;
}
.btn-block {
  width: 100%;
  margin-top: 8px;
}

.prep-card {
  background: var(--card);
  border-left: 4px solid var(--good);
}
.prep-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--good);
  font-weight: 700;
  margin-bottom: 4px;
}
.prep-text {
  font-size: 0.95rem;
  color: var(--ink);
  margin: 0;
}

.folds-card .folds-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 10px;
}
.fold-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fold-chip {
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
}
.fold-chip.done {
  border-color: var(--good);
  color: var(--good);
  background: color-mix(in srgb, var(--good) 12%, transparent);
}
.fold-chip.next {
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  background: var(--line);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-time {
  flex: 0 0 68px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.timeline-body { flex: 1; }
.timeline-title {
  font-weight: 700;
  font-size: 0.95rem;
}
.timeline-item.done .timeline-title { color: var(--ink-soft); text-decoration: line-through; }
.timeline-item.current .timeline-title { color: var(--accent-dark); }
.timeline-item.future .timeline-time { opacity: 0.65; }
.timeline-note {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--line);
  color: var(--ink-soft);
  margin-left: 6px;
  vertical-align: middle;
}
.badge.now { background: var(--accent); color: #fff; }

.intro h2 { font-size: 1.4rem; margin: 4px 0 6px; }
.intro p { color: var(--ink-soft); line-height: 1.45; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  font-size: 0.95rem;
}
.checkbox-row input { width: 20px; height: 20px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 4, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(env(safe-area-inset-bottom, 16px) + 20px);
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 6px; font-size: 1.2rem; }
.modal p { color: var(--ink-soft); margin: 0 0 16px; font-size: 0.92rem; }

.pick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.pick-btn {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
}
.pick-btn.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-dark);
}

.duration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.duration-row:last-child { border-bottom: none; }
.duration-row .name { font-size: 0.9rem; font-weight: 600; flex: 1; }
.duration-row input {
  width: 68px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.95rem;
  text-align: center;
  background: var(--bg);
  color: var(--ink);
}

.stack { display: flex; flex-direction: column; gap: 10px; }

footer.hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin-top: 18px;
  line-height: 1.4;
}
