/* ============================================================
   ConVIZation — the AI Idea Whiteboard
   Design system: fresh blue ink + highlighter-yellow AI accent,
   white surfaces, subtle grays, graphic-recording motif.
   ============================================================ */

:root {
    /* Fresh light-blue accent (primary "ink") */
    --blue-50: #eff8ff;
    --blue-100: #d8ecff;
    --blue-200: #b2ddff;
    --blue-300: #84caff;
    --blue-400: #53b1fd;
    --blue-500: #2e90fa;
    /* primary */
    --blue-600: #1570ef;
    --blue-700: #175cd3;

    /* Highlighter yellow — marks AI-generated / AI-powered actions */
    --hl: #ffe14d;
    --hl-soft: rgba(255, 225, 77, 0.55);
    --hl-wash: #fff6cc;
    --hl-deep: #eab308;
    --hl-ink: #78560a;

    /* Neutrals */
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: #e6ebf1;
    --line-2: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;

    --danger: #ef4444;
    --danger-soft: #fef2f2;

    /* Radii */
    --r-xs: 6px;
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    /* Shadows (soft, cool-tinted) */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 22px 48px rgba(15, 23, 42, 0.16);
    --shadow-blue: 0 8px 22px rgba(46, 144, 250, 0.30);

    --nav-h: 60px;
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Left board dock (Chats | Tasks). --dock-w is overridden INLINE on <html>
       by the resize handle, so never try to redefine it in a media query —
       an inline custom property wins over any @media :root block. Override
       the consumers (.whiteboard-wrap margin / .board-dock width) instead. */
    --dock-w: 360px;
    --dock-rail-w: 46px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--surface-2);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

[v-cloak] {
    display: none !important;
}

button {
    font-family: inherit;
}

/* Global input baseline. There was no element-level rule for inputs at all —
   58 input-related selectors in this file, every one of them per-component,
   so any input a component forgot to style (e.g. .user-search input, which
   set only `width: 100%`) fell back to raw browser UA chrome: harsh black
   1px border, square corners, no padding. Modeled on the already-good
   .chat-create-name. Every existing rule below is class/ID-scoped and keeps
   winning on specificity, so this only fills in what was unstyled — nothing
   here changes. On-canvas inline editing (sticky text, frame/table titles)
   uses [contenteditable], not <input>/<textarea>, so it's untouched too. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
textarea,
select {
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: var(--surface-2);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):focus,
textarea:focus,
select:focus {
    border-color: var(--blue-400);
    background: var(--surface);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-2);
}

/* Interactive chrome (buttons, drag handles, toolbars, headers) should never
   show a native text-selection highlight, even on a quick click or a drag
   that starts on them. Genuinely editable/selectable text (node bodies,
   markdown content, contenteditable fields, inputs/textareas) is untouched. */
button,
select,
.tool-btn,
.node-btn,
.zoom-btn,
.nav-btn,
.header-ghost,
.wb-btn-primary,
.wb-btn-secondary,
.wb-btn-green,
.wb-context-menu-item,
.export-item,
.template-card,
.color-swatch,
.type-badge,
.drawing-toolbar,
.wb-timeline,
.zoom-controls,
.wb-frame-bar,
.wb-frame-title,
.canvas-table-header,
.canvas-code-header,
.canvas-iframe-header,
.sticky-note-header,
.node-title,
.node-actions,
.resize-handle,
.image-resize-handle,
.image-delete-btn,
.shape-resize-handle,
.wb-frame-resize,
.iframe-resize-handle,
.wb-sidebar-header,
.todo-header,
.board-dock-tabs,
.board-dock-edge,
.chat-pane-header,
.dialog-head,
.dialog-foot,
.top-nav,
.whiteboard-header {
    user-select: none;
    -webkit-user-select: none;
}

/* Highlighter marker behind text — the graphic-recording signature */
.hl {
    background-image: linear-gradient(120deg, var(--hl-soft) 0%, var(--hl-soft) 100%);
    background-repeat: no-repeat;
    background-size: 100% 0.42em;
    background-position: 0 82%;
    padding: 0 0.1em;
    border-radius: 3px;
}

/* ---------- Auth screen ---------- */
.auth-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1000px 600px at 15% -10%, var(--blue-50) 0%, transparent 55%),
        radial-gradient(900px 500px at 100% 110%, var(--hl-wash) 0%, transparent 50%),
        var(--surface);
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.auth-brand {
    color: var(--ink);
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}

.auth-brand span {
    color: var(--blue-500);
}

.auth-tagline {
    color: var(--muted);
    margin: 0 0 26px;
    font-size: 14px;
    font-weight: 500;
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-xs);
}

.google-login-btn:hover {
    transform: translateY(-1px);
    border-color: var(--blue-200);
    box-shadow: var(--shadow-sm);
}

.google-login-btn img {
    width: 18px;
    height: 18px;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 22px 0;
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 600;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-divider span {
    padding: 0 12px;
}

.auth-forms .form-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    background: var(--surface-3);
    padding: 4px;
    border-radius: var(--r);
}

.auth-forms .form-tabs button {
    flex: 1;
    padding: 9px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.auth-forms .form-tabs button.active {
    background: var(--surface);
    color: var(--blue-600);
    box-shadow: var(--shadow-xs);
}

.auth-forms input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: var(--r);
    border: 1.5px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font-size: 14px;
    outline: none;
    transition: all 0.15s;
}

.auth-forms input::placeholder {
    color: var(--muted-2);
}

.auth-forms input:focus {
    border-color: var(--blue-400);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--blue-50);
}

.auth-forms .submit-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: var(--r);
    background: var(--blue-500);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-blue);
    transition: all 0.15s;
}

.auth-forms .submit-btn:hover {
    background: var(--blue-600);
    transform: translateY(-1px);
}

.auth-forms .submit-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.auth-forms .auth-error {
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 12px;
    text-align: left;
}

/* ---------- Top navigation ---------- */
.top-nav {
    /* Was a 3-column grid (1fr auto 1fr) centering the brand — column 1 was
       always empty, wasting a third of the bar just to center a logo, which
       is exactly why 7 nav-actions items had nowhere to go and wrapped to a
       second row on anything less than a wide desktop. Plain flex row with
       the brand pinned left gives nav-actions roughly double the room. */
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--nav-h);
    padding: 0 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5000;
}

.nav-brand {
    flex-shrink: 0;
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.nav-brand span {
    color: var(--blue-500);
}

.nav-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-user {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.current-board {
    /* Save status only — the board's NAME is the nav heading now. */
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.current-board em {
    font-style: normal;
}

.nav-btn {
    padding: 9px 15px;
    border-radius: var(--r-sm);
    /* Neutral solid default so plain nav buttons (e.g. ＋ Blank Canvas) don't
       render as white text on the bar. Coloured variants override below. */
    border: 1px solid var(--line, #e2e8f0);
    background: var(--surface, #fff);
    color: var(--ink, #1e293b);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-btn:hover {
    border-color: var(--blue-300, #93c5fd);
    color: var(--blue-600, #2563eb);
}

.nav-btn.save {
    background: var(--blue-500);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--shadow-blue);
}

.nav-btn.save:hover {
    color: #fff;
}

/* Plan / billing button — reads as a premium chip so it stands out. */
.nav-btn.plan {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.28);
    text-transform: capitalize;
}

.nav-btn.plan:hover {
    filter: brightness(1.06);
    color: #fff;
    transform: translateY(-1px);
}

.nav-btn.save:hover {
    background: var(--blue-600);
    transform: translateY(-1px);
}

/* Account menu — consolidates Admin/Logout/profile-name behind one button.
   .export-menu/.show do the actual dropdown positioning/animation (reused
   as-is from the whiteboard header's Export menu); this just anchors it. */
.account-menu-anchor {
    position: relative;
}

.nav-btn.account {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-menu {
    min-width: 160px;
}

.nav-btn.load {
    background: var(--surface);
    color: var(--ink-2);
    border-color: var(--line);
}

.nav-btn.load:hover {
    border-color: var(--blue-300);
    color: var(--blue-600);
}

.nav-btn.logout {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--line);
}

.nav-btn.logout:hover {
    color: var(--danger);
    border-color: #fecaca;
}

/* ---------- Whiteboard shell ---------- */
.whiteboard-wrap {
    background: var(--surface);
    /* Flex column, not a fixed-height header + a canvas whose height assumed
       the header was always exactly 63px tall. When the nav or header wraps
       to a second line (crowded toolbar, narrow laptop, etc.) that hardcoded
       subtraction went stale, total page height exceeded 100vh, and the
       browser scrolled — dragging the absolutely-positioned zoom/minimap/
       timeline controls (anchored inside .whiteboard-canvas) down with it.
       flex:1 + min-height:0 on the canvas below makes it always fill whatever
       is actually left, so nothing downstream needs the header's exact height. */
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-h));
    /* THE PUSH. #whiteboard-root lives OUTSIDE #app, so the dock (which is
       inside #app) reaches it via a body class + the --dock-* vars. The board
       is sized purely by CSS — no JS measures innerWidth — and every screen→
       board coordinate conversion re-reads getBoundingClientRect() per event,
       so narrowing it needs no JS changes. */
    margin-left: var(--dock-rail-w);
    transition: margin-left 0.28s ease;
}

body.dock-open .whiteboard-wrap {
    margin-left: var(--dock-w);
}

.whiteboard-header {
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0; /* never compressed by the flex column — see .whiteboard-wrap */
}

/* Once the board has content, hide the challenge prompt + Start Exploring
   (you can still start from right-click → Explore). Templates/Export/Clear stay. */
.whiteboard-wrap.has-content .header-input,
.whiteboard-wrap.has-content #start-btn {
    display: none;
}

.whiteboard-header h1 {
    font-size: 19px;
    font-weight: 800;
    color: var(--ink);
    margin: 0;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.whiteboard-header .header-input {
    /* Was not a flex container at all, so its two children (the prompt input
       and the #voice-btn mic button, when speech recognition is available)
       just flowed as normal inline content — once .whiteboard-header got
       crowded enough to shrink this element's available width, the mic
       button wrapped onto its own line below the input instead of sitting
       beside it. */
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.whiteboard-header input {
    width: 100%;
    min-width: 0;
    max-width: 640px;
    padding: 11px 16px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--ink);
    font-size: 14px;
    outline: none;
    transition: all 0.15s;
}

.whiteboard-header input::placeholder {
    color: var(--muted-2);
}

.whiteboard-header input:focus {
    border-color: var(--blue-400);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--blue-50);
}

#start-btn {
    padding: 11px 22px;
    border-radius: var(--r);
    background: var(--blue-500);
    color: white;
    font-weight: 700;
    font-size: 14px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-blue);
    transition: all 0.15s;
}

#start-btn:hover {
    background: var(--blue-600);
    transform: translateY(-1px);
}

#start-btn:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

#clear-btn {
    padding: 11px 18px;
    border-radius: var(--r);
    background: var(--surface);
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid var(--line);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

#clear-btn:hover {
    color: var(--ink-2);
    border-color: var(--muted-2);
}

.whiteboard-canvas {
    position: relative;
    overflow: hidden;
    cursor: grab;
    flex: 1;
    min-height: 0;
    touch-action: none;
    background: radial-gradient(circle at 1px 1px, rgba(100, 116, 139, 0.18) 1px, transparent 0);
    background-size: 34px 34px;
}

.whiteboard-canvas.grabbing {
    cursor: grabbing;
}

#connections-svg,
#drawing-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    pointer-events: none;
    overflow: visible;
}

#connections-svg {
    z-index: 1;
}

#drawing-svg {
    /* Above every element layer (images 4, nodes 5, stickies 7, texts 8) so
       pen strokes drawn over a symbol are actually visible. At the old
       z-index:2 the ink rendered UNDERNEATH everything, so drawing across a
       symbol looked like it silently did nothing. Ink behaves like a
       transparent sheet laid over the board. */
    z-index: 9;
}

#shapes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 3;
    pointer-events: none;
}

#nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 5;
    pointer-events: none;
}

#elements-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 6;
    pointer-events: none;
}

#images-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 4;
    pointer-events: none;
}

#stickies-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 7;
    pointer-events: none;
}

/* Empty-state hint */
.canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 3;
    max-width: 460px;
    padding: 0 20px;
}

.canvas-hint .hint-emoji {
    font-size: 40px;
    margin-bottom: 12px;
}

.canvas-hint h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.canvas-hint p {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}

.canvas-hint button {
    margin-top: 18px;
    pointer-events: auto;
}

.canvas-hint kbd {
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 1px 7px;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 600;
    color: var(--ink-2);
}

/* ---------- Context menus ---------- */
.wb-context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 10000;
    display: none;
    min-width: 200px;
}

.wb-context-menu.show {
    display: block;
}

.wb-context-menu-item {
    padding: 9px 14px;
    cursor: pointer;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
    transition: background 0.12s;
}

