:root {
  --bg: #f3ebde;
  --bg-2: #e9dfd0;
  --paper: #fffbf6;
  --ink: #2b221c;
  --muted: #6a5d52;
  --line: #e5d8c6;
  --clay: #b5533a;
  --clay-d: #8c3d28;
  --clay-s: #f6e4dc;
  --sage: #4e6d55;
  --sage-s: #e3ede5;
  --gold: #b8893e;
  --gold-s: #f4e8cf;
  --dusk: #5d5368;
  --dusk-s: #ece7f0;
  --shadow: 0 12px 32px rgba(80, 48, 28, 0.08);
  --shadow-sm: 0 4px 14px rgba(80, 48, 28, 0.06);
  --radius: 22px;
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: Fraunces, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --safe-t: max(14px, env(safe-area-inset-top, 0px));
  --safe-b: max(10px, env(safe-area-inset-bottom, 0px));
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
html { height: 100%; }
body {
  min-height: 100%;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}
textarea, input[type="text"] {
  font-size: 16px;
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 14px 14px;
  outline: none;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
textarea:focus, input[type="text"]:focus { border-color: var(--clay); box-shadow: 0 0 0 3px rgba(181, 83, 58, 0.15); }

#app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background:
    radial-gradient(1200px 420px at 50% -80px, #f8e2c4 0%, transparent 70%),
    var(--bg);
}

.wrap {
  padding: calc(var(--safe-t) + 12px) 20px calc(var(--nav-h) + var(--safe-b) + 20px);
}
.wrap.plain { padding-bottom: calc(var(--safe-b) + 28px); }

h1, h2, h3 { font-family: var(--serif); font-weight: 650; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 2.05rem; line-height: 1.15; }
h2 { font-size: 1.35rem; line-height: 1.25; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.92rem; line-height: 1.45; }
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clay-d);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 16px;
  font-weight: 650;
  font-size: 1.02rem;
  background: var(--clay);
  color: #fff;
  box-shadow: 0 8px 18px rgba(140, 61, 40, 0.22);
  transition: transform 0.12s ease, filter 0.12s ease;
  width: 100%;
}
.btn:active { transform: scale(0.98); filter: brightness(0.96); }
.btn[disabled] { opacity: 0.45; pointer-events: none; box-shadow: none; }
.btn.secondary {
  background: var(--paper);
  color: var(--ink);
  box-shadow: none;
  border: 1.5px solid var(--line);
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  min-height: 44px;
}
.btn.sage { background: var(--sage); box-shadow: 0 8px 18px rgba(78, 109, 85, 0.22); }
.row-btns { display: flex; gap: 10px; }
.row-btns .btn { width: auto; flex: 1; }

/* Cards */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.7);
}
.card + .card, .stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 16px; }

/* Welcome */
.hero {
  text-align: center;
  padding: 18px 8px 8px;
}
.hero-mark {
  width: 108px;
  height: 108px;
  margin: 12px auto 22px;
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.hero h1 { margin-bottom: 10px; }
.hero .lede {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.5;
  max-width: 22rem;
  margin: 0 auto;
}
.step-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 6px 0 18px;
}
.step-dots span {
  width: 7px; height: 7px; border-radius: 99px;
  background: #d5c4ae;
}
.step-dots span.on { background: var(--clay); width: 18px; }

/* Chips / choices */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .mood, .focus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-weight: 600;
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.focus, .mood { width: 100%; border-radius: 16px; min-height: 58px; font-size: 1.02rem; }
.focus-grid, .mood-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mood-grid { grid-template-columns: 1fr 1fr 1fr; }
.focus.on, .mood.on, .chip.on {
  border-color: var(--clay);
  background: var(--clay-s);
  color: var(--clay-d);
  box-shadow: inset 0 0 0 1px var(--clay);
}
.focus .ico, .mood .ico { font-size: 1.15rem; }

/* Today header */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.hello { font-family: var(--serif); font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.date-line { color: var(--muted); margin-top: 4px; font-weight: 500; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  flex: none;
}
.streak {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gold-s);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.streak .flame {
  width: 38px; height: 38px; border-radius: 12px;
  background: #fff;
  display: grid; place-items: center;
  font-size: 1.2rem;
}
.streak strong { font-size: 1.05rem; display: block; }
.week {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin: 12px 0 4px;
}
.day {
  flex: 1;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.day i {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  margin: 0 auto 4px;
  border-radius: 99px;
  background: var(--bg-2);
  font-style: normal;
  font-size: 0.78rem;
  color: transparent;
}
.day.done i { background: var(--sage); color: #fff; }
.day.today i { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--gold); }
.day.miss i { background: #e8d7c8; }

/* Coach */
.coach {
  background:
    linear-gradient(180deg, #fffefb 0%, #fff6ea 100%);
  border: 1px solid #f0e0c8;
  position: relative;
  overflow: hidden;
}
.coach::before {
  content: "";
  position: absolute;
  right: -30px; top: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 210, 140, 0.55), transparent 70%);
  pointer-events: none;
}
.coach h2 { margin: 8px 0 10px; font-size: 1.42rem; }
.coach .body { color: var(--ink); font-size: 1.02rem; line-height: 1.55; }

.verse {
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
.verse p {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.45;
  color: #3a3129;
}
.verse cite {
  display: block;
  margin-top: 8px;
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
}

.cta-check {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
}
.cta-check .arrow { margin-left: auto; font-size: 1.2rem; color: var(--clay); }

.goal-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
}
.check {
  width: 26px; height: 26px; border-radius: 8px;
  border: 1.5px solid var(--line);
  background: #fff;
  flex: none;
  margin-top: 2px;
  display: grid; place-items: center;
  color: transparent;
  font-size: 0.9rem;
  font-weight: 700;
}
.goal-row.on .check { background: var(--sage); border-color: var(--sage); color: #fff; }
.goal-row.on .g-title { text-decoration: line-through; color: var(--muted); }
.g-title { font-weight: 650; line-height: 1.3; display: block; }
.g-meta { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 3px; }

/* Nav */
.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 430px;
  background: rgba(255, 251, 246, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px var(--safe-b);
  height: calc(var(--nav-h) + var(--safe-b));
  z-index: 20;
}
.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--clay-d); }

/* Journal */
.entry { padding: 0; overflow: hidden; }
.entry header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px 0;
}
.entry .mood-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--sage);
  background: var(--sage-s);
  border-radius: 999px;
  padding: 4px 9px;
}
.entry .when { font-weight: 650; }
.entry .body { padding: 10px 16px 16px; color: var(--ink); }
.entry .label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 8px 0 3px; }

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
}
.empty p { margin-top: 8px; line-height: 1.45; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-weight: 650;
  color: var(--clay-d);
  margin: 0 0 8px -6px;
  padding: 0 6px;
}

.privacy {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: center;
}
.about {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}
.danger { color: var(--clay-d); }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  z-index: 40;
  box-shadow: var(--shadow);
  max-width: 90vw;
  white-space: nowrap;
}
#toast[hidden] { display: none; }

.hint { color: var(--muted); font-size: 0.92rem; line-height: 1.4; margin: 6px 0 12px; }
.section-title { margin: 8px 0 10px; }

.goal-card .verse { margin-top: 12px; }
.goal-actions { display: flex; gap: 8px; margin-top: 12px; }
.goal-actions .btn { min-height: 44px; font-size: 0.92rem; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media (min-width: 500px) {
  body { background: #e7dccb; }
  #app {
    min-height: 100dvh;
    box-shadow: 0 0 0 1px rgba(80, 48, 28, 0.06), 0 20px 60px rgba(80, 48, 28, 0.08);
  }
}

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