:root {
  --bg: #F5F4FA; --surface: #FFFFFF; --text: #15141C; --muted: #6A687A;
  --accent: #5B3DF5; --on-accent: #FFFFFF; --accent-soft: #E3DCFF; --on-accent-soft: #2B1B96;
  --outline: #B9B6CC; --divider: #EEECF5; --inverse: #15141C; --on-inverse: #FFFFFF; --danger: #C62F2F;
  --shadow: 0 8px 24px rgba(30, 20, 90, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0E14; --surface: #1C1B24; --text: #F2F1F7; --muted: #A19FB4;
    --accent: #8A73FF; --on-accent: #120A3D; --accent-soft: #2E2566; --on-accent-soft: #E3DCFF;
    --outline: #55536A; --divider: #2A2934; --inverse: #F2F1F7; --on-inverse: #15141C; --danger: #FF7A7A;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0E14; --surface: #1C1B24; --text: #F2F1F7; --muted: #A19FB4;
  --accent: #8A73FF; --on-accent: #120A3D; --accent-soft: #2E2566; --on-accent-soft: #E3DCFF;
  --outline: #55536A; --divider: #2A2934; --inverse: #F2F1F7; --on-inverse: #15141C; --danger: #FF7A7A;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 600 15px/1.45 Manrope, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 28px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 28px; font-weight: 800; }
.login-card p { margin: 0; }
.logo { width: 40px; height: 40px; border-radius: 14px; background: var(--accent) url("/favicon.svg") center/cover; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, input.text { height: 46px; border-radius: 14px; border: 1.5px solid var(--divider); background: var(--bg); padding: 0 14px; color: var(--text); font-size: 15px; }
.field input:focus, input.text:focus { border-color: var(--accent); outline: none; }
.btn { height: 50px; border: 0; border-radius: 18px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 15px; padding: 0 22px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); }
.link { background: none; border: 0; color: var(--muted); padding: 6px 0; text-align: left; }
.link:hover { color: var(--text); }

/* Layout */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; height: 100%; }
.side { display: flex; flex-direction: column; gap: 4px; padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--divider); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 0 8px 18px; }
.brand .logo { width: 32px; height: 32px; border-radius: 11px; }
.nav-item { display: flex; align-items: center; gap: 12px; border: 0; background: none; height: 44px; border-radius: 14px; padding: 0 12px; color: var(--muted); font-weight: 700; text-align: left; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--text); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.sync { font-size: 12px; }
.theme { display: flex; background: var(--bg); border-radius: 12px; padding: 3px; }
.theme button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 6px 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.theme button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.main { overflow-y: auto; padding: 28px clamp(16px, 4vw, 48px) 80px; }
.main-inner { max-width: 760px; margin: 0 auto; }
.panel { width: 420px; background: var(--surface); border-left: 1px solid var(--divider); overflow-y: auto; padding: 18px 22px 28px; display: flex; flex-direction: column; }

/* Headers */
.head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.head .grow { flex: 1; min-width: 0; }
.head h1 { margin: 2px 0 0; font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); display: grid; place-items: center; flex: none; }
.icon-btn.flat { background: none; }
.icon-btn:hover { background: var(--accent-soft); }
.pill { height: 38px; padding: 0 15px; border-radius: 13px; border: 0; background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill:hover { background: var(--accent-soft); }
.pill.on { background: var(--inverse); color: var(--on-inverse); }
.pill.dashed { background: none; border: 1.5px dashed var(--outline); color: var(--muted); }
.pill .count { opacity: .55; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* Week strip */
.week { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; }
.week .days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { border: 0; background: none; border-radius: 22px; padding: 10px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 700; }
.day b { font-size: 17px; color: var(--text); font-weight: 800; }
.day:hover { background: var(--surface); }
.day.today, .day.today b { color: var(--accent); }
.day.on { background: var(--accent); color: var(--accent-soft); }
.day.on b { color: var(--on-accent); }
.dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.dot.has { background: var(--accent); }
.day.on .dot.has { background: var(--on-accent); }

/* List */
.sec { display: flex; align-items: baseline; gap: 12px; margin: 6px 4px 10px; }
.sec h2 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; }
.toggle { border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13px; display: inline-flex; gap: 4px; align-items: center; padding: 6px 8px; border-radius: 10px; }
.toggle:hover { color: var(--text); background: var(--surface); }
.toggle svg { width: 16px; height: 16px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.group-h { display: flex; align-items: center; gap: 8px; font-weight: 800; padding: 10px 4px 0; }
.group-h .muted { font-size: 13px; }
.tdot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--outline); }

.card { background: var(--surface); border-radius: 22px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 12px; border-radius: 22px; cursor: pointer; }
.row:hover { background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.row.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.tc { flex: 1; min-width: 0; }
.tt { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.done > .tt, .row.done .tt { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 6px; color: var(--muted); font-size: 13px; }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 15px; height: 15px; }
.chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }

.cb { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--outline); background: none; padding: 0; display: grid; place-items: center; color: var(--on-accent); flex: none; transition: background .15s, border-color .15s; }
.cb:hover { border-color: var(--accent); }
.cb.on { background: var(--accent); border-color: var(--accent); }
.cb svg { width: 16px; height: 16px; stroke-width: 3; }
.cb.sm { width: 22px; height: 22px; }
.cb.sm svg { width: 13px; height: 13px; }
.cb.sq { border-radius: 8px; }

.subs { margin: -4px 14px 8px 52px; }
.sub { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--divider); cursor: pointer; font-size: 14px; }
.sub .tt { font-size: 14px; font-weight: 600; flex: 1; }
.sub.done .tt { text-decoration: line-through; color: var(--muted); }
.sub .chev { color: var(--outline); }

.quick { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 22px; padding: 6px 8px 6px 18px; margin-bottom: 14px; }
.quick svg { color: var(--accent); }
.quick input { flex: 1; border: 0; background: none; height: 46px; outline: none; font-size: 16px; font-weight: 700; color: var(--text); }
.quick input::placeholder { color: var(--muted); font-weight: 600; }
.quick select { border: 0; background: var(--bg); border-radius: 12px; height: 36px; padding: 0 10px; color: var(--text); font-weight: 700; font-size: 13px; }
.quick input[type="date"] { flex: none; width: 150px; height: 36px; background: var(--bg); border-radius: 12px; padding: 0 10px; font-size: 13px; }

.banner { display: flex; gap: 14px; align-items: center; background: var(--accent-soft); color: var(--on-accent-soft); border-radius: 22px; padding: 14px 16px; border: 0; width: 100%; text-align: left; margin-top: 4px; }
.banner .ic { width: 40px; height: 40px; border-radius: 14px; background: var(--surface); display: grid; place-items: center; color: var(--accent); flex: none; }
.banner .tt { color: var(--text); }

.empty { text-align: center; padding: 40px 16px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; font-weight: 800; }
.empty p { margin: 0; color: var(--muted); }

/* Undated picker */
.picker { background: var(--surface); border-radius: 24px; padding: 18px; margin-top: 12px; box-shadow: var(--shadow); }
.picker h3 { margin: 0; font-size: 20px; font-weight: 800; }
.picker .rows { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; margin: 12px 0; }
.picker .prow { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; background: var(--bg); cursor: pointer; }
.picker .prow .tt { flex: 1; font-size: 15px; }
.picker .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Panel (task detail) */
.panel-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.crumb { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; padding: 4px 0; text-align: left; }
.crumb svg { width: 16px; height: 16px; }
.title-row { display: flex; gap: 12px; align-items: flex-start; margin: 8px 0 18px; }
.title-row .cb { width: 32px; height: 32px; margin-top: 4px; }
.title-input { flex: 1; border: 0; background: none; resize: none; font-size: 26px; line-height: 1.2; font-weight: 800; color: var(--text); padding: 0; outline: none; overflow: hidden; }
.props { background: var(--bg); border-radius: 20px; padding: 2px 14px; }
.prop { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-height: 52px; }
.prop + .prop { border-top: 1px solid var(--divider); }
.prop > svg { color: var(--muted); }
.prop label { flex: 1; }
.prop input[type="date"], .prop select { border: 0; background: var(--surface); border-radius: 12px; height: 36px; padding: 0 10px; color: var(--text); font-weight: 700; }
.lbl { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin: 22px 4px 10px; }
.progress { height: 6px; border-radius: 3px; background: var(--accent-soft); margin: -2px 4px 10px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); border-radius: 3px; }
.subbox { background: var(--bg); border-radius: 20px; padding: 2px 14px; }
.subbox .sub:first-child { border-top: 0; }
.add-sub { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--divider); }
.subbox .sub:first-child + .add-sub, .subbox > .add-sub:first-child { border-top: 0; }
.add-sub svg { color: var(--accent); }
.add-sub input { flex: 1; border: 0; background: none; height: 46px; outline: none; color: var(--text); font-weight: 700; }
.add-sub input::placeholder { color: var(--accent); }
.notes { width: 100%; min-height: 140px; border: 0; border-radius: 20px; background: var(--bg); padding: 14px 16px; resize: vertical; color: var(--text); line-height: 1.55; outline: none; }
.notes:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.panel-foot { margin-top: auto; padding-top: 22px; display: flex; gap: 8px; }
.panel-foot .btn { flex: 1; }
.danger { color: var(--danger) !important; }

/* Tags */
.tag-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.tag-row input.text { flex: 1; height: 40px; background: var(--bg); border-color: transparent; font-weight: 700; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 24px; height: 24px; border-radius: 50%; border: 0; padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--inverse); color: var(--on-inverse); padding: 12px 18px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); z-index: 10; display: flex; gap: 14px; align-items: center; }
.toast button { background: none; border: 0; color: var(--accent-soft); font-weight: 800; }

/* Narrow screens: side nav becomes a top bar, panel overlays. */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--divider); overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand span, .side-foot .sync, .side-foot .link { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
  .nav-item { padding: 0 10px; }
  .panel { position: fixed; inset: 0; width: auto; z-index: 5; }
  .head h1 { font-size: 28px; }
  .quick { flex-wrap: wrap; }
}