.wb-context-menu-item:hover {
    background: var(--blue-50);
    color: var(--blue-700);
}

.wb-context-menu-item.danger {
    color: var(--danger);
}

.wb-context-menu-item.danger:hover {
    background: var(--danger-soft);
}

/* ---------- Modals + buttons ---------- */
.wb-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 10001;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.wb-modal-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 26px;
    max-width: 500px;
    width: 100%;
}

.wb-modal-card.wide {
    max-width: 600px;
    max-height: 82vh;
    overflow-y: auto;
}

.wb-modal-card h3 {
    margin: 0 0 14px;
    font-size: 19px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.wb-modal-card p {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.wb-modal-card textarea {
    width: 100%;
    height: 100px;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    color: var(--ink);
    outline: none;
    transition: all 0.15s;
}

.wb-modal-card textarea:focus {
    border-color: var(--blue-400);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--blue-50);
}

.wb-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.wb-btn-secondary {
    padding: 10px 18px;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.wb-btn-secondary:hover {
    border-color: var(--muted-2);
}

.wb-btn-primary {
    padding: 10px 18px;
    border-radius: var(--r);
    border: none;
    background: var(--blue-500);
    color: white;
    cursor: pointer;
    font-weight: 700;
    box-shadow: var(--shadow-blue);
    transition: all 0.15s;
}

.wb-btn-primary:hover {
    background: var(--blue-600);
    transform: translateY(-1px);
}

.wb-btn-primary:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

/* "green" slot is repurposed as the highlighter-yellow AI action */
.wb-btn-green {
    padding: 10px 18px;
    border-radius: var(--r);
    border: none;
    background: var(--hl);
    color: var(--hl-ink);
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(234, 179, 8, 0.28);
    transition: all 0.15s;
}

.wb-btn-green:hover {
    background: #ffd81f;
    transform: translateY(-1px);
}

.wb-btn-green:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

.converge-count {
    margin: 0 0 12px;
    padding: 9px 12px;
    background: var(--blue-50);
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--blue-700);
}

/* Convergence viewer */
.wb-modal-card.viewer {
    max-width: 900px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.viewer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.viewer-head h3 {
    margin: 0;
}

.viewer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r);
    font-size: 14px;
    line-height: 1.65;
    color: var(--ink);
    min-height: 200px;
}

.viewer-chat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.viewer-chat-title {
    font-weight: 700;
    color: var(--ink-2);
    font-size: 14px;
}

#convergence-chat-history {
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--r);
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
}

.viewer-chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.viewer-chat-input textarea {
    flex: 1;
    min-height: 60px;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    outline: none;
    color: var(--ink);
}

.viewer-chat-input textarea:focus {
    border-color: var(--blue-400);
}

/* Symbol picker */
.wb-modal-card.symbol-card {
    max-width: 640px;
}

.symbol-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.symbol-search-row input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    font-size: 14px;
    outline: none;
    background: var(--surface-2);
    color: var(--ink);
    transition: all 0.15s;
}

.symbol-search-row input:focus {
    border-color: var(--blue-400);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--blue-50);
}

.symbol-search-row button {
    padding: 11px 16px;
    border-radius: var(--r);
    border: none;
    background: var(--hl);
    color: var(--hl-ink);
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.symbol-search-row button:hover {
    background: #ffd81f;
}

.symbol-search-row button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.symbol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px;
}

.symbol-grid .symbol-item {
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 12px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--surface-2);
}

.symbol-grid .symbol-item:hover {
    border-color: var(--blue-300);
    transform: translateY(-2px);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.symbol-grid .symbol-item img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.symbol-grid .symbol-item span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.symbol-empty {
    color: var(--muted);
    font-size: 13px;
    padding: 24px;
    text-align: center;
    grid-column: 1 / -1;
}

/* ---------- Nodes ---------- */
.node {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 16px;
    width: 280px;
    min-height: 200px;
    box-shadow: var(--shadow-md);
    cursor: move;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    z-index: 10;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.node:hover {
    box-shadow: var(--shadow-lg);
}

.node.selected {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px var(--blue-100), var(--shadow-lg);
}

/* Challenge (central) node — blue gradient */
.node.central {
    background: linear-gradient(140deg, var(--blue-500) 0%, var(--blue-600) 100%);
    border-color: transparent;
    color: white;
    min-width: 280px;
    box-shadow: var(--shadow-blue), var(--shadow-md);
}

.node.central .node-title {
    color: white;
}

.node.central .node-content {
    color: rgba(255, 255, 255, 0.92);
}

/* Synthesis node — subtle blue-tinted card with a left ribbon */
.node.node-type-synthesis {
    background: linear-gradient(180deg, var(--blue-50) 0%, var(--surface) 40%);
    border-color: var(--blue-200);
    border-left: 4px solid var(--blue-500);
}

/* Idea node — subtle highlighter tint */
.node.node-type-idea {
    background: linear-gradient(180deg, var(--hl-wash) 0%, var(--surface) 45%);
    border-color: #f5e39a;
    border-left: 4px solid var(--hl-deep);
}

.node.node-type-visual-root {
    background: linear-gradient(145deg, #0f172a 0%, #1d4ed8 100%);
    border-color: transparent;
    color: white;
    box-shadow: var(--shadow-blue), var(--shadow-lg);
}

.node.node-type-visual-root .node-title,
.node.node-type-visual-root .node-content,
.node.node-type-visual-root .node-paragraph {
    color: white;
}

.node.node-dark .markdown-content,
.node.node-dark .markdown-content h1,
.node.node-dark .markdown-content h2,
.node.node-dark .markdown-content h3,
.node.node-dark .markdown-content p,
.node.node-dark .markdown-content li,
.node.node-dark .markdown-content strong {
    color: rgba(255, 255, 255, 0.94);
}

.node.node-dark .markdown-content a { color: #bfdbfe; }
.node.node-dark .markdown-content code { color: #fff; background: rgba(255, 255, 255, 0.14); }

.node.node-type-harvest-card .node-content,
.node.node-type-harvest-sticky .node-content,
.node.node-type-harvest-milestone .node-content,
.node.node-type-visual-root .node-content {
    flex: 0 0 auto;
    overflow: visible;
    min-height: auto;
}

.node.node-type-harvest-sticky {
    background: linear-gradient(180deg, #fff8c5 0%, #fffef5 100%);
    transform: rotate(-0.4deg);
}

.node.node-type-harvest-milestone {
    background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
    border-width: 2px;
}

.type-badge.harvest {
    background: #e0f2fe;
    color: #075985;
}

.type-badge.harvest-milestone { background: #dbeafe; color: #1d4ed8; }
.type-badge.harvest-sticky { background: #fef3c7; color: #92400e; }
.type-badge.harvest-card { background: #e0f2fe; color: #075985; }

.node-title {
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.node-paragraph {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 8px;
    line-height: 1.45;
}

.node.central .node-paragraph {
    color: rgba(255, 255, 255, 0.8);
}

.node-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 10px 12px;
    font-size: 13.5px;
    line-height: 1.55;
    cursor: text;
    color: var(--ink-2);
}

.node-content ul,
.node-content ol {
    margin: 0.3rem 0;
    padding-left: 1.1rem;
}

.node-content li {
    margin: 0.12rem 0;
}

.node-content strong {
    font-weight: 700;
}

.node-content code {
    background: rgba(15, 23, 42, 0.08);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.node-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.node-btn {
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

/* AI-generative actions wear the highlighter */
.node-btn.expand {
    background: var(--hl);
    color: var(--hl-ink);
}

.node-btn.expand:hover {
    background: #ffd81f;
}

.node-btn.chat {
    background: var(--blue-500);
    color: white;
}

.node-btn.chat:hover {
    background: var(--blue-600);
}

.node-btn.converge {
    background: var(--blue-600);
    color: white;
}

.node-btn.converge:hover {
    background: var(--blue-700);
}

.node-btn.view-convergence {
    background: var(--blue-50);
    color: var(--blue-700);
    border: 1px solid var(--blue-200);
}

.node-btn.view-convergence:hover {
    background: var(--blue-100);
}

.node.central .node-btn.chat {
    background: rgba(255, 255, 255, 0.22);
}

.node.central .node-btn.chat:hover {
    background: rgba(255, 255, 255, 0.32);
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(46, 144, 250, 0.45) 50%);
    border-radius: 0 0 var(--r-lg) 0;
}

.resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, rgba(46, 144, 250, 0.85) 50%);
}

.type-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 10px;
    width: fit-content;
}

.type-badge.agent {
    background: var(--surface-3);
    color: var(--ink-2);
}

.type-badge.deep-dive {
    background: var(--blue-600);
    color: white;
}

.type-badge.alternative {
    background: var(--blue-100);
    color: var(--blue-700);
}

.type-badge.wild-card {
    background: var(--hl-deep);
    color: white;
}

.type-badge.synthesis {
    background: var(--blue-500);
    color: white;
}

.type-badge.idea {
    background: var(--hl);
    color: var(--hl-ink);
}

/* ---------- Markdown ---------- */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    font-weight: 700;
    margin: 0.6rem 0 0.4rem;
    letter-spacing: -0.01em;
    color: black;
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.markdown-content li {
    margin: 0.25rem 0;
    color: black;
}

.markdown-content p {
    margin: 0.5rem 0;
    color: black;
}

.markdown-content a {
    color: var(--blue-600);
}

.markdown-content pre {
    background: var(--ink);
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--r);
    overflow-x: auto;
    margin: 0.5rem 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-content table {
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid var(--line);
    padding: 6px 10px;
    font-size: 13px;
}

.markdown-content th {
    background: var(--surface-3);
}

/* ---------- Node (ideation) sidebar ---------- */
.wb-sidebar {
    position: fixed;
    right: 0;
    top: var(--nav-h);
    width: var(--sidebar-width, 400px);
    min-width: 300px;
    max-width: 96vw;
    height: calc(100vh - var(--nav-h));
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    /* Above the floating collaboration chat (7000) when the ideation chat is shown */
    z-index: 7200;
    display: flex;
    flex-direction: column;
}

.wb-sidebar.open {
    transform: translateX(0);
}

/* Drag the left edge to resize (width persists to localStorage) */
.wb-sidebar-resize {
    position: absolute;
    top: 0;
    left: -4px;
    width: 9px;
    height: 100%;
    cursor: ew-resize;
    z-index: 2;
}
.wb-sidebar-resize::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 3px;
    width: 3px;
    height: 42px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: var(--line);
    transition: background 0.15s;
}
.wb-sidebar-resize:hover::before { background: var(--blue-400); }

/* When the ideation sidebar is open, nudge the collab chat clear of it */

/* Ideation chat bubbles — user right (black text on light), AI left */
.wb-chat-row { display: flex; margin-bottom: 12px; }
.wb-chat-row.user { justify-content: flex-end; }
.wb-chat-row.ai { justify-content: flex-start; }
.wb-bubble {
    max-width: 84%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
}
.wb-bubble.user {
    background: var(--surface-3);
    color: #000000;
    border: 1px solid var(--line);
    border-bottom-right-radius: 4px;
}
.wb-bubble.ai {
    background: var(--blue-50);
    color: var(--ink);
    border: 1px solid var(--blue-100);
    border-bottom-left-radius: 4px;
}
.wb-bubble .wb-bubble-who { font-size: 11px; font-weight: 700; opacity: 0.6; margin-bottom: 2px; }
.wb-bubble.ai .markdown-content { font-size: 13px; }

.wb-sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wb-sidebar-header h3 {
    color: var(--ink);
    font-size: 16px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.01em;
}

.wb-sidebar-header button {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.wb-sidebar-header button:hover {
    color: var(--ink);
}

.wb-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.6;
}

.wb-sidebar-content strong {
    color: var(--ink);
}

.wb-sidebar-chat {
    padding: 16px 18px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    background: var(--surface-2);
}

.wb-sidebar-chat input {
    flex: 1;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    outline: none;
    transition: all 0.15s;
}

.wb-sidebar-chat input:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px var(--blue-50);
}

.wb-sidebar-chat button {
    padding: 11px 18px;
    border-radius: var(--r);
    background: var(--blue-500);
    color: white;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.wb-sidebar-chat button:hover {
    background: var(--blue-600);
}

/* ---------- Zoom controls ---------- */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--r);
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 18px;
    color: var(--ink-2);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.15s;
}

.zoom-btn:hover {
    color: var(--blue-600);
    border-color: var(--blue-300);
    transform: translateY(-1px);
}

/* ---------- Drawing toolbar ---------- */
.drawing-toolbar {
    /* Two rows (draw/insert tools, then style/view controls) stacked instead
       of one long strip that wrapped into an arbitrary 3rd row wherever it
       ran out of width. inline-flex so the box sizes to its widest row
       (row 1, ~660px with all 15 tool buttons) rather than stretching to
       max-width — comfortably fits most laptop windows without wrapping.

       max-width is tied to --dock-w/--dock-rail-w (below), not just vw: the
       toolbar is centered inside .whiteboard-canvas, whose width is already
       reduced by the dock's margin-left AND the dock is user-resizable via
       its drag handle, so a fixed vw-based cap can't know how much room is
       actually left. Get this wrong and .whiteboard-canvas's overflow:hidden
       clips part of the toolbar — including the leftmost tool button —
       instead of it wrapping, which is worse than 3 messy rows. */
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    z-index: 100;
    /* Desktop only — the 768px mobile override below resets this to a single
       scrolling strip, where a fixed min-width is harmless (overflow-x:auto
       already handles anything wider than the viewport). min-width wins over
       max-width per spec, so on a genuinely narrow canvas (dock open on a
       ~900-1000px window) this can push the box wider than max-width would
       otherwise allow — .toolbar-row's flex-wrap:wrap fallback still keeps
       every button reachable rather than clipped in that case. */
    min-width: 700px;
    max-width: min(96vw, calc(100vw - var(--dock-rail-w) - 40px));
}

body.dock-open .drawing-toolbar {
    max-width: min(96vw, calc(100vw - var(--dock-w) - 40px));
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    /* One row that SCROLLS rather than wraps. The old two-row split existed to
       stop a ragged third row appearing wherever the strip ran out of width;
       scrolling solves the same problem without spending a second bar of
       vertical space, and — unlike the old max-width approach — it cannot
       clip a tool out of reach when the dock is dragged wide. */
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    max-width: 100%;
}

/* A scrollbar under the tools would read as a border; the row still scrolls
   by wheel, trackpad and drag. */
.toolbar-row::-webkit-scrollbar { height: 0; }

.toolbar-row > * { flex: 0 0 auto; }

/* Compact enough to sit inline with the tool buttons. */
.toolbar-row #line-thickness {
    max-width: 116px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: all 0.15s;
    color: var(--ink-2);
}

.tool-btn:hover {
    background: var(--surface-3);
}

.tool-btn.active {
    background: var(--blue-500);
    color: white;
    box-shadow: var(--shadow-blue);
}

.tool-divider {
    width: 1px;
    height: 22px;
    background: var(--line);
    margin: 0 3px;
}

#line-thickness {
    padding: 5px 8px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    font-size: 12px;
    cursor: pointer;
    color: var(--ink-2);
    background: var(--surface);
    font-family: inherit;
}

.color-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.color-group span {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
}

.color-anchor {
    position: relative;
}

.color-picker-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 1px var(--line), var(--shadow-xs);
    cursor: pointer;
    transition: transform 0.15s;
}

.color-picker-btn:hover {
    transform: scale(1.1);
}

.color-palette {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
    gap: 8px;
    width: 180px;
    z-index: 200;
}

.color-palette.show {
    display: flex;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
    transition: all 0.15s;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: var(--ink);
}

/* ---------- Sticky notes ---------- */
.sticky-note {
    position: absolute;
    width: 220px;
    height: 180px;
    min-width: 180px;
    min-height: 140px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    z-index: 8;
    font-family: 'Bricolage Grotesque', 'Comic Sans MS', cursive, sans-serif;
    display: flex;
    flex-direction: column;
    pointer-events: all;
    overflow: visible;
    transition: box-shadow 0.18s ease;
}

.sticky-note:hover {
    box-shadow: var(--shadow-lg);
}

.sticky-note-header {
    min-height: 38px;
    padding: 6px 8px;
    cursor: move !important;
    border-radius: 9px 9px 0 0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: rgba(15, 23, 42, 0.72);
    flex: 0 0 auto;
}

.sticky-pin {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 4px 2px;
    cursor: move;
}

.sticky-title-input {
    min-width: 0;
    flex: 1;
    border: 0;
    border-radius: 5px;
    padding: 3px 4px;
    background: transparent;
    color: #1f2937;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    outline: none;
}

.sticky-title-input:hover,
.sticky-title-input:focus {
    background: rgba(255, 255, 255, 0.42);
}

.sticky-note-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 0 0 auto;
}

