:root {
  --bg: #f5f3ee; --surface: #ffffff; --surface-2: #ece9e1; --text: #1d2321; --muted: #66706c; --line: #ddd9cf;
  --accent: #256f5c; --accent-text: #ffffff; --accent-soft: #dcede7;
  --warn: #a35c00; --warn-soft: #fbead0; --bad: #b3261e; --bad-soft: #f9dcd9; --ok: #256f5c;
  --radius: 16px; --gap: 12px;
  --top-h: 52px; --capture-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --surface: #1c2220; --surface-2: #262e2b; --text: #e8ece9; --muted: #96a19c; --line: #2f3936;
    --accent: #5cc4a4; --accent-text: #0b1512; --accent-soft: #1d3a31;
    --warn: #f0b45a; --warn-soft: #3a2b12; --bad: #f2897f; --bad-soft: #3b1e1b; --ok: #5cc4a4;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: calc(var(--top-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--capture-h) + env(safe-area-inset-bottom) + 16px);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
h3 { font-size: 1rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

.top {
  position: fixed; inset: 0 0 auto 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.2rem; flex: 1; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.4rem; width: 44px; height: 44px; border-radius: 12px; cursor: pointer; }
.icon-btn:active { background: var(--surface-2); }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 0; }

.capture {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; gap: 8px; align-items: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.capture input { flex: 1; min-width: 0; }

/* controls */
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%; min-height: 46px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }
button, .btn {
  font: inherit; font-weight: 600; min-height: 46px; padding: 0 18px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
button.danger { color: var(--bad); }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.small { min-height: 38px; padding: 0 12px; font-size: .9rem; }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: var(--gap); }

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card + .card, .list > * + * { margin-top: 10px; }
.card.tone-warn { background: var(--warn-soft); border-color: transparent; }
.card.tone-bad { background: var(--bad-soft); border-color: transparent; }
.card.done { opacity: .55; }
.card .title { font-weight: 600; }
.chip {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.ok { background: var(--accent-soft); color: var(--ok); }
button.chip { min-height: 32px; border: 0; cursor: pointer; }
button.chip.on { background: var(--accent); color: var(--accent-text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* today */
.today-card { padding: 18px; }
.today-card .title { font-size: 1.2rem; }
.today-card .first-step { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); }
.today-card .first-step b { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ok); }
.today-card .actions { display: flex; gap: 8px; margin-top: 14px; }
.today-card .actions .primary { flex: 2; }
.today-card .actions button:not(.primary) { flex: 1; }
.more-link { display: block; text-align: center; margin: 22px 0 0; color: var(--muted); }
.hero { text-align: center; padding: 18px 8px 4px; }
.hero .big { font-size: 2rem; font-weight: 700; color: var(--ok); }

/* sheets & toasts */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet > h2 { margin-top: 0; }
.menu a { display: flex; justify-content: space-between; padding: 14px 8px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); font-weight: 500; }
.menu a.current { color: var(--accent); font-weight: 700; }
#toasts { position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(var(--capture-h) + env(safe-area-inset-bottom) + 14px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: 520px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.error { background: var(--bad); color: #fff; }

.thumb { width: 96px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
.check { width: 28px; height: 28px; min-height: 28px; padding: 0; border-radius: 50%; flex: none; border: 2px solid var(--muted); background: none; }
.check.on { background: var(--accent); border-color: var(--accent); }
.day-head { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.unknown { color: var(--warn); font-weight: 600; }
.pre { white-space: pre-wrap; }
