/*
 * Marisou web: design tokens and components. Plain CSS, no build step.
 *
 * CONTRAST (WCAG 2.2 AA; text 4.5:1, UI components/large text 3:1). Computed by web/dev/contrast.mjs.
 *   LIGHT  text #1c1c1e: 17.0 on panel, 15.2 on bg.      text-2 #55555c: 7.4 on panel, 6.6 on bg.
 *          control border #8a8a94: 3.4 on panel, 3.1 on bg.
 *          fallback accent #0a58c8: 6.5 on panel, 5.8 on bg (as text); white text on it: 6.5.
 *          danger #b3261e 6.5, ok #1d6b35 6.5, warn #8a5300 6.3 (on panel).
 *   DARK   text #f2f2f5: 14.9 on panel, 16.2 on bg.      text-2 #a9a9b3: 7.1 on panel, 7.8 on bg.
 *          control border #7d7d88: 4.1 on panel, 3.7 on panel-2.
 *          fallback accent text #79adff: 7.3 on panel, 8.0 on bg; fill #2f6fd8 with white text: 4.8,
 *          and the primary button also carries a 1px accent-text border (9:1) so it reads on dark panels.
 *          danger #ff8a80 7.3, ok #6fd68a 9.2, warn #f0b45a 9.0 (on panel).
 *   SYSTEM ACCENT (AccentColor, where supported): never used raw for text. Derived tokens are
 *          light: text = accent 55% + black (>= 4.9 on panel for every macOS accent incl. yellow 4.9/4.4 on bg),
 *                 fill = accent 50% + black with white text (>= 5.7);
 *          dark:  text = accent 45% white mix (>= 8.8 on panel), fill = accent 50% + black with white text (>= 5.7).
 *   Verified for blue, purple, pink, red, orange, yellow, green, graphite.
 */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f4;
  --panel: #ffffff;
  --panel-2: #f7f7f9;
  --hover: rgba(0, 0, 0, .05);
  --pressed: rgba(0, 0, 0, .09);
  --line: #dcdce2;
  --line-strong: #8a8a94;
  --text: #1c1c1e;
  --text-2: #55555c;
  --accent-text: #0a58c8;
  --accent-fill: #0a58c8;
  --on-accent: #ffffff;
  --accent-soft: rgba(10, 88, 200, .10);
  --focus: #0a58c8;
  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, .10);
  --ok: #1d6b35;
  --ok-soft: rgba(29, 107, 53, .12);
  --warn: #8a5300;
  --info: #0b7285;
  --warn-soft: rgba(138, 83, 0, .12);
  --add-bg: rgba(29, 107, 53, .14);
  --del-bg: rgba(179, 38, 30, .13);
  --shadow: 0 8px 28px rgba(0, 0, 0, .16), 0 1px 3px rgba(0, 0, 0, .10);
}
@supports (color: AccentColor) and (color: color-mix(in srgb, red, blue)) {
  :root, :root[data-theme="light"] {
    --accent-text: color-mix(in srgb, AccentColor 55%, black);
    --accent-fill: color-mix(in srgb, AccentColor 50%, black);
    --accent-soft: color-mix(in srgb, AccentColor 14%, transparent);
    --focus: color-mix(in srgb, AccentColor 55%, black);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161618;
  --panel: #1e1e21;
  --panel-2: #26262a;
  --hover: rgba(255, 255, 255, .07);
  --pressed: rgba(255, 255, 255, .12);
  --line: #38383e;
  --line-strong: #7d7d88;
  --text: #f2f2f5;
  --text-2: #a9a9b3;
  --accent-text: #79adff;
  --accent-fill: #2f6fd8;
  --on-accent: #ffffff;
  --accent-soft: rgba(121, 173, 255, .16);
  --focus: #79adff;
  --danger: #ff8a80;
  --danger-soft: rgba(255, 138, 128, .14);
  --ok: #6fd68a;
  --ok-soft: rgba(111, 214, 138, .14);
  --warn: #f0b45a;
  --info: #5cc8d8;
  --warn-soft: rgba(240, 180, 90, .14);
  --add-bg: rgba(111, 214, 138, .16);
  --del-bg: rgba(255, 138, 128, .16);
  --shadow: 0 8px 28px rgba(0, 0, 0, .55), 0 1px 3px rgba(0, 0, 0, .4);
}
@supports (color: AccentColor) and (color: color-mix(in srgb, red, blue)) {
  :root[data-theme="dark"] {
    --accent-text: color-mix(in srgb, AccentColor 55%, white);
    --accent-fill: color-mix(in srgb, AccentColor 50%, black);
    --accent-soft: color-mix(in srgb, AccentColor 22%, transparent);
    --focus: color-mix(in srgb, AccentColor 55%, white);
  }
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #161618; --panel: #1e1e21; --panel-2: #26262a;
    --hover: rgba(255, 255, 255, .07); --pressed: rgba(255, 255, 255, .12);
    --line: #38383e; --line-strong: #7d7d88; --text: #f2f2f5; --text-2: #a9a9b3;
    --accent-text: #79adff; --accent-fill: #2f6fd8; --on-accent: #ffffff;
    --accent-soft: rgba(121, 173, 255, .16); --focus: #79adff;
    --danger: #ff8a80; --danger-soft: rgba(255, 138, 128, .14);
    --ok: #6fd68a; --ok-soft: rgba(111, 214, 138, .14);
    --warn: #f0b45a; --info: #5cc8d8; --warn-soft: rgba(240, 180, 90, .14);
    --add-bg: rgba(111, 214, 138, .16); --del-bg: rgba(255, 138, 128, .16);
    --shadow: 0 8px 28px rgba(0, 0, 0, .55), 0 1px 3px rgba(0, 0, 0, .4);
  }
  @supports (color: AccentColor) and (color: color-mix(in srgb, red, blue)) {
    :root[data-theme="system"] {
      --accent-text: color-mix(in srgb, AccentColor 55%, white);
      --accent-fill: color-mix(in srgb, AccentColor 50%, black);
      --accent-soft: color-mix(in srgb, AccentColor 22%, transparent);
      --focus: color-mix(in srgb, AccentColor 55%, white);
    }
  }
}

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 8px;
  --r-lg: 12px;
  --toolbar-h: 48px;
  --status-h: 28px;
  --conv-w: 420px;
  --sidebar-w: 212px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent-fill); color: var(--on-accent); padding: 8px 12px; border-radius: var(--r); }