.sticky-color-toggle,
.sticky-note .delete-sticky {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.42);
    color: #334155;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    opacity: 0.65;
    transition: opacity 0.15s, background 0.15s;
}

.sticky-color-toggle:hover,
.sticky-note .delete-sticky:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.72);
}

.sticky-note-body {
    flex: 1;
    padding: 12px;
    min-height: 0;
    border-radius: 0 0 9px 9px;
}

.sticky-note textarea {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    outline: none;
    color: #1f2937;
}

.sticky-color-popover {
    display: none;
    position: absolute;
    z-index: 30;
    top: 34px;
    right: 7px;
    width: 210px;
    padding: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.sticky-color-popover.open {
    display: block;
}

.sticky-color-row {
    display: grid;
    grid-template-columns: 46px 1fr;
    align-items: center;
    gap: 7px;
}

.sticky-color-row + .sticky-color-row {
    margin-top: 8px;
}

.sticky-color-row > span {
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sticky-color-row > div {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.sticky-color-swatch {
    width: 15px;
    height: 15px;
    padding: 0;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 50%;
    background: var(--swatch);
    cursor: pointer;
}

.sticky-color-swatch.selected {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.sticky-resize-handle {
    position: absolute;
    z-index: 4;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    border-radius: 0 0 9px 0;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 48%, rgba(15, 23, 42, 0.3) 49%, rgba(15, 23, 42, 0.3) 57%, transparent 58%);
}

/* ---------- Shapes ---------- */
.whiteboard-shape {
    position: absolute;
    pointer-events: all;
    z-index: 6;
}

.whiteboard-shape.selected {
    outline: 2px dashed var(--blue-500);
    outline-offset: 4px;
}

.shape-resize-handle {
    display: none;
}

.whiteboard-shape.selected .shape-resize-handle {
    display: block;
}

.eraser-mode .shape-resize-handle {
    pointer-events: none !important;
    cursor: crosshair !important;
}

.eraser-mode .whiteboard-shape {
    cursor: crosshair !important;
}

/* ---------- Canvas images (symbols) ---------- */
.canvas-image {
    position: absolute;
    z-index: 6;
    pointer-events: all;
    cursor: move;
}

.canvas-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.canvas-image.rag-visual {
    box-sizing: border-box;
    padding: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
}

.canvas-image.rag-placement-section-anchor {
    padding: 10px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.9);
}

.canvas-image.rag-style-image {
    padding: 5px;
    border-radius: 18px;
    background: #fff;
}

.canvas-image.rag-style-image img {
    border-radius: 13px;
}

.canvas-image.rag-placement-above {
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.16);
}

.canvas-image.selected,
.canvas-image.selected-item {
    outline: 2px dashed var(--blue-500);
    outline-offset: 3px;
}

.canvas-image .image-resize-handle {
    position: absolute;
    bottom: -7px;
    right: -7px;
    width: 14px;
    height: 14px;
    background: var(--blue-500);
    border: 2px solid white;
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.15s;
}

.canvas-image .image-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: white;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.canvas-image:hover .image-resize-handle,
.canvas-image:hover .image-delete-btn {
    opacity: 1;
}

/* ---------- Multi-select ---------- */
.selection-box {
    position: fixed;
    border: 1.5px dashed var(--blue-500);
    background: rgba(46, 144, 250, 0.10);
    pointer-events: none;
    z-index: 99999;
    border-radius: 4px;
}

.selected-item {
    outline: 2px solid var(--blue-500) !important;
    outline-offset: 2px;
}

.no-select {
    user-select: none !important;
}

/* ---------- Tables on canvas ---------- */
.canvas-table {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    z-index: 6;
    pointer-events: all;
    min-width: 200px;
}

.canvas-table-header {
    padding: 8px 12px;
    background: var(--surface-3);
    border-radius: var(--r) var(--r) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-2);
    gap: 8px;
}

.canvas-table-header .table-actions {
    display: flex;
    gap: 4px;
}

.table-name {
    min-width: 60px;
    outline: none;
    cursor: text;
    border-radius: 4px;
    padding: 1px 4px;
    margin: -1px -4px;
}

.table-name[contenteditable="true"] {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    background: var(--surface);
    outline: 2px solid var(--blue-400);
}

.canvas-table-header button {
    padding: 4px 8px;
    border: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    cursor: pointer;
    font-size: 11px;
    color: var(--ink-2);
}

.canvas-table-header button:hover {
    background: var(--blue-50);
    color: var(--blue-600);
}

.canvas-table table {
    width: 100%;
    border-collapse: collapse;
}

.canvas-table th,
.canvas-table td {
    border: 1px solid var(--line);
    padding: 8px;
    min-width: 60px;
    font-size: 13px;
    color: var(--ink-2);
}

.canvas-table th {
    background: var(--surface-2);
    font-weight: 700;
}

.canvas-table td[contenteditable]:focus,
.canvas-table th[contenteditable]:focus {
    background: var(--blue-50);
    outline: none;
}

/* ---------- Code blocks on canvas ---------- */
.canvas-code {
    position: absolute;
    background: var(--ink);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    z-index: 6;
    pointer-events: all;
    min-width: 300px;
    max-width: 600px;
    overflow: hidden;
}

.canvas-code-header {
    padding: 8px 12px;
    background: #0b1220;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.canvas-code-header select {
    padding: 4px 8px;
    border-radius: var(--r-xs);
    border: 1px solid #334155;
    background: #1e293b;
    color: white;
    font-size: 11px;
}

.canvas-code-header button {
    padding: 4px 8px;
    border: none;
    background: #334155;
    color: white;
    border-radius: var(--r-xs);
    cursor: pointer;
    font-size: 11px;
}

.canvas-code textarea {
    width: 100%;
    min-height: 150px;
    background: var(--ink);
    color: #e2e8f0;
    border: none;
    padding: 12px;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

/* ---------- Iframe embeds on canvas ---------- */
.canvas-iframe {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    z-index: 6;
    pointer-events: all;
    min-width: 300px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.canvas-iframe-header {
    padding: 8px 12px;
    background: var(--surface-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-2);
}

.canvas-iframe-header button {
    padding: 4px 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--r-xs);
    cursor: pointer;
    font-size: 11px;
    color: var(--ink-2);
}

.canvas-iframe-content {
    flex: 1;
    overflow: hidden;
}

.canvas-iframe iframe {
    width: 100%;
    height: 100%;
    min-height: 200px;
    border: none;
}

.canvas-iframe textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: none;
    font-size: 12px;
    font-family: monospace;
    resize: vertical;
    outline: none;
    color: var(--ink);
}

/* ---------- History timeline bar ---------- */
.wb-timeline {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 8px 14px;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.wb-timeline button {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    border: none;
    background: var(--blue-500);
    color: white;
    cursor: pointer;
    font-size: 12px;
}

.wb-timeline button:hover {
    background: var(--blue-600);
}

.wb-timeline input[type="range"] {
    width: 200px;
    cursor: pointer;
    accent-color: var(--blue-500);
}

.wb-timeline span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    min-width: 42px;
    text-align: center;
}

.wb-timeline select {
    padding: 4px 6px;
    border-radius: var(--r-xs);
    border: 1px solid var(--line);
    font-size: 12px;
    color: var(--ink-2);
    background: var(--surface);
}

/* ---------- Board dock (left): Chats | Tasks ----------
   Mirrors .wb-sidebar's fixed/top:var(--nav-h) geometry, but unlike that
   drawer (and the .todo-drawer it replaces) it PUSHES the board rather than
   overlaying it — see the .whiteboard-wrap margin rule up top. */
.board-dock {
    position: fixed;
    left: 0;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    width: var(--dock-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 6500; /* .wb-sidebar (7200) stays above; dialogs (11000) above all */
    transition: width 0.28s ease;
}

body.dock-rail .board-dock {
    width: var(--dock-rail-w);
}

/* Drag-to-resize grip on the dock's right edge (open state only). */
.board-dock-resize {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 3;
}
.board-dock-resize:hover::before {
    content: '';
    position: absolute;
    inset: 0 2px;
    background: var(--blue-300);
}
body.dock-rail .board-dock-resize { display: none; }

/* Tab bar — always visible chrome, in both rail and open states. */
.board-dock-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    user-select: none;
}
body.dock-rail .board-dock-tabs {
    flex-direction: column;
    padding: 8px 4px;
}

.board-dock-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    position: relative;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}
.board-dock-tab:hover { background: var(--blue-50); color: var(--blue-700); }
.board-dock-tab.active {
    background: var(--blue-50);
    border-color: var(--blue-200);
    color: var(--blue-700);
}
body.dock-rail .board-dock-tab {
    flex: none;
    width: 100%;
    padding: 9px 0;
}
body.dock-rail .board-dock-tab-label { display: none; }

