/* Projects Manager — design system (no framework). */
[x-cloak] { display: none !important; }

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e3e6ec;
  --border-strong: #cfd4dc;
  --text: #161a23;
  --text-2: #4a5160;
  --muted: #7a8291;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #3f37c9;
  --on-accent: #ffffff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warning: #d97706;
  --warning-soft: #fdf3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #2563eb;

  --st-idea: #64748b;
  --st-planning: #7c3aed;
  --st-active: #16a34a;
  --st-paused: #d97706;
  --st-completed: #2563eb;
  --st-archived: #a8a29e;

  --sidebar-bg: #11141b;
  --sidebar-text: #c3c8d2;
  --sidebar-muted: #7d8494;
  --sidebar-hover: #1c2029;
  --sidebar-active: #262b36;

  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 14px;
  --shadow-s: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-l: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1016;
    --surface: #151922;
    --surface-2: #1a1f29;
    --surface-3: #222833;
    --border: #262c38;
    --border-strong: #343b49;
    --text: #e8ebf1;
    --text-2: #b4bac6;
    --muted: #7f8798;
    --accent: #6d68f5;
    --accent-hover: #807bff;
    --accent-soft: #23234a;
    --accent-text: #a8a5ff;
    --success-soft: #12291c;
    --warning-soft: #2e2213;
    --danger-soft: #331618;
    --st-idea: #8592a6;
    --st-archived: #78716c;
    --sidebar-bg: #0a0c11;
    --sidebar-hover: #151922;
    --sidebar-active: #1d222c;
    --shadow-s: none;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-l: 0 16px 40px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1016; --surface: #151922; --surface-2: #1a1f29; --surface-3: #222833;
  --border: #262c38; --border-strong: #343b49; --text: #e8ebf1; --text-2: #b4bac6; --muted: #7f8798;
  --accent: #6d68f5; --accent-hover: #807bff; --accent-soft: #23234a; --accent-text: #a8a5ff;
  --success-soft: #12291c; --warning-soft: #2e2213; --danger-soft: #331618;
  --st-idea: #8592a6; --st-archived: #78716c;
  --sidebar-bg: #0a0c11; --sidebar-hover: #151922; --sidebar-active: #1d222c;
  --shadow-s: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-l: 0 16px 40px rgba(0, 0, 0, .55);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-size: .85em; }
code { background: var(--surface-3); padding: .1em .4em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--surface-3); padding: .75rem 1rem; border-radius: var(--radius-s); overflow-x: auto; }
pre code { background: none; padding: 0; }
small { font-size: .82em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.s { width: 14px; height: 14px; }
svg.i.l { width: 20px; height: 20px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- form controls ---------- */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: .5rem .7rem;
  transition: border-color .12s, box-shadow .12s;
}
input:not([type=checkbox]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; line-height: 1.5; }
select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8291' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; background-size: 14px;
}
input[type=checkbox] {
  appearance: none; width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer;
  border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface);
  display: inline-grid; place-content: center; transition: background .12s, border-color .12s;
}
input[type=checkbox]::after {
  content: ""; width: 10px; height: 6px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform .12s;
}
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }
input[type=checkbox][role=switch] { width: 34px; height: 20px; border-radius: 999px; place-content: center start; padding: 2px; }
input[type=checkbox][role=switch]::after {
  width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--border-strong);
  transform: none; transition: transform .15s, background .15s;
}
input[type=checkbox][role=switch]:checked::after { background: #fff; transform: translateX(14px); }

label { display: block; font-weight: 550; font-size: .85rem; color: var(--text-2); margin-bottom: .9rem; }
label > input:not([type=checkbox]), label > select, label > textarea { margin-top: .35rem; font-weight: 400; }
label.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 500; cursor: pointer; }
label.check input { margin-top: 1px; }
.field-hint { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
fieldset { border: 0; padding: 0; margin: 0; }

/* ---------- buttons ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; white-space: nowrap;
  font: inherit; font-weight: 550; font-size: .875rem; line-height: 1; cursor: pointer;
  padding: .55rem .9rem; border-radius: var(--radius-s); border: 1px solid transparent;
  background: var(--accent); color: var(--on-accent); transition: background .12s, border-color .12s, color .12s, opacity .12s;
  text-decoration: none;
}
.btn:hover, button:hover { background: var(--accent-hover); text-decoration: none; }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary, button.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-s); }
.btn.secondary:hover, button.secondary:hover { background: var(--surface-2); }
.btn.ghost, button.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger, button.danger { background: var(--surface); color: var(--danger); border-color: var(--border-strong); }
.btn.danger:hover, button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.ghost.danger { background: transparent; border-color: transparent; }
button.ghost.danger:hover { background: var(--danger-soft); }
.btn.sm, button.sm { padding: .38rem .6rem; font-size: .8rem; }
.btn.icon, button.icon { padding: .4rem; }
.btn.icon.sm, button.icon.sm { padding: .3rem; }
.btn.block, button.block { width: 100%; }

[aria-busy=true]::before {
  content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- utilities ---------- */
.row { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.gap-xs { gap: .25rem; } .gap-s { gap: .5rem; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.ok-text { color: var(--success); }
.mono { font-family: var(--mono); font-size: .85rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 1rem; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text); padding: 1rem .75rem; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1.25rem; color: #fff; font-weight: 700; font-size: 1rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.nav-section { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 1rem .6rem .4rem; }
.nav-item {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: var(--radius-s);
  color: var(--sidebar-text); font-weight: 500; font-size: .875rem;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .nav-type { display: inline-flex; flex: none; color: var(--sidebar-muted); }
.nav-item:hover .nav-type, .nav-item.active .nav-type { color: inherit; }
.nav-item .count { margin-left: auto; font-size: .75rem; color: var(--sidebar-muted); font-variant-numeric: tabular-nums; }
.nav-projects { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label { display: flex; align-items: center; gap: .45rem; font-size: .72rem; color: var(--sidebar-muted); padding: .55rem .6rem .2rem; text-transform: capitalize; }
.nav-project { display: flex; align-items: center; gap: .6rem; padding: .85rem .6rem .25rem; }
.nav-project .avatar { width: 34px; height: 34px; font-size: .8rem; }
.nav-project-title { color: #fff; font-weight: 650; font-size: .95rem; }
.nav-project .nav-group-label { padding: .15rem 0 0; }
.tabs.project-tabs { display: none; }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--sidebar-active); display: flex; flex-direction: column; gap: 1px; }
.sidebar-backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: .75rem 2rem; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: .4rem; font-size: .875rem; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs strong { color: var(--text); font-weight: 600; }
.topbar .search { position: relative; margin-left: auto; width: min(320px, 40vw); }
.topbar .search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar .search input { padding-left: 2.1rem; background: var(--surface); }
.menu-btn { display: none; }
.busy-dot { width: 16px; color: var(--accent); }
.content { padding: 1.75rem 2rem 4rem; width: 100%; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
  box-shadow: var(--shadow-s); padding: 1.25rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.card-head h3, .card-head h4 { margin: 0; }
.card-title { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }

/* KPI tiles */
.kpi-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; }
.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-violet { background: color-mix(in srgb, var(--st-planning) 14%, transparent); color: var(--st-planning); }
.tone-info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }

/* status distribution */
.dist-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.dist-bar span { display: block; height: 100%; cursor: pointer; transition: opacity .12s; }
.dist-bar.filtered span:not(.on) { opacity: .25; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .85rem; }
.legend button {
  background: transparent; color: var(--text-2); border: 1px solid var(--border); font-weight: 500;
  padding: .32rem .65rem; border-radius: 999px; font-size: .8rem;
}
.legend button:hover { background: var(--surface-2); }
.legend button.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent-text); }
.legend b { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--st-idea); }
.dot.idea, .bg-idea { background: var(--st-idea); }
.dot.planning, .bg-planning { background: var(--st-planning); }
.dot.active, .bg-active { background: var(--st-active); }
.dot.paused, .bg-paused { background: var(--st-paused); }
.dot.completed, .bg-completed { background: var(--st-completed); }
.dot.archived, .bg-archived { background: var(--st-archived); }

