:root {
  --bg: #f6f6f3;
  --canvas: #fbfbf9;
  --panel: #ffffff;
  --ink: #1c1c1f;
  --muted: #6c6c72;
  --faint: #a3a3a8;
  --line: #e3e3de;
  --accent: #4353e6;
  --accent-ink: #ffffff;
  --danger: #c2372f;
  --ok: #1f8a5b;
  --edge: #8f8f97;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 4px 14px rgba(20, 20, 30, .06);
  --k-actor: #b0487f; --k-client: #2b74d8; --k-service: #5458d0; --k-database: #1b8f69;
  --k-cache: #c86f1c; --k-queue: #a85a12; --k-storage: #0e8183; --k-external: #6b7280;
  --k-process: #4b5563; --k-decision: #b7790a; --k-terminal: #374151; --k-document: #7a7d1f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315; --canvas: #18181b; --panel: #1f1f23; --ink: #ececee; --muted: #a0a0a8; --faint: #6c6c74;
    --line: #2e2e34; --accent: #7b88ff; --accent-ink: #0d0d12; --edge: #7c7c86;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    --k-actor: #e07ab0; --k-client: #66a6ff; --k-service: #9599ff; --k-database: #4cc79c;
    --k-cache: #f0a25a; --k-queue: #e0954a; --k-storage: #3fc0c2; --k-external: #9ca3af;
    --k-process: #b4bcc8; --k-decision: #f0b93f; --k-terminal: #d1d5db; --k-document: #c4c95c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.main { display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.main.panel-closed { grid-template-columns: 1fr 0; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel); min-height: 56px;
}
.title { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; white-space: nowrap; background: transparent;
}
button.pill { cursor: pointer; }
button.pill:hover { border-color: var(--faint); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill.live .dot { background: var(--danger); animation: pulse 1.6s infinite; }
.pill.live { color: var(--ink); }
.pill.warn .dot { background: var(--k-cache); }
.pill.ok .dot { background: var(--ok); }
@keyframes pulse { 50% { opacity: .35; } }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { border-color: transparent; background: transparent; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 240px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none;
  border-radius: 6px; cursor: pointer;
}
.menu button:hover { background: var(--bg); }
.menu button small { display: block; color: var(--muted); font-size: 12px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* latency chip */
.latency { font-variant-numeric: tabular-nums; cursor: default; }
.latency b { color: var(--ink); font-weight: 600; }
.hud {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: 300px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.hud table { width: 100%; border-collapse: collapse; }
.hud td { padding: 3px 0; }
.hud td:last-child { text-align: right; }
.hud .muted { color: var(--muted); }

/* canvas */
.canvas { position: relative; min-height: 0; background: var(--canvas); }
.react-flow { --xy-background-color: var(--canvas); }
.empty {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center;
  color: var(--muted);
}
.empty h2 { margin: 0 0 6px; font-size: 20px; color: var(--ink); font-weight: 600; }
.empty .actions { margin-top: 16px; display: flex; gap: 8px; justify-content: center; pointer-events: auto; }
.follow-btn { position: absolute; left: 50%; transform: translateX(-50%); top: 12px; z-index: 5; box-shadow: var(--shadow); }

/* nodes */
.bn {
  position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center;
  padding: 6px 12px 6px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); --k: var(--k-service); animation: appear .35s ease-out;
}
.bn::before { content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--k); }
.bn-kind { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--k); font-weight: 600; }
.bn-label { font-weight: 600; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bn-items { margin: 4px 0 0; padding: 0 0 0 2px; list-style: none; font-size: 12.5px; line-height: 18px; color: var(--muted); }
.bn-items li { position: relative; padding-left: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bn-items li::before { content: "•"; position: absolute; left: 0; color: var(--k); font-weight: 700; }
.bn-decision .bn-items { text-align: left; }
.bn-actor { --k: var(--k-actor); border-radius: 999px; padding-left: 18px; }
.bn-client { --k: var(--k-client); }
.bn-database { --k: var(--k-database); border-radius: 10px / 18px; }
.bn-cache { --k: var(--k-cache); }
.bn-queue { --k: var(--k-queue); }
.bn-storage { --k: var(--k-storage); border-radius: 10px / 18px; }
.bn-external { --k: var(--k-external); border-style: dashed; }
.bn-process { --k: var(--k-process); }
.bn-terminal { --k: var(--k-terminal); border-radius: 999px; text-align: center; padding: 6px 18px; }
.bn-document { --k: var(--k-document); border-radius: 4px 14px 4px 4px; background: color-mix(in srgb, var(--k) 6%, var(--panel)); }
.bn-document::after { content: ""; position: absolute; top: -1px; right: -1px; width: 14px; height: 14px; border-radius: 0 14px 0 4px;
  background: linear-gradient(225deg, var(--canvas) 50%, color-mix(in srgb, var(--k) 30%, var(--panel)) 50%); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bn-terminal::before, .bn-actor::before { display: none; }
.bn-decision { --k: var(--k-decision); background: transparent; border: 0; box-shadow: none; text-align: center; padding: 0 28px; }
.bn-decision::before { display: none; }
.bn-decision .diamond {
  position: absolute; inset: 0; background: var(--panel); border: 1.5px solid var(--k);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); z-index: -1;
}
.bn-decision .diamond::after { content: ""; position: absolute; inset: 1.5px; background: var(--panel); clip-path: inherit; }
.flash-ring {
  position: absolute; inset: -4px; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--accent); animation: flash 2.2s ease-out forwards;
}
@keyframes flash { 0% { opacity: 1; } 60% { opacity: .6; } 100% { opacity: 0; } }
@keyframes appear { from { opacity: 0; transform: scale(.92); } }
.react-flow__node.selected .bn { outline: 2px solid var(--accent); outline-offset: 2px; }
.react-flow__handle { width: 7px; height: 7px; background: var(--faint); border: 0; opacity: 0; }
.react-flow__node:hover .react-flow__handle { opacity: 1; }

.bg-group {
  width: 100%; height: 100%; border-radius: 14px; border: 1.5px dashed var(--faint);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}
.bg-label { position: absolute; top: 8px; left: 14px; font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }

.react-flow__edge-path { stroke: var(--edge); stroke-width: 1.6; }
.react-flow__edge.flash .react-flow__edge-path { stroke: var(--accent); stroke-width: 2.4; }
.react-flow__edge-text { fill: var(--muted); font-size: 11.5px; }
.react-flow__edge-textbg { fill: var(--canvas); }

/* side panel */
.panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.panel section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 36vh; overflow: auto; }
.note { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; font-size: 13.5px; }
.note .tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 4px; margin-top: 1px; }
.tag.decision { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag.question { background: color-mix(in srgb, var(--k-decision) 18%, transparent); color: var(--k-decision); }
.tag.action { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.note .x { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 2px; }
.note .x:hover { color: var(--danger); }
.transcript { flex: 1; overflow: auto; padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.line { font-size: 13.5px; }
.line time { color: var(--faint); font-size: 11.5px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.line.edit { color: var(--muted); font-style: italic; }
.line.typed::before { content: "typed · "; color: var(--faint); font-size: 11.5px; }
.muted { color: var(--muted); }

/* bottom: captions + input */
.bottombar { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px; display: grid; gap: 8px; }
.captions { min-height: 22px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.captions .prev { color: var(--muted); }
.captions .now { color: var(--ink); }
.say { display: flex; gap: 8px; }
.say input {
  flex: 1; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); outline: none;
}
.say input:focus { border-color: var(--accent); }
.level { width: 46px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.level > i { display: block; height: 100%; background: var(--ok); transition: width .08s; }

/* modal + toast */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--panel); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }
.modal input, .modal select { width: 100%; height: 38px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--bg); border-radius: 9px; margin-bottom: 6px; }
.tabs button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.warn-box { font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--k-cache) 14%, transparent); margin-top: 10px; }
.toasts { position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 120; }
.toast { background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow); max-width: min(560px, 90vw); }
.toast.error { background: var(--danger); color: #fff; }
.toast-action { margin-left: 12px; background: none; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: 2px 10px; cursor: pointer; }

/* stage view: what the meeting bot shows as its camera (1280x720) */
.stage { height: 100%; display: grid; grid-template-rows: auto 1fr auto; background: var(--canvas); }
.stage .stage-title { padding: 18px 28px 0; font-size: 26px; font-weight: 700; }
.stage .captions { padding: 14px 28px 20px; font-size: 22px; }

/* --- collaboration ------------------------------------------------------------------ */
.flow-wrap { position: absolute; inset: 0; }
.flow-wrap.with-toolbar { top: 52px; border-top: 1px solid var(--line); }
.small { font-size: 12.5px; }
.av {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .02em; flex: none;
}
.av.big { width: 28px; height: 28px; font-size: 11px; border: 2px solid var(--panel); margin-left: -6px; }
.av.big:first-child { margin-left: 0; }
.av.me { box-shadow: 0 0 0 2px var(--accent); }
.av.more { background: var(--faint); }
.presence { display: flex; align-items: center; }

.title { flex: 0 1 320px; }
.title-in {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px;
  font-weight: 650; font-size: 16px; padding: 4px 6px; margin-left: -6px; outline: none; text-overflow: ellipsis;
}
.title-in:hover { border-color: var(--line); }
.title-in:focus { border-color: var(--accent); background: var(--bg); }

.toolbar {
  position: absolute; top: 8px; left: 12px; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  max-width: calc(100% - 24px); overflow-x: auto;
}
.tb { height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: none; cursor: pointer; white-space: nowrap; font-size: 13px; }
.tb:hover:not(:disabled) { background: var(--bg); }
.tb:disabled { opacity: .35; cursor: default; }
.tb-warn { background: color-mix(in srgb, var(--k-cache) 20%, transparent); }
.tb-note { color: var(--muted); font-size: 12.5px; padding: 0 8px; white-space: nowrap; }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.follow-btn { top: 64px; }

/* owners and status on boxes */
.owner {
  position: absolute; top: -11px; right: 8px; display: flex; align-items: center; gap: 4px; max-width: 150px;
  padding: 1px 8px 1px 2px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  font-size: 11px; font-weight: 600; color: var(--ink); box-shadow: var(--shadow);
}
.owner .av { width: 16px; height: 16px; font-size: 8px; }
.owner-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-proposed { border: 1.5px dashed var(--k); background: color-mix(in srgb, var(--k) 7%, var(--panel)); box-shadow: none; }
.bn-deprecated { opacity: .5; }
.bn-deprecated .bn-label { text-decoration: line-through; }
.zone-owner { font-weight: 500; }

/* sticky notes */
.sticky {
  position: relative; width: 100%; height: 100%; padding: 9px 11px 16px; border-radius: 3px; color: #2b2b2b;
  font-size: 13px; line-height: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.12);
  transform: rotate(-.6deg); overflow: hidden; animation: appear .35s ease-out;
}
.sticky-text { white-space: pre-wrap; word-break: break-word; }
.sticky-by { position: absolute; right: 8px; bottom: 3px; font-size: 10px; color: rgba(0,0,0,.45); }
.sticky-yellow { background: #fff1a6; } .sticky-pink { background: #ffd3e3; } .sticky-blue { background: #cfe6ff; }
.sticky-green { background: #d2f4d9; } .sticky-purple { background: #e5dcff; }
.react-flow__node.selected .sticky { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden-handle { opacity: 0 !important; pointer-events: none; }
.react-flow__edge.sticky-link .react-flow__edge-path { stroke: var(--faint); stroke-dasharray: 2 4; stroke-width: 1.2; }

/* live cursors */
.cursor { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 0 0; z-index: 1000; transition: transform .08s linear; }
.cursor-name { position: absolute; left: 14px; top: 14px; color: #fff; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.minimap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }

/* inspector */
.inspector { padding: 12px 16px 16px; border-bottom: 1px solid var(--line); }
.insp-head { display: flex; align-items: center; justify-content: space-between; }
.inspector label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.inspector input, .inspector select, .inspector textarea, .note-add input, .note-add select {
  width: 100%; min-height: 34px; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); outline: none; font-size: 13.5px;
}
.inspector input:focus, .inspector textarea:focus, .note-add input:focus { border-color: var(--accent); }
.inspector textarea { resize: vertical; line-height: 1.35; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.insp-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.insp-meta { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); cursor: pointer; transform: none; padding: 0; }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.x { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.x:hover { color: var(--danger); }

/* side panel tabs + notes */
.panel-tabs { margin: 10px 16px 0; }
.notes-panel { flex: 1; overflow: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.note-section h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.note-row { display: flex; gap: 8px; align-items: flex-start; padding: 2px 0; }
.note-row input[type=checkbox] { margin-top: 8px; accent-color: var(--ok); }
.note-body { flex: 1; min-width: 0; }
.note-text, .note-owner {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 4px 6px; margin-left: -6px; outline: none;
}
.note-text:hover, .note-owner:hover { border-color: var(--line); }
.note-text:focus, .note-owner:focus { border-color: var(--accent); background: var(--bg); }
.note-row.done .note-text { text-decoration: line-through; color: var(--muted); }
.note-meta { display: flex; align-items: center; gap: 6px; }
.note-owner { width: auto; max-width: 160px; font-size: 12px; color: var(--muted); padding: 1px 6px; }
.ai-tag { font-size: 9.5px; font-weight: 700; letter-spacing: .05em; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
.note-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.note-add select { width: auto; }
.note-add input { flex: 1 1 140px; width: auto; }
.note-add .owner-in { flex: 0 1 110px; }
.line.paused { color: var(--faint); }
.line.paused::after { content: " · AI paused"; font-size: 11px; }

@media (max-width: 1100px) { .minimap { display: none; } }
@media (max-width: 760px) {
  /* Narrow screens: the side panel slides in over the board while something is selected. */
  .main .panel.has-selection {
    display: flex; position: fixed; right: 8px; top: 120px; bottom: 120px; width: min(340px, calc(100vw - 16px));
    z-index: 40; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  }
  .main .panel.has-selection .panel-tabs, .main .panel.has-selection .notes-panel,
  .main .panel.has-selection .transcript { display: none; }
  .main, .main.panel-closed { grid-template-columns: 1fr; }
  .panel { display: none; }
  .hide-sm { display: none; }
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .title { flex: 1 1 auto; }
  .topbar .spacer { display: none; }
}

/* Arrowheads follow the theme's line color (React Flow sets them inline). */
.react-flow__arrowhead polyline { stroke: var(--edge) !important; fill: var(--edge) !important; }

/* =====================================================================================
   "Sketch" theme (default): warm paper, marker-ish boxes, handwritten labels.
   "Clean" (the rules above) stays available from the ⋯ menu.
   ===================================================================================== */
:root[data-theme="sketch"] {
  --bg: #f4ecdd; --canvas: #fbf6ec; --panel: #fffaf2; --ink: #2f2925; --muted: #7a6e64; --faint: #b3a594;
  --line: #e4d8c4; --accent: #d4623d; --accent-ink: #ffffff; --danger: #bf3b2b; --ok: #4c8a58; --edge: #5a4f47;
  --hand: "Kalam", "Patrick Hand", "Comic Sans MS", cursive;
  --ui: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --pen: color-mix(in srgb, var(--ink) 72%, transparent);
  --shadow: 2px 3px 0 rgba(60, 45, 30, .10), 0 6px 18px rgba(60, 45, 30, .08);
  --k-actor: #b4527a; --k-client: #3f78bf; --k-service: #6b5fb5; --k-database: #4c8a58; --k-cache: #cf7d2b;
  --k-queue: #a9682c; --k-storage: #36878a; --k-external: #7e7064; --k-process: #5d534b; --k-decision: #c4931a;
  --k-terminal: #4a423c; --k-document: #7d7a22;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="sketch"] {
    --bg: #1b1916; --canvas: #22201c; --panel: #2a2622; --ink: #f2eadc; --muted: #bcae9b; --faint: #7f7466;
    --line: #3b3530; --accent: #f08a62; --accent-ink: #1b1916; --edge: #d5c8b4;
    --shadow: 2px 3px 0 rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .3);
    --k-actor: #e687ad; --k-client: #7fb1f0; --k-service: #a89cf0; --k-database: #84c98f; --k-cache: #f2a85d;
    --k-queue: #e0a36a; --k-storage: #6cc6c8; --k-external: #b9ab9c; --k-process: #cfc4b8; --k-decision: #f0c654;
    --k-terminal: #e2d8cc; --k-document: #cfcb6a;
    color-scheme: dark;
  }
}

[data-theme="sketch"] body { font-family: var(--ui); }
[data-theme="sketch"] .canvas {
  background-color: var(--canvas);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .27 0 0 0 0 .18 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="sketch"] .react-flow { --xy-background-color: transparent; --xy-background-pattern-color: color-mix(in srgb, var(--ink) 16%, transparent); }

/* boxes: uneven corners, ink outline, pastel fill, offset "marker" shadow */
[data-theme="sketch"] .bn {
  border: 2px solid color-mix(in srgb, var(--k) 45%, var(--pen));
  border-radius: 14px 19px 12px 17px / 17px 12px 19px 14px;
  background: color-mix(in srgb, var(--k) 11%, var(--panel));
  box-shadow: 3px 4px 0 color-mix(in srgb, var(--ink) 13%, transparent);
  padding: 6px 12px;
}
[data-theme="sketch"] .bn::before { display: none; }
[data-theme="sketch"] .bn-label { font-family: var(--hand); font-weight: 700; font-size: 15px; line-height: 1.15; }
[data-theme="sketch"] .bn-kind { font-family: var(--ui); font-weight: 800; font-size: 10px; }
[data-theme="sketch"] .bn-actor, [data-theme="sketch"] .bn-terminal { border-radius: 999px 980px 999px 970px; }
[data-theme="sketch"] .bn-database, [data-theme="sketch"] .bn-storage { border-radius: 16px 20px 16px 20px / 26px 22px 26px 22px; }
[data-theme="sketch"] .bn-decision { background: transparent; border: 0; box-shadow: none; }
[data-theme="sketch"] .bn-decision .diamond { border: 0; background: color-mix(in srgb, var(--k) 45%, var(--pen)); }
[data-theme="sketch"] .bn-decision .diamond::after { inset: 2px; background: color-mix(in srgb, var(--k) 13%, var(--panel)); }
[data-theme="sketch"] .bn-proposed { border-style: dashed; background: color-mix(in srgb, var(--k) 6%, var(--panel)); box-shadow: none; }
[data-theme="sketch"] .react-flow__node.selected .bn { outline: 2.5px solid var(--accent); outline-offset: 3px; }
[data-theme="sketch"] .flash-ring { box-shadow: 0 0 0 3px var(--accent); border-radius: 18px 22px 16px 20px; }
[data-theme="sketch"] .owner { font-family: var(--ui); border: 1.5px solid var(--line); box-shadow: 1px 2px 0 rgba(60, 45, 30, .08); }

/* arrows: rounder, inkier */
[data-theme="sketch"] .react-flow__edge-path { stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="sketch"] .react-flow__edge-text { font-family: var(--hand); font-size: 13px; fill: var(--muted); }
[data-theme="sketch"] .react-flow__edge-textbg { fill: var(--canvas); }

/* groups: dashed pencil outline with a handwritten title */
[data-theme="sketch"] .bg-group {
  border: 2px dashed color-mix(in srgb, var(--ink) 30%, transparent);
  border-radius: 22px 30px 20px 28px / 28px 20px 30px 22px;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
[data-theme="sketch"] .bg-label { font-family: var(--hand); font-size: 15px; font-weight: 700; letter-spacing: 0; color: var(--muted); }

/* stickies: tape on top, a little more tilt */
[data-theme="sketch"] .sticky { overflow: visible; font-family: var(--hand); font-size: 14px; border-radius: 2px 3px 4px 2px; }
[data-theme="sketch"] .sticky::after {
  content: ""; position: absolute; top: -8px; left: 50%; width: 56px; height: 16px; transform: translateX(-50%) rotate(-4deg);
  background: rgba(255, 255, 255, .55); border: 1px solid rgba(0, 0, 0, .05); box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}
[data-theme="sketch"] .react-flow__node-sticky:nth-child(even) .sticky { transform: rotate(.9deg); }

/* chrome: rounder, softer, ink-outlined */
[data-theme="sketch"] .topbar { border-bottom: 2px solid var(--line); }
[data-theme="sketch"] .title-in { font-family: var(--hand); font-size: 22px; font-weight: 700; }
[data-theme="sketch"] .btn {
  border: 1.5px solid color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: 10px 13px 9px 12px / 12px 9px 13px 10px;
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--ink) 10%, transparent);
  font-weight: 700; transition: transform .08s, box-shadow .08s;
}
[data-theme="sketch"] .btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 color-mix(in srgb, var(--ink) 14%, transparent); }
[data-theme="sketch"] .btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0 transparent; }
[data-theme="sketch"] .btn.primary { border-color: color-mix(in srgb, var(--accent) 70%, var(--ink)); }
[data-theme="sketch"] .pill { border: 1.5px solid var(--line); font-weight: 600; }
[data-theme="sketch"] .toolbar, [data-theme="sketch"] .menu, [data-theme="sketch"] .hud, [data-theme="sketch"] .modal {
  border: 1.5px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: 14px 18px 13px 17px / 17px 13px 18px 14px;
}
[data-theme="sketch"] .tb { font-weight: 700; border-radius: 9px; }
[data-theme="sketch"] .panel { border-left: 2px solid var(--line); }
[data-theme="sketch"] .modal h2, [data-theme="sketch"] .empty h2, [data-theme="sketch"] .stage-title { font-family: var(--hand); font-weight: 700; }
[data-theme="sketch"] .empty h2 { font-size: 30px; }
[data-theme="sketch"] .note-section h4, [data-theme="sketch"] .panel h3 { font-family: var(--hand); font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); }
[data-theme="sketch"] .tabs button.on { font-weight: 700; }
[data-theme="sketch"] .captions { font-size: 16px; }
[data-theme="sketch"] .captions .now { font-weight: 600; }
[data-theme="sketch"] .say input, [data-theme="sketch"] .inspector input, [data-theme="sketch"] .inspector select,
[data-theme="sketch"] .inspector textarea, [data-theme="sketch"] .note-add input, [data-theme="sketch"] .note-add select {
  border: 1.5px solid var(--line); border-radius: 10px 12px 9px 11px;
}
[data-theme="sketch"] .minimap { border: 1.5px solid var(--line); border-radius: 12px; }