/* Collapse/expand chevron — hidden in rail mode (tapping a tab expands). */
.board-dock-collapse {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}
.board-dock-collapse:hover { background: var(--blue-50); color: var(--blue-700); }
body.dock-rail .board-dock-collapse { display: none; }

/* Unread pip on a tab. */
.board-dock-badge {
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger, #ef4444);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
body.dock-rail .board-dock-badge {
    position: absolute;
    top: 3px;
    right: 3px;
}

/* Mobile-only reopen affordance, shown by the ≤900px block when railed. */
.board-dock-edge {
    display: none;
    position: fixed;
    left: 0;
    top: 62%;
    transform: translateY(-50%);
    width: 28px;
    height: 104px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-left: none;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--blue-700);
    cursor: pointer;
    z-index: 6400;
}
body:not(.dock-rail) .board-dock-edge { display: none !important; }

/* Chat + todo panes fill their tab; only their inner lists scroll. Replaces
   the geometry the old floating .chat-widget / .todo-drawer supplied. */
.chat-pane,
.todo-pane {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.todo-pane-inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    background: var(--surface);
}

/* Each tab's pane fills the remaining height; children scroll internally. */
.board-dock-pane {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.dock-rail .board-dock-body { display: none; }
.board-dock-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- Todo list drawer ---------- */


/* Drag the right edge to resize (persists to localStorage) */

.todo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}

.todo-header h2 {
    color: var(--ink);
    font-weight: 800;
    font-size: 16px;
    margin: 0;
    letter-spacing: -0.01em;
}

.todo-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 16px;
}

.todo-header button:hover {
    color: var(--ink);
}

.todo-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}



.add-task {
    display: flex;
    margin-bottom: 15px;
}

.add-task input {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid var(--line);
    border-right: none;
    border-radius: var(--r-sm) 0 0 var(--r-sm);
    font-size: 14px;
    outline: none;
    background: var(--surface);
    color: var(--ink);
}

.add-task input:focus {
    border-color: var(--blue-400);
}

.add-task button {
    padding: 9px 16px;
    background: var(--blue-500);
    color: white;
    border: none;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.add-task button:hover {
    background: var(--blue-600);
}

.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.task-main {
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 8px;
}

.task-main input[type="checkbox"] {
    accent-color: var(--blue-500);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.task-main .task-title {
    flex: 1;
    font-size: 14px;
    color: var(--ink-2);
    cursor: default;
}

.task-main .task-title.completed {
    text-decoration: line-through;
    color: var(--muted-2);
}

.task-edit-input {
    flex: 1;
    background: var(--surface);
    color: var(--ink);
    border: 1.5px solid var(--blue-300);
    border-radius: var(--r-xs);
    padding: 4px 8px;
    font-size: 14px;
    outline: none;
}

.task-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.task-actions button,
.task-actions a {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 14px;
    padding: 3px 5px;
    text-decoration: none;
}

.task-actions button:hover,
.task-actions a:hover {
    color: var(--blue-600);
}

.task-actions .remove-btn {
    font-size: 18px;
    line-height: 1;
}

.task-actions .remove-btn:hover {
    color: var(--danger);
}

.subtask-section {
    padding: 0 10px 10px 34px;
    background: var(--surface-2);
    border-top: 1px solid var(--line-2);
}

.subtask-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.subtask-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    padding: 6px 8px;
    background: var(--surface);
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
}

.subtask-list li input[type="checkbox"] {
    accent-color: var(--blue-500);
}

.subtask-list .task-title {
    flex: 1;
    font-size: 13px;
    color: var(--ink-2);
}

.add-subtask {
    display: flex;
    margin: 8px 0 0;
}

.add-subtask input {
    flex: 1;
    padding: 6px 10px;
    border: 1.5px solid var(--line);
    border-right: none;
    border-radius: var(--r-xs) 0 0 var(--r-xs);
    font-size: 13px;
    outline: none;
    background: var(--surface);
    color: var(--ink);
}

.add-subtask input:focus {
    border-color: var(--blue-400);
}

.add-subtask button {
    padding: 6px 12px;
    background: var(--hl);
    color: var(--hl-ink);
    border: none;
    border-radius: 0 var(--r-xs) var(--r-xs) 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.completed-section {
    margin-top: 20px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.completed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 5px 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.completed-item {
    opacity: 0.75;
}

.link-btn {
    background: none;
    border: none;
    color: var(--blue-500);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
}

.link-modal {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 12px;
    box-shadow: var(--shadow-md);
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-modal input {
    background: var(--surface);
    color: var(--ink);
    border: 1.5px solid var(--line);
    padding: 7px 10px;
    border-radius: var(--r-sm);
    min-width: 240px;
    outline: none;
}

.link-modal input:focus {
    border-color: var(--blue-400);
}

.link-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.link-modal-actions button {
    padding: 5px 11px;
    border-radius: var(--r-xs);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    cursor: pointer;
}

.link-modal-actions button:hover {
    border-color: var(--blue-300);
}

.task-link-preview a {
    color: var(--blue-600);
    font-size: 12px;
}

/* ---------- Collaboration chat widget ---------- */





.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 15px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
}

.chat-msg {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 14px;
    max-width: 82%;
    word-wrap: break-word;
    background: var(--surface);
    border: 1px solid var(--line);
    align-self: flex-start;
    font-size: 13px;
    color: var(--ink);
}

.chat-msg.mine {
    align-self: flex-end;
    background: var(--blue-500);
    border-color: transparent;
    color: white;
}

.chat-msg .sender {
    font-weight: 700;
    margin-right: 5px;
    font-size: 12px;
    color: var(--muted);
}

.chat-msg.mine .sender {
    color: rgba(255, 255, 255, 0.85);
}

.chat-msg .stamp {
    display: block;
    font-size: 10px;
    color: var(--muted-2);
    margin-top: 3px;
    text-align: right;
}

.chat-msg.mine .stamp {
    color: rgba(255, 255, 255, 0.7);
}

.chat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 9px 15px;
    color: var(--ink);
    font-size: 13px;
    background: var(--surface-2);
    outline: none;
}

.chat-input-area input:focus {
    border-color: var(--blue-400);
    background: var(--surface);
}

.chat-input-area button {
    background: var(--blue-500);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    padding: 9px 15px;
    cursor: pointer;
    font-size: 13px;
}

.chat-input-area button:hover {
    background: var(--blue-600);
}

/* ---------- Billing / PayPal subscriptions ---------- */
.billing-card { max-width: 980px; }
.billing-card .dialog-head h3 { margin: 0; }
.billing-card .dialog-head small { color: var(--muted); font-size: 12px; }
.billing-plans {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}
.billing-plan {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px;
    background: var(--surface);
    min-height: 250px;
    box-shadow: var(--shadow-xs);
}
.billing-plan.featured { border-color: var(--blue-300); box-shadow: 0 0 0 3px var(--blue-50), var(--shadow-sm); }
.billing-plan-kicker { color: var(--blue-700); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.billing-plan h4 { margin: 10px 0; font-size: 25px; color: var(--ink); }
.billing-plan h4 small { font-size: 12px; color: var(--muted); margin-left: 4px; font-weight: 600; }
.billing-plan p { color: var(--muted); font-size: 13px; line-height: 1.55; min-height: 62px; }
.billing-plan-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.billing-plan-actions .wb-btn-primary { width: 100%; }
.paypal-button-slot { min-height: 42px; }
.current-plan-chip, .subscription-status {
    display: inline-flex; align-items: center; border-radius: 999px;
    padding: 4px 9px; font-size: 11px; font-weight: 800;
    background: #dcfce7; color: #166534;
}
.subscription-status { margin-left: 8px; }
.status-suspended, .status-approval_pending { background: #fef3c7; color: #92400e; }
.status-cancelled, .status-expired { background: #fee2e2; color: #991b1b; }
.billing-current {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    border: 1px solid #bbf7d0; background: #f0fdf4; padding: 16px;
    border-radius: var(--r); margin-bottom: 14px;
}
.billing-current p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.billing-current-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wb-btn-danger { border: 1px solid #fecaca; background: #fff; color: #b91c1c; border-radius: var(--r-sm); padding: 8px 12px; cursor: pointer; font-weight: 700; }
.billing-admin-note, .billing-setup-note { padding: 13px 15px; border-radius: var(--r); background: var(--blue-50); color: var(--blue-700); font-size: 13px; }
.billing-setup-note { margin-top: 16px; background: #fff7ed; color: #9a3412; }
.billing-footnote { margin: 16px 0 0; color: var(--muted-2); font-size: 11px; line-height: 1.5; }
.dialog-success { margin-bottom: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: #dcfce7; color: #166534; font-size: 13px; }

/* ---------- Save/Load board dialogs (Vue) ---------- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dialog-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dialog-card.wide {
    max-width: 680px;
}

.dialog-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.dialog-head button {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1;
}

.dialog-head button:hover {
    color: var(--ink);
}

.dialog-body {
    padding: 20px 22px;
    overflow-y: auto;
}

.dialog-body label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-2);
    margin: 14px 0 6px;
}

.dialog-body label:first-child {
    margin-top: 0;
}

.dialog-body input[type="text"],
.dialog-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    color: var(--ink);
    background: var(--surface-2);
    transition: all 0.15s;
}

.dialog-body input:focus,
.dialog-body textarea:focus {
    border-color: var(--blue-400);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--blue-50);
}

.dialog-foot {
    padding: 16px 22px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
}

.board-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.board-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.board-list li:hover {
    border-color: var(--blue-300);
    background: var(--blue-50);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.board-list .board-info {
    flex: 1;
    min-width: 0;
}

.board-list .board-name {
    font-weight: 700;
    color: var(--ink);
    font-size: 14px;
}

.board-list .board-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.board-list .board-type {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--hl-wash);
    color: var(--hl-ink);
    white-space: nowrap;
}

.board-list .board-type.excalidraw {
    background: var(--blue-100);
    color: var(--blue-700);
}

.board-list .board-delete {
    background: none;
    border: none;
    color: var(--muted-2);
    cursor: pointer;
    font-size: 15px;
    padding: 6px;
}

.board-list .board-delete:hover {
    color: var(--danger);
}

.access-users-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.access-users-list .chip {
    background: var(--blue-50);
    color: var(--blue-700);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.access-users-list .chip button {
    background: none;
    border: none;
    color: var(--blue-700);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.empty-list {
    color: var(--muted);
    text-align: center;
    padding: 30px 10px;
    font-size: 14px;
}

/* ============================================================
   Added features: frames, text, connectors, export, templates, sync
   ============================================================ */

/* Frames / containers layer (behind content) + text layer (in front) */
#frames-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 1;
    pointer-events: none;
}

#texts-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 8;
    pointer-events: none;
}

/* Frame / titled section */
.wb-frame {
    position: absolute;
    border: 2px dashed var(--frame-color, var(--blue-500));
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--frame-color, #2e90fa) 5%, transparent);
    pointer-events: none;
    /* draw & select through the body; drag via title */
}

.wb-frame-title {
    position: absolute;
    top: -13px;
    left: 12px;
    background: var(--frame-color, var(--blue-500));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.01em;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: move;
    pointer-events: auto;
    max-width: calc(100% - 40px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: var(--shadow-sm);
}

.wb-frame-title[contenteditable="true"] {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    background: var(--surface);
    color: var(--ink);
    outline: 2px solid var(--frame-color, var(--blue-500));
}

.wb-frame-resize {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--frame-color, var(--blue-500));
    border: 2px solid #fff;
    cursor: nwse-resize;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.15s;
}

.wb-frame:hover .wb-frame-resize {
    opacity: 1;
}

/* Free text label */
.wb-text {
    position: absolute;
    pointer-events: auto;
    font-weight: 700;
    line-height: 1.25;
    color: var(--ink);
    padding: 2px 4px;
    border-radius: 6px;
    cursor: move;
    min-width: 20px;
    white-space: pre-wrap;
    max-width: 520px;
}

.wb-text:hover {
    background: rgba(46, 144, 250, 0.06);
}

.wb-text[contenteditable="true"] {
    cursor: text;
    background: var(--surface);
    outline: 2px solid var(--blue-400);
}

.wb-text.selected-item {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

/* Connector-tool source highlight */
.connect-source {
    outline: 3px dashed var(--hl-deep) !important;
    outline-offset: 3px;
}

/* Header ghost buttons + export dropdown */
.header-ghost {
    padding: 11px 16px;
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink-2);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid var(--line);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.header-ghost:hover {
    border-color: var(--blue-300);
    color: var(--blue-600);
}

.header-export-anchor {
    position: relative;
}

.export-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 300;
    min-width: 180px;
}

.export-menu.show {
    display: block;
}

.export-item {
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}

.export-item:hover {
    background: var(--blue-50);
    color: var(--blue-700);
}

/* Templates modal */
.templates-ai-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--hl-wash);
    border: 1px solid #f5e39a;
    border-radius: var(--r);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-weight: 700;
    color: var(--hl-ink);
    font-size: 13px;
    flex-wrap: wrap;
}

.templates-ai-row input[type="checkbox"] {
    accent-color: var(--hl-deep);
    width: 16px;
    height: 16px;
}

.templates-ai-row input[type="text"] {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1.5px solid #f0d878;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    background: var(--surface);
    outline: none;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.template-card {
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--surface-2);
    text-align: left;
}

.template-card:hover {
    border-color: var(--blue-300);
    background: var(--surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.template-card .tc-emoji {
    font-size: 24px;
    margin-bottom: 8px;
}

.template-card .tc-name {
    font-weight: 800;
    font-size: 14px;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.template-card .tc-desc {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
    line-height: 1.4;
}

.templates-status {
    margin-top: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue-700);
    min-height: 18px;
}

/* Collaboration sync toast + conflict banner */
.sync-toast {
    position: fixed;
    top: calc(var(--nav-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    z-index: 8000;
    box-shadow: var(--shadow-md);
}

.sync-conflict {
    position: fixed;
    top: calc(var(--nav-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid #fde68a;
    border-left: 4px solid var(--hl-deep);
    color: var(--ink-2);
    padding: 12px 18px;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 600;
    z-index: 8000;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 92vw;
}

.sync-conflict button {
    padding: 7px 14px;
    border-radius: var(--r-sm);
    border: none;
    background: var(--blue-500);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}

.sync-conflict button.ghost {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--line);
}

/* ============================================================
   Responsive
   ============================================================ */
/* A common "smaller laptop" width (e.g. a MacBook Air's actual window, not
   full 1440px) — no breakpoint existed here before, so nav-actions' 5 items
   (Save/My Boards/Blank Canvas/Plan/Account) would wrap to a second row with
   nothing to stop it. Shrink first; only the 768px breakpoint below actually
   stacks/hides things. Same gap existed for .whiteboard-header (title +
   prompt input + mic + Create/Templates/Export/Clear) on the EMPTY-board
   screen specifically — once a board has content, .header-input and
   #start-btn are hidden (see the has-content rule above) and there's much
   less to fit, so this only bites before the first board is created. */
@media (max-width: 1180px) {
    .nav-btn {
        padding: 7px 11px;
        font-size: 12px;
    }
    .current-board {
        max-width: 140px;
    }
    .nav-btn.account {
        max-width: 130px;
    }

    .whiteboard-header {
        gap: 10px;
        padding: 12px 18px;
        flex-wrap: wrap;
        /* Safe to allow wrapping now — .whiteboard-canvas is flex:1 inside a
           flex-column .whiteboard-wrap, so it just absorbs whatever height
           a 2nd header row needs instead of forcing a page-level scroll. */
    }
    .whiteboard-header h1 {
        font-size: 17px;
    }
    .whiteboard-header .header-input {
        flex-basis: 260px;
    }
    .whiteboard-header input {
        max-width: none;
    }
    #start-btn,
    .header-ghost,
    #clear-btn {
        padding: 9px 14px;
        font-size: 13px;
    }

    /* .drawing-toolbar's own min-width:700px is safe almost everywhere — the
       one exception is the dock OPEN (not railed) on a viewport this narrow,
       where canvas width can drop under 700px and a hard min-width forces
       the box past the canvas edge, which .whiteboard-canvas's overflow:
       hidden then clips (including the leftmost tool button — reproduced and
       confirmed at 1000px/dock-open). Drop back to the dock-aware max-width
       + wrap-fallback from the base rule in exactly that combination. */
    body.dock-open .drawing-toolbar {
        min-width: 0;
    }
}

/* Both sidebars open on a mid-size screen would squeeze the board to a sliver
   (at 1280px: 1280 - 360 dock - 400 right sidebar ≈ 520px). Fall back to the
   rail rather than adding a JS resize listener — there is currently zero
   resize handling in public/js/app/ and this keeps it that way. */
@media (max-width: 1100px) {
    body.dock-open.sidebar-open .whiteboard-wrap { margin-left: var(--dock-rail-w); }
}

@media (max-width: 900px) {
    .wb-sidebar {
        width: min(var(--sidebar-width, 400px), 100vw);
    }
    /* On small screens the sidebar covers the width — don't push the chat off-screen */

    /* Too narrow to give up horizontal space: the dock overlays instead of
       pushing, and collapses fully off-canvas rather than to a rail. */
    .whiteboard-wrap,
    body.dock-open .whiteboard-wrap { margin-left: 0; }
    .board-dock {
        width: min(var(--dock-w), 100vw);
        box-shadow: var(--shadow-lg);
        transition: width 0.28s ease, transform 0.28s ease;
    }
    body.dock-rail .board-dock { transform: translateX(-100%); }
    /* Slim edge-grabber replaces the rail — the only free slot on mobile
       (bottom-left is .zoom-controls/.wb-minimap, top-left is .drawing-toolbar). */
    .board-dock-edge { display: flex; }
}

@media (max-width: 768px) {
    .top-nav {
        gap: 10px;
        padding: 0 14px;
    }

    .nav-actions {
        gap: 8px;
    }

    .nav-user {
        display: none;
    }

    .current-board {
        max-width: 120px;
    }

    .nav-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* Header stacks: title row, then full-width input, then buttons */
    .whiteboard-header {
        flex-wrap: wrap;
        padding: 12px 14px;
        gap: 10px;
    }

    .whiteboard-header h1 {
        font-size: 17px;
        width: 100%;
    }

    .whiteboard-header .header-input {
        flex: 1 1 100%;
        order: 3;
    }

    .whiteboard-header input {
        max-width: none;
    }

    #start-btn,
    #clear-btn {
        flex: 1;
        order: 4;
        text-align: center;
    }

    /* .whiteboard-canvas no longer needs a height override here — it's
       flex:1 inside .whiteboard-wrap now, so it fills whatever's left
       regardless of how tall the (2-row, stacked) header renders. */

    /* Toolbar becomes a single horizontally-scrolling strip. display:contents
       un-wraps the two .toolbar-row groups (desktop-only) so their buttons
       become direct flex items of .drawing-toolbar again, exactly as before
       the two-row split. */
    .drawing-toolbar {
        display: flex;
        flex-direction: row;
        left: 8px;
        right: 8px;
        top: 10px;
        transform: none;
        max-width: none;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        border-radius: var(--r);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .toolbar-row {
        display: contents;
    }

    .drawing-toolbar::-webkit-scrollbar {
        display: none;
    }

    .tool-btn {
        flex: 0 0 auto;
    }

    .color-group span {
        display: none;
    }

    /* Keep floating controls out of each other's way */
    .zoom-controls {
        bottom: 14px;
        left: 14px;
    }

    .wb-timeline {
        left: auto;
        right: 14px;
        bottom: 14px;
        transform: none;
        gap: 6px;
        padding: 6px 10px;
    }

    .wb-timeline input[type="range"] {
        width: 90px;
    }

    .wb-timeline span {
        min-width: 34px;
        font-size: 11px;
    }

    .billing-plans { grid-template-columns: 1fr; }
    .billing-current { align-items: flex-start; flex-direction: column; }

    .wb-modal-card {
        padding: 20px;
    }

    .wb-modal-actions {
        justify-content: stretch;
    }

    .wb-modal-actions button {
        flex: 1;
    }

    .canvas-hint h2 {
        font-size: 19px;
    }

    .canvas-hint p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .top-nav {
        display: flex;
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 8px;
    }

    .nav-brand {
        font-size: 18px;
    }

    .nav-actions {
        margin-left: auto;
        width: 100%;
    }

    .current-board {
        display: none;
    }

    :root {
        --nav-h: 52px;
    }

    .auth-card {
        padding: 28px 22px;
    }

    .auth-brand {
        font-size: 28px;
    }

    .dialog-foot {
        flex-direction: column-reverse;
    }

    .dialog-foot button {
        width: 100%;
    }
}

/* ============================================================
   Smooth timeline replay — transitions for add / move / delete
   ============================================================ */
.wb-animate .node,
.wb-animate .wb-frame,
.wb-animate .sticky-note,
.wb-animate .canvas-image,
.wb-animate .wb-text,
.wb-animate .whiteboard-shape,
.wb-animate .canvas-table,
.wb-animate .canvas-code,
.wb-animate .canvas-iframe,
.wb-animate .wb-world3d,
.wb-animate .wb-group {
    transition: left .34s cubic-bezier(.22, .61, .36, 1), top .34s cubic-bezier(.22, .61, .36, 1),
        width .34s ease, height .34s ease, opacity .3s ease, transform .28s ease;
}

.wb-entering {
    opacity: 0 !important;
    transform: scale(0.9) !important;
}

.wb-exiting {
    opacity: 0 !important;
    transform: scale(0.85) !important;
    pointer-events: none !important;
}

/* ============================================================
   User picker + task assignee + chat states
   ============================================================ */
.user-search {
    position: relative;
}

.user-search input {
    width: 100%;
}

.user-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    z-index: 60;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}

.user-search-results .u-item {
    padding: 8px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-2);
}

.user-search-results .u-item:hover {
    background: var(--blue-50);
    color: var(--blue-700);
}

.user-search-results .u-item .u-email {
    color: var(--muted);
    font-size: 12px;
}

.user-search-results .u-empty {
    padding: 10px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.task-assignee {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--blue-50);
    color: var(--blue-700);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
}

.assign-pop {
    /* Fixed, not absolute: it's positioned from event.clientX/clientY, and now
       that TodoList renders inside the fixed .board-dock an absolute popover
       would resolve against the dock and jump. Matches .link-modal. */
    position: fixed;
    z-index: 9600;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    width: 260px;
}

.assign-pop h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--ink);
}

.chat-empty-hint {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 20px;
    line-height: 1.5;
}

/* ============================================================
   Element context menu, frame drag bar, animate modal, keyframes
   ============================================================ */
.wb-context-menu-sep {
    height: 1px;
    background: var(--line);
    margin: 4px 6px;
}

.menu-kbd {
    float: right;
    margin-left: 18px;
    font-size: 11px;
    color: var(--muted-2);
    background: var(--surface-3);
    border-radius: 4px;
    padding: 1px 6px;
}

/* Full-width invisible drag strip along a frame's top edge */
.wb-frame-bar {
    position: absolute;
    top: -14px;
    left: 0;
    right: 0;
    height: 30px;
    pointer-events: auto;
    cursor: move;
}

.wb-frame-title {
    z-index: 2;
}

/* Animate modal form */
.animate-grid label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-2);
    margin: 12px 0 6px;
}

.animate-grid label:first-child {
    margin-top: 0;
}

.animate-grid select,
.animate-grid input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface-2);
    outline: none;
}