.skip-link:focus { top: 8px; }
.skip-inline { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-inline:focus { position: static; width: auto; height: auto; clip: auto; padding: 4px 10px; border-radius: var(--r); background: var(--accent-fill); color: var(--on-accent); }
.icon { width: 18px; height: 18px; flex: none; }
.grow { flex: 1 1 auto; min-width: 0; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-height: 32px; padding: 4px 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { background: var(--pressed); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent-fill); color: var(--on-accent); border-color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent-fill); filter: brightness(1.12); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.small { min-height: 26px; padding: 2px 8px; font-size: 12.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; background: transparent; border-radius: var(--r); cursor: pointer; color: inherit;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); }
.icon-btn:active:not(:disabled) { background: var(--pressed); }
.icon-btn[aria-pressed="true"], .icon-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.input, .textarea, .select {
  width: 100%; min-height: 32px; padding: 5px 10px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.select { padding-right: 6px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > .seg { justify-self: start; }
.field > span:first-child, .field-label { font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 4px 10px; min-height: 28px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.seg button:focus-visible { outline-offset: -2px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch .track { width: 34px; height: 20px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel-2); position: relative; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--line-strong); transition: transform .12s; }
.switch input:checked + .track { background: var(--accent-fill); border-color: var(--accent-text); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--on-accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- toolbar ---------- */
#toolbar {
  display: flex; align-items: center; gap: 10px; min-height: var(--toolbar-h); padding: 6px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .01em; }
.brand-mark { display: inline-grid; place-items: center; color: var(--accent-text); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark .icon { width: 100%; height: 100%; }
.brand .brand-mark { width: 28px; height: 28px; }
.avatar .brand-mark { width: 22px; height: 22px; }
#toolbar .select { width: auto; max-width: 200px; }
.search { position: relative; flex: 1 1 260px; max-width: 460px; margin: 0 auto; }
.search .input { padding-left: 32px; }
.search > .icon { position: absolute; left: 9px; top: 7px; color: var(--text-2); pointer-events: none; }
.search-pop {
  position: absolute; top: 38px; left: 0; right: 0; z-index: 40; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; padding: 6px;
}
.search-pop h4 { padding: 6px 8px 2px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.search-pop button { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; padding: 6px 8px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; }
.search-pop button:hover, .search-pop button[aria-selected="true"] { background: var(--hover); }

/* ---------- banner ---------- */
#demo-notice { padding: 6px 14px; background: var(--accent-soft, var(--warn-soft)); color: var(--text, inherit); border-bottom: 1px solid var(--border, var(--warn)); font-size: 13px; text-align: center; }
#demo-notice[hidden] { display: none; }
#banner { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn); font-weight: 500; }
#banner.err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ---------- main layout ---------- */
#main { display: flex; flex: 1 1 0; min-height: 0; min-width: 0; }
#sidebar {
  flex: none; width: var(--sidebar-w); display: flex; flex-direction: column; gap: 2px; padding: 10px 8px;
  background: var(--bg); border-right: 1px solid var(--line); overflow: auto;
}
body[data-sidebar="icons"] #sidebar { width: 56px; align-items: center; padding-inline: 6px; }
body[data-sidebar="hidden"] #sidebar { display: none; }
.sb-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px;
  border: 0; border-radius: var(--r); background: transparent; cursor: pointer; text-align: left; position: relative;
}
.sb-item:hover { background: var(--hover); }
.sb-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.sb-item .sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text-2); }
.sb-count { min-width: 20px; padding: 0 6px; text-align: center; border-radius: 10px; background: var(--accent-fill); color: var(--on-accent); font-size: 11.5px; font-weight: 600; }
.sb-title { margin: 14px 10px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
/* labels stay readable for screen readers in icons-only mode (accessible name = visible text, G3) */
body[data-sidebar="icons"] .sb-label, body[data-sidebar="icons"] .sb-tag { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; padding: 0; border: 0; }
body[data-sidebar="icons"] .sb-title { display: none; }
body[data-sidebar="icons"] .sb-item { width: 40px; justify-content: center; padding: 6px; }
body[data-sidebar="icons"] .sb-count { position: absolute; top: 0; right: 0; min-width: 16px; font-size: 10px; padding: 0 4px; }
body[data-sidebar="icons"] .sb-sep { width: 24px; height: 1px; background: var(--line); margin: 8px 0; }
.sb-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.sb-spacer { flex: 1; }
.sb-item.preview { color: var(--text-2); }

#conv {
  flex: 0 0 var(--conv-w); min-width: 280px; max-width: 70vw; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
#canvas { flex: 1 1 0; min-width: 320px; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
body[data-conv="collapsed"] #conv, body[data-conv="collapsed"] #split-conv { display: none; }
body[data-canvas="collapsed"] #canvas, body[data-canvas="collapsed"] #split-conv { display: none; }
body[data-canvas="collapsed"] #conv { flex: 1 1 0; max-width: none; }
.splitter { flex: none; width: 7px; margin-left: -4px; margin-right: -3px; cursor: col-resize; z-index: 5; position: relative; }
.splitter::after { content: ""; position: absolute; inset: 0 3px; background: transparent; transition: background .1s; }
.splitter:hover::after, .splitter:focus-visible::after, .splitter.dragging::after { background: var(--accent-text); }
.splitter:focus-visible { outline: none; }
@media (max-width: 1050px) {
  :root { --conv-w: 340px; }
  #toolbar .brand span { display: none; }
}

/* ---------- panes ---------- */
.pane-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 46px; }
.pane-head h2, .pane-head h1 { font-size: 15px; }
.status-chip { font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap; }
.status-chip[data-status="needs_review"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.status-chip[data-status="in_progress"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-text); }
.status-chip[data-status="done"] { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.status-chip[data-status="unmapped"] { border-style: dashed; }

/* ---------- conversation ---------- */
.timeline { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: auto; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg .avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.msg .avatar img { width: 22px; height: 22px; object-fit: contain; }
.msg-main { min-width: 0; flex: 1; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.msg-meta strong { color: var(--text); font-size: 12.5px; }
.msg.user .msg-main { background: var(--accent-soft); border-radius: var(--r-lg); padding: 8px 12px; }
.msg.user { flex-direction: row-reverse; margin-left: 28px; }
.msg.user .avatar { display: none; }
.msg.pending { opacity: .65; }
.md { overflow-wrap: anywhere; }
.md p { margin: 0 0 .6em; } .md p:last-child { margin-bottom: 0; }
.md h3, .md h4, .md h5, .md h6 { margin: .8em 0 .3em; font-size: 1.05em; }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.4em; }
.md code { font-family: var(--mono); font-size: .9em; background: var(--panel-2); padding: 1px 4px; border-radius: 4px; border: 1px solid var(--line); }
.md pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; overflow: auto; margin: 0 0 .6em; }
.md pre code { background: none; border: 0; padding: 0; }
.md a { color: var(--accent-text); text-decoration: underline; }
.md blockquote { margin: 0 0 .6em; padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--line); }
.md h1, .md h2 { margin: 1em 0 .4em; line-height: 1.25; } .md h1 { font-size: 1.6em; } .md h2 { font-size: 1.3em; }
.md.doc h3 { font-size: 1.12em; } .md.doc h4, .md.doc h5, .md.doc h6 { font-size: 1em; }
.md > :first-child { margin-top: 0; }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin: .2em 0 0; }
.md li.task { list-style: none; margin-left: -1.4em; } .md li.task > input { margin: 0 .5em 0 0; vertical-align: middle; accent-color: var(--accent-fill); }
.md li.task > ul, .md li.task > ol { margin-left: 1.4em; }
.md del { color: var(--text-2); }
.md img.md-img { max-width: 100%; max-height: 420px; border-radius: var(--r); cursor: zoom-in; vertical-align: middle; }
.md-table { overflow-x: auto; margin: 0 0 .8em; max-width: 100%; }
.md-table:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.md-table table { border-collapse: collapse; font-size: .95em; min-width: 50%; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; vertical-align: top; min-width: 3em; }
.md-table th { background: var(--panel-2); font-weight: 600; }
.md-table [data-align="center"] { text-align: center; } .md-table [data-align="right"] { text-align: right; }
.md-code { margin: 0 0 .6em; } .md-code pre { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.md-code-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 6px 2px 10px; font-size: .8em; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0; }
.md-copy { border: 0; background: transparent; color: var(--accent-text); padding: 3px 8px; border-radius: 6px; cursor: pointer; font: inherit; min-height: 24px; }
.md-copy:hover { background: var(--hover); } .md-copy:focus-visible { outline: 2px solid var(--focus); }
/* Frontmatter as a Properties block (Obsidian style) */
.md-props { margin: 0 0 1em; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); font-size: .92em; }
.md-props > summary { cursor: pointer; padding: 6px 10px; font-weight: 600; color: var(--text-2); }
.md-props > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.md-props > :not(summary) { margin: 0 10px 10px; }
.fm-dl { display: grid; gap: 2px; margin: 0; }
.fm-row { display: grid; grid-template-columns: minmax(80px, 28%) 1fr; gap: 10px; padding: 3px 0; align-items: start; border-top: 1px solid var(--line); }
.fm-row:first-child { border-top: 0; }
.fm-row dt { color: var(--text-2); font-weight: 500; overflow-wrap: anywhere; }
.fm-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.fm-text { white-space: pre-wrap; }
.fm-nested { padding-left: 10px; border-left: 2px solid var(--line); }
.fm-chips, .fm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.fm-list { display: grid; }
.fm-chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 8px; background: var(--panel); }
.fm-tag { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-text); }
.fm-raw { margin: 0 0 6px; }
.md-props input[type=checkbox] { margin: 0; vertical-align: middle; }
.md-props-edit { margin: 0 0 .6em; user-select: text; }
@media (max-width: 520px) { .fm-row { grid-template-columns: 1fr; gap: 0; } }
@media (forced-colors: active) { .md-props, .fm-chip { border: 1px solid CanvasText; } .fm-tag { color: LinkText; } }

