:root {
  --bg: #f5f5f9; --card: #ffffff; --text: #1c1c28; --muted: #6b6b80; --line: #e4e4ee;
  --primary: #4f46e5; --primary-text: #ffffff; --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
  --radius: 14px; --shadow: 0 1px 3px rgba(20, 20, 50, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11111a; --card: #1c1c28; --text: #ececf4; --muted: #9a9ab2; --line: #2c2c3e; --primary: #7c75ff; --primary-text: #11111a; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; display: flex; justify-content: space-between; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.task { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 8px; }
.task .main { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task .meta { color: var(--muted); font-size: .85rem; }
.task.overdue { border-left: 4px solid var(--danger); }
.task.due_today { border-left: 4px solid var(--primary); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task.done { opacity: .7; }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.red { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.who { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: .7rem; font-weight: 700; vertical-align: middle; margin-right: 4px; }

.check { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--primary); background: transparent; color: var(--primary); font-size: 1.3rem; cursor: pointer; }
.check:active { background: var(--primary); color: var(--primary-text); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--primary); color: var(--primary-text); font-weight: 600; cursor: pointer; }
.btn.secondary { background: var(--line); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { padding: 6px 10px; font-size: .85rem; border-radius: 9px; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

label.f { display: block; font-size: .85rem; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
textarea { min-height: 80px; resize: vertical; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 8px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; user-select: none; }
.chip.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--text); }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.switch input[type=checkbox] { width: 22px; height: 22px; }
.switch input[type=time] { padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.notice { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--text); font-size: .9rem; margin: 10px 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px; }
.list-item .grow { flex: 1; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.mono { font-family: ui-monospace, monospace; font-size: .8rem; word-break: break-all; background: var(--line); padding: 8px; border-radius: 8px; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav.tabs a { flex: 1; text-align: center; padding: 10px 4px; color: var(--muted); text-decoration: none; font-size: .75rem; }
nav.tabs a b { display: block; font-size: 1.3rem; font-weight: 400; }
nav.tabs a.on { color: var(--primary); font-weight: 600; }
.fab { position: fixed; right: 18px; bottom: calc(80px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-text); font-size: 2rem; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.25); cursor: pointer; z-index: 6; }

#toast { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 616px; margin: 0 auto; background: #2b2b3c; color: #fff; border-radius: 12px; padding: 12px 14px; display: none; align-items: center; justify-content: space-between; gap: 12px; z-index: 20; }
#toast.show { display: flex; }
#toast button { background: none; border: 0; color: #a5a0ff; font-weight: 700; cursor: pointer; }
.center { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