.animate-grid select:focus,
.animate-grid input:focus {
    border-color: var(--blue-400);
    background: var(--surface);
}

.animate-rep-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.animate-rep-row input[type="number"] {
    flex: 1;
}

.animate-check {
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin: 0 !important;
    white-space: nowrap;
    cursor: pointer;
}

.animate-check input {
    accent-color: var(--hl-deep);
    width: 16px;
    height: 16px;
}

/* Persistent image animations (applied to the inner <img>) */
@keyframes wb-anim-wiggle {

    0%,
    100% {
        transform: rotate(-5deg);
    }

    50% {
        transform: rotate(5deg);
    }
}

@keyframes wb-anim-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes wb-anim-jump {

    0%,
    100% {
        transform: translateY(0);
    }

    35% {
        transform: translateY(-16px);
    }

    55% {
        transform: translateY(0);
    }

    70% {
        transform: translateY(-6px);
    }

    85% {
        transform: translateY(0);
    }
}

@keyframes wb-anim-hover {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes wb-anim-buzz {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-2px) rotate(-1deg);
    }

    40% {
        transform: translateX(2px) rotate(1deg);
    }

    60% {
        transform: translateX(-2px) rotate(-1deg);
    }

    80% {
        transform: translateX(2px) rotate(1deg);
    }
}
/* ============================================================
   Real-time collaboration: cursors, presence avatars, chat dock
   ============================================================ */
