:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --side: #efeee9;
  --text: #1b1c1e;
  --muted: #6b6e75;
  --faint: #9a9da3;
  --line: #e4e2dc;
  --hover: #f1f0ec;
  --accent: #1b1c1e;
  --accent-text: #ffffff;
  --danger: #c43d2f;
  --warn: #b26a00;
  --ok: #2f9e6b;
  --shadow: 0 8px 30px rgba(20, 20, 20, 0.08), 0 1px 3px rgba(20, 20, 20, 0.06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151618; --panel: #1d1f22; --side: #111214; --text: #ececec; --muted: #a0a3a9;
    --faint: #6f737a; --line: #2c2f33; --hover: #24272b; --accent: #ececec; --accent-text: #151618;
    --danger: #ef6b5b; --warn: #e3a23b; --ok: #4cc08b;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151618; --panel: #1d1f22; --side: #111214; --text: #ececec; --muted: #a0a3a9;
  --faint: #6f737a; --line: #2c2f33; --hover: #24272b; --accent: #ececec; --accent-text: #151618;
  --danger: #ef6b5b; --warn: #e3a23b; --ok: #4cc08b;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--faint); font-weight: 600; letter-spacing: .02em; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p { color: var(--muted); margin: 0 0 20px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); outline: none;
}
.input:focus { border-color: var(--muted); }
textarea.input { min-height: 110px; resize: vertical; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; font-weight: 500; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 10px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 14px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav-label button { border: 0; background: none; color: var(--faint); font-size: 16px; line-height: 1; padding: 0 2px; }
.nav-label button:hover { color: var(--text); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.06); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item .count.hot { color: var(--danger); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.side-foot button { margin-left: auto; border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: 12px; }

.main { min-width: 0; padding: 28px 40px 80px; max-width: 980px; width: 100%; }
.topbar { display: none; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.head .sub { color: var(--muted); font-size: 13px; width: 100%; margin-top: -8px; }
.head .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--hover); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 500; }

/* ---------- Quick add ---------- */
.quick { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 4px 4px 14px; margin-bottom: 22px; }
.quick:focus-within { border-color: var(--muted); }
.quick input { flex: 1; border: 0; outline: none; background: none; padding: 8px 0; min-width: 0; }
.quick .hint { color: var(--faint); font-size: 12px; white-space: nowrap; }

/* ---------- Sections & tasks ---------- */
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; gap: 8px; padding: 0 2px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.section-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.section-head .n { color: var(--faint); font-size: 13px; }
.section-head .tools { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.section:hover .tools, .section-head .tools:focus-within { opacity: 1; }
.icon-btn { border: 0; background: none; color: var(--muted); border-radius: 6px; padding: 3px 7px; font-size: 13px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.section.paused .section-head h2 { color: var(--muted); }
.tag-paused { font-size: 11px; color: var(--warn); border: 1px solid currentColor; border-radius: 99px; padding: 0 6px; }

.task { display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; border-radius: 8px; border-bottom: 1px solid transparent; }
.task:hover { background: var(--hover); }
.check { flex: none; width: 19px; height: 19px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--faint); background: none; padding: 0; position: relative; }
.check:hover { border-color: var(--text); }
.check.p1 { border-color: var(--warn); }
.check.p2 { border-color: var(--danger); border-width: 2px; }
.check.doing::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: conic-gradient(var(--muted) 0 50%, transparent 50% 100%); }
.check.done { background: var(--ok); border-color: var(--ok); }
.check.done::after { content: ""; position: absolute; left: 5.5px; top: 2.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.t-main { flex: 1; min-width: 0; cursor: pointer; }
.t-title { word-wrap: break-word; }
.task.is-done .t-title { color: var(--faint); text-decoration: line-through; }
.t-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.t-meta span { display: inline-flex; align-items: center; gap: 4px; }
.due.late { color: var(--danger); font-weight: 500; }
.due.today { color: var(--ok); font-weight: 500; }
.avatar { width: 20px; height: 20px; border-radius: 50%; background: var(--hover); border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: 10px; font-weight: 600; color: var(--muted); }
.t-note { color: var(--faint); }
.empty { color: var(--faint); padding: 10px 6px; font-size: 13px; }
.more { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 8px 6px; }
.more:hover { color: var(--text); }
.inline-add { display: flex; padding: 2px 6px; }
.inline-add input { flex: 1; border: 0; background: none; outline: none; padding: 6px 0 6px 29px; color: var(--muted); }
.inline-add input:focus { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 3px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--muted); }
.big-empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.big-empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 21; display: flex; flex-direction: column; animation: slide .18s ease-out; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head .src { font-size: 12px; color: var(--muted); }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer-title { width: 100%; font-size: 18px; font-weight: 600; border: 0; outline: none; background: none; padding: 0 0 14px; resize: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: 12px; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Team ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.member { display: grid; gap: 10px; }
.member-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.member-top .who { font-weight: 600; }
.member-top .mail { color: var(--muted); font-size: 13px; }
.badge { font-size: 11px; border-radius: 99px; padding: 1px 8px; background: var(--hover); color: var(--muted); }
.badge.admin { background: var(--accent); color: var(--accent-text); }
.badge.off { color: var(--danger); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; }
.invite-box { display: flex; gap: 8px; margin-top: 4px; }
.invite-box input { flex: 1; font-size: 12px; }
.note { color: var(--muted); font-size: 13px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--accent); color: var(--accent-text); padding: 9px 16px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 40; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast button { border: 0; background: none; color: inherit; text-decoration: underline; margin-left: 10px; pointer-events: auto; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .shell.menu-open .side { transform: none; }
  .shell.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 25; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; font-weight: 600; }
  .topbar button { border: 0; background: none; font-size: 20px; padding: 2px 6px; }
  .main { padding: 18px 16px 80px; }
  .head h1 { font-size: 20px; }
  .quick .hint { display: none; }
  .section-head .tools { opacity: 1; }
  .grid2 { grid-template-columns: 1fr; }
}