/* pills / badges */
.pill {
  --c: var(--st-idea);
  display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap; text-transform: capitalize;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill svg.i.s { width: 12px; height: 12px; }
.pill.idea { --c: var(--st-idea); } .pill.planning { --c: var(--st-planning); } .pill.active { --c: var(--st-active); }
.pill.paused { --c: var(--st-paused); } .pill.completed { --c: var(--st-completed); } .pill.archived { --c: var(--st-archived); }
.pill.draft { --c: var(--st-idea); }
.pill.open { --c: var(--info); } .pill.applied { --c: var(--success); } .pill.discarded { --c: var(--st-archived); }
.pill.p-high { --c: var(--danger); } .pill.p-medium { --c: var(--warning); } .pill.p-low { --c: var(--st-idea); }

/* select styled as pill */
select.pill-select {
  --c: var(--st-idea);
  width: auto; padding: .28rem 1.7rem .28rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  text-transform: capitalize; color: var(--c); background-color: color-mix(in srgb, var(--c) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--c) 30%, transparent); background-position: right .5rem center; background-size: 12px;
}
select.pill-select.idea { --c: var(--st-idea); } select.pill-select.planning { --c: var(--st-planning); }
select.pill-select.active { --c: var(--st-active); } select.pill-select.paused { --c: var(--st-paused); }
select.pill-select.completed { --c: var(--st-completed); } select.pill-select.archived { --c: var(--st-archived); }
select.pill-select.draft { --c: var(--st-idea); }
select.pill-select.p-high { --c: var(--danger); } select.pill-select.p-medium { --c: var(--warning); } select.pill-select.p-low { --c: var(--st-idea); }
select.pill-select.xs { padding: .12rem 1.4rem .12rem .5rem; font-size: .7rem; background-position: right .4rem center; background-size: 10px; }
select.pill-select option { color: var(--text); background: var(--surface); }

/* progress */
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s; }
.progress.done > span { background: var(--success); }
.progress.lg { height: 8px; }
.progress-row { display: flex; align-items: center; gap: .6rem; }
.progress-row .progress { flex: 1; }
.progress-row small { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.6rem; text-align: right; }

/* toolbar + segmented */
.toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 1.75rem 0 1rem; }
.toolbar h2 { margin: 0; font-size: 1.05rem; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 8px; gap: 2px; }
.segmented button { background: transparent; color: var(--muted); padding: .35rem .55rem; border-radius: 6px; }
.segmented button:hover { background: transparent; color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented.sm button { padding: .2rem .5rem; font-size: .8rem; }

/* Markdown editors: Write / Preview */
.md-toggle { margin-bottom: .5rem; }
.field { margin-bottom: var(--pico-spacing, 1rem); font-weight: 500; }
.field-head { justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.field-head .md-toggle { margin-bottom: 0; }
.md-preview { min-height: 6.5rem; max-height: 22rem; overflow: auto; padding: .75rem 1rem; margin-bottom: var(--pico-spacing, 1rem);
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-weight: 400; }
.md-preview.tall { min-height: 24rem; max-height: 60vh; }

.board-search { position: relative; display: flex; align-items: center; margin: 0; flex: 0 1 12rem; min-width: 8rem; }
.board-search .i { position: absolute; left: .55rem; color: var(--muted); pointer-events: none; }
.board-toolbar .board-search input[type=search] {
  width: 100%; margin: 0; padding: .3rem .6rem .3rem 1.8rem; padding-inline-start: 1.8rem; font-size: .82rem; height: auto;
  background-image: none; border-radius: var(--radius-s);
}
/* pasted images in to-do notes */
.notes-preview { min-height: 0; max-height: 16rem; }
.md img { max-width: 100%; height: auto; border-radius: var(--radius-s); }
.link-btn { all: unset; cursor: pointer; margin-left: .4rem; font-size: .78rem; font-weight: 500; color: var(--accent-text); }
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--accent); }