#cursors-container {
    position: absolute; top: 0; left: 0; width: 10000px; height: 10000px;
    z-index: 9000; pointer-events: none;
}
.remote-cursor {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.4s ease, left 0.08s linear, top 0.08s linear;
    will-change: left, top;
    transform: translate(-2px, -2px);
}
.remote-cursor .rc-arrow { color: var(--cur, #2e90fa); font-size: 16px; transform: rotate(-45deg); line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.remote-cursor .rc-label {
    background: var(--cur, #2e90fa);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

/* Presence avatars in the nav */
.presence-bar { display: flex; align-items: center; gap: -6px; }
.presence-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 11px; font-weight: 800;
    border: 2px solid var(--surface);
    margin-left: -8px;
    box-shadow: var(--shadow-xs);
}
.presence-avatar:first-child { margin-left: 0; }
.presence-dot-live {
    width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.2); margin-right: 4px;
}

/* Chat dock: conversation switcher + threads */
.chat-convos {
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    /* Was max-height:40%, sized for the old short floating widget — in the
       full-height dock that capped the list and left half the panel empty. */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.chat-convo {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; cursor: pointer; font-size: 13px;
    border-bottom: 1px solid var(--line-2);
}
.chat-convo:hover { background: var(--blue-50); }
.chat-convo.active { background: var(--blue-100); font-weight: 700; }
.chat-convo .cc-avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 800; flex: 0 0 auto; }
.chat-convo .cc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-convo .cc-unread { background: var(--blue-500); color: #fff; font-size: 10px; font-weight: 800; border-radius: 999px; padding: 1px 6px; }
.chat-people-add { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.chat-back {
    background: none; border: none; color: var(--blue-600); cursor: pointer;
    font-size: 12px; font-weight: 700; padding: 6px 12px; text-align: left;
}

/* ============================================================
   3D Worlds (Three.js viewports on the board — world3d.js)
   ============================================================ */

#worlds-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 2;
    pointer-events: none;
}

/* Like frames: the body is click-transparent so notes/symbols/drawings can
   be placed on top while unselected; only the header, resize handle and a
   live (selected) viewport receive the mouse. */
.wb-world3d {
    position: absolute;
    /* Rendered height = the saved base height + the reserved toolbar band, so
       the FRAME grows to fit the toolbar (the 3D viewport keeps its size). The
       transition makes that growth smooth; it's suppressed while resizing. */
    height: calc(var(--w3d-base-h, 380px) + var(--w3d-toolbar-h, 0px));
    transition: height .25s ease;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--blue-200, #bcd9fd);
    background: #eef5fc;
    pointer-events: none;
}

/* No height easing while the user is dragging the resize handle. */
.wb-world3d.w3d-resizing {
    transition: none;
}

.wb-world3d.selected-item {
    border-color: var(--blue-500);
}

.world3d-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    border-radius: calc(var(--r-lg) - 2px) calc(var(--r-lg) - 2px) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px 0 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78));
    border-bottom: 1px solid var(--line, #e2e8f0);
    cursor: move;
    pointer-events: auto;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.world3d-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--ink, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.world3d-title::before {
    content: '🧊 ';
}

.world3d-actions {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.world3d-actions button {
    border: 1px solid var(--line, #e2e8f0);
    background: var(--surface, #fff);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink, #1e293b);
    padding: 3px 8px;
    cursor: pointer;
}

.world3d-actions button:hover {
    background: var(--blue-50, #eff8ff);
    border-color: var(--blue-500);
}

.world3d-viewport {
    position: absolute;
    /* Starts below the header (32px) plus the reserved platform-toolbar band
       (--w3d-toolbar-h, 0 when hidden). Its top animates in lock-step with the
       frame's height (same .25s ease), so the viewport HEIGHT stays constant —
       the scene never shrinks; only the frame grows to make room. */
    top: calc(32px + var(--w3d-toolbar-h, 0px));
    left: 0;
    right: 0;
    bottom: 0;
    transition: top .25s ease;
    overflow: hidden;
    border-radius: 0 0 calc(var(--r-lg) - 2px) calc(var(--r-lg) - 2px);
    pointer-events: none; /* inert until the element is selected */
}

.wb-world3d.w3d-resizing .world3d-viewport {
    transition: none;
}

.world3d-viewport.world3d-live {
    pointer-events: auto;
    /* let pointer events drive the 3D scene on touch screens too */
    touch-action: none;
}

.world3d-viewport canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.world3d-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    font-size: 13px;
    padding: 16px;
    text-align: center;
}

/* Interaction hint, only while selected */
.world3d-hint {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.78);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    pointer-events: none;
    z-index: 2;
}

.wb-world3d.selected-item .world3d-hint {
    display: block;
}

.world3d-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: var(--blue-500);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: se-resize;
    pointer-events: auto;
    z-index: 3;
    transform: translate(35%, 35%);
}

/* Edit-mode chrome: the ✏️ Edit toggle + add-platform buttons */
.world3d-edit.active {
    background: var(--blue-500);
    color: #fff;
    border-color: var(--blue-500);
}

.wb-world3d.world3d-editing {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25), var(--shadow-sm);
}

/* The platform toolbar / add buttons only exist in edit mode: the JS toggles
   the `hidden` attribute, but display:flex below would otherwise override it. */
.world3d-platform-toolbar[hidden],
.world3d-add[hidden],
.wb-selection-actions[hidden],
.wb-fill-palette[hidden] {
    display: none !important;
}

/* Belt-and-suspenders: the editing chrome is bound to edit mode by class, so
   it can never linger visible once edit mode is off, regardless of `hidden`. */
.wb-world3d:not(.world3d-editing) .world3d-platform-toolbar,
.wb-world3d:not(.world3d-editing) .world3d-add {
    display: none !important;
}

/* Per-platform toolbar (mode, colour, shape, lock-ratio, delete).
   Everything is sized in `em` off a --w3d-scale-driven font-size, so the whole
   toolbar grows/shrinks with the 3D-world element. */
.world3d-platform-toolbar {
    position: absolute;
    left: 8px;
    right: 8px;
    /* Sits in the band just below the header; the viewport is inset to make
       room (see --w3d-toolbar-h), so it stays inside the frame above the scene. */
    top: 36px;
    display: flex;
    flex-direction: column;
    font-size: calc(11px * var(--w3d-scale, 1));
    gap: 0.55em;
    padding: 0.7em 0.9em;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    pointer-events: auto;
    z-index: 4;
    backdrop-filter: blur(4px);
}

.world3d-pt-row {
    display: flex;
    align-items: center;
    gap: 0.7em;
    flex-wrap: wrap;
}

.world3d-pt-swatches {
    gap: 0.45em;
}

.world3d-swatch {
    width: 1.8em;
    height: 1.8em;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line, #e2e8f0);
    background: var(--sw, #ccc);
    cursor: pointer;
    padding: 0;
}

.world3d-swatch.selected {
    box-shadow: 0 0 0 2px var(--blue-500);
    transform: scale(1.12);
}

.world3d-pt-modes,
.world3d-pt-shapes {
    display: inline-flex;
    gap: 0.35em;
}

.world3d-pt-mode,
.world3d-pt-shape,
.world3d-pt-del {
    border: 1px solid var(--line, #e2e8f0);
    background: var(--surface, #fff);
    border-radius: 8px;
    font-size: 1em;
    font-weight: 700;
    color: var(--ink, #1e293b);
    padding: 0.35em 0.75em;
    cursor: pointer;
    white-space: nowrap;
}

.world3d-pt-mode.selected,
.world3d-pt-shape.selected {
    background: var(--blue-500);
    color: #fff;
    border-color: var(--blue-500);
}

.world3d-pt-del {
    margin-left: auto;
    color: #dc2626;
    border-color: #fecaca;
}

.world3d-pt-lock {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    font-size: 1em;
    font-weight: 600;
    color: var(--ink, #1e293b);
    cursor: pointer;
}

.world3d-pt-hint {
    font-size: 0.92em;
    color: #64748b;
    font-weight: 500;
}

/* Inline face-title editor (double-click a platform face) */
.world3d-title-input {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 90px;
    max-width: 220px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.97);
    border: 2px solid var(--blue-500);
    border-radius: 6px;
    padding: 4px 8px;
    z-index: 6;
    box-shadow: var(--shadow-sm);
    pointer-events: auto;
}

/* ============================================================
   Persistent groups (locked multi-selections)
   ============================================================ */
#groups-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    /* Above every element container (texts=8, stickies=7, elements=6…) so a
       group box overlays its members and receives the click to move them. */
    z-index: 20;
    pointer-events: none;
}

.wb-group {
    position: absolute;
    border: 1.5px dashed var(--blue-500);
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.05);
    pointer-events: auto;
    cursor: move;
    box-sizing: border-box;
}

.wb-group.selected-item {
    background: rgba(37, 99, 235, 0.10);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.wb-group-actions {
    position: absolute;
    top: -30px;
    left: -1px;
    display: flex;
    gap: 4px;
}

.wb-group-ungroup {
    border: 1px solid var(--line, #e2e8f0);
    background: var(--surface, #fff);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink, #1e293b);
    padding: 3px 9px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}

.wb-group-ungroup:hover {
    background: var(--blue-50, #eff8ff);
    border-color: var(--blue-500);
}

.wb-group-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--blue-500);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: se-resize;
    transform: translate(40%, 40%);
}

/* ============================================================
   Selection action bar (Group / Ungroup)
   ============================================================ */
.wb-selection-actions {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.12));
    z-index: 40;
    backdrop-filter: blur(6px);
}

.wb-selection-actions button {
    border: 1px solid var(--line, #e2e8f0);
    background: var(--surface, #fff);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink, #1e293b);
    padding: 6px 12px;
    cursor: pointer;
}

.wb-selection-actions button:hover {
    background: var(--blue-50, #eff8ff);
    border-color: var(--blue-500);
}

/* ============================================================
   Symbol vector fill (Fill tool)
   ============================================================ */
/* One wrapper holds the ink + the fill overlay so an animation applied here
   moves both together (and keeps its own transform-origin centred). */
.canvas-image .symbol-visual {
    position: absolute;
    inset: 0;
    transform-origin: center;
}

.canvas-image svg.symbol-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    z-index: 1; /* ink sits ABOVE the flood-fill overlay so lines stay crisp */
}

/* Paint-bucket space fills are composited here, behind the ink strokes. */
.canvas-image .symbol-fill-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* While a canvas-drawing tool is active (pen, shapes, sticky, frame, text…)
   board elements must stop swallowing pointer events, or you can't start a
   stroke/shape on top of an existing symbol, sticky, node or image — the
   element grabs the mousedown and drags itself instead. Their inner chrome
   (resize handles, delete buttons) is suppressed for the same reason. */
.wb-draw-mode .canvas-image,
.wb-draw-mode .sticky-note,
.wb-draw-mode .node,
.wb-draw-mode .whiteboard-shape,
.wb-draw-mode .wb-text,
.wb-draw-mode .canvas-table,
.wb-draw-mode .canvas-code,
.wb-draw-mode .canvas-iframe {
    pointer-events: none !important;
}

.wb-draw-mode .image-resize-handle,
.wb-draw-mode .image-delete-btn,
.wb-draw-mode .shape-resize-handle {
    display: none !important;
}

/* In Fill mode the vector regions become individually clickable/hoverable */
.symbol-fill-mode .canvas-image svg.symbol-svg {
    pointer-events: auto;
}

/* …but the symbol's own container must NOT behave like a draggable object in
   Fill mode: the move cursor plus hover-revealed resize/delete handles made
   it look like you were about to drag or delete the symbol rather than
   recolour a region, and the container's mousedown started a drag before the
   fill click could land. */
.symbol-fill-mode .canvas-image {
    cursor: crosshair;
}

.symbol-fill-mode .canvas-image .image-resize-handle,
.symbol-fill-mode .canvas-image .image-delete-btn {
    display: none !important;
}

.wb-fill-palette {
    position: absolute;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.12));
    z-index: 40;
    backdrop-filter: blur(6px);
}

.wb-fill-label {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    margin-right: 2px;
}

.wb-fill-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line, #e2e8f0);
    background: var(--sw, #ccc);
    cursor: pointer;
    padding: 0;
}

.wb-fill-swatch.selected {
    box-shadow: 0 0 0 2px var(--blue-500);
    transform: scale(1.12);
}

.wb-fill-eyedropper {
    border: 1px solid var(--line, #e2e8f0);
    background: var(--surface, #fff);
    border-radius: 8px;
    font-size: 13px;
    padding: 2px 7px;
    cursor: pointer;
}

.wb-fill-custom {
    width: 26px;
    height: 24px;
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 6px;
    background: none;
    cursor: pointer;
    padding: 0;
}

/* ============================================================
   Chat groups · threaded replies · reactions (Discord + Reddit)
   ============================================================ */

.chat-header-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Section labels in the conversation list */
.chat-section-label {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px 4px; font-size: 11px; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-2);
}
.chat-newgroup-btn {
    background: var(--blue-50); color: var(--blue-600); border: 1px solid var(--blue-200);
    border-radius: 999px; font-size: 11px; font-weight: 800; padding: 2px 9px; cursor: pointer;
}
.chat-newgroup-btn:hover { background: var(--blue-100); }
.chat-hint-line { padding: 4px 14px 8px; font-size: 12px; color: var(--muted-2); }

/* Members panel (slides over the thread) */
.chat-members-panel {
    background: var(--surface-2); border-bottom: 1px solid var(--line);
    padding: 10px 14px; max-height: 45%; overflow-y: auto;
}
.chat-members-title { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 8px; }
.chat-member-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.chat-member-row .cc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex: 0 0 auto; box-shadow: 0 0 0 2px rgba(34,197,94,0.2); }
.chat-members-add { margin: 8px 0; }
.chat-leave-btn {
    width: 100%; background: none; border: 1px solid var(--line); color: #ef4444;
    border-radius: 8px; padding: 6px; font-size: 12px; font-weight: 700; cursor: pointer; margin-top: 4px;
}
.chat-leave-btn:hover { background: #fef2f2; border-color: #fecaca; }

.cc-avatar.sm { width: 24px; height: 24px; font-size: 10px; }

/* Threaded group messages */
.chat-messages.threaded { padding: 10px 12px; }
.thread-block { margin-bottom: 12px; }
.gmsg { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 4px; }
.gmsg.reply { margin-left: 26px; margin-top: 6px; position: relative; }
.gmsg.reply::before {
    content: ''; position: absolute; left: -14px; top: -2px; bottom: 10px;
    width: 2px; background: var(--line); border-radius: 2px;
}
.gmsg-body {
    flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 7px 11px;
}
.gmsg.mine .gmsg-body { background: var(--blue-50); border-color: var(--blue-200); }
.gmsg-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 2px; }
.gmsg-name { font-weight: 800; font-size: 12px; color: var(--ink); }
.gmsg-head .stamp { font-size: 10px; color: var(--muted-2); }
.gmsg-head .reply-to { font-size: 10px; color: var(--blue-500); font-weight: 700; }
.gmsg-text { font-size: 13px; color: var(--ink); word-wrap: break-word; white-space: pre-wrap; }

/* Reaction row + hover actions */
.gmsg-reactions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 5px; position: relative; }
.reaction-chip {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
    font-size: 11px; padding: 1px 7px; cursor: pointer; line-height: 1.6;
}
.reaction-chip.mine { background: var(--blue-100); border-color: var(--blue-400); font-weight: 700; }
.reaction-chip:hover { border-color: var(--blue-400); }
.gmsg-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity 0.12s; margin-left: auto; }
.gmsg:hover .gmsg-actions { opacity: 1; }
.micro-btn {
    background: none; border: none; cursor: pointer; font-size: 12px; padding: 1px 4px;
    border-radius: 6px; color: var(--muted);
}
.micro-btn:hover { background: var(--surface-2); }
.reaction-menu {
    position: absolute; bottom: 100%; left: 0; margin-bottom: 4px; z-index: 20;
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
    box-shadow: var(--shadow-md); padding: 4px 6px; display: flex; gap: 2px;
}
.reaction-menu button { background: none; border: none; cursor: pointer; font-size: 16px; padding: 2px 4px; border-radius: 8px; }
.reaction-menu button:hover { background: var(--surface-2); transform: scale(1.2); }

/* Reply banner above the input */
.chat-reply-banner {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    background: var(--blue-50); border-top: 1px solid var(--blue-200);
    font-size: 12px; color: var(--muted);
}
.chat-reply-banner strong { color: var(--blue-600); }
.chat-reply-banner button { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--muted-2); font-size: 13px; }