/* who spoke */
.spk { border: 0; background: none; padding: 0; margin-right: 5px; font: inherit; font-weight: 700; cursor: pointer; }
.spk:hover { text-decoration: underline; }

/* spotlight: what's being discussed now */
:root { --spot: #f2b134; }
.react-flow__node.is-focus .bn, .react-flow__node.is-focus .sticky { box-shadow: 0 0 0 3px var(--spot), 0 0 22px color-mix(in srgb, var(--spot) 70%, transparent); }
.react-flow__node.is-focus .bg-group { border-color: var(--spot); }
.spotlight-on .react-flow__node:not(.is-focus):not(.react-flow__node-zone) { opacity: .42; }
.spotlight-on .react-flow__edge:not(.focus) { opacity: .35; }
.react-flow__node, .react-flow__edge { transition: opacity .35s; }
.react-flow__edge.focus .react-flow__edge-path { stroke: var(--spot); stroke-width: 2.6; }

/* reactions */
.reacts { position: absolute; left: 8px; bottom: -11px; display: flex; gap: 4px; }
.react { font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); line-height: 18px; }
.react.confused { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.react.agree { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }

/* hover card */
.hovercard {
  position: fixed; z-index: 60; width: 300px; padding: 12px 14px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; line-height: 1.4;
}
.hc-title { font-weight: 700; font-size: 15px; }
[data-theme="sketch"] .hc-title { font-family: var(--hand); font-size: 17px; }
.hc-meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.hc-desc { margin-top: 8px; }
.hc-tag { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); margin-right: 4px; }
.said { margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.said q { font-style: italic; color: var(--ink); }
.hc-actions { display: flex; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }

/* glossary */
.gl-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.gl-item:hover { background: var(--bg); }
.gl-term { display: block; font-weight: 700; }
[data-theme="sketch"] .gl-term { font-family: var(--hand); font-size: 15px; }
.gl-desc { display: block; color: var(--muted); font-size: 13px; }

/* step numbers + walkthrough */
.step {
  position: absolute; left: -10px; top: -10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--panel); font-size: 11.5px; font-weight: 800; box-shadow: var(--shadow); z-index: 2;
}
.walk-caption {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 8; width: min(680px, calc(100% - 24px));
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel);
  border: 1.5px solid var(--spot); box-shadow: var(--shadow); font-size: 14px;
}
.walk-step { font-weight: 800; color: var(--accent); white-space: nowrap; }
.walk-text { flex: 1; min-width: 0; }
[data-theme="sketch"] .walk-text { font-family: var(--hand); font-size: 16px; }
.walk-ctrl { display: flex; gap: 4px; }
.follow-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 14px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: var(--shadow);
}
.follow-banner .chip { background: rgba(255,255,255,.85); color: #222; border: 0; }
button.av { border: 2px solid var(--panel); cursor: pointer; padding: 0; }
button.av:disabled { cursor: default; }
.av.following { box-shadow: 0 0 0 2px var(--accent); }

/* legend */
.legend {
  position: fixed; top: 128px; left: 20px; z-index: 50; width: 330px; padding: 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12.5px;
}
.lg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.lg-item { display: flex; align-items: center; gap: 6px; }
.lg-swatch { width: 14px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--k) 25%, var(--panel)); border: 2px solid var(--k); }
.lg-swatch.diamond { transform: rotate(45deg) scale(.85); border-radius: 2px; }
.lg-rows { display: grid; gap: 6px; padding-top: 10px; }
.lg-rows > div { display: flex; align-items: center; gap: 8px; }
.lg-line { width: 28px; border-top: 2px solid var(--edge); }
.lg-line.dashed { border-top-style: dashed; }
.lg-box { width: 22px; height: 12px; border-radius: 3px; border: 1.5px solid var(--edge); }
.lg-box.proposed { border-style: dashed; }
.lg-box.deprecated { opacity: .45; }
.lg-spot { width: 22px; height: 12px; border-radius: 3px; box-shadow: 0 0 0 2px var(--spot), 0 0 8px var(--spot); }

