:root {
  --bg: #F5F1E8; --surface: #FFFCF6; --surface-2: #EFE9DC; --line: #E6DECD;
  --ink: #26322A; --ink-2: #56645A; --muted: #8E9A91;
  --sage: #7E9F86; --sage-deep: #4E6E57; --sage-soft: #DDE8DE;
  --amber: #D2A35A; --amber-soft: #F4E7CD; --clay: #C37C60; --clay-soft: #F3DED4;
  --task: #8A9BB5;
  --r: 20px; --shadow: 0 1px 2px rgba(38,50,42,.04), 0 10px 28px -12px rgba(38,50,42,.12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; font: 15px/1.45 var(--sans); color: var(--ink); background: var(--bg);
  padding: 0 0 calc(84px + env(safe-area-inset-bottom)); max-width: 560px; margin-inline: auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--sage-deep); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font: 600 26px/1.15 var(--serif); letter-spacing: -.01em; }
h2 { font: 600 17px/1.2 var(--serif); }
h3 { font: 600 19px/1.2 var(--serif); }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; }
.muted { color: var(--muted); } .ink { color: var(--ink); } .small { font-size: 13px; } .center { text-align: center; display: block; margin-inline: auto; }
.err { color: var(--clay); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 6px; font-size: 12px; }

/* top + nav */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.brand { display: flex; gap: 8px; align-items: center; font: 600 18px var(--serif); color: var(--sage-deep); }
.topbar-r { display: flex; align-items: center; gap: 6px; }
.syncdot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); }
.syncdot[data-s=syncing] { background: var(--amber); animation: pulse 1s infinite; }
.syncdot[data-s=error] { background: var(--clay); } .syncdot[data-s=offline], .syncdot[data-s=signedout] { background: var(--line); outline: 1px solid var(--muted); }
@keyframes pulse { 50% { opacity: .35; } }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--ink-2); font-size: 20px; }
.icon-btn:active { background: var(--surface-2); } .icon-btn:disabled { opacity: .3; }
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 11px; border-radius: 14px; }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--sage-deep); } .nav a.on svg { stroke-width: 2.2; }

