/* ---------- Tokens ---------- */
:root {
  --bg: #f6f6fb;
  --bg-glow-1: rgba(124, 92, 255, .12);
  --bg-glow-2: rgba(56, 189, 248, .10);
  --panel: rgba(255, 255, 255, .78);
  --panel-solid: #ffffff;
  --card: #ffffff;
  --card-hover: #fbfbff;
  --border: rgba(20, 20, 50, .08);
  --border-strong: rgba(20, 20, 50, .14);
  --text: #16161f;
  --text-2: #5b5b72;
  --text-3: #9393a8;
  --accent: #6d4aff;
  --accent-2: #3b82f6;
  --accent-soft: rgba(109, 74, 255, .10);
  --danger: #e5484d;
  --warn: #f59e0b;
  --ok: #22c55e;
  --p1: #3b82f6;
  --p2: #f59e0b;
  --p3: #e5484d;
  --shadow: 0 1px 2px rgba(20, 20, 50, .04), 0 8px 24px -12px rgba(20, 20, 50, .12);
  --shadow-lg: 0 24px 64px -16px rgba(20, 20, 50, .25);
  --radius: 14px;
  --sidebar-w: 268px;
  --drawer-w: 400px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b12;
    --bg-glow-1: rgba(124, 92, 255, .16);
    --bg-glow-2: rgba(56, 189, 248, .08);
    --panel: rgba(20, 20, 30, .72);
    --panel-solid: #14141e;
    --card: #15151f;
    --card-hover: #1a1a26;
    --border: rgba(255, 255, 255, .07);
    --border-strong: rgba(255, 255, 255, .13);
    --text: #ececf4;
    --text-2: #a3a3b8;
    --text-3: #6b6b82;
    --accent: #8b6dff;
    --accent-soft: rgba(139, 109, 255, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b12;
  --bg-glow-1: rgba(124, 92, 255, .16);
  --bg-glow-2: rgba(56, 189, 248, .08);
  --panel: rgba(20, 20, 30, .72);
  --panel-solid: #14141e;
  --card: #15151f;
  --card-hover: #1a1a26;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .13);
  --text: #ececf4;
  --text-2: #a3a3b8;
  --text-3: #6b6b82;
  --accent: #8b6dff;
  --accent-soft: rgba(139, 109, 255, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14.5px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background:
    radial-gradient(900px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd {
  font: 600 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 5px; border-radius: 5px;
  border: 1px solid var(--border-strong); color: var(--text-3); background: var(--card);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px 14px;
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 30;
}
/* Drag handle on the sidebar's right edge; the collapse button shows while hovering the sidebar. */
.sidebar-resizer { position: relative; flex: none; width: 0; z-index: 31; outline: none; }
.sidebar-resizer::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize;
}
.sidebar-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--accent);
  opacity: 0; transition: opacity .15s;
}
.sidebar-resizer:hover::after, .sidebar-resizer:focus-visible::after, body.resizing .sidebar-resizer::after { opacity: 1; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .sidebar, body.resizing .main { pointer-events: none; }
.sidebar-collapse {
  position: absolute; top: 74px; left: -12px; width: 24px; height: 24px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--panel-solid); border: 1px solid var(--border-strong); color: var(--text-2); box-shadow: var(--shadow);
  opacity: 0; transition: opacity .15s, color .15s;
}
.sidebar-collapse svg { width: 14px; height: 14px; }
.sidebar-collapse:hover { color: var(--accent); }
.sidebar:hover + .sidebar-resizer .sidebar-collapse,
.sidebar-resizer:hover .sidebar-collapse, .sidebar-collapse:focus-visible { opacity: 1; }
.sidebar-collapsed .sidebar, .sidebar-collapsed .sidebar-resizer { display: none; }
.sidebar-collapsed .menu-btn { display: inline-grid; margin-left: -6px; }

.brand { display: flex; align-items: center; gap: 0; padding: 0 0 14px; }
/* Three buttons next to the logo: keep them compact so the date underneath still fits. */
.brand .icon-btn { width: 26px; height: 30px; }
.brand-home {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  padding: 6px 2px 6px 4px; border: 0; border-radius: 12px; background: none; text-align: left;
  transition: background .15s;
}
.brand-home:hover { background: var(--accent-soft); }
.logo {
  flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px var(--accent);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.brand-home:hover .logo { transform: rotate(-6deg) scale(1.04); }
.logo svg { width: 24px; height: 24px; stroke-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.wordmark { font-size: 19px; font-weight: 800; letter-spacing: -.035em; color: var(--text); }
.wordmark span {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { margin-top: 2px; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub::first-letter { text-transform: uppercase; }
.theme-toggle { margin-left: auto; }

.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px; height: 36px; margin-bottom: 8px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-3);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
.search svg { width: 16px; height: 16px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px; border-radius: 9px; border: 0;
  background: none; color: var(--text-2); text-align: left; width: 100%;
  font-weight: 500; position: relative;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--accent-soft); color: var(--text); }
.nav-item.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.drop-target { background: var(--accent-soft); outline: 1.5px dashed var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 4px; }
.nav-item .proj-actions { display: none; gap: 2px; }
.nav-item:hover .proj-actions, .nav-item:focus-within .proj-actions { display: flex; }
.nav-item:hover .count { display: none; }
.nav-item input.rename {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-weight: 500; padding: 0;
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 4px 4px 10px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
}
.nav-item.sub { height: 32px; padding-left: 26px; font-size: 13.5px; }
.dot.client { border-radius: 4px; }
.nav-icon.muted { display: grid; place-items: center; width: 18px; color: var(--text-3); }
.nav-icon.muted svg { width: 15px; height: 15px; }
.nav-item.sub .nav-icon.muted svg { width: 13px; height: 13px; }
#groups .empty-hint { color: var(--text-3); font-size: 13px; padding: 6px 10px; }

.sidebar-foot {
  margin-top: auto; padding: 14px 6px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--text-3);
  border-top: 1px solid var(--border);
}
.foot-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; }
.foot-link:hover { color: var(--accent); }
.foot-link svg { width: 15px; height: 15px; }
.shortcuts kbd { padding: 2px 4px; }
.version { color: var(--text-3); text-decoration: none; font-variant-numeric: tabular-nums; }
.version:hover { color: var(--accent); }

/* ---------- Buttons ---------- */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: transparent; color: var(--text-3);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn.small { width: 24px; height: 24px; }
.icon-btn.small svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--danger); background: rgba(229, 72, 77, .1); }

