:root {
  --bg: #f6f5f1; --card: #ffffff; --soft: #efeee9; --line: rgba(0,0,0,.09); --line-strong: rgba(0,0,0,.2);
  --text: #1c1c1a; --text-2: #5f5e5a; --text-3: #8d8c86;
  --accent: #185fa5; --accent-bg: #e6f1fb; --accent-line: #85b7eb;
  --ok: #0f6e56; --ok-fill: #1d9e75; --ok-bg: #e1f5ee;
  --warn: #854f0b; --warn-fill: #ba7517; --warn-bg: #faeeda;
  --bad: #a32d2d; --bad-fill: #e24b4a; --bad-bg: #fcebeb;
  --veg: #639922; --night: #534ab7; --night-bg: #eeedfe;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --r: 10px; --r-lg: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1a; --card: #252524; --soft: #2e2e2c; --line: rgba(255,255,255,.1); --line-strong: rgba(255,255,255,.22);
    --text: #f1efe8; --text-2: #b4b2a9; --text-3: #888780;
    --accent: #85b7eb; --accent-bg: #0c2f52; --accent-line: #378add;
    --ok: #9fe1cb; --ok-fill: #1d9e75; --ok-bg: #0b3d31;
    --warn: #fac775; --warn-fill: #ba7517; --warn-bg: #4a2e07;
    --bad: #f7c1c1; --bad-fill: #e24b4a; --bad-bg: #5a1a1a;
    --night: #afa9ec; --night-bg: #26215c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; margin: 0; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.boot { padding: 40px; text-align: center; color: var(--text-3); }

.shell { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 4px 0 14px; }
.top .sub { color: var(--text-2); font-size: 13px; }
.muted { color: var(--text-3); } .sec { color: var(--text-2); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.ok-t { color: var(--ok); } .bad-t { color: var(--bad); } .warn-t { color: var(--warn); }
.serif { font-family: var(--serif); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin-bottom: 12px; }
.card > h2, .card > h3 { margin-bottom: 8px; }
.label { font-size: 12px; color: var(--text-2); margin: 14px 0 6px; letter-spacing: .02em; }
.label:first-child { margin-top: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.stack > * + * { margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--card); cursor: pointer; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-2); min-height: 36px; padding: 0 8px; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.hero { min-height: 76px; font-size: 18px; border-radius: var(--r-lg); flex-direction: column; gap: 2px; }
.btn.night { background: var(--night-bg); color: var(--night); border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn[aria-pressed="true"] { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-fill); }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--text-2); text-decoration: underline; cursor: pointer; font-size: 13px; }

input[type=number], input[type=time], input[type=date], input[type=text], input[type=password], textarea {
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%; }
textarea { min-height: 64px; resize: vertical; }
input:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.field-err { color: var(--bad); font-size: 13px; margin-top: 4px; }

.banner { border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.info { background: var(--accent-bg); color: var(--accent); }

.bar { height: 7px; border-radius: 4px; background: var(--soft); overflow: hidden; margin: 2px 0 10px; }
.bar > i { display: block; height: 100%; border-radius: 4px; }
.meter-head { display: flex; justify-content: space-between; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; font-size: 13px; background: var(--card); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }
.chip.x { cursor: default; } .chip.x button { border: 0; background: none; padding: 0 0 0 4px; cursor: pointer; color: var(--text-3); }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.bad { background: var(--bad-bg); color: var(--bad); } .tag.warn { background: var(--warn-bg); color: var(--warn); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tile { border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--card); padding: 8px 2px; text-align: center; cursor: pointer; font-size: 12px; line-height: 1.3; }
.tile .e { font-size: 22px; display: block; }
.tile .left { color: var(--text-3); font-size: 11px; }
.tile:active { transform: scale(.97); }

.item { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 8px; }
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { width: 84px; text-align: center; }
.stepper .btn { min-height: 40px; width: 40px; padding: 0; font-size: 18px; }

.check { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.check:first-child { border-top: 0; }
.check .box { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; font-size: 14px; }
.check.ok .box { background: var(--ok-fill); border-color: var(--ok-fill); color: #fff; }
.check.fail .box { border-color: var(--bad-fill); color: var(--bad); }
.check .meta { margin-left: auto; color: var(--text-3); font-size: 12px; text-align: right; }
.check button.box { cursor: pointer; background: var(--card); }

.meal { border-top: 1px solid var(--line); padding: 10px 0; }
.meal:first-child { border-top: 0; padding-top: 0; }
.meal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gratitude { font-family: var(--serif); color: var(--text-2); margin-top: 4px; }

.grid14 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.sq { aspect-ratio: 1; border-radius: 9px; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 13px; color: var(--text-2); background: var(--card); cursor: pointer; padding: 0; }
.sq.kept { background: var(--ok-fill); border-color: var(--ok-fill); color: #fff; }
.sq.broken { background: var(--bad-bg); border-color: var(--bad-fill); color: var(--bad); }
.sq.open { border-style: dashed; border-color: var(--warn-fill); color: var(--warn); }
.sq.today { outline: 2px solid var(--text); outline-offset: 1px; }
.sq.sel { box-shadow: 0 0 0 3px var(--accent-line); }
.sq.future { cursor: default; opacity: .6; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: var(--soft); border-radius: var(--r); padding: 10px; }
.stat .k { font-size: 12px; color: var(--text-2); } .stat .v { font-size: 20px; font-weight: 600; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--text-3); font-size: 10px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.nav a { flex: 1; max-width: 140px; text-align: center; text-decoration: none; color: var(--text-3); font-size: 12px; padding: 4px 0; border-radius: 8px; }
.nav a .i { display: block; font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: .75; }
.nav a.on { color: var(--text); } .nav a.on .i { filter: none; opacity: 1; }

.cols { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .nav { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); gap: 8px; }
  .nav a { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; padding: 8px 0; }
  .nav a .i { display: inline; font-size: 16px; }
  .nav a.on { background: var(--soft); }
  .shell { padding-bottom: 32px; }
}
.center { max-width: 420px; margin: 12vh auto 0; padding: 0 16px; }
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
code { font-size: 12px; word-break: break-all; background: var(--soft); padding: 2px 5px; border-radius: 5px; }