main { padding: 4px 14px 20px; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; margin: 12px 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; list-style: none; }
.card-h::-webkit-details-marker { display: none; }
details > summary { cursor: pointer; }
.sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 10px 0 4px; margin: 0; }
.linkish { color: var(--sage-deep); font-size: 13px; font-weight: 500; text-decoration: none; }
.linkish.center { margin: 2px auto 0; }
.pagehead { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 2px; }
.intro { margin: 6px 2px 10px; font-size: 14px; }
.banner { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; margin: 10px 0; font-size: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.banner.warn { background: var(--amber-soft); color: #6B5223; }

/* day header + ring */
.dayhead { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 0; }
.dh-mid { text-align: center; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--sage); font-weight: 600; }
.ringcard { padding: 10px 10px 12px; }
.ring { display: block; width: min(100%, 330px); margin: 0 auto; overflow: visible; }
.r-track { fill: none; stroke: var(--surface-2); stroke-width: 18; } .r-track.thin { stroke-width: 8; }
.r-tick { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.r-lbl { font-size: 10.5px; fill: var(--muted); text-anchor: middle; dominant-baseline: middle; }
.r-meal { fill: none; stroke-width: 18; stroke-linecap: round; stroke: var(--line); }
.r-meal.st-done { stroke: var(--sage); } .r-meal.st-partial { stroke: var(--amber); }
.r-meal.st-skipped, .r-meal.st-missed { stroke: var(--clay); opacity: .75; }
.r-meal.st-overdue { stroke: var(--clay); stroke-dasharray: 3 5; animation: pulse 2s infinite; }
.r-meal.st-pending, .r-meal.st-upcoming { stroke: #D7CFBE; }
.r-task { fill: none; stroke: var(--task); stroke-width: 8; stroke-linecap: round; opacity: .55; } .r-task.done { opacity: 1; }
.r-hand { stroke: var(--ink-2); stroke-width: 1.2; opacity: .25; } .r-now { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.r-big { font: 600 44px var(--serif); fill: var(--ink); text-anchor: middle; } .r-of { font-size: 22px; fill: var(--muted); }
.r-sub { font-size: 12px; fill: var(--muted); text-anchor: middle; letter-spacing: .1em; text-transform: uppercase; }
.r-sub2 { font-size: 13px; fill: var(--ink-2); text-anchor: middle; }
.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.lg::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; background: var(--sage); }
.lg.partial::before { background: var(--amber); } .lg.skipped::before { background: var(--clay); opacity: .75; }
.lg.overdue::before { background: none; border: 1.5px dashed var(--clay); width: 6px; height: 6px; } .lg.task::before { background: var(--task); }

/* rows */
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); cursor: pointer; }
.card-h + .row, .card > .row:first-child, .dayhdr + .row { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; gap: 8px; align-items: baseline; }
.name { font-weight: 550; }
.time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.menu, .meta { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meta { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.menu i { color: var(--muted); }
.why { display: inline-block; margin-top: 3px; font-size: 12px; color: var(--clay); }
.check { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1.8px solid var(--line); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; transition: .15s; }
.check.sq { border-radius: 9px; width: 26px; height: 26px; }
.st-done .check, .is-done .check { background: var(--sage); border-color: var(--sage); }
.st-partial .check { background: var(--amber); border-color: var(--amber); }
.st-skipped .check, .st-missed .check { background: var(--clay-soft); border-color: var(--clay-soft); color: var(--clay); }
.st-overdue .check { border-color: var(--clay); border-style: dashed; }
.is-done .name { text-decoration: line-through; color: var(--muted); font-weight: 450; }
.pill { flex: none; font-size: 11.5px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-weight: 500; }
.p-done { background: var(--sage-soft); color: var(--sage-deep); } .p-partial { background: var(--amber-soft); color: #7A5C25; }
.p-skipped, .p-missed { background: var(--clay-soft); color: #8E4F37; } .p-overdue { background: var(--clay); color: #fff; }
.dot-hi { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--clay); margin-right: 7px; vertical-align: 2px; }
.badge-miss { font-size: 11px; color: #8E4F37; background: var(--clay-soft); padding: 1px 7px; border-radius: 99px; }
.badge-late { font-size: 11px; color: #7A5C25; background: var(--amber-soft); padding: 1px 7px; border-radius: 99px; }
.carried { box-shadow: inset 3px 0 0 var(--clay), var(--shadow); }
.slot.off { opacity: .45; } .slot-time { width: 64px; flex: none; font-size: 13px; color: var(--sage-deep); font-weight: 600; font-variant-numeric: tabular-nums; }
.chev { color: var(--muted); font-size: 20px; }

/* inputs + buttons */
.in { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid transparent; border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .15s; }
.in:focus { border-color: var(--sage); background: var(--surface); }
textarea.in { resize: vertical; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
.mrow .lbl { margin: 0 0 2px; }
.btn { background: var(--sage-deep); color: #fff; border-radius: 14px; padding: 11px 18px; font-weight: 600; transition: transform .1s; text-align: center; }
.btn:active { transform: scale(.97); } .btn:disabled { opacity: .45; }
.btn.sm { padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.ghost { background: var(--surface-2); color: var(--ink); } .btn.ghost.danger { color: var(--clay); }
.btn.file { cursor: pointer; }
.btnrow { display: flex; gap: 10px; margin-top: 12px; } .btnrow .btn { flex: 1; }
.quickadd, .inline { display: flex; gap: 8px; margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.toggle { display: flex; gap: 10px; align-items: center; margin: 14px 0 4px; font-size: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--sage-deep); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { padding: 7px 13px; border-radius: 99px; background: var(--surface-2); font-size: 13.5px; color: var(--ink-2); transition: .15s; }
.chip.on { background: var(--sage-deep); color: #fff; } .chip.add { background: none; border: 1.5px dashed var(--line); }
.chips.static .chip.on { background: var(--sage-soft); color: var(--sage-deep); }
.wd-tabs, .range { margin: 8px 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.range .chip { flex: none; }
.wd-tabs { gap: 5px; } .wd-tabs .chip { flex: 1; padding: 7px 0; text-align: center; font-size: 13px; }
.quick-dates { margin-top: 8px; } .quick-dates .chip { padding: 5px 11px; font-size: 12.5px; }

/* money */
.mrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.amt { font: 600 19px var(--serif); font-variant-numeric: tabular-nums; }
.amt.t-in { color: var(--sage-deep); } .amt.t-out { color: var(--clay); }
.row .amt { font-size: 16px; }
.money-card.attn { box-shadow: inset 0 0 0 1.5px var(--clay), var(--shadow); }
.monthnav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0; font-family: var(--serif); font-size: 17px; }
.dayhdr { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 14px 0 2px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.card-h + .dayhdr { border-top: 0; padding-top: 4px; }
.tick { color: var(--sage-deep); }
.ticon { width: 34px; height: 34px; border-radius: 11px; background: var(--bg); display: grid; place-items: center; flex: none; }
.amount-in { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 14px 0 4px; font: 600 40px var(--serif); color: var(--clay); }
.amount-in[data-type=in] { color: var(--sage-deep); }
.amount-in input { width: 7ch; font: inherit; color: inherit; border: 0; background: none; outline: none; text-align: left; }
.seg2, .seg3 { display: grid; gap: 8px; background: var(--bg); padding: 4px; border-radius: 14px; }
.seg2 { grid-template-columns: 1fr 1fr; } .seg2 button { padding: 9px; border-radius: 11px; font-weight: 500; color: var(--ink-2); }
.seg2 button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg3 { grid-template-columns: repeat(3, 1fr); background: none; padding: 0; margin: 14px 0 4px; }
.big { padding: 16px 6px; border-radius: 16px; background: var(--bg); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px solid transparent; }
.big.ok.on { background: var(--sage-soft); border-color: var(--sage); color: var(--sage-deep); }
.big.mid.on { background: var(--amber-soft); border-color: var(--amber); color: #7A5C25; }
.big.bad.on { background: var(--clay-soft); border-color: var(--clay); color: #8E4F37; }
.cat { cursor: default; gap: 8px; } .in.emoji { width: 52px; text-align: center; flex: none; padding-inline: 4px; }
.catadd { display: flex; gap: 8px; margin-top: 12px; }

/* bars, heat, strip */
.bar { margin: 10px 0; } .bar-l { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; gap: 8px; }
.bar-l i { font-style: normal; }
.bar-t { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar-t i { display: block; height: 100%; background: var(--sage); border-radius: 99px; }
.bar-t.stack i { border-radius: 0; } .b-partial { background: var(--amber) !important; } .b-skip { background: var(--clay) !important; opacity: .7; }
.headline p { margin: 6px 0; font-size: 15px; } .headline b { color: var(--sage-deep); }
.heat { display: grid; gap: 4px; align-items: center; font-size: 12px; }
.hh { text-align: center; color: var(--muted); } .hr { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px; }
.hc { aspect-ratio: 1; border-radius: 7px; background: rgba(195, 124, 96, var(--a)); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.hc.na { background: var(--surface-2); }
.strip { display: flex; gap: 8px; margin-top: 4px; }
.strip-lbl { display: grid; grid-template-rows: repeat(3, 18px) 16px; gap: 4px; font-size: 11.5px; color: var(--muted); }
.strip-cols { flex: 1; display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; }
.strip-col { display: grid; grid-template-rows: repeat(3, 18px) 16px; gap: 4px; justify-items: center; align-items: center; }
.strip-col span { font-size: 10px; color: var(--muted); } .strip-col.now span { color: var(--ink); font-weight: 700; }
.dot { width: 14px; height: 14px; border-radius: 5px; background: var(--surface-2); display: block; }
.dot.hi { background: var(--sage); } .dot.md { background: var(--amber); } .dot.lo { background: var(--clay); opacity: .8; }

/* sheet + toast */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(38, 50, 42, .28); opacity: 0; transition: opacity .2s; }
.sheet { position: absolute; left: 50%; bottom: 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 6px 18px calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.sheet-wrap.open .sheet { transform: translate(-50%, 0); } .sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-grip { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 4px; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sheet-b > p:first-child { margin-top: 0; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; } .sheet-actions .btn { flex: 1; }
.reasons[hidden], [hidden] { display: none !important; }
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #F5F1E8; padding: 11px 16px; border-radius: 14px; font-size: 14px; display: flex; gap: 14px; align-items: center;
  z-index: 30; transition: .22s; max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { color: #BFD6C4; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