/* project grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.pcard { display: flex; flex-direction: column; gap: .75rem; cursor: pointer; position: relative; transition: border-color .12s, box-shadow .12s, transform .12s; }
.pcard:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); }
.pcard-top { display: flex; align-items: flex-start; gap: .75rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: .95rem; color: #fff; text-transform: uppercase;
}
.pcard h3 { margin: 0; font-size: .98rem; }
.pcard .desc {
  color: var(--text-2); font-size: .85rem; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pcard .meta { display: flex; align-items: center; gap: .9rem; font-size: .78rem; color: var(--muted); padding-top: .75rem; border-top: 1px solid var(--border); }
.pcard .meta span { display: inline-flex; align-items: center; gap: .3rem; }
.pcard .meta .updated { margin-left: auto; }
.card-actions { display: flex; gap: 0; margin: -.3rem -.4rem -.3rem 0; opacity: 0; transition: opacity .12s; }
.pcard:hover .card-actions, .pcard:focus-within .card-actions { opacity: 1; }

/* table */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-weight: 600; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td .row-actions { opacity: 0; display: flex; gap: 2px; justify-content: flex-end; }
tbody tr:hover .row-actions { opacity: 1; }
.cell-project { display: flex; align-items: center; gap: .65rem; min-width: 220px; }
.cell-project .avatar { width: 30px; height: 30px; font-size: .8rem; border-radius: 8px; }

