/* ============================================================
   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;
}

* {
    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;
}

/* 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,
.todo-toggle-tab,
.chat-widget-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 {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    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 {
    grid-column: 2;
    justify-self: center;
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

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

.nav-actions {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

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

.current-board {
    color: var(--blue-600);
    font-size: 12px;
    font-weight: 600;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.current-board em {
    color: var(--muted-2);
    font-style: normal;
    font-weight: 500;
    margin-left: 6px;
}

.nav-btn {
    padding: 9px 15px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-btn.save {
    background: var(--blue-500);
    box-shadow: var(--shadow-blue);
}

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

.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);
    min-height: calc(100vh - var(--nav-h));
}

.whiteboard-header {
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
}

/* 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 {
    flex: 1;
}

.whiteboard-header input {
    width: 100%;
    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;
    height: calc(100vh - var(--nav-h) - 63px);
    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 {
    z-index: 2;
}

#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 */
body.sidebar-open .chat-widget { right: calc(var(--sidebar-width, 400px) + 20px) !important; }

/* 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 {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    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;
    align-items: center;
    flex-wrap: wrap;
    max-width: 92%;
}

.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);
}

/* ---------- Todo list drawer ---------- */
.todo-drawer {
    position: fixed;
    left: 0;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    width: 380px;
    max-width: 90vw;
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 6500;
    transform: translateX(-100%);
    transition: transform 0.35s ease;
}

.todo-drawer.open {
    transform: translateX(0);
}

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

.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;
}

.todo-toggle-tab {
    position: fixed;
    left: 0;
    top: 68%;
    width: 38px;
    height: 118px;
    color: white;
    background: var(--blue-500);
    border-radius: 0 var(--r) var(--r) 0;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 6400;
    writing-mode: vertical-rl;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: all 0.15s;
}

.todo-toggle-tab:hover {
    background: var(--blue-600);
    width: 42px;
}

.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-widget {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 7000;
    transition: height 0.22s ease, top 0.22s ease;
}

.chat-widget:has(.chat-widget-header:active) {
    transition: none;
}

.chat-widget-header {
    background: var(--blue-500);
    color: white;
    padding: 11px 15px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
}

.chat-widget-header:active {
    cursor: grabbing;
}

.chat-widget-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0 5px;
    font-size: 14px;
}

.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; }
.paypal-button-slot { margin-top: 18px; 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
   ============================================================ */
@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 */
    body.sidebar-open .chat-widget { right: 20px !important; }
}

@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 {
        height: calc(100vh - var(--nav-h) - 118px);
    }

    /* Toolbar becomes a single horizontally-scrolling strip */
    .drawing-toolbar {
        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;
    }

    .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;
    }

    .chat-widget {
        width: min(320px, calc(100vw - 24px)) !important;
    }

    .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 {
        grid-column: auto;
        justify-self: auto;
        font-size: 18px;
    }

    .nav-actions {
        grid-column: auto;
        justify-self: auto;
        margin-left: auto;
        width: 100%;
    }

    .current-board {
        display: none;
    }

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

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

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

    .todo-toggle-tab {
        height: 96px;
        font-size: 12px;
    }

    .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 {
    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 {
    position: absolute;
    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);
    max-height: 40%;
    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;
}
