:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1d1f23;
  --muted: #6c6f76;
  --line: #e6e1d8;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --soft: #edf5f2;
  --danger: #c23b30;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
  --heat0: #ebe6dc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --card: #202227; --ink: #ecebe8; --muted: #9a9ca3; --line: #30333a;
    --accent: #4cc2a0; --accent-ink: #0d1f1a; --soft: #1d2b27; --danger: #ef6b5f;
    --shadow: none; --heat0: #2a2d33; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 760px; margin: 0 auto; padding: 12px 16px 80px; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top h1 { font-size: 22px; margin: 4px 0 10px; letter-spacing: -.01em; }
.title-row { display: flex; align-items: center; justify-content: space-between; }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 6px; cursor: pointer; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.pop b { animation: pop .5s ease; }
@keyframes pop { 40% { transform: scale(1.25); color: var(--accent); } }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 14px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.tab.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab small { opacity: .6; margin-left: 4px; }

.add { display: flex; gap: 8px; align-items: flex-end; }
.add textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 11px 14px; min-height: 46px; max-height: 160px; outline: none; }
.add textarea:focus { border-color: var(--accent); }
.add-hint { font-size: 12px; color: var(--muted); margin: 6px 4px 0; min-height: 1em; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }

h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.ccard { background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; border-top: 4px solid var(--c); }
.ccard .name { font-weight: 600; }
.ccard .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.ccard .sub { font-size: 12px; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 26px; margin-top: 8px; }
.spark i { flex: 1; background: var(--c); border-radius: 2px; min-height: 2px; opacity: .85; }

.list { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--c, var(--muted)); background: none; cursor: pointer; margin-top: 1px; display: grid; place-items: center; padding: 0; }
.task.done .check { background: var(--c, var(--accent)); color: #fff; font-size: 14px; }
.task.done .ttext { color: var(--muted); text-decoration: line-through; }
.tbody { flex: 1; min-width: 0; cursor: pointer; }
.ttext { word-wrap: break-word; }
.meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.badge { background: var(--soft); color: var(--accent); border-radius: 6px; padding: 1px 6px; }
.empty { color: var(--muted); padding: 18px 14px; text-align: center; font-size: 14px; }
.more { width: 100%; background: none; border: 0; color: var(--muted); padding: 12px; cursor: pointer; font-size: 14px; }

.plan { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); overflow-x: auto; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--heat0); }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--accent) 35%, var(--heat0)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--accent) 60%, var(--heat0)); }
.heat i[data-l="3"] { background: var(--accent); }
.day { font-size: 13px; color: var(--muted); margin: 14px 4px 6px; }

.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-card { position: relative; background: var(--bg); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
.sheet-card h3 { margin: 0 0 12px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }
.code { font: 12px ui-monospace, Menlo, monospace; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px; word-break: break-all; user-select: all; }
.catrow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.catrow input { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px; min-width: 0; }
.catrow .e { width: 48px; text-align: center; }
.catrow .n { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 20; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 320px; display: grid; gap: 10px; text-align: center; }
.login .logo { font-size: 44px; }
.login h1 { margin: 0 0 8px; }
.login input { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px; }
.err { color: var(--danger); min-height: 1em; margin: 0; }
.wins .task.done .ttext { text-decoration: none; color: var(--ink); }
.btn.mic { font-size: 20px; padding: 9px 12px; }
.btn.mic.rec { background: var(--danger); border-color: var(--danger); animation: rec 1.2s ease-in-out infinite; }
@keyframes rec { 50% { opacity: .55; } }
.badge.warn { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.cal { flex: none; background: none; border: 1px solid var(--line); border-radius: 10px; width: 34px; height: 30px; cursor: pointer; filter: grayscale(1); opacity: .45; padding: 0; }
.cal.on { filter: none; opacity: 1; border-color: var(--accent); background: var(--soft); }