.btn {
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--card); font-weight: 600;
  transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  border: 0; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -8px var(--accent);
}
.btn.primary:hover { box-shadow: 0 8px 22px -6px var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(229, 72, 77, .08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 36px clamp(16px, 5vw, 64px) 80px; }
.main > * { max-width: 780px; margin-left: auto; margin-right: auto; }

.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.heading { flex: 1; min-width: 0; }
.heading h1 { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -.03em; font-weight: 750; }
.heading p { margin: 4px 0 0; color: var(--text-2); }
.menu-btn { display: none; }

.progress[hidden] { display: none; }
.progress { position: relative; width: 52px; height: 52px; display: grid; place-items: center; }
.progress svg { position: absolute; inset: 0; width: 52px; height: 52px; transform: rotate(-90deg); }
.progress circle { fill: none; stroke-width: 4; }
.progress .track { stroke: var(--border-strong); }
.progress .bar {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 113.1; stroke-dashoffset: 113.1;
  transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1);
}
.progress span { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Composer ---------- */
.composer {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; margin-bottom: 26px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.composer .plus { color: var(--accent); display: grid; }
.composer input { flex: 1; min-width: 0; height: 36px; border: 0; outline: none; background: none; font-size: 15px; }
.composer input::placeholder { color: var(--text-3); }
.chips { flex-basis: 100%; display: none; gap: 6px; flex-wrap: wrap; padding: 0 0 4px 28px; }
.chips.show { display: flex; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.chip.neutral { background: var(--bg); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.chip svg { width: 13px; height: 13px; }

/* ---------- List ---------- */
.group { margin-bottom: 26px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  margin: 0 4px 8px; font-size: 12.5px; font-weight: 650; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
}
.group-head .n { color: var(--text-3); font-weight: 500; }
.group-head.overdue { color: var(--danger); }
.group-head button { background: none; border: 0; padding: 0; display: inline-flex; align-items: center; gap: 6px; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; }
.group-head .chev { width: 14px; height: 14px; transition: transform .2s; }
.group.collapsed .chev { transform: rotate(-90deg); }
.group.collapsed .todos { display: none; }

.todos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.todo {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 10px 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; position: relative;
  transition: background .12s, border-color .12s, box-shadow .2s, opacity .3s, transform .3s;
  animation: in .25s ease both;
}
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
.todo:hover { background: var(--card-hover); border-color: var(--border-strong); }
.todo.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.todo.dragging { opacity: .4; }
.todo.drag-over-top::before, .todo.drag-over-bottom::after {
  content: ""; position: absolute; left: 10px; right: 10px; height: 2px; border-radius: 2px; background: var(--accent);
}
.todo.drag-over-top::before { top: -5px; }
.todo.drag-over-bottom::after { bottom: -5px; }
.todo.leaving { opacity: 0; transform: translateX(12px); }

.check {
  --c: var(--text-3);
  flex: none; width: 22px; height: 22px; margin-top: 0; border-radius: 50%;
  border: 2px solid var(--c); background: transparent; padding: 0;
  display: grid; place-items: center; color: #fff;
  transition: background .15s, border-color .15s, transform .15s;
}
.check svg { width: 13px; height: 13px; stroke-width: 3.2; opacity: 0; transform: scale(.5); transition: opacity .15s, transform .2s cubic-bezier(.3, 1.6, .5, 1); }
.check:hover { background: color-mix(in srgb, var(--c) 14%, transparent); }
.check:hover svg { opacity: .6; transform: scale(1); stroke: var(--c); }
.p1 .check { --c: var(--p1); }
.p2 .check { --c: var(--p2); }
.p3 .check { --c: var(--p3); }
.todo.done .check, .todo.checking .check { background: var(--c); border-color: var(--c); }
.todo.done .check svg, .todo.checking .check svg { opacity: 1; transform: scale(1); stroke: #fff; }
.todo.checking .check { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.2); } }
.todo.done .check { --c: var(--text-3); }

.todo .body { flex: 1; min-width: 0; }
.todo .title { overflow-wrap: anywhere; font-weight: 500; padding-top: 1px; }
.todo.done .title, .todo.checking .title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.meta:empty { display: none; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta svg { width: 13px; height: 13px; }
.meta .dot { width: 8px; height: 8px; margin: 0; }
.meta .cat {
  height: 19px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  color: var(--text-2); border: 1px solid var(--border-strong);
}
.meta .due.today { color: var(--accent); font-weight: 600; }
.meta .due.overdue { color: var(--danger); font-weight: 600; }
.todo .row-act { opacity: 0; margin: -4px 0; }
.todo:hover .row-act, .todo .row-act:focus-visible { opacity: 1; }
.todo .row-act + .row-act { margin-left: -8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty .art {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), transparent); color: var(--accent);
  border: 1px solid var(--border);
}
.empty .art svg { width: 34px; height: 34px; stroke-width: 1.6; }
.empty h3 { margin: 0 0 4px; color: var(--text); font-size: 17px; }
.empty p { margin: 0; }

/* ---------- Drawer ---------- */
.drawer {
  width: 0; flex: none; overflow: hidden;
  background: var(--panel-solid); border-left: 1px solid var(--border);
  transition: width .28s cubic-bezier(.2, .8, .2, 1);
  z-index: 25;
}
.drawer.open { width: var(--drawer-w); }
.drawer-inner { width: var(--drawer-w); height: 100%; overflow-y: auto; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.drawer .drawer-inner.todo { align-items: stretch; gap: 18px; padding: 18px 22px 24px; }
.drawer .drawer-inner.todo:hover { background: none; }
.drawer-top { display: flex; align-items: center; gap: 8px; }
.drawer-top .spacer { flex: 1; }
.drawer-title-row { display: flex; gap: 12px; align-items: flex-start; }
.drawer-title-row .check { margin-top: 6px; }
.drawer textarea.title-input {
  flex: 1; border: 0; outline: none; background: none; resize: none; overflow: hidden;
  font-size: 20px; font-weight: 650; letter-spacing: -.02em; line-height: 1.35; padding: 0;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.input, .drawer select, .drawer input[type="date"] {
  height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--card); outline: none; width: 100%;
}
.input:focus, .drawer select:focus, .drawer input[type="date"]:focus, .drawer textarea.notes:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.drawer textarea.notes {
  min-height: 160px; padding: 12px; border-radius: 10px; resize: vertical;
  border: 1px solid var(--border-strong); background: var(--card); outline: none; line-height: 1.55;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.label-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text-2);
  transition: background .12s, color .12s, border-color .12s;
}
.label-pill svg { width: 13px; height: 13px; }
.label-pill:hover { border-color: var(--accent); color: var(--text); }
.label-pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.label-pill.add { border-style: dashed; color: var(--text-3); }
.date-row { display: flex; gap: 6px; flex-wrap: wrap; }
.date-row .pill { flex: none; }
.pill {
  height: 30px; padding: 0 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text-2);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.seg button {
  height: 32px; border: 0; border-radius: 8px; background: none; font-weight: 600; font-size: 13px; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button .dot { width: 8px; height: 8px; margin: 0; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.drawer .stamp { margin-top: auto; font-size: 12px; color: var(--text-3); }

/* ---------- Agenda ---------- */
.main.wide { padding-left: clamp(16px, 3vw, 40px); padding-right: clamp(16px, 3vw, 40px); }
.main.wide > * { max-width: 1500px; }
.view-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-tools:empty { display: none; }
.seg.mini { display: inline-grid; grid-template-columns: repeat(3, auto); padding: 3px; }
.seg.mini button { height: 28px; padding: 0 10px; font-size: 12.5px; }
/* Same pill as the week toggle, so the header's right edge lines up visibly with the composer. */
.nav-btns { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.nav-btns .icon-btn { width: 28px; height: 28px; }
.nav-btns .btn.small { height: 28px; border: 0; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: default; }

/* --tray is the side column; the header and composer above the agenda stop where the calendar stops. */
.main.wide { --tray: 260px; --tray-gap: 18px; --wd-h: 20px; }
.agenda { display: grid; grid-template-columns: minmax(0, 1fr) var(--tray); gap: var(--tray-gap); align-items: start; }
.main.wide .topbar,
.main.wide .composer {
  width: calc(min(100%, 1500px) - var(--tray) - var(--tray-gap));
  margin-left: max(0px, calc((100% - 1500px) / 2));
  margin-right: 0;
}
.cal { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .7fr)); gap: 6px; }
.cal.no-weekend { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cal-wd { height: var(--wd-h); line-height: var(--wd-h); padding: 0 8px; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.day {
  min-height: 118px; display: flex; flex-direction: column; gap: 4px;
  padding: 6px 6px 8px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
  transition: border-color .12s, background .12s;
}
.day.weekend { background: color-mix(in srgb, var(--card) 55%, transparent); }
.day.is-past .day-head { opacity: .55; }
.day.is-today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.day-head { display: flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 2px 0 4px; font-size: 12.5px; color: var(--text-2); }
.dname { display: none; }
.dnum { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.is-today .dnum { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: #fff; }
.dmonth { color: var(--text-3); }
.day-add {
  margin-left: auto; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px;
  display: grid; place-items: center; background: none; color: var(--text-3); opacity: 0;
}
.day:hover .day-add, .day-add:focus-visible { opacity: 1; }
.day-add:hover { background: var(--accent-soft); color: var(--accent); }
.day-add svg { width: 14px; height: 14px; }
.day .day-items, .tray .day-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }

.ag-item {
  display: flex; align-items: flex-start; gap: 6px; min-width: 0;
  padding: 4px 6px 4px 6px; border-radius: 7px; border-left: 3px solid var(--cc);
  background: var(--bg); font-size: 12.5px; line-height: 1.3; cursor: pointer;
  transition: background .12s, opacity .2s;
}
.ag-item:hover { background: var(--accent-soft); }
.ag-item.selected { box-shadow: 0 0 0 1.5px var(--accent); }
.ag-item.dragging { opacity: .4; }
.ag-item.done { opacity: .65; }
.ag-item.done .ag-title { text-decoration: line-through; color: var(--text-3); }
.ag-title {
  flex: 1; min-width: 0; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.tray .ag-title { -webkit-line-clamp: 3; }
.mini-check {
  --c: var(--text-3);
  flex: none; width: 14px; height: 14px; margin-top: 1px; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--c); background: none; display: grid; place-items: center;
}
.mini-check svg { width: 9px; height: 9px; stroke-width: 3.5; stroke: #fff; opacity: 0; }
.mini-check:hover { background: color-mix(in srgb, var(--c) 25%, transparent); }
.p1 .mini-check { --c: var(--p1); }
.p2 .mini-check { --c: var(--p2); }
.p3 .mini-check { --c: var(--p3); }
.ag-item.done .mini-check { --c: var(--text-3); background: var(--text-3); }
.ag-item.done .mini-check svg { opacity: 1; }
.day.drop-target, .tray-sec.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.day-input {
  width: 100%; height: 26px; padding: 0 7px; border-radius: 7px; outline: none;
  border: 1px solid var(--accent); background: var(--bg); font-size: 12.5px;
}

/* Start level with the first row of days, below the weekday labels. */
.tray { position: sticky; top: 0; margin-top: calc(var(--wd-h) + 6px); display: flex; flex-direction: column; gap: 14px; }
.tray-sec { padding: 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); }
.tray-sec h4 { margin: 0 2px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.tray-sec.overdue h4 { color: var(--danger); }
.tray-sec .n { color: var(--text-3); font-weight: 500; }
.tray-hint { margin: 0 2px; font-size: 12.5px; color: var(--text-3); }

@media (max-width: 1400px) {
  .agenda { grid-template-columns: minmax(0, 1fr); }
  .main.wide .topbar, .main.wide .composer { width: auto; margin-left: auto; margin-right: auto; }
  .tray { margin-top: 0; position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
}
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; }
  .view-tools { order: 3; width: 100%; justify-content: space-between; }
  .cal, .cal.no-weekend { grid-template-columns: minmax(0, 1fr); }
  .cal-wd { display: none; }
  .day { min-height: 0; }
  .day.weekend:not(.is-today) .day-items:empty { display: none; }
  .day.is-past:not(:has(.ag-item)) { display: none; }
  .agenda { display: flex; flex-direction: column; }
  .tray { order: -1; }
  .dname { display: inline; text-transform: capitalize; }
  .day-add { opacity: 1; }
}

/* ---------- Snooze menu ---------- */
.menu {
  position: fixed; z-index: 80; min-width: 230px; padding: 6px; border-radius: 12px;
  background: var(--panel-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: in .15s ease;
}
.menu-head { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.menu button {
  width: 100%; height: 34px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  border: 0; border-radius: 8px; background: none; font-size: 13.5px; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); outline: none; }
.menu-hint { font-size: 12px; color: var(--text-3); }
.ag-snooze {
  flex: none; width: 18px; height: 18px; margin: -1px -3px 0 0; padding: 0; border: 0; border-radius: 5px;
  display: grid; place-items: center; background: none; color: var(--text-3); opacity: 0;
}
.ag-item:hover .ag-snooze, .ag-snooze:focus-visible { opacity: 1; }
.ag-snooze:hover { color: var(--accent); background: var(--accent-soft); }
.ag-snooze svg { width: 13px; height: 13px; }
@media (hover: none) { .ag-snooze { opacity: 1; } }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); padding: 32px 28px 28px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
}
.login-card.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.login-sub { margin: 4px 0 22px; color: var(--text-2); }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field > span:first-child { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.login-field .input { height: 42px; font-size: 15px; }
.login-field .input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.remember { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; color: var(--text-2); font-size: 13.5px; cursor: pointer; }
.remember input { width: 16px; height: 16px; accent-color: var(--accent); }
.login-error {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
  color: var(--danger); background: rgba(229, 72, 77, .1); border: 1px solid rgba(229, 72, 77, .25);
}
.login-btn { width: 100%; height: 42px; font-size: 15px; }
.login-btn:disabled { opacity: .7; cursor: default; }

/* ---------- Toast & modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 10px 10px 16px; border-radius: 12px;
  background: #1c1c28; color: #f0f0f6; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s; z-index: 100;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: rgba(255, 255, 255, .1); color: #fff; height: 30px; padding: 0 12px; border-radius: 8px; font-weight: 600; }
.toast button:hover { background: rgba(255, 255, 255, .18); }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(5, 5, 15, .45); backdrop-filter: blur(4px); z-index: 90; padding: 16px; }
.modal[hidden] { display: none; }
.modal .box {
  width: min(400px, 100%); background: var(--panel-solid); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; box-shadow: var(--shadow-lg); animation: in .2s ease;
}
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--text-2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dlg-label { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; padding: 0; background-color: var(--sw); box-shadow: inset 0 0 0 2px var(--panel-solid); }
.swatch:disabled {
  cursor: not-allowed; opacity: .3;
  background-image: linear-gradient(135deg, transparent 44%, var(--panel-solid) 44% 56%, transparent 56%);
}
.modal .dlg-note { margin: 10px 0 0; font-size: 12.5px; color: var(--text-3); }
.swatch.on { border-color: var(--text); }

/* ---------- Settings ---------- */
.modal .box.settings { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px 22px 22px; }
.set-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.set-head h3 { margin: 0; }
.set-sec { padding: 14px 0 4px; }
.set-sec + .set-sec { border-top: 1px solid var(--border); margin-top: 10px; }
.set-sec h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; cursor: default; }
label.set-row { cursor: pointer; }
.set-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-label b { font-weight: 600; font-size: 14px; }
.set-label span { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
.set-row select.input { width: auto; min-width: 150px; flex: none; }
.set-row .seg.mini { flex: none; }
.set-note { margin: 8px 0 0 !important; font-size: 12.5px; color: var(--text-3) !important; }
.set-text { margin: 6px 0 0 !important; font-size: 13.5px; }
.set-text code { font-size: 12px; padding: 1px 5px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); }
.set-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.set-form { margin-top: 4px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); animation: in .15s ease; }
.set-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.set-field > span { font-size: 12px; font-weight: 600; color: var(--text-3); }
.set-error {
  margin: 0 0 10px !important; padding: 8px 10px; border-radius: 9px; font-size: 13px;
  color: var(--danger) !important; background: rgba(229, 72, 77, .1); border: 1px solid rgba(229, 72, 77, .25);
}
.set-error[hidden] { display: none; }

.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
@media (max-width: 520px) {
  .set-row:not(label) { flex-direction: column; align-items: stretch; gap: 8px; }
  .set-row select.input { width: 100%; }
}

.scrim { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .drawer { position: fixed; right: 0; top: 0; bottom: 0; box-shadow: var(--shadow-lg); }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .25s ease; background: var(--panel-solid); max-width: 86vw; }
  /* On a phone the sidebar is a slide-over menu: no drag handle, and "collapsed" doesn't apply. */
  .sidebar-collapsed .sidebar { display: flex; }
  .sidebar-resizer { display: none; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(5, 5, 15, .4); z-index: 20; }
  .menu-btn { display: inline-grid; margin-left: -6px; }
  .main { padding: 18px 16px 80px; }
  .heading h1 { font-size: 24px; }
  .composer .btn { display: none; }
  .drawer.open { width: 100%; }
  .drawer-inner { width: 100%; }
  .todo .row-act { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
