/* ===== Tokens ===== */
:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --surface-3: #e9e8e2;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e6f0fc;
  --mark: #fff1b8;
  --good: #0ca30c;  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --c-note: #2a78d6; --c-info: #2a78d6; --c-tip: #1baf7a; --c-success: #0ca30c;
  --c-important: #6250d6; --c-warning: #eda100; --c-caution: #d03b3b; --c-question: #eb6834;
  --c-quote: #898781; --c-abstract: #199e70; --c-summary: #199e70;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --topbar-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --line-strong: #383835;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #15253a; --mark: #5a4a10;
    --good-ink: #0ca30c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --c-note: #3987e5; --c-info: #3987e5; --c-tip: #199e70; --c-important: #9085e9;
    --c-warning: #c98500; --c-question: #d95926; --c-caution: #e66767;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --line: #2c2c2a; --line-strong: #383835;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #15253a; --mark: #5a4a10;
  --good-ink: #0ca30c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --c-note: #3987e5; --c-info: #3987e5; --c-tip: #199e70; --c-important: #9085e9;
  --c-warning: #c98500; --c-question: #d95926; --c-caution: #e66767;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--ink-2); background: var(--surface); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.pill:empty { display: none; }

/* ===== Top bar ===== */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 16px; }
.topnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.topnav a { color: var(--ink-2); padding: 6px 10px; border-radius: 7px; font-size: 14px; white-space: nowrap; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.search-trigger { margin-left: auto; display: flex; align-items: center; gap: 18px; padding: 6px 10px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 8px; color: var(--muted); font-size: 14px; }
.icon-btn { border: 1px solid transparent; background: none; width: 34px; height: 34px; border-radius: 8px; font-size: 17px; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.only-mobile { display: none; }

/* ===== Layout ===== */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr) 300px; min-height: calc(100vh - var(--topbar-h)); }
.layout.no-right { grid-template-columns: 290px minmax(0, 1fr); }
.layout.no-right .rightbar { display: none; }
.sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 12px 10px 24px; }
.rightbar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; border-left: 1px solid var(--line); padding: 18px 16px 40px; font-size: 14px; }
.main { padding: 28px 40px 80px; min-width: 0; outline: none; }
.main.wide { max-width: none; }
.tree-filter { width: 100%; margin-bottom: 10px; }