.md-note { font-size: .85em; color: var(--text-2); margin: 0 0 .6em; }
.md-mermaid { margin: 0 0 .8em; overflow-x: auto; }
.md-mermaid[data-state="done"] { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.md-mermaid[data-state="done"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.md-mermaid svg { display: block; margin: 0 auto; height: auto; max-width: none; width: max(min(100%, var(--mmd-w, 100%)), calc(var(--mmd-w, 0px) * .6)); }
.md-mermaid-src { margin-top: 8px; font-size: .85em; color: var(--text-2); }
.md-mermaid-src summary { cursor: pointer; min-height: 24px; } .md-mermaid-src summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.md-mermaid-src .md-code { margin-top: 6px; }
.md-mermaid[data-state="error"] .md-note { border-left: 3px solid var(--danger); padding-left: 8px; color: var(--text); }
@media (prefers-reduced-motion: reduce) { .md-mermaid svg *, .md-mermaid svg { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .md-mermaid[data-state="done"] { border-color: CanvasText; } .md-mermaid svg { background: Canvas; } .md-mermaid svg text, .md-mermaid svg tspan { fill: CanvasText; } }
.md-chart { margin: 0 0 .8em; max-width: 680px; }
.md-chart figcaption { font-weight: 600; margin-bottom: 4px; }
.md-chart-plot { display: flex; flex-direction: column; gap: 6px; }
.md-chart[data-type="pie"] .md-chart-plot { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 16px; } .md-chart[data-type="pie"] svg { max-width: 240px; }
.md-chart svg { width: 100%; height: auto; }
.md-chart { --chart-1: #0a58c8; --chart-2: #c2410c; --chart-3: #15803d; --chart-4: #7e3fb3; --chart-5: #a16207; --chart-6: #0e7490; }
:root[data-theme="dark"] .md-chart { --chart-1: #79adff; --chart-2: #fb923c; --chart-3: #4ade80; --chart-4: #c4a0ff; --chart-5: #facc15; --chart-6: #22d3ee; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .md-chart { --chart-1: #79adff; --chart-2: #fb923c; --chart-3: #4ade80; --chart-4: #c4a0ff; --chart-5: #facc15; --chart-6: #22d3ee; } }
.md-chart .c0 { fill: var(--chart-1); stroke: var(--chart-1); } .md-chart .c1 { fill: var(--chart-2); stroke: var(--chart-2); } .md-chart .c2 { fill: var(--chart-3); stroke: var(--chart-3); }
.md-chart .c3 { fill: var(--chart-4); stroke: var(--chart-4); } .md-chart .c4 { fill: var(--chart-5); stroke: var(--chart-5); } .md-chart .c5 { fill: var(--chart-6); stroke: var(--chart-6); }
.md-chart rect.c0, .md-chart rect.c1, .md-chart rect.c2, .md-chart rect.c3, .md-chart rect.c4, .md-chart rect.c5 { stroke: none; }
.md-chart path { stroke: var(--panel); stroke-width: 2; } .md-chart circle:not(.sw) { stroke: var(--panel); stroke-width: 1.5; }
.md-chart polyline.line { fill: none; stroke-width: 2.5; }
.md-chart .grid { stroke: var(--line); stroke-width: 1; } .md-chart .zero { stroke: var(--line-strong); stroke-width: 1; }
.md-chart text { font: 12px var(--font); stroke: none; } .md-chart .axis { fill: var(--text-2); } .md-chart .val { fill: var(--text); }
.md-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; font-size: .9em; }
.md-legend .sw.c0 { background: var(--chart-1); } .md-legend .sw.c1 { background: var(--chart-2); } .md-legend .sw.c2 { background: var(--chart-3); } .md-legend .sw.c3 { background: var(--chart-4); } .md-legend .sw.c4 { background: var(--chart-5); } .md-legend .sw.c5 { background: var(--chart-6); }
.md-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.md-lightbox { border: 0; padding: 12px; border-radius: var(--r); background: var(--panel); color: var(--text); max-width: 94vw; max-height: 94vh; }
.md-lightbox::backdrop { background: rgba(0, 0, 0, .6); }
.md-lightbox img { display: block; max-width: calc(94vw - 24px); max-height: calc(94vh - 80px); margin: 0 auto 10px; }
.rich-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.rich-bar { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.rich-bar[hidden] { display: none; }
.tb-group { display: inline-flex; gap: 2px; align-items: center; }
.tb-select { min-height: 30px; padding: 2px 6px; }
.rich-scroll { background: var(--panel); }
.md.rich { outline: none; min-height: 60%; max-width: 820px; margin-inline: auto; caret-color: var(--text); }
.md.rich:focus-visible { box-shadow: none; }
.md.rich[contenteditable="true"]:focus { outline: none; }
.md.rich pre { white-space: pre-wrap; } .md.rich pre[data-lang]::before { content: attr(data-lang); display: block; color: var(--text-2); font-size: .8em; margin-bottom: 4px; }
.md.rich th, .md.rich td { min-width: 4em; }
.md.rich .md-table { overflow-x: auto; }
/* Documents sit centred in the pane, like a page (Steff, 25 Nov 2026) */
.doc-view { max-width: 820px; margin-inline: auto; }
.code-editor.doc-width { padding-inline: max(18px, calc((100% - 820px) / 2)); }
.streaming-dots::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-text); margin-left: 4px; animation: pulse 1s ease-in-out infinite; vertical-align: middle; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 8px; border-radius: 12px; font-size: 12px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
}
button.chip { cursor: pointer; } button.chip:hover { background: var(--hover); }
.chip .icon { width: 14px; height: 14px; }
.chip .x { border: 0; background: transparent; padding: 0; display: grid; cursor: pointer; border-radius: 50%; }
.chip.mem { border-color: var(--accent-text); color: var(--accent-text); }

.card { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); padding: 10px 12px; }
.exec-card { display: grid; gap: 6px; margin-left: 38px; border-color: var(--line); background: var(--panel-2); }
.exec-card .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exec-card .agent { font-weight: 600; }
.exec-card .task { color: var(--text-2); font-size: 12.5px; }
.exec-card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.exec-card.waiting_for_approval { border-color: var(--warn); }
.exec-card.failed { border-color: var(--danger); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 10px; border: 1px solid var(--line-strong); color: var(--text-2); background: var(--panel); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill[data-state="running"] { color: var(--accent-text); border-color: var(--accent-text); background: var(--accent-soft); }
.pill[data-state="running"]::before { animation: pulse 1.1s ease-in-out infinite; }
.pill[data-state="queued"] { color: var(--text-2); }
.pill[data-state="waiting_for_approval"] { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.pill[data-state="completed"] { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.pill[data-state="failed"] { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.pill[data-state="cancelled"] { color: var(--text-2); border-style: dashed; }
.timer { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; }
.perm-card { margin-left: 38px; border-color: var(--warn); background: var(--warn-soft); display: grid; gap: 6px; }
.perm-card .tool { font-family: var(--mono); font-size: 12.5px; }
.decision { margin-left: 38px; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); padding: 6px 10px; border-left: 3px solid var(--line-strong); }
.decision.approved { border-color: var(--ok); } .decision.sent_back { border-color: var(--warn); }
.decision.policy.allowed { border-color: var(--ok); } .decision.policy.denied { border-color: var(--danger, var(--warn)); }
.decision.policy code, .perm-card code { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.policy-grid { display: grid; gap: 10px; }
.policy-grid textarea { width: 100%; min-height: 88px; font-family: var(--mono); font-size: 12.5px; }
.decision q { color: var(--text); quotes: "\201C" "\201D"; }
.err-item { margin-left: 38px; display: flex; gap: 8px; color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: var(--r); }
.skeleton { display: grid; gap: 8px; padding: 6px 0; }
.skel-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 36px 20px; margin: auto; max-width: 420px; }
.empty-title { font-weight: 600; font-size: 15px; }
.error-state { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 24px; color: var(--danger); margin: auto; }
.error-state .muted { color: var(--text-2); }
.jump-end { position: absolute; right: 18px; bottom: 120px; box-shadow: var(--shadow); }

.composer { padding: 10px 12px 12px; border-top: 1px solid var(--line); position: relative; }
.composer-box { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); padding: 8px; display: grid; gap: 6px; }
.composer-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.composer textarea { border: 0; background: transparent; resize: none; width: 100%; min-height: 40px; max-height: 180px; padding: 2px 4px; line-height: 1.45; }
.composer textarea:focus-visible { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 6px; }
.composer-hint { font-size: 11.5px; color: var(--text-2); }
.mention-pop { position: absolute; left: 14px; bottom: calc(100% - 6px); z-index: 30; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 4px; }
.mention-pop [role="option"] { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.mention-pop [aria-selected="true"], .mention-pop [role="option"]:hover { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- canvas tabs and views ---------- */
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); overflow-x: auto; background: var(--bg); min-height: 42px; align-items: flex-end; scrollbar-width: thin; }
.tab { display: flex; align-items: center; gap: 6px; max-width: 220px; padding: 5px 4px 5px 10px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--r) var(--r) 0 0; background: transparent; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { background: var(--hover); }
.tab.selected { background: var(--panel); border-color: var(--line); font-weight: 600; }
.tab-label { display: flex; align-items: center; gap: 6px; min-width: 0; outline-offset: 2px; }
.tab .t-title { overflow: hidden; text-overflow: ellipsis; }
.tab .badge { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-fill); border: 1px solid var(--accent-text); flex: none; }
.tab .dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.tab .close { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 50%; cursor: pointer; flex: none; }
.tab .close:hover { background: var(--pressed); }
.tab .close .icon { width: 13px; height: 13px; }
.views { flex: 1; min-height: 0; position: relative; display: flex; }
.view { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.view-scroll { flex: 1; overflow: auto; padding: 18px 22px 28px; }
.view-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 50px; flex-wrap: wrap; }
.view-head h2 { font-size: 16px; }
.page { max-width: 880px; margin: 0 auto; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 22px 0 8px; font-weight: 600; }
.list { display: grid; gap: 6px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); }
button.list-row { text-align: left; width: 100%; cursor: pointer; }
.list-row:hover { background: var(--hover); }
.list-row.selected { border-color: var(--accent-text); background: var(--accent-soft); }

/* home */
.greeting { font-size: 24px; font-weight: 700; margin: 6px 0 2px; }

/* inbox */
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 6px; }
.fchip { padding: 3px 12px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-size: 13px; }
.fchip[aria-pressed="true"] { background: var(--accent-fill); color: var(--on-accent); border-color: var(--accent-text); }
.fchip .n { opacity: .85; margin-left: 4px; font-variant-numeric: tabular-nums; }
.inbox-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.inbox-row.current { border-color: var(--accent-text); }
.inbox-row .open { all: unset; cursor: pointer; display: block; min-width: 0; }
.inbox-row .open:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.inbox-row .name { font-weight: 600; }
.inbox-row .prev { color: var(--text-2); font-size: 12.5px; }
.inbox-row .side { display: flex; align-items: center; gap: 8px; }
.inbox-row .select { width: auto; min-height: 28px; }
.kanban { display: flex; gap: 12px; padding: 10px 16px 16px; overflow-x: auto; flex: 1; align-items: flex-start; }
.kcol { flex: 0 0 210px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px; display: grid; gap: 8px; max-height: 100%; overflow: auto; }
.kcol h3 { font-size: 12.5px; display: flex; justify-content: space-between; padding: 2px 4px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; display: grid; gap: 6px; }

/* resources */
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.crumbs button { border: 0; background: transparent; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.crumbs button:hover { background: var(--hover); }
.local-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 0 7px; border-radius: 10px; border: 1px solid var(--ok); color: var(--ok); background: var(--ok-soft); white-space: nowrap; }
.local-badge .icon { width: 12px; height: 12px; }
.file-row { display: grid; grid-template-columns: 24px 1fr 90px 130px auto; gap: 8px; align-items: center; padding: 4px 8px; border-radius: var(--r); }
.file-row:hover { background: var(--hover); }
.file-row .name-btn { all: unset; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 0; }
.file-row .name-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-row .actions { display: flex; gap: 2px; opacity: 0; }
.file-row:hover .actions, .file-row:focus-within .actions { opacity: 1; }
@media (max-width: 1100px) { .file-row { grid-template-columns: 24px 1fr auto; } .file-row .col-size, .file-row .col-date { display: none; } }
.code-editor { flex: 1; width: 100%; border: 0; resize: none; padding: 14px 18px; font: 13px/1.55 var(--mono); background: var(--panel); color: var(--text); tab-size: 2; min-height: 0; }
.code-editor:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0; }
.notice { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn); flex-wrap: wrap; }
.notice.err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.notice .btn { color: var(--text); }

