:root {
  --bg: #f4f5fb; --card: #ffffff; --ink: #1b1d2b; --mute: #6b7088; --line: #e6e8f2;
  --brand: #4f46e5; --brand-ink: #fff; --ok: #16a34a;
  --p1: #ef4444; --p2: #f59e0b; --p3: #22c55e;
  --shadow: 0 1px 2px rgba(20,22,50,.06), 0 4px 14px rgba(20,22,50,.05);
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1020; --card: #1a1c33; --ink: #eef0ff; --mute: #9a9fc0; --line: #2a2d4d; --brand: #818cf8; --brand-ink: #0f1020; --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.app { max-width: 1100px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px 120px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.sub { margin: 2px 0 0; color: var(--mute); font-size: 14px; }
.me { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; background: var(--card); border-radius: 999px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; flex: none; background: color-mix(in srgb, var(--c) 22%, var(--card)); box-shadow: inset 0 0 0 2px var(--c); }
.avatar.sm { width: 22px; height: 22px; font-size: 12px; box-shadow: inset 0 0 0 1.5px var(--c); }
.avatar.lg { width: 64px; height: 64px; font-size: 34px; box-shadow: inset 0 0 0 3px var(--c); }

.people { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.people::-webkit-scrollbar { display: none; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 600; white-space: nowrap; border: 2px solid transparent; min-height: 46px; }
.chip.all { padding-left: 14px; }
.chip.on { border-color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 12%, var(--card)); }
.chip.add { color: var(--mute); padding: 6px 14px; }

.summary { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 10px; overflow-x: auto; margin-bottom: 14px; }
.summary:empty { display: none; }
.stat { background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; border-left: 5px solid var(--c); }
.stat b { font-size: 20px; display: block; line-height: 1.1; }
.stat span { color: var(--mute); font-size: 12px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: color-mix(in srgb, var(--mute) 15%, transparent); padding: 4px; border-radius: 14px; margin-bottom: 14px; }
.seg button { padding: 10px; border-radius: 11px; font-weight: 700; color: var(--mute); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.count { font-weight: 600; font-size: 12px; background: var(--brand); color: var(--brand-ink); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.count:empty { display: none; }

.cols { display: block; }
.col { display: none; }
.col.show { display: block; }
@media (min-width: 900px) {
  .seg { display: none; }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
  .col { display: block; }
  .col::before { content: attr(data-title); display: block; font-size: 20px; font-weight: 800; margin: 0 0 10px; }
}

.group { margin-bottom: 18px; }
.group h3 { margin: 0 0 8px 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); display: flex; gap: 8px; align-items: center; }
.group h3.late { color: var(--p1); }
.group h3 .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

.task { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--r); padding: 10px 12px 10px 10px; margin-bottom: 8px; box-shadow: var(--shadow); border-left: 5px solid var(--pc); transition: transform .25s, opacity .25s; }
.task.done { opacity: .55; }
.task.pop { transform: scale(.97); opacity: .4; }
.check { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2.5px solid var(--line); display: grid; place-items: center; color: transparent; font-size: 22px; font-weight: 800; transition: .15s; background: transparent; }
.check:hover { border-color: var(--ok); }
.check:active { transform: scale(.9); }
.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.body { flex: 1; min-width: 0; text-align: left; padding: 2px 0; }
.title { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; }
.done .title { text-decoration: line-through; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--mute) 14%, transparent); color: var(--mute); }
.tag.late { background: color-mix(in srgb, var(--p1) 16%, transparent); color: var(--p1); }
.tag.today { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.tag.owner { padding-left: 3px; }

.empty { text-align: center; color: var(--mute); padding: 22px 16px; margin-bottom: 16px; background: var(--card); border-radius: var(--r); border: 2px dashed var(--line); }
.empty big { display: block; font-size: 34px; margin-bottom: 6px; }
.fold > summary { cursor: pointer; color: var(--mute); font-weight: 600; font-size: 13px; padding: 6px 4px 10px; list-style: none; }
.fold > summary::before { content: "▸ "; }
.fold[open] > summary::before { content: "▾ "; }

.fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + 20px); width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 36px; line-height: 1; box-shadow: 0 8px 24px rgba(79,70,229,.45); z-index: 5; display: grid; place-items: center; padding-bottom: 4px; }
.fab:active { transform: scale(.94); }

.scrim { position: fixed; inset: 0; background: rgba(10,12,30,.5); z-index: 10; }
.sheet { position: fixed; z-index: 11; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 26px 26px 0 0; padding: 12px 18px calc(env(safe-area-inset-bottom) + 22px); box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 640px) { .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; transform: translate(-50%, -50%); border-radius: 26px; animation: none; padding-bottom: 22px; } }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 14px; font-size: 21px; }
.field { margin-bottom: 14px; }
.field > label, .lbl { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; color: var(--mute); margin-bottom: 6px; }
input[type=text], input[type=date], input[type=number], select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 2px solid transparent; border-radius: 14px; padding: 12px 14px; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { padding: 10px 14px; min-height: 46px; border-radius: 14px; background: var(--bg); font-weight: 650; display: flex; align-items: center; gap: 8px; border: 2px solid transparent; }
.opt.on { border-color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 14%, var(--card)); }
.opt.grow { flex: 1; justify-content: center; }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }
.swatch { width: 40px; height: 40px; border-radius: 50%; background: var(--c); border: 3px solid var(--card); box-shadow: 0 0 0 2px transparent; }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.emo { width: 46px; height: 46px; border-radius: 14px; background: var(--bg); font-size: 24px; border: 2px solid transparent; }
.emo.on { border-color: var(--brand); }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { flex: 1; min-height: 52px; border-radius: 16px; font-weight: 750; background: var(--bg); }
.btn.primary { background: var(--brand); color: var(--brand-ink); flex: 2; }
.btn.danger { color: var(--p1); flex: 0 0 auto; padding: 0 18px; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-bottom: 8px; }
.who { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; border-radius: 20px; background: var(--bg); font-weight: 700; border: 2px solid transparent; position: relative; }
.who.on { border-color: var(--c); }
.who small { color: var(--mute); font-weight: 600; }
.who .edit { position: absolute; top: 6px; right: 8px; font-size: 14px; color: var(--mute); padding: 4px; }
.link { color: var(--brand); font-weight: 700; padding: 10px 0; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translateX(-50%); z-index: 20; background: var(--ink); color: var(--bg); border-radius: 16px; padding: 12px 16px; display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.3); width: max-content; max-width: calc(100vw - 32px); animation: up .2s ease-out; }
.toast button { color: var(--brand); font-weight: 800; filter: brightness(1.3) saturate(1.2); }
