:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #2c3330;
  --muted: #6c7470;
  --line: #e4e0d8;
  --accent: #4f8a72;        /* sage */
  --accent-ink: #ffffff;
  --accent-soft: #e3efe8;
  --lav: #7c70bd;
  --lav-soft: #ece9f7;
  --peach: #b8693a;
  --peach-soft: #f8e9dd;
  --sky-soft: #e4eef6;
  --sky: #3f6f93;
  --hero: linear-gradient(150deg, #e7f1ea 0%, #efeaf7 100%);
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16191b; --card: #1f2427; --ink: #e7e5e0; --muted: #9aa29e; --line: #2e3438;
    --accent: #7dbb9f; --accent-ink: #10201a; --accent-soft: #23352d;
    --lav: #aea4e6; --lav-soft: #2b2840; --peach: #e8a57a; --peach-soft: #3a2a20;
    --sky-soft: #1f2e3a; --sky: #9cc3e2;
    --hero: linear-gradient(150deg, #1f2f28 0%, #27243a 100%);
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16191b; --card: #1f2427; --ink: #e7e5e0; --muted: #9aa29e; --line: #2e3438;
  --accent: #7dbb9f; --accent-ink: #10201a; --accent-soft: #23352d;
  --lav: #aea4e6; --lav-soft: #2b2840; --peach: #e8a57a; --peach-soft: #3a2a20;
  --sky-soft: #1f2e3a; --sky: #9cc3e2;
  --hero: linear-gradient(150deg, #1f2f28 0%, #27243a 100%);
  --shadow: 0 1px 2px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.45rem; font-weight: 650; margin-bottom: 6px; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 26px 2px 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; margin-top: 32px; }
.lead { font-size: 1.1rem; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
}
.top h1 { font-size: 1.05rem; font-weight: 650; letter-spacing: .01em; flex: 1; }
.sync { width: 9px; height: 9px; border-radius: 50%; background: transparent; }
.sync[data-state="ok"] { background: var(--accent); }
.sync[data-state="wait"] { background: var(--lav); animation: pulse 1.2s ease-in-out infinite; }
.sync[data-state="off"] { background: var(--muted); opacity: .5; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 10px; color: var(--muted); display: grid; }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: .78rem; color: var(--muted); padding: 4px 0; border-radius: 12px; white-space: nowrap;
}
.tabs button span { font-size: 1.3rem; line-height: 1.2; filter: grayscale(.6); opacity: .75; transition: transform .2s; }
.tabs button[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabs button[aria-current="page"] span { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px;
  padding: 10px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 550;
  text-align: center;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; margin-top: 12px; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .9rem; }
.btn.dashed { width: 100%; border-style: dashed; background: transparent; color: var(--muted); margin-top: 14px; }
.btn:active { transform: scale(.98); }
.link { background: none; border: 0; color: var(--accent); font-weight: 550; padding: 8px 4px; }
.link.danger { color: var(--peach); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions .btn { flex: 1 1 auto; }
.actions.two { display: grid; grid-template-columns: 1fr 1fr; }
.actions.quiet { margin-top: 4px; }

textarea, input[type="date"], .add input {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px;
  resize: vertical; outline: none; box-shadow: var(--shadow);
}
textarea:focus, input:focus { border-color: var(--accent); }
#dump { min-height: 210px; margin-top: 10px; font-size: 1.02rem; }

.notice { background: var(--lav-soft); border-radius: 14px; padding: 10px 14px; font-size: .92rem; }
.gentle { margin-top: 26px; background: var(--peach-soft); border-radius: 14px; padding: 12px 14px; font-size: .92rem; }
.gentle .link { color: var(--peach); padding: 0 0 0 4px; }

/* Segmented choices */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  flex: 1 1 auto; min-height: 40px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: .92rem; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.seg.wide button { flex: 1 1 0; min-height: 44px; }
.energy { margin: 6px 0 16px; }
.label { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }

/* The "start here" card */
.hero {
  background: var(--hero); border-radius: 24px; padding: 20px 18px 12px; box-shadow: var(--shadow);
  animation: rise .35s ease-out;
}
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.hero h2 { font-size: 1.5rem; margin-bottom: 10px; overflow-wrap: anywhere; }
.step { background: var(--card); border-radius: 14px; padding: 10px 14px; margin: 12px 0 10px; }
.step span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--lav); font-weight: 700; margin-bottom: 2px; }
.enough { font-size: .93rem; }
.enough b { color: var(--accent); font-weight: 650; }
.worth { font-size: .88rem; color: var(--muted); margin: 0; }

/* Lists */
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 4px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 4px 8px 4px 4px; }
.item-main { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 10px 4px; display: grid; gap: 5px; }
.item-main.static { cursor: default; }
.item-title { font-weight: 520; overflow-wrap: anywhere; }
.tick {
  flex: none; width: 44px; height: 44px; border: 0; background: none; position: relative; border-radius: 50%;
}
.tick::before {
  content: ""; position: absolute; inset: 11px; border-radius: 50%; border: 2px solid var(--line);
  transition: background .2s, border-color .2s;
}
.tick:hover::before, .tick:active::before { border-color: var(--accent); background: var(--accent-soft); }
.tick.on { display: inline-block; }
.tick.on::before { background: var(--accent); border-color: var(--accent); }
.tick.on::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent-ink); font-size: .85rem; font-weight: 700; }
.item.won { opacity: .9; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--sky-soft); color: var(--sky); font-weight: 550; white-space: nowrap; }
.chip.soft { background: transparent; color: var(--muted); padding-left: 0; padding-right: 4px; }
.chip.today { background: var(--accent-soft); color: var(--accent); }
.chip.late { background: var(--peach-soft); color: var(--peach); }
.chip.decide { background: var(--lav-soft); color: var(--lav); }
.chip.people { background: var(--peach-soft); color: var(--peach); }