/* Create-group modal (in-dock) */
.chat-create-modal {
    position: absolute; inset: 40px 12px auto 12px; z-index: 30;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow-lg); padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.chat-create-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 14px; color: var(--ink); }
.chat-create-head button { background: none; border: none; cursor: pointer; font-size: 15px; color: var(--muted); }
.chat-create-name {
    border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 12px;
    font-size: 13px; background: var(--surface-2); color: var(--ink); outline: none;
}
.chat-create-name:focus { border-color: var(--blue-400); background: var(--surface); }
.chat-create-members { display: flex; flex-wrap: wrap; gap: 5px; }
.chat-create-members:empty { display: none; }
.chat-member-chip {
    display: inline-flex; align-items: center; gap: 4px; background: var(--blue-50);
    border: 1px solid var(--blue-200); border-radius: 999px; font-size: 12px; padding: 2px 4px 2px 9px; color: var(--blue-600);
}
.chat-member-chip button { background: none; border: none; cursor: pointer; color: var(--blue-600); font-size: 11px; }
.chat-create-submit {
    background: var(--blue-500); color: #fff; border: none; border-radius: 8px;
    padding: 9px; font-size: 13px; font-weight: 800; cursor: pointer;
}
.chat-create-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-create-submit:not(:disabled):hover { background: var(--blue-600); }

/* ============================================================
   Facilitation & intelligence layer
   (beautify · minimap · spotlight · voting · comments ·
    clustering · presentation · voice · critique · board search)
   ============================================================ */

/* Smooth view transitions (summon / presentation) */
.whiteboard-canvas.view-anim #frames-container,
.whiteboard-canvas.view-anim #worlds-container,
.whiteboard-canvas.view-anim #connections-svg,
.whiteboard-canvas.view-anim #drawing-svg,
.whiteboard-canvas.view-anim #shapes-container,
.whiteboard-canvas.view-anim #nodes-container,
.whiteboard-canvas.view-anim #elements-container,
.whiteboard-canvas.view-anim #images-container,
.whiteboard-canvas.view-anim #stickies-container,
.whiteboard-canvas.view-anim #texts-container,
.whiteboard-canvas.view-anim #cursors-container {
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Applied by WhiteboardEngine.focusElement() after flying to an element that
   a chat message referenced, so the user can see which one was meant. */
.wb-ref-flash {
    outline: 3px solid var(--blue-400);
    outline-offset: 3px;
    animation: wb-ref-pulse 1.6s ease-out;
}
@keyframes wb-ref-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 144, 250, 0.55); }
    70%  { box-shadow: 0 0 0 18px rgba(46, 144, 250, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 144, 250, 0); }
}

/* Inline board-element reference inside a chat message. */
.el-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    margin: 0 1px;
    border-radius: 999px;
    border: 1px solid var(--blue-200);
    background: var(--blue-50);
    color: var(--blue-700);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    vertical-align: baseline;
}
.el-ref-chip:hover { background: var(--blue-100, #dbeafe); }

/* Referenced in the chat header but never styled — it was inheriting raw UA
   button chrome next to the styled .chat-back / .chat-header-title. */
.chat-toggle {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
}
.chat-toggle:hover { background: var(--blue-50); color: var(--blue-700); }

/* Wrapper around a message body so long refs/words can't force the pane wide. */
.gmsg-text-wrap { min-width: 0; overflow-wrap: anywhere; }

/* Composer popover for picking a board element to reference. */
.ref-btn {
    flex-shrink: 0;
    width: 34px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}
.ref-btn:hover { background: var(--blue-50); }

.ref-picker {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(100% + 6px);
    max-height: 300px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    z-index: 30;
    overflow: hidden;
}
.ref-picker-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.ref-picker-head input {
    flex: 1; min-width: 0; padding: 6px 9px; font: inherit; font-size: 13px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
}
.ref-picker-head button { border: none; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; }
.ref-picker-list { overflow-y: auto; padding: 6px; }
.ref-picker-label {
    font-size: 10px; font-weight: 800; text-transform: uppercase;
    letter-spacing: .07em; color: var(--muted-2); padding: 7px 6px 4px;
}
.ref-picker-item {
    display: block; width: 100%; text-align: left;
    padding: 7px 9px; border: none; border-radius: var(--r-sm);
    background: none; font: inherit; font-size: 13px; color: var(--ink);
    cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ref-picker-item:hover { background: var(--blue-50); color: var(--blue-700); }
.ref-picker-empty { padding: 12px 8px; font-size: 12px; color: var(--muted-2); }

/* The composer is the popover's positioning context. */
.chat-input-area { position: relative; }

/* Facilitation bar */
.facilitate-bar {
    position: absolute;
    top: 150px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    padding: 8px 5px;
    z-index: 900;
}
body.sidebar-open .facilitate-bar { right: calc(var(--sidebar-width, 400px) + 16px); }
.fac-btn {
    width: 34px; height: 34px;
    border: none; border-radius: 50%;
    background: none; cursor: pointer; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
}
.fac-btn:hover { background: var(--blue-50); }
.fac-btn.active { background: var(--blue-100); box-shadow: inset 0 0 0 2px var(--blue-400); }
.fac-btn.busy { pointer-events: none; opacity: 0.7; }

/* Mini-map */
.wb-minimap {
    position: absolute;
    bottom: 66px;
    left: 16px;
    width: 200px; height: 140px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    z-index: 900;
    cursor: crosshair;
}
.wb-minimap canvas { display: block; }
.wb-minimap-viewport {
    position: absolute;
    border: 2px solid var(--blue-500);
    border-radius: 3px;
    background: rgba(46, 144, 250, 0.08);
    pointer-events: none;
}

/* Spotlight cursor */
.remote-cursor.spotlight .rc-arrow { display: none; }
.remote-cursor.spotlight::before {
    content: '';
    display: block;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--cur) 0%, transparent 68%);
    box-shadow: 0 0 22px 8px color-mix(in srgb, var(--cur) 45%, transparent);
    animation: spotlight-pulse 1.2s ease-in-out infinite;
}
@keyframes spotlight-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* Dot-voting */
.vote-panel {
    position: absolute;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--blue-200);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    z-index: 950;
}
.vote-dots-left { color: var(--blue-500); letter-spacing: 2px; }
body.vote-mode .whiteboard-canvas { cursor: cell !important; }
.vote-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--blue-500);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: var(--shadow-sm);
    z-index: 60;
    pointer-events: none;
}
.vote-badge.mine { background: #eab308; }
.vote-badge.final { background: #16a34a; }

/* Comment pins + popover */
.comment-pin {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 22px; height: 22px;
    border-radius: 999px 999px 999px 4px;
    background: #f97316;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    z-index: 60;
    pointer-events: auto;
}
.comment-pin.resolved { background: #16a34a; }
.comment-popover {
    position: fixed;
    width: 290px;
    max-height: 340px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 8000;
}
.comment-pop-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 12px; font-size: 13px; font-weight: 800; color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.comment-pop-head button {
    background: none; border: 1px solid var(--line); border-radius: 7px;
    font-size: 11px; font-weight: 700; padding: 3px 8px; cursor: pointer; color: var(--muted);
}
.comment-pop-head button:hover { background: var(--blue-50); }
.comment-thread { flex: 1; overflow-y: auto; padding: 10px 12px; min-height: 60px; }
.comment-empty { color: var(--muted-2); font-size: 12px; }
.comment-item { margin-bottom: 9px; }
.comment-item.reply { margin-left: 14px; padding-left: 9px; border-left: 2px solid var(--line); }
.comment-author { font-size: 12px; font-weight: 800; color: var(--ink); }
.comment-when { font-size: 10px; color: var(--muted-2); }
.comment-body { font-size: 12.5px; color: var(--ink); margin-top: 1px; white-space: pre-wrap; word-wrap: break-word; }
.comment-input-row { display: flex; gap: 6px; padding: 9px 10px; border-top: 1px solid var(--line); }
.comment-input-row input {
    flex: 1; border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 12px;
    font-size: 12.5px; background: var(--surface-2); outline: none; color: var(--ink);
}
.comment-input-row input:focus { border-color: var(--blue-400); background: var(--surface); }
.comment-input-row button {
    background: var(--blue-500); border: none; color: #fff; border-radius: 50%;
    width: 32px; height: 32px; cursor: pointer; font-size: 12px;
}

/* Presentation mode */
body.presenting .top-nav,
body.presenting .whiteboard-header,
body.presenting .drawing-toolbar,
body.presenting .zoom-controls,
body.presenting .facilitate-bar,
body.presenting .wb-timeline,
body.presenting .board-dock,
body.presenting .board-dock-edge,
body.presenting .wb-minimap,
body.presenting .canvas-hint { display: none !important; }

/* Dock is hidden while presenting, so reclaim the space it was pushing. */
body.presenting .whiteboard-wrap { margin-left: 0 !important; }
.present-hud {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 700;
    z-index: 9500;
    backdrop-filter: blur(6px);
}
.present-hud button {
    background: none; border: none; color: #fff; font-size: 17px; cursor: pointer;
    width: 30px; height: 30px; border-radius: 50%;
}
.present-hud button:hover { background: rgba(255, 255, 255, 0.15); }

/* Voice input */
#voice-btn {
    border: 1.5px solid var(--line);
    background: var(--surface);
    border-radius: 50%;
    width: 38px; height: 38px;
    cursor: pointer;
    font-size: 15px;
    flex: 0 0 auto;
}
#voice-btn:hover { border-color: var(--blue-400); }
#voice-btn.listening {
    background: #fee2e2;
    border-color: #ef4444;
    animation: voice-pulse 1.1s ease-in-out infinite;
}
@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); }
    50% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
}

