:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #18202b; --muted: #687385; --line: #e3e6eb;
  --accent: #0f766e; --accent-soft: #e0f2ef; --late: #c2410c; --late-soft: #fdeee6;
  --no: #8a93a3; --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1318; --card: #181e26; --ink: #e8ecf1; --muted: #98a2b3; --line: #2a323d;
    --accent: #2dd4bf; --accent-soft: #123a36; --late: #fb923c; --late-soft: #3a2316; --no: #6b7584;
    --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: var(--accent); }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 10px; background: var(--bg); }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.topbar .home { color: var(--ink); text-decoration: none; min-width: 0; }
.topbar .home h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .actions { display: flex; align-items: center; gap: 8px; flex: none; }
.btn-new { background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; padding: 9px 14px; border-radius: 12px; white-space: nowrap; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-size: 18px; }
.icon-btn.active { color: var(--accent); border-color: var(--accent); }
.view { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(40px + env(safe-area-inset-bottom)); }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px; padding: 4px 0; }
.tabbar a .ico { display: block; font-size: 18px; line-height: 1.2; }
.tabbar a.active { color: var(--accent); font-weight: 600; }

.fab { position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 7; width: 56px; height: 56px;
  border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 30px; box-shadow: 0 6px 16px rgba(15,118,110,.35); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-title .meta { color: var(--muted); font-size: 14px; }

.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 2px 14px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

.list { padding: 0; margin: 0; list-style: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: transparent;
  display: grid; place-items: center; color: #fff; font-size: 15px; padding: 0; }
.check.done { background: var(--accent); border-color: var(--accent); }
.check.not_done { background: var(--no); border-color: var(--no); }
.row .body { flex: 1; min-width: 0; }
.row .ttl { font-weight: 550; overflow-wrap: anywhere; }
.row.done .ttl, .row.not_done .ttl { color: var(--muted); text-decoration: line-through; }
.row .sub { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.late { background: var(--late-soft); color: var(--late); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

.weekday { margin-top: 14px; }
.weekday h3 { font-size: 14px; color: var(--muted); margin: 0 4px 6px; text-transform: capitalize; font-weight: 600; }
.weekday h3.today { color: var(--accent); }

.pager { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 4px; }
.pager button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 6px 12px; font-size: 16px; }
.pager strong { font-size: 16px; text-transform: capitalize; }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 10px; }
.month .dow { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.month button { aspect-ratio: 1; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 15px; position: relative; }
.month button.out { color: var(--muted); opacity: .45; }
.month button.today { outline: 2px solid var(--accent); }
.month button.sel { background: var(--accent); color: #fff; }
.month button i { position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); }
.month button.sel i { background: #fff; }

form.stack { display: grid; gap: 14px; padding: 16px; }
label.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 99px; padding: 7px 13px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { border: 0; border-radius: 12px; padding: 13px 16px; font: inherit; font-weight: 600; background: var(--accent); color: #fff; width: 100%; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--late); border: 1px solid var(--line); }
.btn:disabled { opacity: .6; }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--late); font-size: 14px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.logo { width: 56px; height: 56px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 700; margin-bottom: 14px; }

.person { padding: 14px; display: grid; gap: 6px; }
.person + .person { border-top: 1px solid var(--line); }
.person .line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.person .pct { font-size: 20px; font-weight: 700; }
.person .stats { color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.stats .late { color: var(--late); }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet .panel { width: 100%; max-width: 640px; background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; max-height: 90vh; overflow: auto; }
.sheet .panel h3 { margin: 0 0 2px; }
.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: #18202b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
