:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --text: #1d2321;
  --muted: #66706c;
  --line: #dfe3df;
  --accent: #155e63;
  --accent-ink: #ffffff;
  --accent-soft: #dcebea;
  --day: #b26a00;
  --day-soft: #fbeed9;
  --night: #3d4fa8;
  --night-soft: #e3e6f7;
  --finish: #a3361f;
  --finish-soft: #fbe5df;
  --ok: #2e7d4f;
  --radius: 16px;
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111514; --card: #1b2120; --text: #e9eeec; --muted: #9aa5a1; --line: #2c3533;
    --accent: #4fb3a9; --accent-ink: #062523; --accent-soft: #183433;
    --day: #f0b25a; --day-soft: #33281a; --night: #9aa8f2; --night-soft: #23284a;
    --finish: #f08b72; --finish-soft: #3a211b; --ok: #6fcf97;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom));
}
body.focus-mode { padding-bottom: 24px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; margin: 4px 0 2px; }
h2 { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.sub { color: var(--muted); margin: 0 0 8px; }
.hidden { display: none !important; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 8px 0; display: flex; gap: 12px; align-items: center; min-height: 64px; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 600; font-size: 18px; overflow-wrap: anywhere; }
.card .meta { color: var(--muted); font-size: 14px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.card .reason { font-size: 14px; color: var(--accent); margin-top: 3px; }
.card.tap { cursor: pointer; }
.check { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: grid; place-items: center; }
.check::after { content: ""; width: 14px; height: 8px; border: solid var(--muted); border-width: 0 0 3px 3px; transform: rotate(-45deg) translate(1px, -1px); opacity: .35; }
.check:active, .check.done { background: var(--ok); border-color: var(--ok); }
.check.done::after { border-color: #fff; opacity: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.tag.day { background: var(--day-soft); color: var(--day); }
.tag.night { background: var(--night-soft); color: var(--night); }

.finish { background: var(--finish-soft); border-color: transparent; }
.finish .title { color: var(--text); }
.finish .pct { font-size: 26px; font-weight: 800; color: var(--finish); flex: none; }
.finish .bar > i { background: var(--finish); }
.sec-day h2 { color: var(--day); }
.sec-night h2 { color: var(--night); }
.empty { color: var(--muted); padding: 14px 4px; }
.now-tag { color: var(--accent); }

/* Buttons */
.big { display: block; width: 100%; min-height: 64px; border: 0; border-radius: var(--radius); font-size: 19px; font-weight: 800; letter-spacing: .02em; margin: 10px 0; background: var(--accent); color: var(--accent-ink); }
.big.alt { background: var(--card); color: var(--accent); border: 2px solid var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; flex: 1 1 auto; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.sel { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 12px 4px; min-height: 44px; }
.minutes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.minutes .btn { min-height: 64px; font-size: 20px; }
.banner { background: var(--day-soft); color: var(--text); border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.banner b { flex: 1; }

/* Segmented tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.tabs button { flex: none; min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.tabs button.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tabs .n { opacity: .7; font-weight: 500; margin-left: 4px; }

/* Quick add bar */
.qa { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 10px 12px; background: var(--bg); border-top: 1px solid var(--line); z-index: 5; }
.qa form { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.qa input { flex: 1; min-width: 0; min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; }
.mic { width: 56px; height: 52px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.mic svg { width: 26px; height: 26px; }
.mic.listening { background: var(--finish); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.qa-inline { position: static; border: 0; padding: 0; background: none; }

/* Bottom nav */
nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 6; }
nav.tabbar a { display: grid; place-items: center; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .05em; }
nav.tabbar a svg { width: 24px; height: 24px; margin-bottom: -10px; }
nav.tabbar a.sel { color: var(--accent); }

/* Toast */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 86px + env(safe-area-inset-bottom)); max-width: 616px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 14px 12px 16px; display: flex; align-items: center; gap: 12px; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast .msg { flex: 1; }
.toast .msg small { display: block; opacity: .75; }
.toast button { background: none; border: 0; color: var(--bg); font-weight: 800; padding: 10px; min-height: 44px; }
body.focus-mode .toast { bottom: 20px; }

/* Sheet (task detail / edit) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 4px; font-size: 22px; overflow-wrap: anywhere; }
.sheet .close { float: right; }
label.f { display: block; margin: 12px 0 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.sheet input[type=text], .sheet input[type=date], .sheet input[type=number], .sheet select, .sheet textarea { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 8px 12px; }
.sheet textarea { min-height: 90px; }
input[type=range] { width: 100%; height: 44px; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.chips input { width: 18px; height: 18px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.grid2 > div { min-width: 0; }
details summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; color: var(--accent); cursor: pointer; }

/* Focus ("Just tell me") */
.focus { text-align: center; padding-top: 6vh; }
.focus .label { color: var(--muted); letter-spacing: .08em; font-weight: 700; font-size: 14px; }
.focus .task { font-size: 30px; font-weight: 800; margin: 12px 0; overflow-wrap: anywhere; }
.focus .why { color: var(--accent); font-weight: 600; }
.focus .step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 22px 0; text-align: left; }
.focus .step b { display: block; font-size: 13px; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.focus .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.focus .actions .wide { grid-column: span 2; }
.focus .actions .btn { min-height: 60px; font-size: 18px; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; padding: 16px; }
.login input { width: 100%; min-height: 52px; margin: 6px 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; }
.err { color: var(--finish); min-height: 24px; }

/* v1.1 */
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; text-align: center; }
.btn.small { flex: none; min-height: 44px; padding: 0 12px; font-size: 15px; }
.field { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 8px 12px; }
.warn { background: var(--finish-soft); color: var(--text); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.msgline { min-height: 24px; margin: 10px 0 0; font-weight: 600; }
.msgline.good { color: var(--ok); }
.msgline.bad { color: var(--finish); }
.ck { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px 10px; }
.ck-item { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.ck-item label { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; overflow-wrap: anywhere; }
.ck-item input { width: 22px; height: 22px; flex: none; accent-color: var(--ok); }
.ck-done { text-decoration: line-through; color: var(--muted); }
.ck-del { width: 44px; height: 44px; flex: none; border: 0; background: none; color: var(--muted); font-size: 18px; }
.ck .row { margin-top: 8px; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