/* ===== Tree ===== */
.tree details > summary { list-style: none; cursor: pointer; padding: 4px 6px; border-radius: 6px; font-weight: 600; font-size: 13.5px; color: var(--ink); display: flex; align-items: center; gap: 6px; user-select: none; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary::before { content: "▸"; color: var(--muted); font-size: 11px; width: 10px; transition: transform .15s; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary:hover { background: var(--surface-2); }
.tree summary .count { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px; }
.tree .children { padding-left: 12px; border-left: 1px solid var(--line); margin-left: 10px; }
.tree a { display: flex; align-items: center; gap: 7px; padding: 3px 6px; border-radius: 6px; color: var(--ink-2); font-size: 13.5px; line-height: 1.35; }
.tree a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.tree a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.tree a .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tree a .cc { font-size: 11px; color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--line-strong); }
.dot.reviewed { background: var(--good); }
.dot.draft { background: var(--warning); }
.dot.seed { background: transparent; border: 1.5px solid var(--muted); }
.sidebar-foot { margin-top: 18px; padding: 10px 6px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar-foot .legend span { display: inline-flex; align-items: center; gap: 5px; margin-right: 10px; }

/* ===== Note header ===== */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.note-head h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -.01em; }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13.5px; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.chip b { color: var(--ink); font-weight: 600; }
a.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.tag { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
.chip.st-reviewed::before, .chip.st-draft::before, .chip.st-seed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.chip.st-reviewed::before { background: var(--good); }
.chip.st-draft::before { background: var(--warning); }
.chip.st-seed::before { border: 1.5px solid var(--muted); }
.lvl { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12.5px; padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.lvl::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.lvl.alto, .lvl.alta, .lvl.critical { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.lvl.medio, .lvl.media { color: #c4562c; background: color-mix(in srgb, var(--serious) 16%, transparent); }
.lvl.bajo, .lvl.baja { color: #9a6a00; background: color-mix(in srgb, var(--warning) 20%, transparent); }
.lvl.info { color: var(--ink-2); background: var(--surface-2); }
:root[data-theme="dark"] .lvl.medio, :root[data-theme="dark"] .lvl.media { color: var(--serious); }
:root[data-theme="dark"] .lvl.bajo, :root[data-theme="dark"] .lvl.baja { color: var(--warning); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lvl.medio, :root:not([data-theme="light"]) .lvl.media { color: var(--serious); }
  :root:not([data-theme="light"]) .lvl.bajo, :root:not([data-theme="light"]) .lvl.baja { color: var(--warning); }
}

.meta-card { margin: 16px 0 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 0 -1px -1px 0; }
.meta-grid > div { background: var(--surface); padding: 9px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.meta-grid .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.meta-grid .v { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.meta-card details summary { padding: 7px 13px; font-size: 12.5px; color: var(--muted); cursor: pointer; border-top: 1px solid var(--line); }
.meta-card details pre { margin: 0; border-radius: 0; border: 0; border-top: 1px solid var(--line); }

/* ===== Markdown content ===== */
.md { max-width: 860px; overflow-wrap: break-word; }
.md.full { max-width: none; }
.md h1 { display: none; }
.md h2 { font-size: 22px; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); letter-spacing: -.005em; }
.md h3 { font-size: 18px; margin: 26px 0 8px; }
.md h4 { font-size: 15.5px; margin: 20px 0 6px; }
.md h2, .md h3, .md h4 { scroll-margin-top: calc(var(--topbar-h) + 12px); position: relative; }
.md .anchor { opacity: 0; margin-left: 6px; font-weight: 400; color: var(--muted); font-size: .8em; }
.md h2:hover .anchor, .md h3:hover .anchor { opacity: 1; }
.md p, .md ul, .md ol { margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.md code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); overflow-wrap: anywhere; }
.md pre { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.md pre code { background: none; border: 0; padding: 0; overflow-wrap: normal; }
.md pre .copy { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; }
.md pre:hover .copy { opacity: 1; }
.md mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
.md blockquote { margin: 0 0 14px; padding: 4px 16px; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.md img { max-width: 100%; }
.md a.ext::after { content: "↗"; font-size: .75em; margin-left: 2px; color: var(--muted); }
.md a.wl { color: var(--accent); border-bottom: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
.md a.wl:hover { text-decoration: none; border-bottom-style: solid; }
.md a.wl.broken { color: var(--critical); border-bottom-color: var(--critical); }
.md a.tag { font-size: .88em; padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.md a.tag:hover { text-decoration: none; }
.md .cite { font-size: .74em; vertical-align: super; line-height: 0; font-weight: 600; padding: 0 2px; color: var(--accent-ink); cursor: help; white-space: nowrap; }
.md .cite a { color: inherit; }
.md li.task { list-style: none; margin-left: -22px; display: flex; gap: 8px; align-items: flex-start; }
.md li.task > input { margin-top: 5px; flex: none; accent-color: var(--accent); }
.md li.task.done > .tt { color: var(--muted); text-decoration: line-through; }
.prio { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 5px; white-space: nowrap; }
.prio.p-hi { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.prio.p-md { color: #c4562c; background: color-mix(in srgb, var(--serious) 16%, transparent); }
.prio.p-lo { color: var(--ink-2); background: var(--surface-2); }
.blocked { font-size: 11.5px; font-weight: 600; color: var(--critical); white-space: nowrap; }
.effort { font: 600 11px var(--mono); padding: 0 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); }

/* Tables */
.table-wrap { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.table-tools { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.table-tools input { padding: 3px 8px; font-size: 13px; width: 200px; max-width: 100%; }
.table-tools .sp { flex: 1; }
.table-scroll { overflow-x: auto; max-height: 75vh; overflow-y: auto; }
.md table, table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; line-height: 1.45; }
.md th, .md td, table.data th, table.data td { padding: 8px 11px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.md th, table.data th { position: sticky; top: 0; background: var(--surface); font-weight: 600; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; box-shadow: inset 0 -1px 0 var(--line-strong); }
.md th:hover, table.data th:hover { color: var(--ink); }
th[data-sort="asc"]::after { content: " ▲"; font-size: 9px; }
th[data-sort="desc"]::after { content: " ▼"; font-size: 9px; }
.md tbody tr:hover, table.data tbody tr:hover { background: var(--surface-2); }
.md tr:last-child td, table.data tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Callouts */
.callout { --c: var(--c-note); margin: 0 0 16px; border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 7%, var(--surface)); border-radius: 8px; padding: 10px 14px; color: var(--ink); }
.callout-title { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--c); margin-bottom: 4px; }
.callout-title .ic { font-size: 15px; }
.callout-body > :last-child { margin-bottom: 0; }
.callout.fold .callout-title { cursor: pointer; }
.callout.fold .callout-title::after { content: "▾"; margin-left: auto; }
.callout.fold.closed .callout-title::after { content: "▸"; }
.callout.fold.closed .callout-body { display: none; }
.callout.c-info { --c: var(--c-info); } .callout.c-tip { --c: var(--c-tip); } .callout.c-success { --c: var(--c-success); }
.callout.c-important { --c: var(--c-important); } .callout.c-warning { --c: var(--c-warning); } .callout.c-caution { --c: var(--c-caution); }
.callout.c-question { --c: var(--c-question); } .callout.c-quote { --c: var(--c-quote); } .callout.c-abstract, .callout.c-summary { --c: var(--c-abstract); }
.callout.c-quote .callout-body { font-style: italic; }

.mermaid-box svg { max-width: min(100%, 680px) !important; height: auto; }
.mermaid-box { margin: 0 0 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow-x: auto; text-align: center; }
.dv { margin: 0 0 18px; }
.dv-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.dv-head code { font-size: 11.5px; }
.dv h4 { margin: 12px 0 6px; }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ===== Right bar ===== */
.rb-sec { margin-bottom: 22px; }
.rb-sec h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.toc a { display: block; color: var(--ink-2); padding: 2px 0 2px 10px; border-left: 2px solid var(--line); font-size: 13px; line-height: 1.4; }
.toc a.l3 { padding-left: 22px; font-size: 12.5px; }
.toc a:hover { color: var(--ink); text-decoration: none; border-left-color: var(--line-strong); }
.toc a.on { color: var(--accent-ink); border-left-color: var(--accent); }
.linklist a { display: block; padding: 3px 0; font-size: 13px; line-height: 1.35; }
.linklist .more { font-size: 12.5px; color: var(--muted); cursor: pointer; }

/* Comments */
.comments .c-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--surface); font-size: 13.5px; }
.comments .c-item.resolved { opacity: .6; }
.comments .c-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.comments .c-meta b { color: var(--ink-2); }
.comments .c-meta .sp { flex: 1; }
.comments .c-meta button { border: 0; background: none; padding: 0 3px; color: var(--muted); font-size: 12px; }
.comments .c-meta button:hover { color: var(--ink); }
.comments .c-quote { border-left: 3px solid var(--warning); padding: 2px 8px; margin: 5px 0; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 0 4px 4px 0; cursor: pointer; }
.comments .c-text { white-space: pre-wrap; margin-top: 3px; }
.comments form textarea { width: 100%; min-height: 66px; resize: vertical; font-size: 13.5px; }
.comments form .row { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.comments form input { flex: 1; min-width: 0; font-size: 13px; padding: 4px 8px; }
.comments .quote-preview { font-size: 12.5px; padding: 4px 8px; margin-bottom: 6px; background: var(--surface-2); border-left: 3px solid var(--warning); border-radius: 0 4px 4px 0; display: flex; gap: 6px; }
.comments .quote-preview span { flex: 1; }
.sel-comment { position: absolute; z-index: 40; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow); font-size: 13px; }
mark.c-hl { background: color-mix(in srgb, var(--warning) 35%, transparent); cursor: pointer; }

/* ===== Dashboard ===== */
.hero { margin-bottom: 22px; }
.hero h1 { font-size: 32px; margin: 0 0 6px; letter-spacing: -.015em; }
.hero p { margin: 0; color: var(--ink-2); max-width: 820px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 12px; margin: 20px 0 26px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: block; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .k { font-size: 12.5px; color: var(--ink-2); }
.kpi .v { font-size: 30px; font-weight: 650; line-height: 1.15; margin: 3px 0 2px; }
.kpi .s { font-size: 12px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card h3 { margin: 0 0 2px; font-size: 15.5px; }
.card .sub { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.section-title { font-size: 20px; margin: 32px 0 12px; }
.moc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.moc { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); }
.moc:hover { text-decoration: none; border-color: var(--accent); }
.moc b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.moc span { font-size: 12.5px; color: var(--muted); line-height: 1.4; display: block; }

/* Impact x effort matrix */
.matrix { display: grid; grid-template-columns: 70px repeat(var(--cols), 1fr); gap: 3px; font-size: 13px; }
.matrix .h { color: var(--muted); font-size: 12px; display: grid; place-items: center; padding: 4px; }
.matrix .h.row { justify-content: end; text-align: right; }
.matrix .cell { border-radius: 6px; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 0; color: var(--ink); background: var(--surface-2); transition: outline .1s; }
.matrix .cell b { font-size: 22px; line-height: 1.1; }
.matrix .cell span { font-size: 11.5px; }
.matrix .cell:hover, .matrix .cell.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.matrix .cell.dark { color: #fff; }
.matrix .cell.dark span { color: rgba(255,255,255,.85); }

/* ===== Explorer ===== */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); gap: 2px; }
.filters select, .filters input { font-size: 13.5px; padding: 4px 8px; }
.filters .sp { flex: 1; }
.result-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; font-size: 13.5px; color: var(--ink-2); }
.result-bar .sp { flex: 1; }

/* ===== Kanban ===== */
.kb-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 14px; }
.kb-tools .sp { flex: 1; }
.kb-person { border: 1px solid var(--line-strong); background: var(--surface); padding: 3px 10px; border-radius: 99px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.kb-person i { width: 9px; height: 9px; border-radius: 50%; }
.kb-person.on { border-color: var(--ink); background: var(--surface-3); font-weight: 600; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.lane { flex: 0 0 310px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); max-height: 78vh; display: flex; flex-direction: column; }
.lane.empty-lane { flex-basis: 200px; opacity: .75; }
.lane-head { padding: 10px 12px; font-weight: 650; font-size: 14px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); }
.lane-head .n { margin-left: auto; font-weight: 500; font-size: 12px; color: var(--muted); background: var(--surface); padding: 0 7px; border-radius: 99px; }
.lane-body { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--pc, var(--line-strong)); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; line-height: 1.4; }
.kcard:hover { border-color: var(--line-strong); border-left-color: var(--pc, var(--line-strong)); box-shadow: var(--shadow); }
.kcard .kc-top { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 12px; }
.kcard .kc-top a { font-weight: 700; font-size: 12px; }
.kcard .kc-foot { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 6px; }
.kcard .ptag { font-size: 11px; padding: 0 7px; border-radius: 99px; color: #fff; font-weight: 600; }
.kcard .etag { font-size: 11px; padding: 0 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); }
.kcard.done { opacity: .6; }

/* ===== Graph ===== */
.graph-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); height: calc(100vh - 230px); min-height: 420px; overflow: hidden; }
.graph-wrap svg { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-wrap .legend { position: absolute; left: 10px; bottom: 10px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; gap: 3px; max-height: 60%; overflow: auto; }
.graph-wrap .legend label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.graph-wrap .legend i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.g-link { stroke: var(--line-strong); stroke-opacity: .55; }
.g-node { stroke: var(--surface); stroke-width: 1.5px; cursor: pointer; }
.g-label { font-size: 10px; fill: var(--ink-2); pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.g-dim { opacity: .12; }
.mini-graph { height: 220px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.mini-graph svg { width: 100%; height: 100%; }

/* ===== Tags ===== */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a { padding: 4px 11px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; }
.tag-cloud a:hover { border-color: var(--accent); text-decoration: none; }
.tag-cloud a b { color: var(--muted); font-weight: 500; margin-left: 4px; font-size: 12px; }
.tag-group { margin-bottom: 18px; }
.tag-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.note-list { display: grid; gap: 8px; }
.note-row { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; color: var(--ink); }
.note-row:hover { text-decoration: none; border-color: var(--accent); }
.note-row b { font-size: 14.5px; }
.note-row .p { font-size: 13px; color: var(--ink-2); margin-top: 3px; line-height: 1.45; }
.note-row .m { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== Search ===== */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.modal[hidden] { display: none; }
.modal-card { width: min(760px, 100%); max-height: 84vh; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.modal-card .mc-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 8px; }
.modal-card .mc-head h2 { font-size: 17px; margin: 0; flex: 1; }
.modal-card .mc-body { padding: 14px 18px; overflow-y: auto; }
.modal-card .mc-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-card textarea.prompt { width: 100%; min-height: 300px; font: 12.5px/1.5 var(--mono); resize: vertical; }
.modal-card .opts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13.5px; }
.modal-card .opts label { display: flex; align-items: center; gap: 5px; }
.modal-card .tpl { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.search-card input#search-input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px; font-size: 17px; outline: none; }
.search-filters { display: flex; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.search-filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; font-size: 12px; padding: 1px 9px; color: var(--ink-2); }
.search-filters button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.search-results { overflow-y: auto; padding: 6px; }
.search-results a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); }
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); text-decoration: none; }
.search-results .r-t { font-weight: 600; font-size: 14.5px; }
.search-results .r-p { font-size: 12px; color: var(--muted); }
.search-results .r-s { font-size: 13px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; }
.search-help { padding: 7px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* Popover & toast */
.popover { position: absolute; z-index: 60; width: 360px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; font-size: 13.5px; line-height: 1.45; pointer-events: none; }
.popover .pt { font-weight: 650; margin-bottom: 4px; }
.popover .pp { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 9px; font-size: 14px; box-shadow: var(--shadow); }

/* ===== Responsive ===== */
@media (max-width: 1250px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .rightbar { display: none; }
  .rightbar.inline { display: block; position: static; height: auto; border: 0; border-top: 1px solid var(--line); padding: 20px 0 0; grid-column: 2; }
}
@media (max-width: 860px) {
  .layout, .layout.no-right { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: grid; }
  .sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 290px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .main { padding: 20px 16px 60px; }
  .topnav { display: none; }
  .search-trigger kbd { display: none; }
  .search-trigger { gap: 6px; }
  .rightbar.inline { grid-column: 1; padding: 20px 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .note-head h1 { font-size: 24px; }
  .brand-text { display: none; }
}
@media print {
  .topbar, .sidebar, .rightbar, .note-actions, .table-tools, .md pre .copy { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  body { background: #fff; color: #000; }
  .callout { break-inside: avoid; }
}

/* ===== Inicio del proyecto ===== */
.home-head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 4px; }
.home-head h1 { font-size: 32px; margin: 0 0 4px; letter-spacing: -.015em; }
.home-head p { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 13px; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.seg button i { width: 9px; height: 9px; border-radius: 50%; }
.task-list { display: grid; gap: 2px; }
.task-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; color: var(--ink); font-size: 13.5px; line-height: 1.35; }
a.task-row:hover { background: var(--surface-2); text-decoration: none; }
.task-row .tr-code { font: 600 12px var(--mono); color: var(--accent-ink); min-width: 46px; flex: none; }
.task-row .tr-text { flex: 1; min-width: 0; }
.task-row .tr-meta { display: flex; gap: 4px; align-items: center; flex: none; }
.ptag { font-size: 11px; padding: 0 7px; border-radius: 99px; color: #fff; font-weight: 600; white-space: nowrap; line-height: 18px; }
.home-tabs { display: flex; gap: 4px; margin: 26px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.home-tabs button { border: 1px solid transparent; border-bottom: 0; background: none; padding: 9px 16px; border-radius: 9px 9px 0 0; font-size: 14.5px; color: var(--ink-2); white-space: nowrap; margin-bottom: -1px; }
.home-tabs button:hover { color: var(--ink); background: var(--surface-2); }
.home-tabs button.on { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; }
.home-doc { border-top-left-radius: 0; border-top: 0; padding: 20px 24px 26px; }
.doc-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; }
.doc-head h2 { margin: 0 0 6px; font-size: 21px; }
.ql-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ql-group h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ql { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); margin-bottom: 6px; }
.ql:hover { border-color: var(--accent); text-decoration: none; }
.ql .ic { font-size: 18px; width: 24px; text-align: center; flex: none; }
.ql b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.ql small { color: var(--muted); font-size: 11.5px; }

/* ===== Mapa visual ===== */
.mm-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; color: var(--ink-2); }
.mm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mm-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.mm-dot.qw, .mm-bar .qw { background: var(--good); }
.mm-dot.pp, .mm-bar .pp { background: var(--accent); }
.mm-dot.bl, .mm-bar .bl { background: var(--critical); }
.mm-dot.ot, .mm-bar .ot { background: var(--muted); }
.mm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; align-items: start; }
.mm-group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 12px 8px; }
.mm-group.mm-other { background: var(--surface-2); }
.mm-head { display: flex; align-items: baseline; gap: 8px; }
.mm-head h3 { margin: 0; font-size: 15px; flex: 1; }
.mm-head .n { font-size: 22px; font-weight: 650; }
.mm-bar { display: flex; gap: 2px; height: 8px; margin: 8px 0 6px; }
.mm-bar span { border-radius: 3px; }
.mm-sub summary { cursor: pointer; padding: 5px 2px; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; list-style: none; }
.mm-sub summary::-webkit-details-marker { display: none; }
.mm-sub summary b { margin-left: auto; color: var(--ink); }
.mm-items { padding: 0 0 6px; }
.mm-item { font-size: 13px; padding: 5px 6px; }

/* ===== Tableros: pestañas y modal de tarea ===== */
.kb-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.kb-tab { padding: 7px 14px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 500; }
.kb-tab:hover { text-decoration: none; border-color: var(--accent); }
.kb-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.kb-tab .n { font-size: 12px; margin-left: 4px; opacity: .8; }
.kb-hint { margin-left: auto; }
.kcard { cursor: pointer; }
.kcard:focus-visible { outline: 2px solid var(--accent); }
.unblocks { font-size: 11.5px; font-weight: 600; color: var(--good-ink); }
.modal-card.wide { width: min(900px, 100%); }
.code-big { font: 700 13px var(--mono); padding: 3px 9px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.card-modal .card-text { font-size: 16px; margin: 14px 0; }
.card-modal .xref { padding: 9px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 10px; font-size: 13.5px; line-height: 1.7; }
.card-modal .blocked-box { border-left: 3px solid var(--critical); }
.card-sec { font-size: 15px; margin: 20px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.card-fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; font-size: 14px; }
.card-fields dt { color: var(--muted); font-size: 12.5px; padding-top: 2px; }
.card-fields dd { margin: 0; }
.card-fields hr { grid-column: 1 / -1; border: 0; border-top: 1px dashed var(--line); margin: 4px 0; width: 100%; }
.code-link { font-weight: 600; }
@media (max-width: 860px) {
  .card-fields { grid-template-columns: 1fr; }
  .kb-hint { display: none; }
  .task-row { flex-wrap: wrap; }
  .home-doc { padding: 16px; }
}
.card-modal .md h2 { font-size: 17px; margin-top: 22px; } .card-modal .md h3 { font-size: 15px; }

/* Notas: columna centrada (los tableros siguen a todo el ancho) */
.note-view { max-width: 980px; margin: 0 auto; }
.note-view.wide { max-width: none; }
.note-view .md { max-width: none; }