/* Board search (My Boards dialog) */
.board-search-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.board-search-input {
    flex: 1;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 13px;
    background: var(--surface-2);
    color: var(--ink);
    outline: none;
}
.board-search-input:focus { border-color: var(--blue-400); background: var(--surface); }
.board-search-hint { font-size: 12px; color: var(--muted-2); }
.board-snippet {
    font-size: 11.5px;
    color: var(--muted);
    background: var(--blue-50);
    border-radius: 6px;
    padding: 3px 8px;
    margin-top: 4px;
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Node context panel: thinking style, files, links ---------- */
/* Lives between the node's chat history and its composer. Collapsed by
   default so the panel stays a chat panel until you go looking for what the
   node knows. */
.wb-node-brain {
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    flex: 0 0 auto;
    max-height: 46vh;
    overflow-y: auto;
}

.wb-brain-head { padding: 0; }

.wb-brain-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.wb-brain-toggle:hover { color: var(--ink-2); }
.wb-brain-caret { font-size: 10px; }

.wb-brain-badges {
    margin-left: auto;
    display: flex;
    gap: 5px;
    text-transform: none;
    letter-spacing: 0;
}

.wb-badge {
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-2);
}

.wb-brain-body { padding: 4px 18px 16px; }

.wb-brain-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 6px;
}

.wb-brain-row label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-2);
    white-space: nowrap;
}

.wb-brain-row select {
    flex: 1;
    padding: 7px 10px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    outline: none;
}

.wb-brain-row select:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px var(--blue-50);
}

.wb-doc-add,
.wb-brain-action {
    margin-left: auto;
    padding: 6px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.wb-doc-add:hover,
.wb-brain-action:hover:not(:disabled) {
    border-color: var(--blue-400);
    color: var(--blue-600);
}

.wb-brain-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.wb-brain-empty {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    padding: 4px 0 2px;
}

/* --- attached files --- */
.wb-doc-list { display: flex; flex-direction: column; gap: 6px; }

.wb-doc-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 7px 10px;
}

.wb-doc-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wb-doc-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wb-doc-status {
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

.wb-doc-status.ready { background: var(--blue-50); color: var(--blue-700); }
.wb-doc-status.pending { background: var(--hl-wash); color: var(--hl-ink); }
.wb-doc-status.failed { background: var(--danger-soft); color: var(--danger); }

.wb-doc-del {
    border: none;
    background: none;
    color: var(--muted-2);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.wb-doc-del:hover { color: var(--danger); }

.wb-doc-note {
    font-size: 11px;
    line-height: 1.45;
    color: var(--muted);
    margin-top: 4px;
}

.wb-doc-note.failed { color: var(--danger); }

/* --- linked nodes --- */
.wb-link-list { display: flex; flex-direction: column; gap: 4px; }

.wb-link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ink-2);
    padding: 4px 0;
}

.wb-link-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.wb-link-arrow { color: var(--muted-2); font-weight: 700; }

.wb-link-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wb-link-kind {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
}

/* --- what an answer drew on --- */
.wb-chat-context {
    font-size: 11px;
    line-height: 1.45;
    color: var(--muted);
    padding: 2px 4px 8px 6px;
    border-left: 2px solid var(--line);
    margin: -2px 0 6px 6px;
}

/* ---------- Link type picker ---------- */
.wb-link-pair {
    font-size: 13px;
    color: var(--ink-2);
}

.wb-link-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 14px 0;
}

.wb-link-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.wb-link-option:hover { border-color: var(--blue-300); background: var(--surface-2); }

.wb-link-option.selected {
    border-color: var(--blue-500);
    background: var(--blue-50);
}

.wb-link-option input { margin: 0; }

.wb-link-option-body { display: flex; flex-direction: column; gap: 1px; }

.wb-link-option-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
}

.wb-link-option-desc {
    font-size: 11.5px;
    color: var(--muted);
}

#link-type-label {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 13px;
    outline: none;
}

#link-type-label:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px var(--blue-50);
}

/* ---------- Node conversation modal ---------- */
.wb-converse-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin: 14px 0 12px;
}

.wb-converse-grid label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-2);
    margin-bottom: 5px;
}

.wb-converse-grid select,
.wb-converse-grid input[type="range"] {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    outline: none;
}

.wb-converse-grid input[type="range"] {
    padding: 0;
    border: none;
    accent-color: var(--blue-500);
}

.wb-converse-hint {
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--muted);
    margin-top: 8px;
}

.wb-converse-status {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--blue-700);
    min-height: 18px;
    margin-top: 8px;
}

@media (max-width: 620px) {
    .wb-converse-grid { grid-template-columns: 1fr; }
}

/* A node's thinking style, shown on the card itself */
.type-badge.persona {
    background: var(--surface-3);
    color: var(--ink-2);
    border: 1px solid var(--line);
}

/* ---------- Editing a node in place ---------- */
.node-title.editing {
    outline: none;
    background: var(--blue-50);
    border-radius: var(--r-xs);
    box-shadow: 0 0 0 2px var(--blue-200);
    padding: 1px 5px;
    margin: -1px -5px;
    cursor: text;
}

.node-content-placeholder {
    color: var(--muted-2);
    font-style: italic;
    font-size: 13px;
}

.node-content-editor {
    width: 100%;
    min-height: 96px;
    resize: vertical;
    border: 1.5px solid var(--blue-300);
    border-radius: var(--r-sm);
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--surface);
    outline: none;
}

.node-content-editor:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-50);
}

/* Dark-themed node cards need the editor to follow, or it blinds the card. */
.node.node-dark .node-content-editor {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.35);
}

.node.node-dark .node-title.editing {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* ---------- Connector guidance banner ---------- */
/* Only visible while the connect tool is armed. Sits above the board, clear of
   the toolbar, and never blocks a click on a card. */
.wb-connect-hint {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    border-radius: 999px;
    background: var(--ink);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    max-width: min(560px, calc(100vw - 40px));
}

.wb-connect-hint[hidden] { display: none; }

.wb-connect-hint strong { color: var(--blue-300); }

.wb-connect-hint button {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: #ffffff;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.wb-connect-hint button:hover { background: rgba(255, 255, 255, 0.15); }

/* Two actions share the row now, so let them share the space evenly. */
.wb-brain-row #node-link-btn { margin-left: auto; }
.wb-brain-row #node-converse-btn { margin-left: 0; }

/* Starting a node-to-node conversation, on the card itself. Generative and
   billed, so it wears the highlighter like Expand does — a deeper tone so the
   two AI actions stay distinguishable side by side. */
.node-btn.talk {
    background: var(--hl-deep);
    color: #ffffff;
}

.node-btn.talk:hover {
    background: #ca9a04;
}

/* ---------- Node-to-node turns in a node's chat ---------- */
/* Read from THIS node's seat: its own turns sit left in the AI style, every
   other participant's sit right in their own colour, so a debate reads like a
   conversation and mirrors correctly when you open the other node. */
.wb-bubble.peer {
    background: var(--hl-wash);
    color: var(--ink);
    border: 1px solid var(--hl-deep);
    border-bottom-right-radius: 4px;
}

.wb-bubble.peer .wb-bubble-who { color: var(--hl-ink); opacity: 1; }

.wb-bubble.peer .markdown-content { font-size: 13px; }

/* ---------- The part of the board a node belongs to ---------- */
/* Its cluster summary is already in the node's prompt; showing it here is what
   makes that visible rather than mysterious. */
.wb-cluster {
    margin: 10px 0 4px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--blue-400);
}

.wb-cluster[hidden] { display: none; }

.wb-cluster-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.wb-cluster-label {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--ink);
}

.wb-cluster-size {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-left: auto;
    white-space: nowrap;
}

.wb-cluster-summary {
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink-2);
    max-height: 140px;
    overflow-y: auto;
}

.wb-cluster-summary p { margin: 0 0 6px; }
.wb-cluster-summary p:last-child { margin-bottom: 0; }

/* ---------- Pan/zoom compositing ---------- */
/* Applied only while the board is actually moving (see markTransforming), so
   twelve promoted layers don't sit in memory for the whole session. */
.whiteboard-canvas.wb-transforming #nodes-container,
.whiteboard-canvas.wb-transforming #connections-svg,
.whiteboard-canvas.wb-transforming #drawing-svg,
.whiteboard-canvas.wb-transforming #shapes-container,
.whiteboard-canvas.wb-transforming #elements-container,
.whiteboard-canvas.wb-transforming #images-container,
.whiteboard-canvas.wb-transforming #stickies-container,
.whiteboard-canvas.wb-transforming #frames-container,
.whiteboard-canvas.wb-transforming #texts-container,
.whiteboard-canvas.wb-transforming #cursors-container,
.whiteboard-canvas.wb-transforming #worlds-container,
.whiteboard-canvas.wb-transforming #groups-container {
    will-change: transform;
}

/* A gesture must never fight a CSS transition: view-anim owns the transition
   for scripted fly-to moves, so suppress it while the user is driving. */
.whiteboard-canvas.wb-transforming #nodes-container,
.whiteboard-canvas.wb-transforming #connections-svg,
.whiteboard-canvas.wb-transforming #frames-container,
.whiteboard-canvas.wb-transforming #worlds-container {
    transition: none;
}

/* ---------- Toolbar: single row, collapsible ---------- */
.drawing-toolbar {
    /* Now a row: the collapse control sits beside the tools rather than above
       them, so collapsing leaves a small handle instead of a tall stub.
       max-width is deliberately NOT set here — the dock-aware pair of rules
       above already gets it right, and repeating it would subtract the dock's
       width even while the dock is closed. */
    flex-direction: row;
    align-items: center;
}

.toolbar-collapse {
    flex: 0 0 auto;
    width: 22px;
    height: 30px;
    margin-right: 2px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--r-xs);
}

.toolbar-collapse:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.drawing-toolbar.collapsed .toolbar-row { display: none; }

.drawing-toolbar.collapsed {
    padding: 6px 8px;
    /* The expanded bar carries a 700px min-width so the tools never squash.
       Collapsed there is nothing to fit, and keeping it would leave a
       700px-wide empty bar floating over the board. */
    min-width: 0;
}

/* ---------- Nav: board menu + subscription in the account menu ---------- */
.nav-btn.board-menu-btn {
    font-weight: 700;
}

.export-menu-sep {
    height: 1px;
    margin: 4px 0;
    background: var(--line);
}

.export-item.danger { color: var(--danger); }
.export-item.danger:hover { background: var(--danger-soft); }

.plan-chip {
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--hl-wash);
    color: var(--hl-ink);
    font-size: 11px;
    font-weight: 800;
    text-transform: capitalize;
}

.account-menu .export-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Board title in the nav ---------- */
.nav-board-title {
    margin: 0 0 0 8px;
    font-size: 15px;
    font-weight: 800;
    color: var(--ink);
    /* A real board name can be long, and it must never push the nav actions
       off the bar — it truncates, they don't. */
    min-width: 0;
    max-width: 28vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1180px) {
    .nav-board-title { max-width: 20vw; font-size: 13px; }
}

/* ---------- Export as a section inside the Board menu ---------- */
.export-item.submenu-toggle {
    justify-content: flex-start;
    gap: 8px;
}

.submenu-caret {
    margin-left: auto;
    font-size: 10px;
    color: var(--muted);
    transition: transform 0.15s;
}

.export-item.submenu-toggle.open .submenu-caret {
    transform: rotate(90deg);
}

/* Indented and tinted so the three formats read as belonging to Export rather
   than as three more top-level board actions. */
.export-submenu {
    background: var(--surface-2);
    border-radius: var(--r-xs);
    margin: 2px 0;
}

.export-submenu .export-item {
    padding-left: 26px;
    font-size: 12.5px;
}

/* ---------- Whiteboard header retires once there is a board ---------- */
/* The title moved to the nav, so this header holds nothing but the prompt
   input and Create button — and .has-content already hides both of those.
   What was left was an empty bar taking a strip of canvas, so hide the bar
   itself on exactly the same condition. An empty board still shows it, which
   is the only state where the prompt is any use. */
.whiteboard-wrap.has-content .whiteboard-header {
    display: none;
}

/* ---------- "Ground in this board" option ---------- */
.wb-converse-ground {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    cursor: pointer;
}

.wb-converse-ground input {
    width: auto;
    margin-top: 2px;
    flex: 0 0 auto;
    accent-color: var(--blue-500);
}

.wb-converse-ground span {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}

.wb-converse-ground strong {
    display: block;
    font-size: 12.5px;
    color: var(--ink);
    margin-bottom: 2px;
}

/* Why a node is in its cluster, and whether that cluster feeds its prompt */
.wb-cluster-why {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
}

.wb-cluster-use {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}

.wb-cluster-use input {
    width: auto;
    margin: 0;
    accent-color: var(--blue-500);
}

/* Present but not feeding the AI — shown, dimmed, and clearly switchable. */
.wb-cluster.inactive {
    border-left-color: var(--line);
    background: var(--surface-2);
}

.wb-cluster.inactive .wb-cluster-summary,
.wb-cluster.inactive .wb-cluster-label {
    opacity: 0.55;
}
