:root {
  --paper: #f6f4ef;
  --card: #fffdf9;
  --ink: #1b1d1f;
  --muted: #676b6e;
  --faint: #9a9c9b;
  --line: #e4e0d6;
  --accent: #1f5c4a;
  --accent-ink: #ffffff;
  --accent-soft: #e3eee8;
  --warn: #9a6512;
  --warn-soft: #f7ecd6;
  --risk: #a63b2a;
  --risk-soft: #f6e1dc;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --gutter: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141615; --card: #1c1f1e; --ink: #ecebe6; --muted: #a3a6a2; --faint: #6f736f; --line: #2c302e;
    --accent: #7cc3a6; --accent-ink: #0e1a15; --accent-soft: #1e2d27;
    --warn: #e0b060; --warn-soft: #2d2618; --risk: #ec8a78; --risk-soft: #321e1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.public { padding-bottom: 0; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 34px; line-height: 1.12; }
h2 { font-size: 22px; line-height: 1.25; }
h3 { font-size: 17px; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 var(--gutter); }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 28px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; letter-spacing: 0.02em; }
.eyebrow { font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px var(--gutter) 6px; max-width: 640px; margin: 0 auto; }
.brand { font-family: var(--serif); font-size: 18px; text-decoration: none; }
.brand b { font-weight: 600; }
.iconbtn { position: relative; background: none; border: 0; padding: 8px; margin: -8px; color: var(--ink); cursor: pointer; border-radius: 10px; }
.iconbtn svg { width: 22px; height: 22px; display: block; }
.dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--risk); color: #fff; font-size: 11px; line-height: 16px; text-align: center; }

/* Bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 640px; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0 8px; font-size: 12px; text-decoration: none; color: var(--muted); }
.nav a svg { width: 22px; height: 22px; }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

main { padding: 10px 0 40px; }

/* Buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 15px; padding: 11px 16px; border-radius: 12px; cursor: pointer;
  min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding-left: 8px; padding-right: 8px; }
.btn.block { width: 100%; }
.btn.lg { font-size: 16px; padding: 14px 20px; min-height: 52px; }
.btn.danger { color: var(--risk); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .iconbtn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 46px;
}
textarea { resize: vertical; line-height: 1.5; }
textarea.goal { min-height: 170px; font-size: 18px; font-family: var(--serif); }
.field + .field { margin-top: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.flat { background: transparent; }
.card.accent { background: var(--accent-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.risk { background: var(--risk-soft); border-color: transparent; }
.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }

/* Today */
.today-head { padding: 14px 0 4px; }
.today-head .date { color: var(--muted); margin-top: 4px; }
.focus { font-family: var(--serif); font-size: 19px; line-height: 1.4; }
.task { padding: 18px; }
.task .proj { font-size: 12.5px; color: var(--muted); letter-spacing: 0.02em; }
.task .name { font-size: 18px; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.task .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.task .why { font-size: 14px; color: var(--muted); margin-top: 8px; }
.task.next { border-left: 3px solid var(--accent); }
.task.closed .name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.actions .btn { padding: 10px 6px; font-size: 14px; min-height: 42px; }
.note-box { margin-top: 12px; }
.note-box textarea { min-height: 70px; font-size: 15px; }
.reply { margin-top: 12px; font-size: 15px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.total { display: flex; justify-content: space-between; padding: 14px 18px; font-weight: 600; }
.pill { white-space: nowrap; display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.at_risk { background: var(--warn-soft); color: var(--warn); }
.pill.behind { background: var(--risk-soft); color: var(--risk); }
.pill.neutral { background: var(--line); color: var(--muted); }

/* Progress */
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stats > div { background: var(--card); padding: 14px 16px; }
.stats .k { font-size: 12.5px; color: var(--muted); }
.stats .v { font-size: 20px; font-family: var(--serif); margin-top: 2px; }
.big-num { font-family: var(--serif); font-size: 52px; line-height: 1; }

/* Timeline */
.tl-figure { font-family: var(--serif); font-size: 40px; line-height: 1.05; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.compare .v { font-family: var(--serif); font-size: 26px; }
ul.plain { margin: 6px 0 0; padding-left: 18px; }
ul.plain li + li { margin-top: 4px; }

/* Milestones */
details.ms { border-top: 1px solid var(--line); }
details.ms:first-child { border-top: 0; }
details.ms summary { list-style: none; cursor: pointer; padding: 16px 18px; display: flex; gap: 12px; align-items: baseline; justify-content: space-between; }
details.ms summary::-webkit-details-marker { display: none; }
details.ms .tasks > div { padding: 12px 18px 12px 30px; border-top: 1px dashed var(--line); font-size: 15px; }
.status-tag { font-size: 12px; color: var(--muted); white-space: nowrap; }
.status-tag.done { color: var(--accent); }
.status-tag.blocked { color: var(--risk); }

/* Loop steps on landing */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: 44px; }
.hero p.lede { font-size: 19px; color: var(--muted); margin-top: 16px; max-width: 34ch; }
.loop { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.loop li { counter-increment: step; display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.loop li::before { content: counter(step); font-family: var(--serif); font-size: 22px; color: var(--accent); }
.loop li b { display: block; }

/* Misc */
.loading { display: flex; gap: 12px; align-items: center; padding: 28px 0; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .bar > span { transition: none; } }
.error { color: var(--risk); font-size: 14px; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.event { padding: 12px 18px; }
.event .when { font-size: 12.5px; color: var(--faint); }
.tabs { display: flex; gap: 6px; }
.empty { text-align: center; padding: 40px 10px; }
.empty h2 { margin-bottom: 8px; }

@media (min-width: 720px) {
  h1 { font-size: 40px; }
  .hero h1 { font-size: 56px; }
}
.list a, a.card { text-decoration: none; display: block; color: inherit; }
.list a:hover { background: color-mix(in srgb, var(--card) 94%, var(--ink)); }