/* empty state */
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }
.empty .empty-icon { width: 52px; height: 52px; margin: 0 auto 1rem; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.empty h3 { color: var(--text); margin-bottom: .25rem; }
.empty p { margin-bottom: 1.25rem; }
.empty.sm { padding: 1.75rem 1rem; }

/* ---------- project page ---------- */
.project-hero { margin-bottom: 1.25rem; }
.hero-top { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.hero-top .avatar { width: 52px; height: 52px; font-size: 1.3rem; border-radius: 13px; }
.hero-title h1 { margin: 0 0 .2rem; font-size: 1.45rem; }
.hero-title .sub { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; color: var(--muted); font-size: .82rem; }
.hero-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: .45rem; padding: .7rem .85rem; margin-bottom: -1px;
  color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .tab-count { font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums; }
.tabs a.active .tab-count { background: var(--accent-soft); color: var(--accent-text); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.side-stack { display: flex; flex-direction: column; gap: 1rem; }

/* markdown */
.md { overflow-wrap: anywhere; color: var(--text-2); line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); margin: 1.2em 0 .5em; }
.md h1 { font-size: 1.3rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1rem; }
.md ul, .md ol { padding-left: 1.3rem; margin: 0 0 .75rem; }
.md li { margin: .2rem 0; }
.md blockquote { margin: 0 0 .75rem; padding: .25rem 1rem; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md table { margin-bottom: .75rem; }
.md td, .md th { padding: .4rem .6rem; border: 1px solid var(--border); }
.md tbody tr { cursor: default; }
.md h1, .md h2, .md h3 { scroll-margin-top: 5rem; } /* clears the sticky topbar */
.md-toc { margin-bottom: 1rem; padding: .6rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface-2); }
.md-toc-title { margin: 0 0 .3rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.md-toc ol { list-style: none; margin: 0; padding: 0; columns: 2 16rem; column-gap: 1.5rem; }
.md-toc li { padding: .12rem 0 .12rem calc(var(--lvl, 0) * 1rem); font-size: .86rem; break-inside: avoid; }
.md-toc li.top { font-weight: 550; }

/* strategies: fixed slots in a left nav, detail on the right */
.strategy-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1rem; align-items: start; }
.strategy-layout.no-nav { grid-template-columns: minmax(0, 1fr); }
.strategy-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.strategy-main > div { display: flex; flex-direction: column; gap: 1rem; }
.strategy-nav { padding: .4rem; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 1rem; }
.strategy-nav-item { display: flex; align-items: center; gap: .5rem; padding-right: .5rem; border-radius: 8px; }
.strategy-nav-item:hover { background: var(--surface-2); }
.strategy-nav-item.active { background: var(--accent-soft); }
.strategy-nav-item a { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; color: var(--text); text-decoration: none; }
.strategy-nav-item a > .i { flex: none; color: var(--muted); }
.strategy-nav-item.active a > .i, .strategy-nav-item.master a > .i { color: var(--accent-text); }
.strategy-nav-item .slot-label { display: block; font-weight: 500; font-size: .88rem; line-height: 1.25; }
.strategy-nav-item .slot-sub { display: block; font-size: .72rem; color: var(--muted); }
.strategy-nav-item.empty .slot-label { color: var(--muted); font-weight: 400; }
.strategy-nav-item.off .slot-label { opacity: .55; text-decoration: line-through; text-decoration-color: var(--border-strong); }
.strategy-nav-item input[role=switch] { flex: none; transform: scale(.85); }
.strategy.off .md, .strategy.off h3 { opacity: .55; }
.strategy-history summary { cursor: pointer; display: flex; align-items: center; gap: .4rem; font-weight: 600; font-size: .9rem; }
.strategy-history .sessions { margin-top: .75rem; }
.strategy-history li.selected { background: var(--accent-soft); border-radius: 8px; }
.editor .inline-field { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; font-weight: 500; }
.editor .inline-field select { width: auto; margin: 0; }
.strategy.archived { opacity: .6; }
.strategy .card-head { align-items: flex-start; }
.strategy .card-head h3 { margin: 0 0 .25rem; }
.strategy-foot { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }
.editor input { font-weight: 600; margin-bottom: .75rem; }
.editor textarea { font-family: var(--mono); font-size: .85rem; margin-bottom: .75rem; }

/* to-do board */
.board-toolbar { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.board-toolbar label.check { margin: 0; font-size: .85rem; white-space: nowrap; }
.board-actions { margin-left: auto; }
.add-todo-btn { box-shadow: 0 0 0 3px var(--accent-soft); }
/* "Clear" in the Done column header */
.lane-col-head .clear-done {
  flex: none; display: inline-flex; align-items: center; gap: .25rem; margin: -.15rem 0; padding: .1rem .45rem; font-size: .72rem;
  color: var(--danger); background: var(--surface); border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
}
.lane-col-head .clear-done:hover { background: var(--danger-soft); border-color: var(--danger); }
.todo-meta .assignee { flex: none; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 1rem; align-items: start; }
.todo-items { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.todo {
  display: flex; align-items: flex-start; gap: .55rem; padding: .55rem .6rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-s); position: relative;
}
.todo:hover { border-color: var(--border-strong); }
.todo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; overflow-wrap: anywhere; cursor: default; }
.todo-title { font-size: .875rem; line-height: 1.4; }
.todo-body.clickable { cursor: pointer; }
.todo-body.clickable:hover .todo-title { color: var(--accent, var(--text)); text-decoration: underline; text-underline-offset: 2px; }
.todo-notes { font-size: .78rem; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.todo-result { display: block; font-size: .78rem; line-height: 1.4; color: var(--text-2); padding: .3rem .5rem; border-left: 2px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.todo-result { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.todo-result > :first-child { margin-top: 0; } .todo-result > :last-child { margin-bottom: 0; }
.todo-result p, .todo-result ul { margin: 0 0 .3rem; }
.todo.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo.done { background: transparent; box-shadow: none; }
.todo-meta { display: flex; align-items: center; gap: .3rem; }
.todo-meta .pill { font-size: .68rem; padding: .05rem .45rem; }
.todo.prio-high { border-left: 3px solid var(--danger); padding-left: calc(.6rem - 2px); }
.fact-mark { display: inline-flex; color: var(--accent-text); }
.fact-mark svg.i { width: 12px; height: 12px; fill: currentColor; }
.todo-actions {
  position: absolute; top: .3rem; right: .3rem; display: flex; gap: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-s); box-shadow: var(--shadow-s); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.todo:hover .todo-actions, .todo:focus-within .todo-actions { opacity: 1; pointer-events: auto; }
.todo-actions button { padding: .25rem; }
@media (hover: none) { .todo-actions { position: static; opacity: 1; pointer-events: auto; border: 0; box-shadow: none; background: none; } }

/* board: filters, hints, drag and drop */
.filter-chips { margin: 0; }
.chip.sm { padding: .22rem .6rem; font-size: .76rem; display: inline-flex; align-items: center; gap: .35rem; }
.chip-count { font-size: .7rem; font-variant-numeric: tabular-nums; opacity: .75; }
.backup-notice { background: var(--surface-2); border: 1px solid var(--border); }
.todo[draggable=true] { cursor: grab; }
.todo.dragging { opacity: .45; }
.todo.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.todo.drop-after { box-shadow: 0 3px 0 0 var(--accent); }

/* to-do status (kanban stages) and the board: one column per status */
.s-idea, select.pill-select.s-idea { --c: var(--st-planning); } .s-backlog, select.pill-select.s-backlog { --c: var(--st-idea); }
.s-in_progress, select.pill-select.s-in_progress { --c: var(--info); } .s-in_review, select.pill-select.s-in_review { --c: var(--warning); }
.s-done, select.pill-select.s-done { --c: var(--success); }
.status-dot { flex: none; width: .55rem; height: .55rem; border-radius: 50%; background: var(--c); }
.todo-meta { flex-wrap: wrap; }
.board-scroll { margin-bottom: 1rem; }
.board.lanes {
  --board-cols: repeat(5, minmax(0, 1fr));
  display: flex; flex-direction: column; align-items: stretch; gap: .75rem;
}
.board.lanes.hide-done { --board-cols: repeat(4, minmax(0, 1fr)) 6.5rem; }
.lane { min-width: 0; }
.lane-cols { display: grid; grid-template-columns: var(--board-cols); gap: .6rem; align-items: stretch; }
/* each status column is one block: a tinted header band in the status color, then its cards */
.lane-col {
  --c: var(--border-strong); min-width: 0; min-height: 8rem; display: flex; flex-direction: column; gap: .4rem;
  background: color-mix(in srgb, var(--c) 5%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--border));
  border-top: 3px solid var(--c); border-radius: var(--radius); padding: 0 .4rem .4rem;
}
.lane-col-head {
  position: sticky; top: 4rem; z-index: 2; display: flex; align-items: center; gap: .45rem; min-width: 0;
  margin: 0 -.4rem .1rem; padding: .5rem .6rem; font-size: .82rem; font-weight: 700; color: var(--text);
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.lane-col-head .status-dot { width: .6rem; height: .6rem; }
.lane-col-head .count {
  margin-left: auto; flex: none; font-size: .72rem; font-weight: 600; padding: 0 .45rem; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.lane-col.col-idea { --c: var(--st-planning); } .lane-col.col-backlog { --c: var(--st-idea); }
.lane-col.col-in_progress { --c: var(--info); } .lane-col.col-in_review { --c: var(--warning); } .lane-col.col-done { --c: var(--success); }
.lane-col.drop-into { border-color: var(--accent); background: var(--accent-soft); }
.lane-col .todo-items { margin: 0; gap: .4rem; }
.lane-empty { font-size: .75rem; color: var(--muted); text-align: center; padding: .3rem; }
.lane-hidden, .add-btn {
  all: unset; box-sizing: border-box; cursor: pointer; padding: .25rem .4rem; border-radius: var(--radius-s); font-size: .76rem; color: var(--muted);
}
.lane-hidden { text-align: center; }
.lane-hidden:hover, .add-btn:hover { color: var(--text); background: var(--surface-3); }
.lane-hidden:focus-visible, .add-btn:focus-visible { outline: 2px solid var(--accent); }
/* "+ Add" in each cell: quiet until the lane is hovered */
.add-btn { display: flex; align-items: center; gap: .3rem; margin-top: auto; opacity: 0; transition: opacity .12s; }
.lane-col:not(:has(.todo)) .add-btn { opacity: .5; }
.lane:hover .add-btn, .add-btn:focus-visible, .add-btn:hover { opacity: 1; }
@media (hover: none) { .add-btn { opacity: 1; } }
/* narrow screens: the whole board scrolls sideways as one, so the columns stay aligned */
@media (max-width: 1100px) {
  .board-scroll { overflow-x: auto; padding-bottom: .25rem; }
  .board.lanes { min-width: 62rem; }
  .board.lanes.hide-done { min-width: 52rem; }
  .lane-col-head { position: static; }
}
.act-todo_status .act-dot { background: var(--info); }
.act-todo_assigned .act-dot { background: var(--accent); }

/* dashboard: type filter, sort */
.toolbar-select { width: auto; margin: 0; padding: .35rem 2rem .35rem .6rem; font-size: .8rem; height: auto; }
th .th-sort { all: unset; cursor: pointer; font: inherit; color: inherit; white-space: nowrap; }
th .th-sort:hover, th .th-sort.on { color: var(--text); }
th .th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* planner */
.planner-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.planner-hero { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.planner-hero .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
.planner-hero h3 { margin: 0; }
.planner-hero p { margin: 0; font-size: .82rem; color: var(--muted); }
/* settings */
.settings-card { max-width: 860px; }
.provider-rows { display: grid; gap: .5rem; margin: .5rem 0 1rem; }
.provider-row {
  display: grid; grid-template-columns: 220px 1fr; gap: .35rem 1rem; align-items: center;
  padding: .75rem; border: 1px solid var(--border); border-radius: 10px;
}
.provider-row.unavailable .provider-name strong { color: var(--muted); }
.provider-name { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.provider-model input { margin: 0; width: 100%; }
.provider-meta { grid-column: 2; display: flex; flex-direction: column; gap: .1rem; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }
.sessions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sessions li { display: flex; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--border); align-items: flex-start; }
.sessions li:first-child { border-top: 0; padding-top: 0; }
.sessions .s-goal { color: var(--text); font-weight: 550; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sessions .s-meta { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
.sessions li button { opacity: 0; }
.sessions li:hover button { opacity: 1; }

.session-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.session-head h3 { margin: .35rem 0 .2rem; }
.session-head .back { display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; color: var(--muted); }
.transcript { display: flex; flex-direction: column; gap: 1.1rem; margin-bottom: 1rem; }
.msg { display: flex; gap: .7rem; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .75rem; font-weight: 700; }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.msg.user .msg-avatar { background: var(--surface-3); color: var(--text-2); }
.bubble { max-width: min(760px, 85%); padding: .8rem 1rem; border-radius: var(--radius-l); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--on-accent); border-top-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; flex: 1; box-shadow: var(--shadow-s); }
.bubble > p:last-child { margin-bottom: 0; }
.questions { display: flex; flex-direction: column; gap: .75rem; margin-top: .75rem; }
.questions fieldset { padding: .85rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.questions legend { float: left; width: 100%; font-weight: 600; margin-bottom: .2rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; clear: both; }
.chip { padding: .38rem .75rem; border-radius: 999px; font-size: .82rem; font-weight: 500; background: var(--surface); color: var(--text-2); border: 1px solid var(--border-strong); }
.chip:hover { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.chip.selected { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip:disabled { opacity: .6; }
.chip:disabled:hover { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.chip.selected:disabled:hover { background: var(--accent); color: var(--on-accent); }
.questions input { margin-top: .25rem; padding: .45rem .65rem; font-size: .85rem; }
.proposal { display: flex; flex-direction: column; gap: .5rem; margin-top: .85rem; }
.proposal details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.proposal summary { display: flex; align-items: center; gap: .5rem; padding: .65rem .85rem; font-weight: 600; cursor: pointer; list-style: none; }
.proposal summary::-webkit-details-marker { display: none; }
.proposal summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.1rem; transition: transform .15s; }
.proposal details[open] summary::after { transform: rotate(90deg); }
.proposal details > :not(summary) { padding: 0 .85rem .85rem; }
.proposal ol { margin: 0; padding-left: 2rem; display: flex; flex-direction: column; gap: .35rem; }
.proposal ol li { font-size: .875rem; }
.thinking { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.composer {
  position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
  padding: .75rem; box-shadow: var(--shadow-l);
}
.composer textarea { border: 0; padding: .25rem .25rem .5rem; box-shadow: none !important; background: transparent; }
.composer .row { padding-top: .6rem; border-top: 1px solid var(--border); }
.kbd-hint { font-size: .75rem; color: var(--muted); }

/* ---------- dialogs ---------- */
dialog {
  position: fixed; inset: 0; z-index: 100; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 1rem; border: 0; background: rgba(10, 12, 18, .85);
  display: none; align-items: center; justify-content: center; color: var(--text);
}
dialog[open] { display: flex; }
.modal { width: min(580px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-l); border: 1px solid var(--border); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1.25rem; }
.modal-body > p { color: var(--text-2); }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
.modal-foot .muted { margin-right: auto; font-size: .78rem; }
.confirm-dialog { z-index: 110; }
.confirm-message { margin: 0; white-space: pre-line; color: var(--text); }
.confirm-dialog button.confirm-ok.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.confirm-dialog button.confirm-ok.danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200; max-width: min(420px, calc(100vw - 2rem));
  display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; border-radius: var(--radius);
  background: #1b1f29; color: #fff; cursor: pointer; box-shadow: var(--shadow-l); font-weight: 500;
}
.toast .ti { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--success); flex: none; }
.toast.error .ti { background: var(--danger); }
.toast-action { margin-left: .25rem; padding: .25rem .6rem; font-size: .8rem; background: transparent; color: #a5b4fc; border: 1px solid rgba(255,255,255,.25); }
.toast-action:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-l);
  }
  .sidebar.open { transform: none; }
  .tabs.project-tabs { display: flex; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .4); }
  .menu-btn { display: inline-flex; }
  .overview-grid, .planner-grid { grid-template-columns: 1fr; }
  .strategy-layout { grid-template-columns: minmax(0, 1fr); }
  .strategy-nav { position: static; flex-direction: row; overflow-x: auto; }
  .strategy-nav-item { flex: none; }
  .strategy-nav-item .slot-label { white-space: nowrap; }
}
@media (max-width: 640px) {
  .topbar { padding: .65rem 16px; gap: .5rem; }
  .topbar .search { display: none; }
  .topbar .busy-dot { margin-left: auto; }
  .topbar .new-label { display: none; }
  .content { padding: 1.25rem 16px 3rem; }
  .hero-actions { margin-left: 0; width: 100%; }
  .two-col { grid-template-columns: 1fr; }
  .provider-row { grid-template-columns: 1fr; }
  .provider-meta { grid-column: 1; }
  .bubble { max-width: 100%; }
  .msg-avatar { display: none; }
  .card-actions, td .row-actions, .sessions li button { opacity: 1; }
}

/* master plan */
.master-card { margin-bottom: 1rem; }
.master-card .card-title { display: flex; align-items: center; gap: .4rem; }
.master-card.missing { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: color-mix(in srgb, var(--warning-soft) 55%, var(--surface)); }
.master-missing { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.master-missing .kpi-icon { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.card.strategy.master { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); }
select.pill-select.kind { --c: var(--accent-text); }
.callout { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem .8rem; margin-bottom: 1rem; border-radius: 8px; font-size: .85rem; background: var(--warning-soft); color: var(--text-2); }
.callout > .i { color: var(--warning); flex: none; margin-top: .15rem; }

/* ---------- work off ---------- */
.work { display: flex; flex-direction: column; gap: 1rem; max-width: 860px; }
.work .board-toolbar { margin-bottom: 0; }
.work-card { padding: 1.5rem; }
.work-title { margin: .75rem 0 .5rem; font-size: 1.45rem; line-height: 1.3; }
.work-result { margin-top: 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.work-result label { font-weight: 600; }
.work-result textarea { margin: 0; }
.facts { margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.fact { padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.fact:last-child { padding-bottom: 0; border-bottom: 0; }
.fact dt { font-weight: 600; font-size: .875rem; margin-bottom: .25rem; }
.fact dd { margin: 0; font-size: .875rem; }
.work-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.work-runs { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.work-runs ul { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.work-runs li { display: flex; align-items: center; gap: .5rem; font-size: .875rem; margin: 0; }
.pill.snoozed { --c: var(--info); }
.pill.done-pill { --c: var(--success); }
.pill.fact-pill { --c: var(--accent-text); gap: .2rem; }
.pill.fact-pill svg.i { width: 11px; height: 11px; fill: currentColor; }
.todo-actions .fact-toggle.on { color: var(--accent-text); }
.todo-actions .fact-toggle.on svg.i { fill: currentColor; }
.pill.run-running { --c: var(--info); } .pill.run-waiting { --c: var(--warning); } .pill.run-idle { --c: var(--accent-text); }
.pill.run-done { --c: var(--success); } .pill.run-failed { --c: var(--danger); } .pill.run-stopped { --c: var(--st-archived); }
.pill.allowed { --c: var(--success); } .pill.denied { --c: var(--danger); }

/* agent transcript */
.agent-transcript { gap: .7rem; }
.agent-transcript .bubble.md { color: var(--text); }
.tool-call { margin-left: 2.4rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: .85rem; }
.tool-call summary { display: flex; align-items: center; gap: .5rem; padding: .45rem .75rem; cursor: pointer; list-style: none; min-width: 0; }
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary code { background: none; padding: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-call summary > .i { color: var(--muted); }
.tool-call.error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.tool-call.pending summary > .i { color: var(--accent); }
.tool-call pre { margin: 0 .75rem .6rem; max-height: 18rem; overflow: auto; font-size: .78rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.permission { margin-left: 2.4rem; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: .45rem; }
.permission.open { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); background: color-mix(in srgb, var(--warning-soft) 50%, var(--surface)); box-shadow: var(--shadow); }
.permission > .row > .i { color: var(--warning); }
.permission-input { display: block; white-space: pre-wrap; max-height: 10rem; overflow: auto; }
.permission-actions { display: flex; flex-direction: column; gap: .5rem; }
.permission-actions input { margin: 0; padding: .45rem .65rem; font-size: .85rem; }
.turn-end { margin-left: 2.4rem; font-size: .78rem; color: var(--muted); display: flex; gap: .35rem; }
.turn-end.error { color: var(--danger); }
@media (max-width: 640px) {
  .tool-call, .permission, .turn-end { margin-left: 0; }
}

/* decide with AI */
.decision-summary { margin: 0; padding: .6rem .85rem; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); }
.decision-apply { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.decision-apply label:not(.check) { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: .85rem; color: var(--text-2); }
.decision-apply select { margin: 0; padding: .35rem 2rem .35rem .6rem; font-size: .85rem; max-width: 22rem; }
.decision-apply button { margin-left: auto; }
.work-runs li .i { flex: none; }
.bubble .md table, .proposal .md table { display: block; max-width: 100%; overflow-x: auto; }
.decision-apply label:not(.check) { white-space: nowrap; }

/* global search */
.topbar .search-results { position: absolute; top: calc(100% + .35rem); right: 0; width: min(460px, 90vw); max-height: 70vh; overflow: auto; z-index: 50; padding: .35rem 0; box-shadow: var(--shadow); }
.search-group + .search-group { border-top: 1px solid var(--border); }
.search-group-label { padding: .45rem .75rem .15rem; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.search-hit { display: flex; flex-direction: column; gap: .1rem; padding: .4rem .75rem; color: var(--text); text-decoration: none; min-width: 0; }
.search-hit:hover, .search-hit:focus { background: var(--surface-3); text-decoration: none; }
.search-hit.archived { opacity: .6; }
.search-foot { margin: .35rem 0 0; padding: .4rem .75rem 0; border-top: 1px solid var(--border); font-size: .72rem; }
.import-button { cursor: pointer; margin: 0; }

/* due dates */
.pill.due { --c: var(--muted); text-transform: none; }
.pill.due.overdue { --c: var(--danger); font-weight: 600; }

/* activity */
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; font-size: .85rem; }
.activity li { display: flex; align-items: baseline; gap: .55rem; margin: 0; min-width: 0; }
.activity li > .grow { overflow-wrap: anywhere; }
.activity li small { white-space: nowrap; }
.act-dot { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); transform: translateY(-.05rem); }
.act-todo_done .act-dot, .act-agent_completed .act-dot { background: var(--success); }
.act-decision_applied .act-dot, .act-plan_applied .act-dot { background: var(--accent); }
.act-strategy_created .act-dot, .act-strategy_updated .act-dot { background: var(--info); }
.act-todo_reopened .act-dot { background: var(--warning); }

/* agent run: notices and changes */
.notice { display: flex; align-items: center; gap: .5rem; margin: .75rem 0; padding: .6rem .85rem; border-radius: var(--radius); font-size: .85rem; }
.notice.warn { background: var(--warning-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border)); }
.notice.warn .i { color: var(--warning); flex: none; }
.diff-card { margin: .75rem 0; display: flex; flex-direction: column; gap: .5rem; }
.diff-card p { margin: 0; }
pre.diff { margin: 0; max-height: 28rem; overflow: auto; font-size: .78rem; line-height: 1.45; white-space: pre; }
pre.diff .add { color: var(--success); background: var(--success-soft); }
pre.diff .del { color: var(--danger); background: var(--danger-soft); }
pre.diff .hunk { color: var(--info); }

/* keyboard shortcuts */
.shortcuts { margin: 0; display: grid; gap: .45rem; }
.shortcuts > div { display: flex; align-items: center; gap: .75rem; }
.shortcuts dt { width: 4.5rem; display: flex; gap: .25rem; margin: 0; }
.shortcuts dd { margin: 0; color: var(--text-2); font-size: .9rem; }
kbd { display: inline-block; min-width: 1.5rem; padding: .1rem .4rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--radius-s); background: var(--surface-2); color: var(--text); font: 600 .78rem/1.4 var(--font-mono, ui-monospace, monospace); text-align: center; }

/* ---------- today ---------- */
.agenda-group { margin-bottom: 1.5rem; }
.agenda-head { display: flex; align-items: center; gap: .5rem; font-size: .95rem; margin: 0 0 .6rem; }
.agenda-head .count, .nav-item .count.alert { font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.agenda-head.overdue { color: var(--danger); }
.nav-item .count.alert { background: var(--danger); color: #fff; }
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-item { display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.agenda-item:last-child { border-bottom: 0; }
.agenda-main { display: flex; flex-direction: column; gap: .2rem; min-width: 12rem; color: inherit; text-decoration: none; }
.agenda-main:hover .todo-title { text-decoration: underline; text-underline-offset: 2px; }
.agenda-meta { display: flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--text-2); }
.avatar.xs { width: 18px; height: 18px; font-size: .55rem; border-radius: 5px; }
.agenda-actions { display: flex; gap: .25rem; }

/* ---------- activity, selection, keyboard focus ---------- */
.activity-chips { margin: 0; }
.activity li.linked { cursor: pointer; border-radius: var(--radius-s); }
.activity li.linked:hover .grow { text-decoration: underline; text-underline-offset: 2px; }
.bulk-bar {
  position: sticky; top: .5rem; z-index: 20; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: .55rem .8rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--accent); box-shadow: var(--shadow);
}
.bulk-bar input[type=date] { width: auto; }
.todo.selected { border-color: var(--accent); background: var(--accent-soft); }
.todo.kb-focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- project overview ---------- */
.hero-locs { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.loc-chip {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; min-width: 0; padding: .15rem .25rem .15rem .55rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: .78rem;
}
a.loc-chip { padding-right: .6rem; }
a.loc-chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.loc-chip code { background: none; padding: 0; font-size: .76rem; }
.loc-chip.missing { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
button.icon.xs { padding: .18rem; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 30; min-width: 230px; padding: .35rem; display: flex; flex-direction: column; box-shadow: var(--shadow-l); }
.menu-list button { justify-content: flex-start; width: 100%; padding: .5rem .6rem; font-size: .85rem; font-weight: 500; gap: .5rem; }
.menu-list button small { margin-left: auto; font-weight: 400; }
.menu-list hr { margin: .3rem 0; }
.stat-strip { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--border); row-gap: .9rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; padding: .25rem .9rem; border-left: 1px solid var(--border); color: var(--text); }
.stat:first-child { border-left: 0; padding-left: 0; }
.stat:hover { text-decoration: none; }
.stat-strip.flat { margin-top: 0; padding-top: 0; border-top: 0; }
.stat .dist-bar { margin-top: .45rem; }
.stat .legend { margin-top: .6rem; }
a.stat:hover .label { color: var(--accent-text); }
.stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-s); }
.stat .label { font-size: .75rem; color: var(--muted); font-weight: 550; }
.stat .value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: .5rem; }
.stat .value small { font-size: .75rem; font-weight: 500; }
.stat .progress { margin-top: .3rem; }
.stat.alert .value, .stat.alert .label { color: var(--danger); }

.main-stack { min-width: 0; }
.card-head.wrap { flex-wrap: wrap; gap: .5rem; }
.card-title svg { vertical-align: -2px; margin-right: .35rem; }
.focus-item {
  display: flex; gap: 1rem; align-items: flex-start; padding: .9rem 1rem; margin-bottom: .75rem;
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--surface-2);
}
.focus-item.overdue { border-left-color: var(--danger); }
.focus-title { display: block; font-size: 1.05rem; font-weight: 650; color: var(--text); line-height: 1.35; margin-bottom: .4rem; overflow-wrap: anywhere; }
.focus-title:hover { color: var(--accent-text); }
.focus-notes { margin: .5rem 0 0; font-size: .82rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.focus-actions { display: flex; flex-direction: column; gap: .4rem; flex: none; }
.focus-actions button { justify-content: center; }
.next-list { list-style: none; margin: 0; padding: 0; }
.next-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem .25rem; border-top: 1px solid var(--border); font-size: .875rem; min-width: 0; }
.next-list li:first-child { border-top: 0; }
.next-list a.grow { color: var(--text); min-width: 0; }
.next-list a.grow:hover { color: var(--accent-text); }
.next-actions { display: flex; opacity: 0; transition: opacity .12s; }
.next-list li:hover .next-actions, .next-list li:focus-within .next-actions { opacity: 1; }
@media (hover: none) { .next-actions { opacity: 1; } }

.master-title { margin: .2rem 0 .6rem; font-size: 1.05rem; }
.master-title a { color: var(--text); }
.master-toc { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.toc-chip { font-size: .76rem; padding: .2rem .6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-chip:hover { border-color: var(--accent); color: var(--accent-text); text-decoration: none; }
.md.clamp { max-height: 15rem; overflow: hidden; -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.md.clamp.expanded { max-height: none; -webkit-mask-image: none; mask-image: none; }

.glance { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.glance a { display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; margin: 0 -.5rem; border-radius: var(--radius-s); color: var(--text); }
.glance a:hover { background: var(--surface-2); text-decoration: none; }
.glance a > svg { color: var(--muted); flex: none; }
.glance-kind { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }
.glance-title { display: block; font-size: .85rem; }
.glance li.off { opacity: .55; }

.getting-started { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.steps li:first-child { border-top: 0; }
.steps li strong { display: block; font-size: .9rem; }
.steps li small { display: block; }
.steps li.done strong { color: var(--muted); text-decoration: line-through; }
.step-mark { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.steps li.done .step-mark { background: var(--success); color: #fff; }

/* overview: responsive (after the base rules above, so these win) */
@media (max-width: 640px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:first-child { grid-column: span 2; }
  .stat:nth-child(2) { border-left: 0; padding-left: 0; }
  .focus-item { flex-direction: column; }
  .focus-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .next-list .pill:not(.due) { display: none; }
  .loc-chip { max-width: 100%; }
}

/* ---------- accounts ---------- */
.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 1rem; background: var(--bg); z-index: 50; }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: .75rem; padding: 1.75rem; }
.auth-card .brand { color: var(--text); padding: 0 0 .5rem; }
.auth-card h2 { margin: 0 0 .25rem; font-size: 1.2rem; }
.auth-card label { display: flex; flex-direction: column; gap: .3rem; margin: 0; }
.auth-error { margin: 0; padding: .5rem .7rem; border-radius: var(--radius-s); background: var(--danger-soft); color: var(--danger); font-size: .85rem; }
.nav-account { display: flex; align-items: center; gap: .25rem; margin-top: .25rem; padding-top: .5rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.nav-account .nav-item { min-width: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: .75rem; border-radius: 50%; }
.readonly-note { display: flex; align-items: center; gap: .5rem; margin: 0 0 1rem; padding: .55rem .8rem; border-radius: var(--radius-s); background: var(--surface-3); color: var(--text-2); font-size: .85rem; }
.members-card { max-width: 720px; }
.member-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.member-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.member-list li:last-child { border-bottom: 0; }
.member-list .grow { display: flex; flex-direction: column; }
.role-select { width: auto; margin: 0; }
.member-add { display: flex; gap: .5rem; flex-wrap: wrap; }
.member-add select { margin: 0; width: auto; }
.member-add select:first-child { flex: 1 1 220px; }
.member-add button { margin: 0; }
.role-legend { display: grid; gap: .25rem; margin: 1rem 0 0; padding-top: .75rem; border-top: 1px solid var(--border); font-size: .8rem; }
.role-legend div { display: flex; gap: .5rem; }
.role-legend dt { font-weight: 600; min-width: 4.5rem; }
.role-legend dd { margin: 0; color: var(--muted); }
.users-table tr.disabled td { opacity: .55; }
.users-table td.actions { text-align: right; white-space: nowrap; }

/* pinned projects */
.pin-mark { color: var(--accent); margin-right: .3rem; vertical-align: -2px; }
button.icon.on { color: var(--accent); }

/* tags and repeating to-dos */
.tag-pill { cursor: pointer; border: 0; color: var(--accent-text); background: var(--accent-soft); font: inherit; font-size: inherit; }
.tag-pill:hover, .tag-pill.on { background: var(--accent); color: #fff; }
.repeat-pill .i { width: .8em; height: .8em; }
.chip.tag-chip:not(.selected) { color: var(--accent-text); }

/* command palette */
.palette-dialog { align-items: flex-start; }
.palette { max-width: 560px; width: 100%; margin-top: 12vh; padding: .5rem; }
.palette input { margin: 0 0 .4rem; }
.palette ul { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.palette li { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 6px; cursor: pointer; list-style: none; margin: 0; }
.palette li.active { background: var(--accent-soft); color: var(--accent-text); }
.palette li .grow { min-width: 0; }
.palette-empty { cursor: default; }