/* artifact */
.art-bar { display: flex; gap: 8px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.art-bar .comment { flex: 1 1 260px; min-height: 34px; height: 34px; resize: vertical; }
.art-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.compare { flex: 1; min-height: 0; overflow: auto; font: 13px/1.5 var(--mono); }
.compare .crow { display: grid; grid-template-columns: 1fr 1fr; }
.compare .crow > .diff-line:first-child { border-right: 1px solid var(--line); }
.diff-line { padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.5em; }
.diff-line.add { background: var(--add-bg); } .diff-line.del { background: var(--del-bg); }
.diff-line.pad { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--hover) 6px 7px); }
.diff-sign { display: inline-block; width: 1.4em; color: var(--text-2); user-select: none; }

/* settings, memory, agents forms */
.form { max-width: 640px; }
.mem-entry { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.mem-entry.disabled .mem-text { opacity: .6; text-decoration: line-through; }
.mem-entry.focused { border-color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent-text); }
.mem-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- status bar ---------- */
#statusbar { display: flex; align-items: center; gap: 16px; min-height: var(--status-h); padding: 2px 12px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dot.off { background: var(--danger); }
.dot.unknown { background: var(--line-strong); }

/* ---------- toasts, dialogs ---------- */
#toasts { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(520px, 92vw); }
.toast { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--text); color: var(--bg); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.toast .btn { color: var(--bg); border-color: transparent; } .toast .btn:hover:not(:disabled) { background: rgba(127,127,127,.3); }
.toast .icon-btn { color: var(--bg); }
.toast.error { background: var(--danger); color: #fff; }
.toast.error .icon-btn { color: #fff; }
.toast-msg { flex: 1; }
dialog.dialog { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); width: min(440px, 92vw); }
dialog.dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog.dialog h2 { font-size: 16px; margin-bottom: 12px; }
dialog.dialog p { margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.picker-list { max-height: 280px; overflow: auto; display: grid; gap: 4px; margin: 8px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media (forced-colors: active) {
  .btn, .input, .select, .textarea, .chip, .pill { border: 1px solid ButtonText; }
}

/* Login (AU-1) */
#login { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--bg); }
.login-card { display: grid; gap: 8px; width: min(360px, 90vw); padding: 28px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--shadow); }
.login-card img { justify-self: center; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card label { font-size: 13px; font-weight: 600; margin-top: 6px; }
.login-card .btn { margin-top: 12px; justify-content: center; }
.login-error { color: var(--danger); font-size: 13px; min-height: 1em; }
.login-error:empty { display: none; }

/* ---------- labels (BL-1): name is always text, colour is only a dot ---------- */
.lbl-list { display: flex; flex-wrap: wrap; gap: 4px; }
.lbl-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 1px 8px; border-radius: 11px; font-size: 12px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); }
.lbl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--lc-l, var(--text-2)); }
:root[data-theme="dark"] .lbl-dot[data-obj] { background: var(--lc-d, var(--lc-l)); }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .lbl-dot[data-obj] { background: var(--lc-d, var(--lc-l)); } }
.lbl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.fgroup { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fgroup + .fgroup:not([hidden]) { margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--line-strong); }
.fchip.lblf { display: inline-flex; align-items: center; gap: 6px; }
.fchip.lblf .dot-slot { display: inline-flex; }
.fchip[aria-pressed="true"] .lbl-dot { box-shadow: 0 0 0 1.5px var(--on-accent); }
.inbox-row .lbl-list { margin-top: 4px; }