/* Wins */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.stat { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 8px; text-align: center; }
.stat b { display: block; font-size: 1.8rem; color: var(--accent); line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }

.past { margin-top: 26px; }
.past summary { color: var(--muted); font-size: .9rem; cursor: pointer; padding: 6px 0; }
.past-dump { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 10px 0; font-size: .92rem; }

.add { display: flex; gap: 8px; margin-top: 14px; }
.add input { flex: 1; min-width: 0; }

.empty, .sorting { text-align: center; padding-top: 48px; }
.calm, .breathe {
  width: 110px; height: 110px; margin: 0 auto 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent-soft), var(--lav-soft));
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent-soft) 50%, transparent);
}
.breathe { animation: breathe 4s ease-in-out infinite; }
.soft-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }

/* Item details, slides up from the bottom */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-body {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  animation: up .25s ease-out;
}
.sheet-top { display: flex; justify-content: flex-end; position: sticky; top: -8px; background: var(--bg); padding-top: 4px; z-index: 1; }
.field { display: block; margin: 0 0 16px; }
.field > span { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.title-input { font-size: 1.15rem; font-weight: 600; }
.due-row { display: flex; gap: 8px; align-items: center; }
.due-row input { flex: 1; min-width: 0; }
.note { background: var(--card); border-radius: 12px; padding: 8px 12px; margin-bottom: 6px; }
.note p { margin: 0 0 2px; }
.field .btn.small { margin-top: 8px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.sheet-actions .btn { flex: 1 1 auto; }
.decide-box { background: var(--lav-soft); border-radius: 18px; padding: 14px; margin-bottom: 18px; display: grid; gap: 10px; }
.decide-box label { font-weight: 600; }

/* 5-minute timer */
.timer { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; }
.timer[hidden] { display: none; }
.timer-body { width: 100%; max-width: 420px; text-align: center; }
.timer-body h2 { overflow-wrap: anywhere; }
.timer-body .step { text-align: left; }
.clock {
  --p: 100; width: 190px; height: 190px; margin: 22px auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--accent-soft) 0);
}
.clock b { width: 156px; height: 156px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 2.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer .actions { justify-content: center; flex-direction: column; }

/* Little celebration when something's done */
.cheer {
  position: fixed; left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 40;
  margin: 0 auto; max-width: 420px; background: var(--ink); color: var(--bg); border-radius: 18px; padding: 14px 18px 14px 58px;
  box-shadow: 0 8px 30px rgb(0 0 0 / .2); pointer-events: none;
}
.cheer[hidden] { display: none; }
.cheer p { margin: 0; font-weight: 550; }
.cheer.show { animation: pop 2.6s ease forwards; }
.bloom { position: absolute; left: 30px; top: 50%; width: 0; height: 0; }
.bloom i {
  position: absolute; width: 9px; height: 9px; border-radius: 50%; left: -4px; top: -4px; background: var(--accent);
  animation: burst .8s ease-out forwards;
}
.bloom i:nth-child(odd) { background: var(--lav); }
.bloom i:nth-child(3n) { background: var(--peach); }
.bloom i:nth-child(1) { --a: 0deg; } .bloom i:nth-child(2) { --a: 45deg; } .bloom i:nth-child(3) { --a: 90deg; } .bloom i:nth-child(4) { --a: 135deg; }
.bloom i:nth-child(5) { --a: 180deg; } .bloom i:nth-child(6) { --a: 225deg; } .bloom i:nth-child(7) { --a: 270deg; } .bloom i:nth-child(8) { --a: 315deg; }

@keyframes burst { from { transform: rotate(var(--a)) translateX(0) scale(1.2); opacity: 1; } to { transform: rotate(var(--a)) translateX(22px) scale(.3); opacity: 0; } }
@keyframes pop { 0% { transform: translateY(20px); opacity: 0; } 10%, 85% { transform: none; opacity: 1; } 100% { transform: translateY(10px); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes breathe { 0%, 100% { transform: scale(.85); } 50% { transform: scale(1.05); } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .cheer.show { opacity: 1; } }
