:root {
  --paper: #F3E6D4;
  --card: #FFFBF6;
  --ink: #2C1810;
  --muted: #5C4034;
  --line: #E4D3C1;
  --terra: #8C2F12;
  --terra-soft: #C4512C;
  --leaf: #1E5C3E;
  --leaf-bg: #E7F2EA;
  --shadow: 0 10px 28px rgba(80, 40, 10, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 20px;
  line-height: 1.35;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 50% -80px, #F8E7D2 0%, transparent 60%),
    var(--paper);
  min-height: 100vh;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  z-index: 50;
}
.skip:focus { top: 8px; }

.top {
  text-align: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 4px;
  max-width: 480px;
  margin: 0 auto;
}
.brand {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.7rem;
  letter-spacing: 0.01em;
}
.motto {
  margin: 2px 0 0;
  color: var(--terra);
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
}
.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 4px 16px calc(112px + env(safe-area-inset-bottom));
}

h1, h2 {
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 8px;
}
h1 { font-size: 1.85rem; }
h1 a { color: var(--terra); }
h2 { font-size: 1.45rem; margin-top: 18px; }

.why, .lead, .detail { color: var(--muted); margin: 0 0 8px; }

.message, .comeback, .card, .streak, .ladder {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.message {
  border-left: 8px solid var(--terra-soft);
  padding: 12px 14px;
  font-size: 1.15rem;
  margin: 0 0 10px;
}

.comeback {
  background: var(--leaf-bg);
  border: 2px solid var(--leaf);
  padding: 16px;
  margin: 0 0 14px;
}
.comeback h2 { margin-top: 0; color: var(--leaf); }
.comeback p { margin: 0 0 8px; }
.comeback p:last-child { margin: 0; font-weight: 700; }

.streak {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  margin: 0 0 8px;
}
.streak-num {
  font-family: Georgia, Palatino, serif;
  font-size: 2.6rem;
  line-height: 1;
  color: var(--terra);
  min-width: 1.3ch;
}
.streak-title { font-weight: 800; font-size: 1.2rem; display: block; }
.streak-detail { color: var(--muted); margin: 2px 0 0; }

.progress { margin: 0 0 8px; font-weight: 700; }

.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.step {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  min-height: 64px;
  font-size: 1.12rem;
  line-height: 1.25;
  box-shadow: var(--shadow);
}
.step .box {
  width: 36px;
  height: 36px;
  flex: none;
  border: 3px solid var(--terra);
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.step[aria-pressed="true"] {
  border-color: var(--leaf);
  background: #F4FBF6;
}
.step[aria-pressed="true"] .box {
  background: var(--leaf);
  border-color: var(--leaf);
}
.step[aria-pressed="true"] .box::after {
  content: "";
  width: 8px;
  height: 14px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.ladder { padding: 4px 12px 4px 8px; }
.rung {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: stretch;
  min-height: 54px;
}
.sides { display: flex; align-items: stretch; }
.rail { width: 10px; background: var(--terra); }
.bar {
  flex: 1;
  align-self: center;
  height: 16px;
  background: #F6E4D4;
  border-top: 3px solid var(--terra);
  border-bottom: 3px solid var(--terra);
}
.fill { display: block; height: 100%; background: var(--terra-soft); width: 0; }
.rung.is-today .bar { background: #fff; }
.rung-text {
  margin: 0;
  padding: 0 0 0 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 1.05rem;
}
.rung-text strong { font-size: 1.15rem; }

.quiet { margin: 14px 0; }

button, .btn, input, textarea {
  font: inherit;
  color: var(--ink);
}
button, .btn {
  border: 0;
  border-radius: 16px;
  min-height: 56px;
  padding: 12px 16px;
  background: var(--terra);
  color: #fff;
  font-weight: 800;
  width: 100%;
}
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--terra);
  border: 2px solid var(--terra);
}
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 0;
  min-height: 48px;
  font-weight: 700;
}
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 4px solid var(--terra-soft);
  outline-offset: 2px;
}

label { display: block; font-weight: 800; margin: 12px 0 6px; }
input, textarea {
  width: 100%;
  border: 2px solid #CDB8A4;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  min-height: 56px;
}
textarea { min-height: 84px; resize: vertical; }

.edit-row { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.edit-row input { flex: 1; }
.edit-row button {
  width: auto;
  min-width: 96px;
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
}

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.note { color: var(--muted); font-size: 1rem; }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: #FFFBF6;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabs a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 800;
  padding: 16px 4px 18px;
  min-height: 60px;
}
.tabs a[aria-current="page"] {
  background: var(--terra);
  color: #fff;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  z-index: 15;
  max-width: 90vw;
}
#toast:empty { display: none; }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(44, 24, 16, 0.5);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-card {
  background: var(--card);
  width: min(480px, 100%);
  border-radius: 24px 24px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
.sheet-card h2 { margin-top: 0; }
.sheet-card button { margin-top: 10px; }
#sheet-no { background: transparent; color: var(--ink); border: 2px solid var(--ink); }

.noscript { padding: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