/* popovers: label picker and menu button menu */
.pop { position: fixed; z-index: 60; min-width: 200px; max-width: min(320px, 92vw); max-height: min(360px, 60vh); overflow: auto; padding: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.pop-set { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 4px; }
.pop-set legend { font-size: 12px; font-weight: 600; color: var(--text-2); padding: 2px 6px; }
.pop-opts { display: grid; gap: 2px; }
.pop-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pop-opt:hover { background: var(--hover); }
.pop-opt:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.menu-item:hover { background: var(--hover); }
.menu-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.menu-item .mi-check { width: 14px; height: 14px; visibility: hidden; }
.menu-item[aria-checked="true"] .mi-check { visibility: visible; }
.menu-item[aria-checked="true"] { font-weight: 600; }

/* board */
.kcol-body { display: grid; gap: 8px; min-height: 48px; align-content: start; }
.kcol.drop-target { outline: 2px dashed var(--accent-text); outline-offset: -2px; background: var(--accent-soft); }
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .5; }
.kcard .kopen { all: unset; cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.kcard .kopen:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.kmove .icon { width: 14px; height: 14px; }
.kstatus { display: inline-flex; margin-left: 6px; }

/* settings labels */
.lbl-rows { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.lbl-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.lbl-colors { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.lbl-swatch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
@media (forced-colors: active) {
  .lbl-dot { forced-color-adjust: none; background: Highlight; }
  .lbl-chip, .pop, .lbl-row { border: 1px solid CanvasText; }
  .kcol.drop-target { outline-color: Highlight; }
}

/* ---------- vault (BL-3): wikilinks, Links panel, quick switcher ---------- */
.md a.wikilink { text-decoration-style: solid; }
.md a.wikilink.unresolved, .md .wikilink-embed.unresolved { text-decoration: underline dashed; text-underline-offset: 3px; }
.md .wikilink-embed { color: var(--text-2); }
.kbd { font: 11.5px var(--mono); padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text-2); background: var(--panel-2); margin-left: 6px; }
.links-panel { border-top: 1px solid var(--line); background: var(--panel-2); max-height: 38%; overflow: auto; flex: none; }
.links-panel h3 { font-size: 13px; margin: 0; }
.links-toggle { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 16px; cursor: pointer; font-weight: 600; color: var(--text-2); position: sticky; top: 0; background: var(--panel-2); }
.links-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.links-toggle .icon { transition: transform .12s; transform: rotate(-90deg); }
.links-toggle[aria-expanded="true"] .icon { transform: none; }
.links-body { padding: 0 16px 12px; display: grid; gap: 10px; }
.links-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 0 0 4px; }
.links-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.links-group p { margin: 0; }
.link-item { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.link-item:hover { background: var(--hover); }
.link-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.link-title { font-weight: 600; margin-right: 6px; }
.link-snippet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.link-missing { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 8px; }
dialog.switcher { width: min(620px, 94vw); padding: 12px; margin: 10vh auto auto; }
.sw-input { width: 100%; }
.sw-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; display: grid; gap: 2px; }
.sw-opt { padding: 6px 10px; border-radius: 6px; cursor: pointer; border-left: 3px solid transparent; min-width: 0; }
.sw-opt[aria-selected="true"] { background: var(--hover); border-left-color: var(--accent-text); }
.sw-main { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-opt mark { background: var(--accent-soft); color: inherit; font-weight: 700; text-decoration: underline; border-radius: 2px; }
.sw-empty { margin: 10px 4px 0; }
.sw-hint { margin: 10px 4px 0; }
@media (forced-colors: active) { .sw-opt[aria-selected="true"] { outline: 2px solid Highlight; } .sw-opt mark { background: transparent; color: Highlight; } }

/* vault search (BL-3 slice 2a) */
.md button.tag { all: unset; cursor: pointer; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 0 7px; font-size: .92em; }
.md button.tag:hover { text-decoration: underline; }
.md button.tag:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-pop button.has-snippet { flex-wrap: wrap; }
.search-pop .hit-snippet { flex-basis: 100%; padding-left: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-pop mark, .vs mark, .links-panel mark { background: var(--accent-soft); color: inherit; font-weight: 700; text-decoration: underline; border-radius: 2px; }
.vs { display: grid; gap: 10px; padding: 8px 16px; }
.vs h3 { font-size: 13px; margin: 6px 0 4px; }
.vs-bar { display: flex; align-items: center; gap: 8px; }
.vs-bar .input { flex: 1; }
.vs-results, .vs-tags, .vs-tags ul, .vs-missing { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.vs-tags ul { padding-left: 16px; }
.vs-status { margin: 0; }
.vs-hit .vs-path { margin-left: 4px; }
.tag-facet { all: unset; box-sizing: border-box; cursor: pointer; padding: 2px 8px; border-radius: 6px; color: var(--accent-text); }
.tag-facet:hover { background: var(--hover); }
.tag-facet:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.vs-missing li { display: flex; align-items: center; gap: 4px; padding: 2px 8px; }
@media (forced-colors: active) { .md button.tag { color: LinkText; border: 1px solid LinkText; } .search-pop mark, .vs mark, .links-panel mark { background: transparent; color: Highlight; } }
/* Bronnen views: switcher, mindmap, graph */
.res-bar { padding: 8px 16px 0; }
.res-tabs { display: inline-flex; border-bottom: 1px solid var(--line); gap: 4px; }
.res-tab { border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; min-height: 32px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font: inherit; }
.res-tab:hover { background: var(--hover); }
.res-tab[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent-text); font-weight: 600; }
.res-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.res-search-slot:empty { display: none; }
.res-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.res-pane[hidden] { display: none; }
.viz-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 16px; }
.viz-bar .spacer { flex: 1; }
.viz-chk { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.viz-sum { margin: 0; padding: 0 16px 6px; }
.viz-stage { position: relative; flex: 1; min-height: 320px; margin: 0 16px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.viz-state { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; overflow: auto; }
.viz-state[hidden] { display: none; }
.mm-svg, .gr-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.mm-svg.panning, .gr-canvas.panning { cursor: grabbing; }
.gr-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mm-links path { fill: none; stroke: var(--line-strong); stroke-width: 1.4; }
.mm-node { cursor: pointer; outline: none; }
.mm-node rect { fill: var(--panel-2); stroke: var(--line-strong); stroke-width: 1; }
.mm-node text { fill: var(--text); font: 13px system-ui, sans-serif; pointer-events: none; }
.mm-root rect { stroke: var(--accent-text); stroke-width: 1.8; }
.mm-folder rect { fill: var(--accent-soft); }
.mm-ghost rect { stroke-dasharray: 4 3; fill: var(--panel); }
.mm-ghost { cursor: default; }
.mm-chev { fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.mm-node:hover rect { stroke: var(--accent-text); }
.mm-node:focus-visible rect { stroke: var(--focus); stroke-width: 3; }
.gr-list { position: absolute; inset: 0; overflow: auto; }
.gr-list[hidden] { display: none; }
.gr-table { width: 100%; border-collapse: collapse; }
.gr-table th, .gr-table td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-weight: normal; }
.gr-table thead th { position: sticky; top: 0; background: var(--panel); font-weight: 600; }
.sort-btn, .linklike { border: 0; background: transparent; color: var(--accent-text); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; min-height: 24px; }
.sort-btn { color: var(--text); text-decoration: none; font-weight: 600; }
.sort-btn:focus-visible, .linklike:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
th[aria-sort="ascending"] .sort-btn::after { content: " \2191"; } th[aria-sort="descending"] .sort-btn::after { content: " \2193"; }
.gr-ghost { color: var(--text-2); font-style: italic; }
@media (forced-colors: active) {
  .mm-node rect { fill: Canvas; stroke: CanvasText; } .mm-node text { fill: CanvasText; } .mm-links path { stroke: GrayText; }
  .mm-node:focus-visible rect { stroke: Highlight; stroke-width: 4; } .mm-chev { stroke: CanvasText; }
  .viz-stage { border-color: CanvasText; } .res-tab[aria-selected="true"] { border-bottom-color: Highlight; }
}
/* Bronnen: collapsible vault search section */
.res-search { padding: 0 16px; }
.res-search > summary { cursor: pointer; padding: 6px 0; font-size: 13px; color: var(--accent-text); }
.res-search > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.res-search .vs { padding: 4px 0 8px; }
.rename-list { margin: 8px 0; padding-left: 20px; max-height: 40vh; overflow: auto; }

/* BL-3 slice 3: [[ autocomplete, note transclusion, graph legend, kind badge */
.wiki-pop { position: fixed; z-index: 80; list-style: none; margin: 0; padding: 4px; min-width: 240px; max-width: min(420px, 92vw); max-height: min(300px, 50vh); overflow: auto; background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.wiki-pop[hidden] { display: none; }
.wa-opt { display: grid; gap: 1px; padding: 5px 8px; border-radius: 6px; cursor: pointer; border-left: 3px solid transparent; min-width: 0; }
.wa-opt[aria-selected="true"] { background: var(--hover); border-left-color: var(--accent-text); }
.wa-main { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-opt mark { background: var(--accent-soft); color: inherit; font-weight: 700; text-decoration: underline; border-radius: 2px; }
.md-embed { margin: .8em 0; border: 1px solid var(--line-strong); border-left: 3px solid var(--accent-text); border-radius: var(--r); background: var(--panel-2); padding: 6px 12px 8px; }
.md-embed-head { font-size: .85em; font-weight: 600; margin-bottom: 4px; }
.md-embed-body > :first-child { margin-top: 0; }
.md-embed-body > :last-child { margin-bottom: 0; }
.md-embed-src { display: block; margin-top: 6px; }
.md-embed-fallback { border-style: dashed; }
.md-embed-fallback p { margin: 0 0 6px; }
.gr-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 0 16px 6px; }
.gr-legend ul { display: flex; flex-wrap: wrap; gap: 2px 12px; list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.gr-legend li { display: inline-flex; align-items: center; gap: 5px; }
.gr-swatch { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--line-strong); flex: none; }
.kind-badge { flex: none; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border: 1px solid var(--accent-text); color: var(--accent-text); border-radius: 999px; }
.kind-badge[hidden] { display: none; }
@media (forced-colors: active) {
  .wiki-pop, .md-embed, .kind-badge { border: 1px solid CanvasText; }
  .wa-opt[aria-selected="true"] { outline: 2px solid Highlight; }
  .wa-opt mark { background: transparent; color: Highlight; }
  .gr-swatch { forced-color-adjust: none; background: CanvasText; border-color: CanvasText; }
}

/* Design systems (BL-4). Tokens arrive as --ds-* properties on the preview element only; Marisou's chrome never reads them. */
.ds-panel { border-top: 1px solid var(--line); background: var(--panel); max-height: 45%; overflow: auto; flex: none; padding: 10px 16px 14px; display: grid; gap: 8px; }
.ds-panel h3 { font-size: 13px; margin: 0; color: var(--text-2); }
.ds-status { font-weight: 600; }
.ds-status.ok { color: var(--ok); } .ds-status.warn { color: var(--warn); } .ds-status.err { color: var(--danger); }
.ds-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.ds-issue { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ds-level { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; border-radius: 4px; border: 1px solid currentColor; }
.ds-issue.error .ds-level { color: var(--danger); } .ds-issue.warning .ds-level { color: var(--warn); } .ds-issue.info .ds-level { color: var(--info); }
.ds-active { border-color: var(--ok); color: var(--ok); }
.ds-preview { display: grid; gap: 8px; }
.ds-preview h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 6px 0 0; }
.ds-swatches { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; }
.ds-swatches li, .ds-type li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ds-swatch { flex: none; width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line-strong); }
.ds-swatches code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-type { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ds-type code { flex: none; min-width: 110px; }
.ds-sample { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-comps { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-comp { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r); font-size: 13px; }
.ds-doc { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 18px; }
.ds-doc h1 { font-size: 1.4em; margin: 0 0 .4em; }
.ds-applied { font-family: var(--dsx-font, var(--font)); }
.ds-applied.ds-has-bg { background: var(--dsx-bg); color: var(--text); }
.doc-view.ds-applied.ds-has-bg { border-radius: var(--r-lg); padding: 18px 22px; }
.ds-applied h1, .ds-applied h2, .ds-applied h3 { font-family: var(--dsx-head-font, var(--dsx-font, var(--font))); }
.ds-chip[hidden] { display: none; }
.ds-current { display: grid; gap: 6px; margin-bottom: 8px; }
.ds-note { display: flex; gap: 8px; align-items: center; color: var(--warn); }
.ds-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ds-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ds-state { font-size: 12px; font-weight: 600; }
.ds-state.ok { color: var(--ok); } .ds-state.warn { color: var(--warn); } .ds-state.err { color: var(--danger); }
@media (forced-colors: active) {
  .ds-applied, .ds-applied.ds-has-bg { background: Canvas; color: CanvasText; }
  .ds-swatch { forced-color-adjust: none; }
  .ds-level, .ds-comp { border: 1px solid CanvasText; }
}
.ds-comp.low { outline: 2px dashed var(--warn); outline-offset: 2px; }
.ds-low { font-size: 11px; }