/* catch me up */
.catchup {
  position: fixed; right: 16px; top: 70px; z-index: 70; width: min(420px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  padding: 14px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.catchup h3 { margin: 0; }
[data-theme="sketch"] .catchup h3 { font-family: var(--hand); font-size: 20px; }
.catchup-text { white-space: pre-wrap; margin-top: 8px; line-height: 1.5; font-size: 14px; }

/* disagreements and gaps */
.flags { position: absolute; right: 8px; bottom: -11px; display: flex; gap: 4px; }
.flag { font-size: 10.5px; font-weight: 800; padding: 0 7px; border-radius: 999px; line-height: 18px; white-space: nowrap; background: var(--panel); }
.flag.conflict { color: #a0521b; border: 1.5px solid #e08a3c; background: color-mix(in srgb, #e08a3c 16%, var(--panel)); }
.flag.gap { color: var(--danger); border: 1.5px dashed color-mix(in srgb, var(--danger) 70%, transparent); }
.hc-flag { margin-top: 8px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; }
.hc-flag.conflict { background: color-mix(in srgb, #e08a3c 14%, var(--panel)); }
.hc-flag.gap { background: color-mix(in srgb, var(--danger) 9%, var(--panel)); }
.flag-sides { display: flex; flex-direction: column; gap: 1px; margin-top: 3px; font-size: 12.5px; }
.flags-section h4 { color: var(--accent); }
.flag-row { padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; cursor: pointer; border: 1px solid var(--line); }
.flag-row.conflict { background: color-mix(in srgb, #e08a3c 10%, var(--panel)); border-color: color-mix(in srgb, #e08a3c 45%, var(--line)); }
.flag-row.gap { background: color-mix(in srgb, var(--danger) 6%, var(--panel)); border-style: dashed; }
.flag-kind { font-size: 11.5px; font-weight: 800; color: var(--muted); }
.flag-text { font-weight: 600; margin: 2px 0; }
.flag-actions { display: flex; gap: 6px; margin-top: 6px; }
.flag-closed { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
@media (prefers-color-scheme: dark) { .flag.conflict { color: #f0a868; } }

/* ask the board */
.drawer {
  position: fixed; right: 16px; top: 70px; bottom: 130px; z-index: 70; width: min(420px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.drawer[hidden] { display: none; }
[data-theme="sketch"] .drawer h3 { font-family: var(--hand); font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; }
.ask-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 0; }
.ask-hints { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ask-q { font-weight: 700; }
.ask-a { margin-top: 4px; line-height: 1.5; white-space: pre-wrap; }
.ask-ref {
  border: 0; padding: 0 6px; margin: 0 1px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 700;
  background: color-mix(in srgb, var(--spot) 30%, var(--panel)); color: var(--ink);
}
.ask-ref:hover { background: color-mix(in srgb, var(--spot) 55%, var(--panel)); }
.ask-raise { margin-top: 6px; }
.ask-form { display: flex; gap: 6px; }
.ask-form input { flex: 1; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.ask-form input:focus { border-color: var(--accent); }

/* views: switcher, lanes, sequence, collapsed groups, moving dots */
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--bg); }
.seg .tb { height: 26px; padding: 0 9px; }
.seg .tb.on { background: var(--panel); box-shadow: var(--shadow); color: var(--accent); }
.lane { width: 100%; height: 100%; border-radius: 12px; background: color-mix(in srgb, var(--ink) 4%, transparent); border: 1px solid var(--line); }
.lane-none { background: transparent; border-style: dashed; }
.lane-label { position: absolute; left: 0; top: 0; bottom: 0; width: 170px; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  font-weight: 800; color: var(--ink); border-right: 1px dashed var(--line); }
.lane-none .lane-label { color: var(--muted); font-weight: 600; }
.lane-label .av { width: 22px; height: 22px; font-size: 9.5px; }
[data-theme="sketch"] .lane-label { font-family: var(--hand); font-size: 17px; }
.view-note { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 5; font-size: 12.5px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.seq-wrap { position: absolute; inset: 0; overflow: auto; padding: 24px 16px; }
.seq { display: block; height: auto; margin: 0 auto; }
.seq-box { fill: color-mix(in srgb, var(--k) 12%, var(--panel)); stroke: color-mix(in srgb, var(--k) 70%, var(--ink)); stroke-width: 1.8; }
.seq-part.is-focus .seq-box { stroke: var(--spot); stroke-width: 3.5; }
.seq-kind { text-anchor: middle; font-size: 9.5px; font-weight: 800; letter-spacing: .05em; fill: var(--k); }
.seq-label { text-anchor: middle; font-size: 14px; font-weight: 700; fill: var(--ink); }
[data-theme="sketch"] .seq-label { font-family: var(--hand); font-size: 16px; }
.seq-life { stroke: var(--faint); stroke-dasharray: 4 5; stroke-width: 1.3; }
.seq-msg line { stroke: var(--edge); stroke-width: 1.8; }
.seq-msg.dashed line { stroke-dasharray: 6 4; }
.seq-msg.focus line { stroke: var(--spot); stroke-width: 3; }
.seq-head { fill: var(--edge); }
.seq-num-bg { fill: var(--ink); }
.seq-num { text-anchor: middle; font-size: 10.5px; font-weight: 800; fill: var(--panel); }
.seq-text { text-anchor: middle; font-size: 12.5px; fill: var(--muted); paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; }
[data-theme="sketch"] .seq-text { font-family: var(--hand); font-size: 14px; }
.bn-group { --k: var(--k-service); cursor: pointer; box-shadow: 4px 4px 0 -1px var(--panel), 4px 4px 0 0 var(--line), 8px 8px 0 -1px var(--panel), 8px 8px 0 0 var(--line); }
[data-theme="sketch"] .bn-group { border-style: double; border-width: 4px; }
.grp-open { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.zone-toggle { border: 0; background: none; padding: 0 4px 0 0; cursor: pointer; color: inherit; font: inherit; }
.flow-dot { fill: var(--spot); stroke: var(--panel); stroke-width: 2; filter: drop-shadow(0 0 4px var(--spot)); }

/* what changed since */
.diff-tag { font-size: 9.5px; font-weight: 800; letter-spacing: .05em; padding: 1px 6px; border-radius: 999px; color: #fff; white-space: nowrap; }
.bn > .diff-tag { position: absolute; top: -10px; left: 10px; z-index: 2; }
.diff-tag.added { background: #2f9e5b; } .diff-tag.changed { background: #d08a1c; } .diff-tag.removed { background: #c2372f; }
.bn.diff-added { box-shadow: 0 0 0 3px #2f9e5b; }
.bn.diff-changed { box-shadow: 0 0 0 3px #d08a1c; }
.bn.diff-removed { opacity: .55; border-style: dashed; box-shadow: 0 0 0 2px #c2372f; }
.bn.diff-removed .bn-label { text-decoration: line-through; }
.react-flow__edge.diff-added .react-flow__edge-path { stroke: #2f9e5b; stroke-width: 2.6; }
.react-flow__edge.diff-removed .react-flow__edge-path { stroke: #c2372f; stroke-dasharray: 4 4; opacity: .7; }
.hc-was { margin-top: 6px; font-size: 12.5px; color: #b5701a; }
.historybar {
  position: absolute; left: 12px; right: 12px; top: 8px; z-index: 9; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 12px; background: var(--panel); border: 1.5px solid var(--accent); box-shadow: var(--shadow);
}
.historybar input[type=range] { flex: 1 1 200px; accent-color: var(--accent); }
.hb-time { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.hb-counts { display: flex; gap: 6px; }
.hb-jump { height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); padding: 0 6px; }
/* import + send */
.modal.wide { width: min(560px, 100%); }
.dropzone { display: flex; flex-direction: column; gap: 6px; padding: 18px; margin-top: 10px; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; text-align: center; }
.dropzone:hover { border-color: var(--accent); }
.dropzone input { display: none; }
.dropzone span { color: var(--muted); font-size: 12.5px; }
.modal textarea.mmd { width: 100%; margin-top: 10px; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font: 12.5px ui-monospace, Menlo, monospace; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.send-list { display: grid; gap: 4px; }
.send-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 10px; cursor: pointer; }
.send-row:hover { background: var(--bg); }
.send-row.off { opacity: .6; cursor: default; }
.send-row input { margin-top: 4px; }
.send-row small { display: block; color: var(--muted); }
.send-row small.ok { color: var(--ok); } .send-row small.err { color: var(--danger); }

/* consent */
.consent {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 10px;
  width: min(640px, calc(100vw - 24px)); padding: 9px 12px; border-radius: 12px; background: var(--panel);
  border: 1.5px solid var(--danger); box-shadow: var(--shadow); font-size: 13.5px;
}
.consent span:nth-child(2) { flex: 1; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s infinite; flex: none; }
.notice { margin: 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 8px; }
.modal .check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 12px; }
.modal .check input { width: auto; height: auto; }
.menu button.danger-item { color: var(--danger); }
.modal pre.cmd { margin: 6px 0 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg); font: 12px ui-monospace, Menlo, monospace; white-space: pre-wrap; }
.modal ol.steps { margin: 6px 0 10px; padding-left: 20px; display: grid; gap: 6px; }
.modal ol.steps .btn { text-decoration: none; }

/* the Plan section (Gantt chart) */
.plan { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--canvas); }
.plan-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.plan-title { border: 1px solid transparent; background: transparent; border-radius: 6px; font-weight: 700; font-size: 17px; padding: 4px 6px; min-width: 160px; outline: none; }
.plan-title:hover { border-color: var(--line); } .plan-title:focus { border-color: var(--accent); background: var(--bg); }
[data-theme="sketch"] .plan-title { font-family: var(--hand); font-size: 21px; }
.plan-warn { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 7px 14px; font-size: 13px; background: color-mix(in srgb, #e08a3c 14%, var(--panel)); border-bottom: 1px solid var(--line); }
.plan-empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); }
.plan-empty > div { max-width: 560px; } .plan-empty h2 { color: var(--ink); margin: 0 0 8px; }
[data-theme="sketch"] .plan-empty h2 { font-family: var(--hand); font-size: 30px; }
.plan-empty p:first-of-type { font-style: italic; color: var(--ink); }
.plan-scroll { flex: 1; overflow: auto; position: relative; }
.plan-canvas { position: relative; }
.plan-header { position: sticky; top: 0; z-index: 4; background: var(--panel); border-bottom: 1px solid var(--line); }
.pcorner { position: sticky; left: 0; height: 100%; display: flex; align-items: flex-end; padding: 0 12px 6px; font-size: 11.5px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; background: var(--panel); border-right: 1px solid var(--line); z-index: 2; }
.pmonth { position: absolute; top: 5px; font-size: 12px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.ptick { position: absolute; bottom: 5px; font-size: 10.5px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 3px; height: 15px; }
.pweekend { position: absolute; background: color-mix(in srgb, var(--ink) 4%, transparent); pointer-events: none; }
.ptoday { position: absolute; width: 0; border-left: 2px solid var(--danger); z-index: 3; pointer-events: none; }
.ptoday span { position: absolute; top: -2px; left: 4px; font-size: 10px; font-weight: 800; color: var(--danger); }
.pdeps { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; }
.pdep { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.pdep.bad { stroke: var(--danger); stroke-dasharray: 4 3; }
.pdeps marker path { fill: var(--faint); }
.prow { position: relative; display: flex; align-items: center; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); cursor: default; }
.prow:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.prow.selected { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.pcell { position: sticky; left: 0; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 0 12px;
  background: var(--panel); border-right: 1px solid var(--line); overflow: hidden; }
.pname { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="sketch"] .pname { font-family: var(--hand); font-size: 15px; }
.pdates { font-size: 11px; color: var(--muted); }
.pbar { position: absolute; top: 7px; height: 22px; border-radius: 6px; background: color-mix(in srgb, var(--k-service) 30%, var(--panel));
  border: 1.5px solid color-mix(in srgb, var(--k-service) 70%, var(--ink)); cursor: grab; overflow: hidden; z-index: 2; touch-action: none; }
.pbar.dragging { cursor: grabbing; opacity: .85; box-shadow: var(--shadow); }
.pbar.s-in_progress { background: color-mix(in srgb, var(--accent) 30%, var(--panel)); border-color: var(--accent); }
.pbar.s-done { background: color-mix(in srgb, var(--ok) 30%, var(--panel)); border-color: var(--ok); }
.pbar.s-at_risk { background: color-mix(in srgb, var(--danger) 22%, var(--panel)); border-color: var(--danger); }
.pprog { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--ink) 18%, transparent); }
.plabel { position: relative; padding: 0 8px; font-size: 12px; font-weight: 700; line-height: 19px; white-space: nowrap; }
[data-theme="sketch"] .plabel, [data-theme="sketch"] .pafter { font-family: var(--hand); font-size: 14px; }
.pgrip { position: absolute; right: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.pgrip:hover { background: color-mix(in srgb, var(--ink) 20%, transparent); }
.pmile { position: absolute; top: 9px; width: 18px; height: 18px; transform: rotate(45deg); background: var(--k-decision); border: 2px solid color-mix(in srgb, var(--k-decision) 60%, var(--ink));
  cursor: grab; z-index: 2; touch-action: none; border-radius: 2px; }
.pmile.fixed { background: var(--danger); border-color: color-mix(in srgb, var(--danger) 60%, var(--ink)); }
.pmile.s-done { background: var(--ok); }
.pafter { position: absolute; top: 9px; font-size: 12px; font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 6px; z-index: 2; pointer-events: none; }
.powner { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--muted); font-family: var(--ui, inherit); font-size: 11.5px; }
.powner .av { width: 16px; height: 16px; font-size: 8px; }
.prow.is-focus .pbar, .prow.is-focus .pmile { box-shadow: 0 0 0 3px var(--spot), 0 0 16px color-mix(in srgb, var(--spot) 70%, transparent); }
.plan.spotlight-on .prow:not(.is-focus):not(.pphase) .pbar, .plan.spotlight-on .prow:not(.is-focus) .pmile { opacity: .45; }
.seg.sections { margin-left: 4px; }
.after-list { max-height: 140px; overflow: auto; display: grid; gap: 2px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; }
.inspector .check { display: flex; align-items: center; gap: 8px; color: var(--ink); margin: 8px 0 0; font-size: 13px; }
.inspector .check input { width: auto; min-height: 0; }
.inspector input[type=date] { font-family: inherit; }

/* plan: outline, summary tasks, critical path, what a change did */
.pnum { color: var(--faint); font-family: var(--ui, inherit); font-size: 11px; font-weight: 700; margin-right: 6px; }
.pcaret { border: 0; background: none; padding: 0 4px 0 0; margin-left: -14px; width: 14px; cursor: pointer; color: var(--muted); font: inherit; }
.psummary .pname { font-weight: 800; }
.psum { position: absolute; top: 13px; height: 9px; background: var(--ink); border-radius: 1px; cursor: grab; z-index: 2; touch-action: none; overflow: visible; }
.psum::before, .psum::after { content: ""; position: absolute; top: 7px; border: 6px solid transparent; border-top: 7px solid var(--ink); }
.psum::before { left: -1px; border-left-width: 0; } .psum::after { right: -1px; border-right-width: 0; }
.psum .pprog { background: color-mix(in srgb, var(--panel) 45%, transparent); }
.psum.critical { background: var(--danger); } .psum.critical::before, .psum.critical::after { border-top-color: var(--danger); }
.pbar.critical { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.pmile.critical { outline: 2px solid var(--danger); outline-offset: 1px; }
.pghost { position: absolute; top: 7px; height: 22px; border: 1.5px dashed var(--faint); border-radius: 6px; z-index: 1; pointer-events: none; }
.pdelta { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: #d08a1c; color: #fff; font: 800 10.5px/17px var(--ui, inherit); }
.pfinish { font-size: 13px; color: var(--muted); } .pfinish b { color: var(--ink); }
.plan-impact { padding: 6px 14px 8px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--accent) 9%, var(--panel)); font-size: 13px; display: grid; gap: 4px; }
.plan-impact.risky { background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }
.pi-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pi-risk, .pi-item { text-align: left; border: 0; background: none; padding: 1px 0; cursor: pointer; font: inherit; color: inherit; }
.pi-risk { color: var(--danger); font-weight: 600; }
.pi-risk:hover, .pi-item:hover { text-decoration: underline; }
.pi-moved { display: flex; flex-wrap: wrap; gap: 2px 16px; }
.pi-item b { color: #b5701a; }
.insp-meta.crit-note { color: var(--danger); }

/* plan: people and workload */
.ppeople-head { background: color-mix(in srgb, var(--ink) 4%, transparent); border-top: 2px solid var(--line); }
.ppeople-head .pcell { flex-direction: row; align-items: center; justify-content: space-between; font-weight: 800; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
[data-theme="sketch"] .ppeople-head .pcell > span { font-family: var(--hand); font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.pperson .pname { display: flex; align-items: center; gap: 6px; }
.pperson .av { width: 18px; height: 18px; font-size: 8.5px; }
.pload { position: absolute; top: 8px; height: 20px; border-radius: 4px; font: 700 10.5px/20px var(--ui, inherit); text-align: center;
  color: var(--ink); overflow: hidden; white-space: nowrap; z-index: 2; border: 1px solid transparent; }
.pload.part { background: color-mix(in srgb, var(--ok) 22%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pload.full { background: color-mix(in srgb, var(--ok) 45%, var(--panel)); border-color: var(--ok); }
.pload.over { background: color-mix(in srgb, var(--danger) 45%, var(--panel)); border-color: var(--danger); color: #fff; }
.pload.off { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--ink) 10%, transparent) 0 4px, transparent 4px 8px);
  border-color: var(--line); color: var(--muted); }
.assign-list { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.assign-row { display: flex; align-items: center; gap: 6px; }
.assign-row .av { width: 18px; height: 18px; font-size: 8.5px; }
.assign-name { flex: 1; font-size: 13px; }
.assign-row select { width: auto !important; min-height: 28px !important; padding: 2px 6px !important; }
.assign-add { display: flex; gap: 6px; }
.assign-add input { flex: 1; min-width: 0; }
.assign-add .btn { height: 32px; }

/* microphone check */
.miccheck-level { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.level.big { width: 220px; height: 10px; border-radius: 5px; }
.miccheck-text { min-height: 72px; padding: 10px 12px; border-radius: 10px; background: var(--bg); line-height: 1.5; font-size: 15px; }
.check-steps { margin: 0 0 12px; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }

/* business processes: step times, pain points and ideas */
.bn-time { position: absolute; top: -11px; left: 8px; padding: 0 7px; border-radius: 999px; line-height: 18px; font-size: 10.5px;
  font-weight: 700; white-space: nowrap; background: var(--panel); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow); }
.bn-time.slowest { border-color: var(--danger); color: var(--danger); }
.flag.pain { color: var(--danger); border: 1.5px solid color-mix(in srgb, var(--danger) 60%, transparent); background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }
.flag.idea { color: var(--ok); border: 1.5px solid color-mix(in srgb, var(--ok) 60%, transparent); background: color-mix(in srgb, var(--ok) 12%, var(--panel)); }
.process-summary { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: grid; gap: 4px; font-size: 13px; }
.process-summary b { font-size: 15px; }
.process-summary .slow { cursor: pointer; }
.process-summary .slow:hover { text-decoration: underline; }
.note-about { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.note-about button { font-size: 11px; padding: 0 7px; border-radius: 999px; border: 1px solid var(--line); background: none; cursor: pointer; color: var(--muted); }
.note-section.pain h4 { color: var(--danger); }
.note-section.idea h4 { color: var(--ok); }
.sop { position: fixed; inset: 5vh 50% auto auto; transform: translateX(50%); width: min(820px, calc(100vw - 32px)); max-height: 90vh;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 110; }
.sop .insp-head { padding: 14px 18px 0; }
.sop-body { overflow: auto; padding: 4px 22px 18px; line-height: 1.5; font-size: 14px; }
.sop-body table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.sop-body th, .sop-body td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.sop-body h1 { font-size: 22px; margin: 8px 0; } .sop-body h2 { font-size: 16px; margin: 18px 0 6px; }
.sop-actions { display: flex; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
