/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #1A1A1E;
    --bg-secondary: #222228;
    --bg-tertiary: #2A2A30;
    --bg-hover: #2C2C33;
    --bg-card: #1E1E24;
    --border: #2E2E36;
    --border-light: #38383F;
    --text-primary: #EAEAED;
    --text-secondary: #A0A0A8;
    --text-muted: #6E6E76;
    --accent: #C4785A;
    --accent-hover: #D4885F;
    --accent-dim: rgba(196, 120, 90, 0.12);
    --green: #4ade80;
    --yellow: #facc15;
    --red: #f87171;
    --blue: #60a5fa;
    --orange: #fb923c;
    --radius: 8px;
    --radius-lg: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    /* Serif for wiki article headings — encyclopedic feel, system fonts only
       (no extra network request). Georgia is a screen-tuned serif on Mac/Win. */
    --wk-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
    --sidebar-w: 280px;
    --transition: 150ms ease;
}

html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* === Layout === */
#app {
    display: flex;
    height: 100vh;
}

/* === Top Navigation — moved to shared nav.css (used by app + landing) === */

/* Top view management */
.top-view { display: none; }
.top-view.active { display: flex; }

#view-projects {
    flex-direction: row;
    height: calc(100vh - 42px);
    margin-top: 42px;
}

#view-projects #app {
    display: flex;
    width: 100%;
    height: 100%;
}

#view-board {
    flex-direction: column;
    height: calc(100vh - 42px);
    margin-top: 42px;
    overflow: hidden;
}

#view-agents {
    flex-direction: column;
    height: calc(100vh - 42px);
    margin-top: 42px;
    overflow: hidden;
    padding: 0;
}

/* Override existing #app height since it's now nested */
#app { height: 100% !important; }
.welcome { height: 100% !important; }

/* === Agent Workshop === */
@keyframes aw-fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes aw-slideUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }
@keyframes aw-pulse { 0%,100% { opacity: 0.3 } 50% { opacity: 0.8 } }

.aw-layout {
    display: flex; height: 100%; overflow: hidden;
}

/* Roster sidebar */
.aw-roster {
    width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
    border-right: 1px solid #35343B; background: #1A1A1E;
}
.aw-roster-header {
    padding: 16px 18px; border-bottom: 1px solid #35343B;
}
.aw-section-label {
    font-size: 10px; font-weight: 700; color: #736C60;
    letter-spacing: 1px; text-transform: uppercase; margin-bottom: 16px;
}
.aw-roster-list {
    flex: 1; overflow-y: auto; padding: 8px 10px;
    scrollbar-width: thin; scrollbar-color: #35343B transparent;
}
.aw-roster-footer { padding: 8px 10px 10px; }
.aw-roster-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; text-align: center;
}

/* Roster cards */
.aw-agent-card {
    padding: 14px 14px; margin-bottom: 4px; border-radius: 12px;
    cursor: pointer; border: 1px solid transparent;
    transition: all 0.12s; animation: aw-slideUp 0.2s ease both;
}
.aw-agent-card:hover { background: #302F36; }
.aw-agent-card.selected {
    background: #C4785A12; border-color: #C4785A38;
}
.aw-card-row {
    display: flex; align-items: center; gap: 12px;
}
.aw-agent-avatar {
    width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
    border: 1.5px solid; display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800; transition: all 0.2s;
}
/* House (default) agent in the workshop — copper ✦ identity. */
.aw-house-avatar {
    color: #C4785A; background: rgba(196,120,90,0.10);
    border-color: rgba(196,120,90,0.30) !important; font-size: 18px;
}
.aw-avatar-large.aw-house-avatar { font-size: 26px; }
.aw-default-pill, .aw-default-badge {
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    color: #C4785A; background: rgba(196,120,90,0.12);
    border: 1px solid rgba(196,120,90,0.30); border-radius: 5px; padding: 1px 6px;
}
.aw-default-actions { margin-top: 12px; display: flex; gap: 8px; }
.aw-default-note {
    margin-top: 18px; padding: 10px 12px; border-radius: 8px;
    background: rgba(196,120,90,0.06); border: 1px solid rgba(196,120,90,0.18);
    font-size: 11.5px; color: #B8B0A4; line-height: 1.5;
}
.aw-card-info { flex: 1; min-width: 0; }
.aw-card-name-row { display: flex; align-items: center; gap: 6px; }
.aw-agent-name { font-size: 13px; font-weight: 600; color: #B8B0A4; }
.aw-agent-name.sel { color: #EAEAED; }
.aw-model-icon { font-size: 9px; }
.aw-agent-role {
    font-size: 11px; color: #736C60; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.aw-skill-chips { display: flex; gap: 4px; margin-top: 8px; }
.aw-skill-chip {
    font-size: 10px; padding: 2px 6px; border-radius: 4px;
    background: #2C2C33; color: #736C60;
}

/* New agent card */
/* Solid, obviously-clickable "New agent" — the always-available create action. */
.aw-roster-new {
    padding: 11px; border-radius: 10px; cursor: pointer;
    border: 1px solid #C4785A40; background: #C4785A14;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background 0.12s, border-color 0.12s;
}
.aw-roster-new:hover { background: #C4785A24; border-color: #C4785A66; }
.aw-roster-new.creating { background: #C4785A2E; border-color: #C4785A80; }
.aw-roster-new .aw-new-icon { font-size: 15px; color: #C4785A; font-weight: 700; }
.aw-roster-new .aw-new-label { font-size: 13px; font-weight: 600; color: #DE9474; }

/* "‹ Agents" back link at the top of a detail/profile pane → returns to the
   launchpad (the agents home). */
.aw-back-link {
    background: none; border: none; cursor: pointer; font-family: inherit;
    color: #928B7E; font-size: 12px; padding: 0 0 14px; display: inline-flex;
    align-items: center; gap: 4px; transition: color 0.12s;
}
.aw-back-link:hover { color: #C4785A; }

/* Editor panel */
.aw-editor {
    flex: 1; overflow-y: auto; background: #1A1A1E;
    scrollbar-width: thin; scrollbar-color: #35343B transparent;
}
.aw-editor-empty {
    height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
    font-size: 13px;
}
.aw-editor-content {
    padding: 28px 36px 52px; max-width: 740px;
}
/* Zero-agents onboarding — mirrors the agent page's type/colors/card language */
.aw-onboard {
    min-height: 100%; display: flex; flex-direction: column; align-items: center;
    text-align: center; padding: 52px 36px 64px; max-width: 620px; margin: 0 auto;
}
/* "Resume unfinished agent" pill on HOME — set aside when you left mid-build. */
.aw-resume-card {
    display: inline-flex; align-items: center; gap: 8px; align-self: center;
    margin-bottom: 22px; padding: 9px 16px; cursor: pointer;
    background: rgba(196,120,90,0.10); border: 1px solid rgba(196,120,90,0.35);
    border-radius: 999px; color: #E0C3B2; font-family: inherit; font-size: 12px; font-weight: 600;
    transition: background 0.12s, border-color 0.12s;
}
.aw-resume-card:hover { background: rgba(196,120,90,0.18); border-color: rgba(196,120,90,0.55); }
.aw-resume-icon { font-size: 13px; color: #C4785A; }
/* Same glyph treatment as the other agent empty states (◈, opacity 0.12) */
.aw-onboard-glyph { font-size: 40px; opacity: 0.12; margin-bottom: 14px; }
/* Matches .aw-profile-name */
.aw-onboard-title { font-size: 20px; font-weight: 800; color: #EAEAED; letter-spacing: -0.3px; }
/* Matches secondary body text (.aw-profile-role / .aw-profile-desc) */
.aw-onboard-sub {
    font-size: 13px; line-height: 1.7; color: #B8B0A4;
    margin: 8px 0 22px; max-width: 440px;
}
/* Labeled divider — same tone as .aw-section-label */
.aw-onboard-divider {
    display: flex; align-items: center; gap: 12px; width: 100%; max-width: 460px;
    margin: 30px 0 20px; color: #736C60; font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px; white-space: nowrap;
}
.aw-onboard-divider::before, .aw-onboard-divider::after {
    content: ''; flex: 1; height: 1px; background: #2E2E36;
}
.aw-tpl-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    width: 100%; max-width: 480px;
}
/* Mirrors .aw-skill-btn: transparent, #35343B border, 9px radius, #302F36 hover */
.aw-tpl-card {
    display: flex; flex-direction: column; align-items: flex-start; text-align: left;
    gap: 4px; padding: 11px 12px; background: transparent; border: 1px solid #35343B;
    border-radius: 9px; cursor: pointer; font-family: inherit; transition: all 0.12s;
}
.aw-tpl-card:hover { background: #302F36; }
.aw-tpl-icon { font-size: 16px; color: #C4785A; line-height: 1; }
/* Matches .aw-model-name / .aw-model-desc */
.aw-tpl-label { font-size: 13px; font-weight: 600; color: #EAEAED; }
.aw-tpl-blurb { font-size: 10px; line-height: 1.4; color: #736C60; }
@media (max-width: 560px) {
    .aw-tpl-grid { grid-template-columns: repeat(2, 1fr); }
}
.aw-section { margin-bottom: 36px; }

/* Identity section */
.aw-identity-row { display: flex; gap: 20px; align-items: flex-start; }
.aw-avatar-large {
    width: 72px; height: 72px; border-radius: 20px; flex-shrink: 0;
    border: 2px solid; display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 800; transition: all 0.2s;
}
/* Editable avatar badge (click to pick an emoji) */
.aw-avatar-wrap { position: relative; flex-shrink: 0; }
.aw-avatar-edit { cursor: pointer; font-family: inherit; padding: 0; position: relative; }
.aw-avatar-edit::after {
    content: '✎'; position: absolute; right: -4px; bottom: -4px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #2C2C33; border: 1px solid #3A3A42; color: #B8B0A4;
    font-size: 11px; font-weight: 400; display: flex; align-items: center; justify-content: center;
    transition: all 0.12s;
}
.aw-avatar-edit:hover::after { color: #DE9474; border-color: #C4785A55; }
.aw-avatar-picker {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
    background: #222228; border: 1px solid #35343B; border-radius: 12px; padding: 8px;
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
.aw-av-opt {
    width: 30px; height: 30px; border: none; background: none; border-radius: 8px;
    cursor: pointer; font-size: 18px; font-family: inherit; padding: 0;
    display: flex; align-items: center; justify-content: center; transition: background 0.12s;
}
.aw-av-opt:hover { background: #2E2E36; }
.aw-av-opt.selected { background: #C4785A22; outline: 1px solid #C4785A55; }
.aw-av-letter { font-weight: 800; color: #B8B0A4; font-size: 14px; }
.aw-identity-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.aw-field-row { display: flex; gap: 10px; }
.aw-field { }
.aw-field-label { font-size: 10px; color: #736C60; margin-bottom: 4px; }

/* Inputs */
.aw-input {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid #35343B; background: #1A1A1E; color: #EAEAED;
    font-size: 13px; font-family: 'Inter', -apple-system, sans-serif;
    outline: none; transition: border-color 0.15s;
}
.aw-input:focus { border-color: #C4785A; }
.aw-input::placeholder { color: #736C60; }
.aw-input-name { font-size: 14px; font-weight: 600; }
.aw-textarea { resize: vertical; line-height: 1.6; font-size: 12.5px; }

/* Color swatches */
.aw-color-swatches { display: flex; gap: 7px; }
.aw-color-swatch {
    width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
    border: none; transition: all 0.15s; background: color-mix(in srgb, var(--swatch) 20%, transparent);
}
.aw-color-swatch:hover { background: color-mix(in srgb, var(--swatch) 50%, transparent); }
.aw-color-swatch.selected {
    background: var(--swatch);
    box-shadow: 0 0 0 2.5px #1A1A1E, 0 0 0 4.5px var(--swatch);
}

/* Model picker */
.aw-model-trigger {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 14px; border-radius: 10px; border: 1px solid #35343B;
    background: #1A1A1E; cursor: pointer; font-family: inherit; text-align: left;
    transition: border-color 0.15s;
}
.aw-model-trigger:hover { border-color: #C4785A; }
.aw-model-icon-lg { font-size: 20px; }
.aw-model-info { flex: 1; }
.aw-model-name { font-size: 13px; font-weight: 600; color: #EAEAED; }
.aw-model-desc { font-size: 10px; color: #736C60; margin-top: 2px; }
.aw-tier-badge {
    font-size: 9px; padding: 3px 8px; border-radius: 4px; font-weight: 700;
}
.aw-chevron { color: #736C60; font-size: 10px; }
.aw-model-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #2C2C33; border: 1px solid #35343B; border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5); z-index: 50; overflow: hidden;
}
.aw-model-option {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 14px; border: none; cursor: pointer; font-family: inherit;
    text-align: left; background: none; transition: background 0.1s;
}
.aw-model-option:hover { background: #302F36; }
.aw-model-option.active { background: rgba(123,147,219,0.05); }
/* Unfunded model — shown but not selectable; badge points at the fix. */
.aw-model-locked { cursor: default; opacity: 0.5; }
.aw-model-locked:hover { background: none; }
.aw-model-locked .aw-model-name { color: #8c857a; }
.aw-model-lock-badge {
    font-size: 9px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap;
    color: #B8B0A4; background: #2c2b31; border: 1px solid #3a3940;
    border-radius: 4px; padding: 2px 7px;
}

/* Sliders */
.aw-slider-section { }
.aw-slider-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.aw-slider-value {
    font-size: 11px; font-family: 'JetBrains Mono', 'SF Mono', monospace; color: #928B7E;
}
.aw-range {
    width: 100%; height: 4px; cursor: pointer; accent-color: #C4785A;
}
.aw-slider-labels {
    display: flex; justify-content: space-between; font-size: 10px; color: #736C60; margin-top: 3px;
}

/* === Knowledge Base (grounded responses) === */
.aw-grounding { margin-top: 18px; }
.aw-grounding-desc { font-size: 11px; color: #B8B0A4; margin-top: 8px; transition: all 0.15s; }
.aw-kb-managed {
    font-size: 9px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
    color: #736C60; border: 1px solid #35343B; border-radius: 4px; padding: 1px 6px; cursor: help;
}
.aw-kb-dropzone {
    position: relative; border: 1px solid #2E2E36; border-radius: 10px;
    padding: 10px; background: #1E1E22; transition: border-color 0.15s, background 0.15s;
}
.aw-kb-dropzone.empty { border-style: dashed; border-color: #3A3A42; }
.aw-kb-dropzone.dragover { border-color: #C4785A; border-style: solid; background: rgba(196,120,90,0.06); }
.aw-kb-addbar { display: flex; align-items: center; gap: 8px; }
.aw-kb-dropzone:not(.empty) .aw-kb-addbar {
    margin-top: 10px; padding-top: 10px; border-top: 1px solid #2E2E36;
}
.aw-kb-addhint { font-size: 11px; color: #736C60; margin-right: auto; }
.aw-kb-btn {
    font-family: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
    color: #DE9474; background: rgba(196,120,90,0.10); border: 1px solid rgba(196,120,90,0.30);
    padding: 6px 12px; border-radius: 7px; display: inline-flex; align-items: center; transition: all 0.12s;
}
.aw-kb-btn:hover { background: rgba(196,120,90,0.18); border-color: rgba(196,120,90,0.5); }
.aw-kb-dropoverlay {
    display: none; position: absolute; inset: 0; border-radius: 10px;
    align-items: center; justify-content: center; pointer-events: none;
    background: rgba(196,120,90,0.08); color: #DE9474; font-size: 12px; font-weight: 600;
}
.aw-kb-dropzone.dragover .aw-kb-dropoverlay { display: flex; }
.aw-kb-paste { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; margin-bottom: 4px; }
.aw-kb-paste-actions { display: flex; justify-content: flex-end; gap: 8px; }
.aw-kb-list { display: flex; flex-direction: column; gap: 6px; }
.aw-kb-empty { font-size: 12px; color: #736C60; padding: 4px 0; }
.aw-kb-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    background: #222228; border: 1px solid #2E2E36; border-radius: 9px;
}
.aw-kb-icon { font-size: 14px; flex-shrink: 0; }
.aw-kb-title {
    flex: 1; min-width: 0; font-size: 12px; color: #EAEAED;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.aw-kb-meta { font-size: 10px; color: #736C60; flex-shrink: 0; }
.aw-kb-pill { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; flex-shrink: 0; }
.aw-kb-pill.ready { color: #7BC4A8; background: rgba(123,196,168,0.10); }
.aw-kb-pill.failed { color: #CF6E6E; background: rgba(207,110,117,0.10); }
.aw-kb-pill.working { color: #D4A853; background: rgba(212,168,83,0.10); }
.aw-kb-remove {
    background: none; border: none; cursor: pointer; color: #736C60;
    font-size: 12px; padding: 2px 4px; border-radius: 4px; flex-shrink: 0; transition: color 0.15s;
}
.aw-kb-remove:hover { color: #CF6E6E; }
.aw-kb-edit {
    background: none; border: none; cursor: pointer; color: #736C60;
    font-size: 12px; padding: 2px 4px; border-radius: 4px; flex-shrink: 0; transition: color 0.15s;
}
.aw-kb-edit:hover { color: #DE9474; }
/* Read-only Knowledge & Grounding in the profile view */
.aw-profile-kb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.aw-profile-kb-desc { font-size: 12px; color: #928B7E; margin-bottom: 10px; }
.aw-ground-badge {
    font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
    padding: 2px 9px; border-radius: 10px; border: 1px solid;
}
.aw-kb-list-ro { display: flex; flex-direction: column; gap: 6px; }
.aw-pv-grounded {
    margin-top: 8px; padding-top: 6px; border-top: 1px solid #2E2E36;
    font-size: 10px; color: #736C60;
}
.aw-autonomy-desc {
    font-size: 11px; color: #B8B0A4; margin-top: 8px; transition: all 0.15s;
}

/* Skills grid */
.aw-skills-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
@media (max-width: 900px) {
    .aw-skills-grid { grid-template-columns: repeat(3, 1fr); }
}
.aw-skill-btn {
    padding: 11px 12px; border-radius: 9px; cursor: pointer;
    font-family: inherit; text-align: left; transition: all 0.12s;
    border: 1px solid #35343B; background: transparent;
}
.aw-skill-btn:hover { background: #302F36; }
.aw-skill-btn.active {
    background: color-mix(in srgb, var(--agent-color) 5%, transparent);
    border-color: color-mix(in srgb, var(--agent-color) 25%, transparent);
}
.aw-skill-top { display: flex; align-items: center; gap: 6px; }
.aw-skill-icon { font-size: 14px; color: #736C60; }
.aw-skill-btn.active .aw-skill-icon { color: var(--agent-color); }
.aw-skill-label { font-size: 11px; color: #B8B0A4; }
.aw-skill-btn.active .aw-skill-label { font-weight: 600; color: #EAEAED; }
.aw-skill-check { margin-left: auto; font-size: 10px; color: var(--agent-color); }
.aw-skill-desc { font-size: 10px; color: #736C60; margin-top: 4px; }

/* System prompt */
.aw-prompt-header {
    display: flex; align-items: center; margin-bottom: 12px;
}
.aw-prompt-toggle {
    margin-left: auto; display: flex; border-radius: 6px; overflow: hidden;
    border: 1px solid #35343B;
}
.aw-prompt-toggle button {
    padding: 5px 14px; border: none; cursor: pointer;
    font-family: inherit; font-size: 11px; background: transparent;
    color: #736C60; font-weight: 400; transition: all 0.12s;
}
.aw-prompt-toggle button.active {
    background: #C4785A; color: #fff; font-weight: 600;
}
.aw-prompt-auto {
    padding: 14px 16px; border-radius: 9px; background: #1A1A1E;
    border: 1px solid #35343B; font-size: 12px; color: #B8B0A4;
    line-height: 1.7; font-family: 'JetBrains Mono', 'SF Mono', monospace;
    min-height: 96px; white-space: pre-wrap;
}
.aw-prompt-manual {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 12px; line-height: 1.7; resize: vertical;
}
.aw-char-count {
    font-size: 10px; color: #736C60; margin-top: 4px; text-align: right;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
}

/* Preview chat */
.aw-preview {
    border-radius: 12px; border: 1px solid #35343B; overflow: hidden; background: #1A1A1E;
}
.aw-preview-msgs {
    height: 200px; overflow-y: auto; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px;
    scrollbar-width: thin; scrollbar-color: #35343B transparent;
}
.aw-preview-empty {
    height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
    color: #736C60; font-size: 12px;
}
.aw-preview-hints { font-size: 10px; margin-top: 4px; color: #928B7E; }
.aw-pv-msg {
    max-width: 82%; padding: 9px 13px; font-size: 12px; line-height: 1.55;
    animation: aw-slideUp 0.15s ease;
}
.aw-pv-msg.user {
    align-self: flex-end; border-radius: 12px 12px 3px 12px;
    background: #C4785A12; border: 1px solid #C4785A38; color: #DE9474;
}
.aw-pv-msg.agent {
    align-self: flex-start; border-radius: 12px 12px 12px 3px;
    background: #222228; border: 1px solid color-mix(in srgb, var(--agent-color) 10%, transparent);
    color: #B8B0A4;
}
.aw-pv-msg.error {
    align-self: stretch; max-width: 100%; border-radius: 8px;
    background: rgba(207,110,117,0.08); border: 1px solid rgba(207,110,117,0.32);
    color: #CF9095; font-size: 11px;
}
.aw-pv-agent-name { font-size: 10px; font-weight: 600; margin-bottom: 3px; }
/* Markdown rendered inside an agent reply — compact, bubble-friendly */
.aw-pv-md > :first-child { margin-top: 0; }
.aw-pv-md > :last-child { margin-bottom: 0; }
.aw-pv-md p { margin: 0 0 6px; }
.aw-pv-md ul, .aw-pv-md ol { margin: 4px 0 6px; padding-left: 18px; }
.aw-pv-md li { margin: 2px 0; }
.aw-pv-md h1, .aw-pv-md h2, .aw-pv-md h3, .aw-pv-md h4 {
    font-size: 12px; font-weight: 700; margin: 8px 0 4px; color: #C8C2B6;
}
.aw-pv-md code {
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    background: #1A1A1E; border: 1px solid #34343B; border-radius: 4px; padding: 1px 4px;
}
.aw-pv-md pre {
    background: #1A1A1E; border: 1px solid #34343B; border-radius: 6px;
    padding: 8px 10px; margin: 6px 0; overflow-x: auto;
}
.aw-pv-md pre code { background: none; border: none; padding: 0; font-size: 11px; }
.aw-pv-md a { color: var(--agent-color, #7B93DB); text-decoration: underline; }
.aw-pv-md blockquote {
    margin: 6px 0; padding-left: 10px; border-left: 2px solid #34343B; color: #928B7E;
}
.aw-pv-typing { display: flex; gap: 4px; padding: 3px 0; }
.aw-pv-typing span {
    width: 5px; height: 5px; border-radius: 50%;
    animation: aw-pulse 1.2s ease infinite;
}
.aw-preview-label {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.aw-pv-clear {
    background: none; border: none; cursor: pointer;
    font-size: 10px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase;
    color: #736C60; padding: 2px 4px; border-radius: 4px; transition: color 0.15s;
}
.aw-pv-clear:hover { color: #C4785A; }
.aw-pv-stale {
    padding: 7px 14px; font-size: 11px; line-height: 1.5; color: #C9A86B;
    background: rgba(212,168,83,0.06); border-top: 1px solid rgba(212,168,83,0.22);
}
.aw-pv-stale button {
    background: none; border: none; cursor: pointer; padding: 0;
    font: inherit; font-weight: 600; color: #D4A853; text-decoration: underline;
}
.aw-pv-stale button:hover { color: #E0B96A; }
.aw-preview-input-bar {
    border-top: 1px solid #35343B; padding: 10px 14px;
    display: flex; gap: 8px; align-items: center;
}
.aw-preview-input {
    flex: 1; border: none; background: none; color: #EAEAED;
    font-size: 13px; outline: none; font-family: inherit;
}
.aw-preview-input::placeholder { color: #736C60; }
.aw-preview-send {
    border-radius: 7px; padding: 6px 14px; font-size: 11px;
    font-weight: 600; cursor: pointer; font-family: inherit;
    border: 1px solid; transition: opacity 0.15s;
}
.aw-preview-send:hover { opacity: 0.85; }

/* Actions bar */
.aw-actions {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 0; border-top: 1px solid #35343B;
}
.aw-actions-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.aw-unsaved { font-size: 11px; color: #D4A853; }
.aw-btn {
    padding: 8px 18px; border-radius: 8px; font-size: 12px;
    cursor: pointer; font-family: inherit; transition: all 0.12s;
}
.aw-btn-save {
    background: #C4785A; color: #fff; border: none; font-weight: 600;
    padding: 9px 24px;
}
.aw-btn-save.disabled {
    background: #2C2C33; color: #736C60; cursor: not-allowed;
}
.aw-btn-muted {
    background: none; border: 1px solid #35343B; color: #736C60;
}
.aw-btn-delete {
    background: none; border: 1px solid #35343B; color: #736C60;
}
.aw-btn-delete:hover { border-color: #CF6E6E; color: #CF6E6E; }
.aw-delete-confirm { display: flex; align-items: center; gap: 8px; }
.aw-btn-danger-fill {
    background: #CF6E6E; color: #fff; border: none; font-weight: 600;
    padding: 7px 16px; border-radius: 7px; font-size: 12px; cursor: pointer;
    font-family: inherit;
}
.aw-btn-muted { font-size: 12px; }

/* Profile view (read-only) */
.aw-profile { padding: 28px 36px 52px; max-width: 640px; }
.aw-profile-hero { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 28px; }
.aw-profile-info { flex: 1; padding-top: 4px; }
.aw-profile-name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aw-profile-name { font-size: 20px; font-weight: 800; color: #EAEAED; letter-spacing: -0.3px; }
.aw-profile-model-badge { font-size: 9px; padding: 3px 8px; border-radius: 5px; font-weight: 700; }
.aw-profile-role { font-size: 13px; color: #B8B0A4; margin-top: 3px; }
.aw-profile-edit-btn {
    padding: 8px 18px; border-radius: 8px; border: 1px solid #35343B;
    background: none; color: #B8B0A4; font-size: 12px; font-weight: 500;
    cursor: pointer; font-family: inherit; transition: all 0.12s; flex-shrink: 0;
}
.aw-profile-edit-btn:hover { border-color: #C4785A; color: #DE9474; }
.aw-profile-desc { font-size: 12px; color: #B8B0A4; line-height: 1.8; margin-bottom: 28px; }
.aw-profile-section { margin-bottom: 28px; }
.aw-profile-skills { display: flex; flex-wrap: wrap; gap: 8px; }
.aw-profile-skill {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: 7px; font-size: 11px; font-weight: 500;
}
.aw-profile-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.aw-profile-slider-label { font-size: 11px; color: #B8B0A4; margin-bottom: 8px; }
.aw-profile-slider-track {
    width: 100%; height: 3px; border-radius: 2px; background: #35343B; position: relative;
}
.aw-profile-slider-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 2px; }
.aw-profile-slider-dot {
    position: absolute; top: -3px; width: 9px; height: 9px; border-radius: 5px;
    border: 2px solid #1A1A1E; transform: translateX(-50%);
}
.aw-profile-slider-labels {
    display: flex; justify-content: space-between; font-size: 10px; color: #736C60; margin-top: 4px;
}
.aw-profile-prompt {
    padding: 14px 16px; border-radius: 12px; background: #2C2C33;
    font-size: 12px; font-family: 'JetBrains Mono', 'SF Mono', monospace;
    color: #928B7E; line-height: 1.7; white-space: pre-wrap;
}
.aw-profile-delete-btn {
    padding: 6px 0; border: none; background: none; color: #736C60;
    font-size: 11px; cursor: pointer; font-family: inherit; transition: color 0.12s;
}
.aw-profile-delete-btn:hover { color: #CF6E6E; }

/* Form row for side-by-side fields */
.form-row {
    display: flex;
    gap: 12px;
}

/* Task detail */
.task-detail-section { margin-bottom: 16px; }
.task-detail-section label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; display: block; margin-bottom: 4px; }
.task-detail-section .value { font-size: 13px; color: var(--text-primary); }
.task-detail-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; background: var(--bg-tertiary); padding: 12px; border-radius: var(--radius); }
.task-detail-row { display: flex; gap: 16px; flex-wrap: wrap; }
.task-detail-row .task-detail-section { flex: 1; min-width: 120px; }
.task-detail-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.task-chat-placeholder { margin-top: 16px; padding: 20px; background: var(--bg-tertiary); border-radius: var(--radius); text-align: center; color: var(--text-muted); font-size: 12px; }

/* Task Agent Panel */
.task-agent-panel {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.task-agent-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.task-agent-panel-header h4 { font-size: 14px; font-weight: 600; }
.task-agent-messages {
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
}
.task-agent-msg {
    margin-bottom: 12px;
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
}
.task-agent-msg.user { background: var(--accent-dim); border-left: 3px solid var(--accent); }
.task-agent-msg.assistant { background: var(--bg-tertiary); border-left: 3px solid var(--green); }
.task-agent-msg-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}
.task-agent-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}
.task-agent-input-row { display: flex; gap: 8px; }
.task-agent-input-row textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 10px;
    font-family: var(--font);
    font-size: 13px;
    resize: none;
}
.task-agent-input-row textarea:focus { outline: none; border-color: var(--accent); }

/* Review Panel */
.task-review-panel {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg, 12px);
    margin-bottom: 16px;
}
.task-review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}
.task-review-header h4 { font-size: 16px; font-weight: 600; }
.task-review-actions-top { display: flex; gap: 8px; flex-wrap: wrap; }
.review-content { max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.review-section { margin-bottom: 16px; }
.review-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.review-section-body {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.review-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.review-file {
    font-family: var(--mono);
    font-size: 12px;
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent);
}
.review-diff-block {
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-secondary);
}

/* Assign Task List */
.assign-task-list { max-height: 400px; overflow-y: auto; }
.assign-task-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}
.assign-task-item:hover { background: var(--accent-dim); }
.assign-task-item:last-child { border-bottom: none; }
.assign-task-item-title { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.assign-task-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Task Detail Layout with Chat */
.task-detail-layout {
    display: flex;
    gap: 0;
    min-height: 500px;
}

.task-detail-info {
    flex: 0 0 340px;
    padding-right: 20px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: 560px;
}

.task-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-left: 20px;
    min-width: 0;
}

.task-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.task-chat-header h4 { font-size: 14px; font-weight: 600; }

.task-chat-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.task-chat-messages {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
    min-height: 200px;
    max-height: 400px;
}

.task-chat-msg {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    max-width: 90%;
}

.task-chat-msg.user {
    background: var(--accent-dim);
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.task-chat-msg.agent {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--green);
    border-bottom-left-radius: 2px;
}

.task-chat-msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.task-chat-msg-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.task-chat-msg-time {
    font-size: 10px;
    color: var(--text-muted);
}

.task-chat-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.task-chat-input-row {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.task-chat-input-row textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 10px;
    font-family: var(--font);
    font-size: 13px;
    resize: none;
}

.task-chat-input-row textarea:focus { outline: none; border-color: var(--accent); }

.task-chat-send-btn { padding: 8px 16px !important; align-self: flex-end; }

@media (max-width: 900px) {
    .task-detail-layout { flex-direction: column; }
    .task-detail-info { flex: none; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 16px; max-height: none; }
    .task-chat-panel { padding-left: 0; padding-top: 16px; }
}

/* Assign dropdown in task detail */
.assign-dropdown-wrap { margin-top: 8px; }

/* Agent Chat Modal */
.agent-chat-messages {
    height: 300px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.agent-chat-msg {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    max-width: 85%;
    white-space: pre-wrap;
}
.agent-chat-msg.user { background: var(--accent-dim); margin-left: auto; }
.agent-chat-msg.agent { background: var(--bg-tertiary); }
.agent-chat-input-row { display: flex; gap: 8px; }
.agent-chat-input-row textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px;
    font-family: var(--font);
    font-size: 13px;
    resize: none;
}
.agent-chat-input-row textarea:focus { outline: none; border-color: var(--accent); }

/* Responsive */
@media (max-width: 768px) {
    #sidebar { width: 100%; position: fixed; z-index: 100; transform: translateX(-100%); transition: transform 0.2s; }
    #sidebar.open { transform: translateX(0); }
    .tab-content { padding: 16px; }
    .project-header { padding: 16px; }
    .tabs { padding: 0 16px; }
}

/* Commits tab toolbar */
.commits-toolbar {
    display: flex;
    align-items: center;
    padding: 0 0 12px 0;
}
.commits-toolbar select {
    background: var(--bg-tertiary, #2a2a2a);
    color: var(--text-primary, #e0e0e0);
    border: 1px solid var(--border, #3a3a3a);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
}

/* Agent Task History */
.agent-history { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.agent-history-empty { color: var(--text-secondary); font-size: 12px; font-style: italic; }
.agent-history-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-secondary); padding: 4px 0; user-select: none; }
.agent-history-header:hover { color: var(--text-primary); }
.agent-history-toggle { font-size: 10px; transition: transform 0.2s; }
.agent-history-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.agent-history-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; background: var(--bg-tertiary); cursor: pointer; font-size: 12px; transition: background 0.15s; }
.agent-history-item:hover { background: var(--border); }
.agent-history-item.current { border-left: 3px solid var(--blue); }
.agent-history-item.approved { border-left: 3px solid var(--green); }
.agent-history-item.rejected { border-left: 3px solid var(--red); }
.agent-history-item.review { border-left: 3px solid var(--yellow); }
.agent-history-status { font-size: 11px; white-space: nowrap; min-width: 90px; }
.agent-history-status.working { color: var(--blue); }
.agent-history-status.approved { color: var(--green); }
.agent-history-status.rejected { color: var(--red); }
.agent-history-status.review { color: var(--yellow); }
.agent-history-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.agent-history-meta { color: var(--text-secondary); font-size: 11px; white-space: nowrap; }

/* === Agent Profile === */
.agent-profile-layout { display: flex; flex-direction: column; gap: 16px; }
.agent-profile-info { display: flex; flex-direction: column; gap: 12px; }
.agent-profile-stats { display: flex; gap: 20px; }
.agent-stat { display: flex; flex-direction: column; align-items: center; }
.agent-stat-num { font-size: 24px; font-weight: 700; color: var(--accent); }
.agent-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.agent-profile-meta { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); }
.agent-profile-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.agent-task-card {
    border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
    transition: all 0.15s;
}
.agent-task-card[open] { border-color: var(--accent); }
.agent-task-card-summary {
    padding: 12px; cursor: pointer; list-style: none; user-select: none;
    transition: background 0.15s; border-radius: 8px;
}
.agent-task-card-summary::-webkit-details-marker { display: none; }
.agent-task-card-summary::before {
    content: '▸'; display: inline-block; margin-right: 8px; transition: transform 0.15s;
    color: var(--text-muted); font-size: 12px;
}
.agent-task-card[open] > .agent-task-card-summary::before { transform: rotate(90deg); }
.agent-task-card-summary:hover { background: var(--bg-tertiary); }
.agent-task-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.agent-task-title { font-weight: 600; font-size: 14px; }
.agent-task-card-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-secondary); }
.agent-task-card-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.agent-task-card-timeline {
    border-top: 1px solid var(--border); padding: 12px; max-height: 400px; overflow-y: auto;
}

/* Clickable task cards in agent profile */
.agent-task-card-clickable {
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.agent-task-card-clickable:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}
.agent-task-card-clickable .agent-task-card-summary {
    cursor: pointer;
}
.agent-task-card-clickable .agent-task-card-summary::before {
    content: '→';
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 12px;
}

/* Thinking log */
.thinking-log-hint {
    font-size: 12px; color: var(--text-muted); padding: 8px 0 12px; font-style: italic;
}
.thinking-log { gap: 2px; }
.tl-thinking-entry {
    padding: 8px 12px; border-radius: 6px; border-left: 3px solid var(--border);
    margin-bottom: 4px; font-size: 13px; background: var(--bg-secondary);
}
.tl-thinking-entry.tl-thinking-error { border-left-color: var(--red); }
.tl-thinking-entry.tl-thinking-completion { border-left-color: var(--green); }
.tl-thinking-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.tl-thinking-icon { font-size: 14px; }
.tl-thinking-type {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: 0.5px;
}
.tl-thinking-body {
    color: var(--text-primary); line-height: 1.4;
    max-height: 100px; overflow: hidden; position: relative;
}
.tl-thinking-detail { margin-top: 6px; }
.tl-thinking-detail summary {
    font-size: 11px; color: var(--accent); cursor: pointer;
}
.tl-thinking-detail pre {
    font-size: 11px; max-height: 300px; overflow: auto;
    background: var(--bg-primary); padding: 8px; border-radius: 4px;
    margin-top: 4px; white-space: pre-wrap; word-break: break-all;
}

/* Clickable agent names */
.mc-agent-name[onclick], .agent-card-name[onclick] { transition: color 0.15s; }
.mc-agent-name[onclick]:hover, .agent-card-name[onclick]:hover { color: var(--accent); text-decoration: underline; }

/* (removed old chat-in-timeline styles) */

/* === Brainstorm Graph — Hagentic Canvas === */
.bs-view {
    --bs-bg: #1A1A1E;
    --bs-surface: #222228;
    --bs-surface-hover: #2A2A30;
    --bs-surface-raised: #2C2C33;
    --bs-border: #2E2E36;
    --bs-border-light: #38383F;
    --bs-text: #EAEAED;
    --bs-text-secondary: #A0A0A8;
    --bs-text-tertiary: #6E6E76;
    --bs-text-muted: #4E4E56;
    --bs-accent: #C4785A;
    --bs-accent-soft: rgba(196,120,90,0.08);
    --bs-accent-border: rgba(196,120,90,0.25);
    --bs-accent-text: #DE9474;
    --bs-branch: #6DCF97;
    --bs-note: #F0D26B;
    --bs-visual: #C490D0;
    --bs-user-bubble: #3A3D58;
    --bs-ai-bubble: #26262D;
    --bs-visual-soft: rgba(196,144,208,0.08);
    --bs-visual-border: rgba(196,144,208,0.25);
    position: fixed; top: 43px; left: 0; right: 0; bottom: 0;
    background: var(--bs-bg);
    z-index: 1000; display: flex; flex-direction: column;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
    color: var(--bs-text); font-family: 'Inter', -apple-system, sans-serif;
}
.bs-view.open { opacity: 1; pointer-events: auto; }

/* Floating nav pills — sit on the canvas */
/* Floating collaboration header (top-left), stacked: back link, title (opens the
   collaboration menu), and a "Saved · Wiki" status line. */
.bs-collab-head {
    position: absolute; top: 14px; left: 18px; z-index: 30;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    max-width: min(62%, 560px);
}
.bs-back-btn {
    background: transparent; border: none; color: var(--bs-text-muted);
    padding: 2px 4px 4px 0; cursor: pointer; font-size: 12px; font-family: inherit;
    font-weight: 500; transition: color 0.15s; white-space: nowrap;
}
.bs-back-btn:hover { color: var(--bs-text-secondary); }

.bs-collab-titlerow { position: relative; display: flex; align-items: center; max-width: 100%; }
.bs-collab-titlebtn {
    display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
    background: none; border: none; cursor: pointer; font-family: inherit;
    padding: 1px 4px 1px 0; text-align: left; border-radius: 6px;
    transition: opacity 0.15s;
}
.bs-collab-titlebtn:hover { opacity: 0.92; }
.bs-collab-title {
    font-size: 19px; font-weight: 700; color: var(--bs-text);
    letter-spacing: -0.3px; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px;
}
.bs-collab-title.untitled { color: var(--bs-text-muted); font-weight: 600; }
.bs-collab-titlebtn:hover .bs-collab-title { color: var(--bs-accent-text); }
.bs-collab-chevron {
    font-size: 13px; color: var(--bs-text-muted); flex-shrink: 0; line-height: 1;
    transition: transform 0.18s ease, color 0.15s;
}
.bs-collab-titlebtn:hover .bs-collab-chevron { color: var(--bs-text-secondary); }
.bs-collab-chevron.open { transform: rotate(180deg); }

.bs-title-input {
    background: transparent; border: none; color: var(--bs-accent-text);
    font-size: 19px; font-weight: 700; font-family: inherit; letter-spacing: -0.3px;
    width: 460px; max-width: 100%; min-width: 120px; outline: none; padding: 1px 0;
}
.bs-title-input::placeholder { color: var(--bs-text-muted); font-weight: 600; }

.bs-collab-meta {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--bs-text-muted); padding-left: 1px;
}
.bs-meta-sep { opacity: 0.55; }
/* Plain-language wiki status — the words carry the meaning, not a symbol/colour. */
.bs-wiki-status { font-weight: 500; }
.bs-wiki-status.on { color: var(--bs-text-secondary); }
.bs-wiki-status.off { color: var(--bs-text-muted); }

/* Collaboration menu (anchored under the title) */
.bs-collab-menu {
    position: absolute; top: 100%; left: 0; margin-top: 8px;
    min-width: 248px; z-index: 120;
    background: #1E1E23; border: 1px solid #35343B; border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0,0,0,0.5); padding: 6px;
}
.bs-collab-menu[hidden] { display: none; }
.bs-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; background: none; border: none; cursor: pointer;
    color: #C6C1B4; text-align: left; font-size: 13px; font-family: var(--font);
    border-radius: 7px; transition: background 0.12s, color 0.12s;
}
.bs-menu-item:hover { background: rgba(255,255,255,0.06); color: #EAEAED; }
.bs-menu-ic { width: 16px; text-align: center; color: #8a8a9a; flex-shrink: 0; font-size: 13px; }
.bs-menu-item:hover .bs-menu-ic { color: #C4785A; }
.bs-menu-item.subtle { font-size: 12px; color: #8a8a9a; }
.bs-menu-item.danger { color: #CF6E6E; }
.bs-menu-item.danger:hover { background: rgba(207,110,117,0.10); color: #E07B7B; }
.bs-menu-item.danger:hover .bs-menu-ic { color: #CF6E6E; }
.bs-menu-sep { height: 1px; background: #2E2E36; margin: 5px 6px; }
.bs-menu-extra:empty { display: none; }
/* Toggle switch inside the "Add to wiki" item */
.bs-menu-switch {
    margin-left: auto; width: 30px; height: 16px; border-radius: 8px; flex-shrink: 0;
    background: #35343B; position: relative; transition: background 0.2s;
}
.bs-menu-switch.on { background: #C4785A; }
.bs-menu-switch-thumb {
    position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
    background: #fff; border-radius: 50%; transition: left 0.2s;
}
.bs-menu-switch.on .bs-menu-switch-thumb { left: 16px; }

/* Canvas container with dot grid */
.bs-canvas-container {
    flex: 1; position: relative; overflow: hidden; background: var(--bs-bg);
}
.bs-canvas, .bs-edges {
    position: absolute; top: 0; left: 0; transform-origin: 0 0; transition: none;
}
.bs-edges { width: 8000px; height: 8000px; pointer-events: none; z-index: 0; }
.bs-canvas { z-index: 1; }

/* Sticky note cards */
.bs-node {
    position: absolute; width: 200px; min-height: 100px;
    border-radius: 10px; padding: 0; cursor: pointer;
    transition: opacity 0.3s, box-shadow 0.2s; user-select: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    border: 1.5px solid transparent;
}
.bs-node:active { cursor: grabbing; }
.bs-node:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.bs-node.selected { }
.bs-node.dimmed { opacity: 0.35 !important; }

/* Pin dot at top center */
.bs-node-pin {
    position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
    width: 10px; height: 10px; border-radius: 50%; z-index: 1;
}

/* Node inner content */
.bs-node-inner { padding: 14px 14px 8px; }
.bs-node-title {
    font-size: 12.5px; font-weight: 700; line-height: 1.35; color: var(--bs-text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 6px; cursor: text;
}
.bs-node-title-placeholder { font-weight: 400; font-style: italic; opacity: 0.45; }
.bs-node-title-editing {
    outline: none; -webkit-line-clamp: unset; background: rgba(255,255,255,0.05);
    border-radius: 3px; padding: 1px 3px; margin: -1px -3px;
}
.bs-node-summary {
    font-size: 10px; color: var(--bs-text-secondary); line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 8px;
}
.bs-node-stats {
    display: flex; gap: 8px; font-size: 9px; color: var(--bs-text-tertiary);
    font-family: 'SF Mono', 'Menlo', monospace;
}
.bs-node-note {
    font-size: 9.5px; color: var(--bs-note); padding: 6px 14px 8px;
    border-top: 1px solid rgba(240,210,107,0.15); background: rgba(240,210,107,0.04);
    cursor: text; display: none; line-height: 1.4;
    border-radius: 0 0 10px 10px;
}
.bs-node:hover .bs-node-note, .bs-node-note.has-note { display: block; }
.bs-node-note-editing { outline: none; background: rgba(240,210,107,0.08); font-size: 10px; }
.bs-node-note-placeholder { opacity: 0.5; font-style: italic; }

/* Delete and drag handles on hover */
.bs-node-delete {
    position: absolute; top: -8px; left: -8px; width: 20px; height: 20px;
    border-radius: 50%; background: #2E2E36; border: 1.5px solid #444;
    color: var(--bs-text-secondary); font-size: 10px; cursor: pointer;
    display: none; align-items: center; justify-content: center; z-index: 2;
    transition: all 0.15s;
}
.bs-node:hover .bs-node-delete { display: flex; }
.bs-node-delete:hover { background: rgba(255,60,60,0.25); color: #e55; border-color: #e55; }
.bs-node-drag-dots {
    position: absolute; top: 8px; right: 8px; font-size: 9px;
    color: var(--bs-text-muted); display: none; letter-spacing: 1px; opacity: 0.5;
}
.bs-node:hover .bs-node-drag-dots { display: block; }

/* Shipped badge */
.bs-node-shipped-badge {
    margin: 0 12px 6px; padding: 3px 8px; font-size: 9px; font-weight: 600;
    color: #34d399; background: rgba(16,185,129,0.12); border-radius: 4px;
    cursor: pointer; text-align: center;
}

/* Thinking indicator */
.bs-node-thinking { animation: bsNodePulse 1.5s ease-in-out infinite; }
@keyframes bsNodePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(196,120,90,0.4), 0 2px 8px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 12px 4px rgba(196,120,90,0.25), 0 2px 8px rgba(0,0,0,0.3); }
}
/* Reduced motion: a steady copper glow still signals "working", without the pulse. */
@media (prefers-reduced-motion: reduce) {
    .bs-node-thinking { animation: none; box-shadow: 0 0 10px 2px rgba(196,120,90,0.3), 0 2px 8px rgba(0,0,0,0.3); }
}
.bs-node-new { animation: bsNodeAppear 0.4s ease-out; }
@keyframes bsNodeAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Canvas controls bottom-left */
.bs-controls {
    position: absolute; bottom: 16px; left: 16px; z-index: 15;
    display: flex; align-items: center; gap: 2px;
    background: var(--bs-surface); border: 1px solid var(--bs-border);
    border-radius: 8px; padding: 4px 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.bs-ctrl-btn {
    background: transparent; border: none; color: var(--bs-text-secondary);
    padding: 4px 8px; cursor: pointer; font-size: 13px; border-radius: 4px;
    transition: all 0.15s; white-space: nowrap;
}
.bs-ctrl-btn:hover { background: var(--bs-surface-hover); color: var(--bs-text); }
.bs-ctrl-text { font-size: 10px; color: var(--bs-text-tertiary); font-family: inherit; }
.bs-ctrl-zoom { font-size: 11px; color: var(--bs-text-tertiary); min-width: 36px; text-align: center; }
.bs-ctrl-sep { width: 1px; height: 16px; background: var(--bs-border); margin: 0 4px; }
.bs-ctrl-new { color: var(--bs-text-tertiary); padding: 5px 6px; display: flex; align-items: center; }
.bs-ctrl-new:hover { color: var(--bs-text); }
.bs-ctrl-new.active { background: var(--bs-accent-soft); color: var(--bs-accent); }

/* Ghost sticky for placement mode */
.bs-ghost {
    position: absolute; width: 164px; height: 80px; border-radius: 8px;
    background: var(--bs-surface); border: 1.5px solid var(--bs-border);
    pointer-events: none; z-index: 5; opacity: 0.45;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.bs-ghost-input {
    position: absolute; z-index: 6; width: 164px;
    background: var(--bs-surface); border: 2px solid var(--bs-accent);
    border-radius: 6px; padding: 10px 12px; color: var(--bs-text);
    font-size: 12px; font-family: inherit; outline: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Hint bar bottom-right */
.bs-hint {
    position: absolute; bottom: 16px; right: 16px; z-index: 15;
    font-size: 11px; color: var(--bs-text-muted);
    background: var(--bs-surface); border: 1px solid var(--bs-border);
    border-radius: 6px; padding: 6px 12px;
}

/* === Slideout Panel === */
.bs-slideout {
    position: absolute; top: 0; right: 0; bottom: 0; width: 40vw; min-width: 480px;
    display: flex; z-index: 20;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 32px rgba(0,0,0,0.35);
}

/* Full-screen chat-first entry for a brand-new/empty collaboration */
.bs-slideout.bs-slideout-focus { width: 100%; min-width: 0; left: 0; box-shadow: none; }
.bs-slideout-focus .bs-slideout-header,
.bs-slideout-focus .bs-slideout-breadcrumbs,
.bs-slideout-focus .bs-slideout-resize { display: none; }
.bs-slideout-focus .bs-slideout-messages { align-items: center; justify-content: center; padding: 24px; }
.bs-slideout-focus .bs-slideout-input-area { width: 100%; max-width: 680px; margin: 0 auto; }
.bs-slideout-focus .bs-slideout-input-hint { text-align: center; }
.bs-focus-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; max-width: 460px; margin: auto; }
.bs-focus-logo { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, #C4785A, #9B8FDE); margin-bottom: 6px; }
.bs-focus-title { font-size: 24px; font-weight: 800; color: #EAEAED; letter-spacing: -0.4px; }
.bs-focus-sub { font-size: 14px; color: #8C8C96; line-height: 1.6; max-width: 360px; }
/* Graceful exit on first message: overlay (out of flow, so the incoming
   message flows underneath) and fade out, then JS removes it. */
.bs-focus-hero-leaving {
    position: absolute; inset: 0; margin: 0; pointer-events: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    animation: bsFocusHeroOut 0.22s ease forwards;
}
@keyframes bsFocusHeroOut { to { opacity: 0; transform: translateY(-8px); } }
/* Focus-mode teammate chips — one tap to @mention an available agent */
.bs-focus-agents { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.bs-focus-agent-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px 6px 7px; border-radius: 20px; cursor: pointer;
    background: var(--bs-surface); border: 1px solid var(--bs-border);
    font-family: inherit; transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.bs-focus-agent-chip:hover { border-color: color-mix(in srgb, var(--ac) 45%, transparent); background: var(--bs-surface-hover); transform: translateY(-1px); }
.bs-focus-agent-av {
    width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.bs-focus-agent-name { font-size: 12.5px; font-weight: 600; color: var(--bs-text); }
.bs-focus-agent-role { font-size: 11px; color: var(--bs-text-muted); }
/* One-time branch coachmark */
.bs-branch-tip {
    display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 8px 12px;
    background: rgba(196,120,90,0.10); border: 1px solid rgba(196,120,90,0.28);
    border-radius: 9px; font-size: 12px; color: var(--bs-text-secondary, #A0A0A8);
}
.bs-branch-tip-icon { color: var(--bs-accent, #C4785A); flex-shrink: 0; }
.bs-branch-tip-text { flex: 1; line-height: 1.4; }
.bs-branch-tip-dismiss {
    flex-shrink: 0; background: none; border: 1px solid rgba(196,120,90,0.35);
    color: var(--bs-accent-text, #DE9474); font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: 6px; cursor: pointer; font-family: inherit; transition: all 0.12s;
}
.bs-branch-tip-dismiss:hover { background: rgba(196,120,90,0.18); }
.bs-slideout.open { transform: translateX(0); }
.bs-slideout-resize {
    width: 6px; cursor: col-resize; background: transparent; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; position: relative;
}
.bs-slideout-resize::after {
    content: ''; width: 3px; height: 32px; background: var(--bs-border-light);
    border-radius: 2px; transition: background 0.15s;
}
.bs-slideout-resize:hover::after { background: var(--bs-accent); }

.bs-slideout-chat {
    flex: 1; display: flex; flex-direction: column; background: var(--bs-bg);
    border-left: 1px solid rgba(255,255,255,0.06); min-width: 0;
    position: relative;
}

/* Header — clean, airy */
.bs-slideout-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px; flex-shrink: 0;
    background: var(--bs-bg);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.bs-slideout-close {
    background: transparent; border: none; color: var(--bs-text-muted);
    font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
    transition: all 0.15s; opacity: 0.5;
}
.bs-slideout-close:hover { opacity: 1; color: var(--bs-text); }
.bs-slideout-title {
    flex: 1; font-size: 14px; font-weight: 600; color: var(--bs-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    outline: none; border-radius: 4px; padding: 2px 6px;
}
.bs-slideout-title-placeholder { font-weight: 400; font-style: italic; opacity: 0.45; }
.bs-slideout-title[contenteditable="true"] {
    background: rgba(255,255,255,0.04); cursor: text;
}
.bs-slideout-title:focus { background: rgba(255,255,255,0.06); }
.bs-slideout-header-actions { display: flex; gap: 2px; align-items: center; }
.bs-slideout-hdr-btn {
    width: 28px; height: 28px; border: none; background: transparent;
    color: var(--bs-text-muted); cursor: pointer; border-radius: 8px;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; opacity: 0.6;
}
.bs-slideout-hdr-btn:hover { background: rgba(255,255,255,0.06); color: var(--bs-text); opacity: 1; }

/* Slideout context menu */
.bs-slideout-menu-wrap { position: relative; }
.bs-slideout-menu {
    display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
    background: var(--bs-surface-raised); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; padding: 4px; min-width: 170px; z-index: 100;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.bs-slideout-menu.open { display: block; }
.bs-slideout-menu-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    font-size: 13px; color: var(--bs-text); border-radius: 8px;
    cursor: pointer; transition: background 0.1s;
}
.bs-slideout-menu-item:hover { background: rgba(255,255,255,0.06); }
.bs-slideout-menu-item span { font-size: 14px; width: 18px; text-align: center; }
.bs-slideout-menu-danger { color: #f87171; }
.bs-slideout-menu-danger:hover { background: rgba(248,113,113,0.1); }
.bs-slideout-menu-sep { height: 1px; background: rgba(255,255,255,0.06); margin: 4px 8px; }

/* Breadcrumbs */
.bs-slideout-breadcrumbs {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 18px; font-size: 11px;
    overflow-x: auto; white-space: nowrap; flex-shrink: 0;
    background: transparent;
}
.bs-slideout-breadcrumbs::-webkit-scrollbar { height: 0; }
.bs-crumb {
    color: var(--bs-text-muted); cursor: pointer; padding: 2px 6px;
    border-radius: 4px; transition: all 0.15s; flex-shrink: 0;
    font-weight: 400; font-size: 11px;
}
.bs-crumb:hover { background: rgba(255,255,255,0.06); color: var(--bs-text); }
.bs-crumb.active { background: var(--bs-accent-soft); font-weight: 600; font-size: 11px; padding: 2px 7px; border-radius: 5px; color: var(--bs-accent-text); }
.bs-crumb-sep { color: var(--bs-text-muted); flex-shrink: 0; font-size: 8px; margin: 0 4px; }

/* Messages stream */
.bs-slideout-messages {
    flex: 1; overflow-y: auto; padding: 16px 18px;
    display: flex; flex-direction: column; gap: 16px;
    position: relative;
}
.bs-slideout-messages::-webkit-scrollbar { width: 4px; }
.bs-slideout-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.bs-slideout-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
.bs-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.bs-msg-user { flex-direction: row-reverse; }
.bs-msg-avatar {
    font-size: 13px; flex-shrink: 0; margin-top: 2px;
    width: 26px; height: 26px; border-radius: 50%;
    background: rgba(196,120,90,0.12); display: flex; align-items: center; justify-content: center;
}
.bs-msg-bubble {
    max-width: 88%; padding: 10px 14px; border-radius: 16px;
    font-size: 13.5px; line-height: 1.6; word-break: break-word;
}
.bs-msg-user .bs-msg-bubble {
    background: var(--bs-user-bubble); color: var(--bs-text);
    border-radius: 16px 16px 4px 16px;
}
.bs-msg-ai .bs-msg-bubble {
    background: transparent; color: var(--bs-text-secondary);
    border-radius: 16px 16px 16px 4px;
    cursor: text; padding: 4px 2px;
}

/* Markdown prose inside AI replies. The global `* { margin:0 }` reset strips
   all block spacing, so marked's <p>/<ul>/<li>/headings render as a cramped
   wall of text. Restore readable vertical rhythm, scoped to AI bubbles only
   (user messages are plain text and unaffected). */
.bs-msg-ai .bs-msg-bubble > :first-child { margin-top: 0; }
.bs-msg-ai .bs-msg-bubble > :last-child { margin-bottom: 0; }
.bs-msg-ai .bs-msg-bubble p { margin: 0 0 0.7em; }
.bs-msg-ai .bs-msg-bubble ul,
.bs-msg-ai .bs-msg-bubble ol { margin: 0.5em 0 0.7em; padding-left: 1.4em; }
.bs-msg-ai .bs-msg-bubble li { margin: 0.25em 0; }
.bs-msg-ai .bs-msg-bubble li > ul,
.bs-msg-ai .bs-msg-bubble li > ol { margin: 0.25em 0 0.1em; }
.bs-msg-ai .bs-msg-bubble h1,
.bs-msg-ai .bs-msg-bubble h2,
.bs-msg-ai .bs-msg-bubble h3,
.bs-msg-ai .bs-msg-bubble h4 {
    margin: 1.1em 0 0.4em; line-height: 1.3;
    color: var(--bs-text); font-weight: 650;
}
.bs-msg-ai .bs-msg-bubble h1 { font-size: 1.3em; }
.bs-msg-ai .bs-msg-bubble h2 { font-size: 1.18em; }
.bs-msg-ai .bs-msg-bubble h3 { font-size: 1.08em; }
.bs-msg-ai .bs-msg-bubble h4 { font-size: 1em; }
.bs-msg-ai .bs-msg-bubble strong { color: var(--bs-text); font-weight: 650; }
.bs-msg-ai .bs-msg-bubble a {
    color: var(--bs-accent); text-decoration: none;
    border-bottom: 1px solid rgba(196,120,90,0.35);
}
.bs-msg-ai .bs-msg-bubble a:hover { border-bottom-color: var(--bs-accent); }
.bs-msg-ai .bs-msg-bubble code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em; background: rgba(255,255,255,0.06);
    padding: 1px 5px; border-radius: 4px; color: var(--bs-text);
}
.bs-msg-ai .bs-msg-bubble pre {
    background: rgba(255,255,255,0.04); border: 1px solid var(--bs-border);
    border-radius: 8px; padding: 10px 12px; margin: 0.6em 0;
    overflow-x: auto; line-height: 1.45;
}
.bs-msg-ai .bs-msg-bubble pre code {
    background: none; padding: 0; font-size: 0.86em;
}
.bs-msg-ai .bs-msg-bubble blockquote {
    margin: 0.6em 0; padding: 2px 0 2px 12px;
    border-left: 2px solid rgba(196,120,90,0.4); color: var(--bs-text-muted);
}
.bs-msg-ai .bs-msg-bubble hr {
    border: none; border-top: 1px solid var(--bs-border); margin: 1em 0;
}
.bs-msg-ai .bs-msg-bubble table {
    border-collapse: collapse; margin: 0.6em 0; font-size: 0.95em;
}
.bs-msg-ai .bs-msg-bubble th,
.bs-msg-ai .bs-msg-bubble td {
    border: 1px solid var(--bs-border); padding: 5px 9px; text-align: left;
}
.bs-msg-ai .bs-msg-bubble th {
    background: rgba(255,255,255,0.04); color: var(--bs-text); font-weight: 600;
}

/* Ancestor collapsed messages */
.bs-msg-ancestor {
    opacity: 0.5; cursor: pointer; transition: opacity 0.15s;
    padding: 6px 10px; border-radius: 8px; font-size: 11.5px;
    color: var(--bs-text-tertiary); background: rgba(255,255,255,0.03);
}
.bs-msg-ancestor:hover { opacity: 0.8; background: rgba(255,255,255,0.06); }
.bs-msg-ancestor-label {
    font-weight: 600; color: var(--bs-text-secondary); font-size: 10px;
    padding: 8px 0 4px; text-transform: uppercase; letter-spacing: 0.5px;
}

/* Branch pills */
.bs-branch-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; margin: 2px 4px 2px 0; border-radius: 14px;
    font-size: 11.5px; font-weight: 600; cursor: pointer; transition: all 0.15s;
    background: rgba(109,207,151,0.08); color: var(--bs-branch);
    border: 1px solid rgba(109,207,151,0.15);
}
.bs-branch-pill:hover { background: rgba(109,207,151,0.18); border-color: rgba(109,207,151,0.35); }

/* Visual pills */
.bs-visual-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; margin: 2px 4px 2px 0; border-radius: 14px;
    font-size: 11.5px; font-weight: 600; cursor: pointer; transition: all 0.15s;
    background: rgba(196,144,208,0.08); color: var(--bs-visual);
    border: 1px solid rgba(196,144,208,0.15);
}
.bs-visual-pill:hover { background: rgba(196,144,208,0.18); border-color: rgba(196,144,208,0.35); }
.bs-visual-pill.active { background: rgba(196,144,208,0.22); border-color: var(--bs-visual); }
.bs-visual-pill .bs-visual-pill-pin { font-size: 9px; margin-left: 2px; }

/* Thinking indicator */
.bs-thinking { display: flex; gap: 5px; padding: 8px 4px; }
.bs-thinking span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--bs-accent); animation: bsThink 1.2s ease-in-out infinite;
}
.bs-thinking span:nth-child(2) { animation-delay: 0.2s; }
.bs-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bsThink {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* House (default) agent mark — the warm ✦ symbol that stands in for a name. */
.bs-house-mark {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; line-height: 1; color: var(--bs-accent);
    background: var(--bs-accent-soft, rgba(196,120,90,0.10));
    border: 1.5px solid var(--bs-accent-border, rgba(196,120,90,0.28));
}
/* Breathing glow while the house agent is thinking. */
.bs-house-thinking { animation: bsHouseBreathe 1.5s ease-in-out infinite; }
@keyframes bsHouseBreathe {
    0%, 100% { transform: scale(0.86); opacity: 0.6; box-shadow: 0 0 0 0 rgba(196,120,90,0); }
    50%      { transform: scale(1);    opacity: 1;   box-shadow: 0 0 12px 1px rgba(196,120,90,0.4); }
}
@media (prefers-reduced-motion: reduce) {
    .bs-house-thinking { animation: none; opacity: 1; transform: none; }
}

/* Chat input — floating pill */
.bs-slideout-input-area {
    padding: 8px 14px 12px; flex-shrink: 0;
    background: var(--bs-bg);
}
.bs-slideout-input-wrap {
    display: flex; align-items: flex-end; cursor: text;
    background: var(--bs-surface); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px; padding: 4px 4px 4px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.bs-slideout-input-wrap:focus-within {
    border-color: rgba(196,120,90,0.4);
    box-shadow: 0 0 0 3px rgba(196,120,90,0.08);
}
.bs-slideout-input {
    flex: 1; background: transparent; border: none;
    color: var(--bs-text); padding: 8px 4px; cursor: text;
    font-size: 13.5px; font-family: inherit; outline: none;
    min-height: 42px; max-height: 180px; line-height: 1.5;
    overflow-y: auto; white-space: pre-wrap; word-wrap: break-word;
}
.bs-slideout-input:empty:before {
    content: attr(data-placeholder);
    color: var(--bs-text-muted); pointer-events: none;
}
.bs-slideout-input .bs-input-mention {
    display: inline-flex; align-items: center;
    padding: 1px 6px; border-radius: 4px;
    font-size: 12px; font-weight: 600;
    white-space: nowrap; vertical-align: baseline;
    user-select: all; cursor: default;
}
.bs-slideout-send {
    width: 32px; height: 32px; border: none; border-radius: 50%;
    background: var(--bs-accent, #C4785A); color: #fff; cursor: pointer;
    flex-shrink: 0; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.85;
}
.bs-slideout-send:hover { opacity: 1; transform: scale(1.05); }
.bs-slideout-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.bs-slideout-send svg { width: 15px; height: 15px; }
.bs-slideout-stop {
    width: 32px; height: 32px; border: none; border-radius: 50%;
    background: rgba(248,113,113,0.15); color: #F87171; cursor: pointer;
    flex-shrink: 0; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px;
}
.bs-slideout-stop:hover { background: rgba(248,113,113,0.25); color: #FCA5A5; }
.bs-slideout-input-hint {
    font-size: 9px; color: var(--bs-text-muted); opacity: 0.4;
    text-align: center; padding: 5px 0 0; font-family: monospace;
}
.bs-slideout-esc-pill {
    padding: 1px 4px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.1);
    font-size: 8px;
}

/* System messages in brainstorm chat */
.bs-msg-system {
    text-align: center; font-size: 11px; color: var(--bs-text-muted);
    padding: 6px 12px; margin: 4px 0;
    opacity: 0.5;
}

/* Center divider between chat and visual panes */
.bs-center-divider {
    width: 7px; cursor: col-resize; background: transparent; flex-shrink: 0;
    display: none; align-items: center; justify-content: center;
    position: relative; z-index: 2;
}
.bs-center-divider.visible { display: flex; }
.bs-center-divider-grip {
    width: 4px; height: 48px; border-radius: 2px;
    background: var(--bs-border-light); opacity: 0.3; transition: opacity 0.15s;
}
.bs-center-divider:hover .bs-center-divider-grip { opacity: 0.7; background: var(--bs-accent); }

/* Visual pane */
.bs-slideout-visual {
    width: 0; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
    background: #16161C; border-left: none;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.bs-slideout-visual.open { min-width: 260px; }
.bs-visual-header {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-bottom: 1px solid var(--bs-border);
    background: var(--bs-surface-raised); flex-shrink: 0;
}
.bs-visual-label { flex: 1; font-size: 12px; font-weight: 600; color: var(--bs-visual); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-visual-zoom-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.bs-visual-zoom-btn {
    background: transparent; border: none; color: var(--bs-text-muted);
    border-radius: 4px; min-width: 20px; height: 20px; cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
    transition: color 0.15s;
}
.bs-visual-zoom-btn:hover { color: var(--bs-text); }
.bs-visual-zoom-level {
    font-size: 10px; color: var(--bs-text-muted); min-width: 30px; text-align: center;
    font-variant-numeric: tabular-nums;
}
.bs-visual-fullscreen-btn {
    background: transparent; border: none; color: var(--bs-text-muted);
    cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px;
    transition: color 0.15s; flex-shrink: 0; line-height: 1;
}
.bs-visual-fullscreen-btn:hover { color: var(--bs-visual); }
.bs-visual-pin { background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px; flex-shrink: 0; opacity: 0.7; }
.bs-visual-pin:hover { opacity: 1; }
/* Frame wrap: overflow auto so zoomed-in content is scrollable */
.bs-visual-frame-wrap {
    flex: 1; overflow: auto; position: relative; background: #16161C; min-height: 0;
}
.bs-visual-frame-wrap iframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;
}

/* === Fullscreen Overlay === */
.bs-fullscreen-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: #0e0e12;
    display: flex; flex-direction: column;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s;
}
.bs-fullscreen-overlay.open { opacity: 1; pointer-events: auto; }
.bs-fullscreen-header {
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px; height: 46px; flex-shrink: 0;
    background: rgba(26,26,32,0.95); border-bottom: 1px solid rgba(255,255,255,0.07);
    backdrop-filter: blur(8px);
}
.bs-fullscreen-title {
    flex: 1; font-size: 13px; font-weight: 600; color: var(--bs-visual);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bs-fullscreen-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.bs-fullscreen-ctrl {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    color: var(--bs-text-secondary); border-radius: 6px;
    min-width: 28px; height: 28px; cursor: pointer; font-size: 14px; font-family: inherit;
    display: flex; align-items: center; justify-content: center; padding: 0 6px;
    transition: background 0.15s, color 0.15s;
}
.bs-fullscreen-ctrl:hover { background: rgba(255,255,255,0.12); color: var(--bs-text); }
.bs-fullscreen-zoom-level {
    font-size: 11px; color: var(--bs-text-muted); min-width: 36px; text-align: center;
    font-variant-numeric: tabular-nums;
}
.bs-fullscreen-sep { width: 1px; height: 18px; background: rgba(255,255,255,0.1); margin: 0 4px; }
.bs-fullscreen-tab-btn { gap: 4px; font-size: 12px; padding: 0 10px; }
.bs-fullscreen-close { font-size: 16px; margin-left: 4px; }
.bs-fullscreen-close:hover { background: rgba(220,60,60,0.2); color: #ff6b6b; }
.bs-fullscreen-frame-wrap {
    flex: 1; overflow: auto; background: #16161C;
    position: relative; min-height: 0;
}
.bs-fullscreen-frame-wrap iframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;
}
.bs-visual-filmstrip {
    display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--bs-border);
    overflow-x: auto; flex-shrink: 0; background: var(--bs-surface);
}
.bs-filmstrip-thumb {
    width: 52px; height: 40px; border-radius: 4px; overflow: hidden;
    border: 2px solid transparent; cursor: pointer; flex-shrink: 0;
    transition: border-color 0.15s;
}
.bs-filmstrip-thumb.active { border-color: var(--bs-visual); }
.bs-filmstrip-thumb { position: relative; }
.bs-filmstrip-pin { position: absolute; top: -4px; right: -4px; font-size: 8px; line-height: 1; }
.bs-filmstrip-thumb iframe {
    width: 289px; height: 222px; border: none; pointer-events: none;
    transform: scale(0.18); transform-origin: 0 0;
}

/* Delete confirmation modal */
.bs-delete-modal {
    display: none; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 100; align-items: center; justify-content: center;
}
.bs-delete-modal.open { display: flex; }
.bs-delete-dialog {
    background: var(--bs-surface-raised); border: 1px solid var(--bs-border);
    border-radius: 12px; padding: 24px; max-width: 380px; width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.bs-delete-dialog h3 { margin: 0 0 8px; font-size: 16px; color: var(--bs-text); }
.bs-delete-dialog p { margin: 0 0 20px; font-size: 13px; color: var(--bs-text-secondary); line-height: 1.5; }
.bs-delete-actions { display: flex; gap: 10px; justify-content: flex-end; }
.bs-delete-cancel {
    padding: 8px 16px; border-radius: 6px; border: 1px solid var(--bs-border);
    background: transparent; color: var(--bs-text-secondary); cursor: pointer; font-size: 13px;
}
.bs-delete-cancel:hover { background: var(--bs-surface-hover); }
.bs-delete-confirm {
    padding: 8px 16px; border-radius: 6px; border: none;
    background: #e74c3c; color: #fff; cursor: pointer; font-size: 13px; font-weight: 600;
}
.bs-delete-confirm:hover { background: #c0392b; }

/* Plan execution button */
.bs-plan-exec-btn {
    width: 100%; padding: 8px 14px; font-size: 12px; font-weight: 600;
    color: var(--bs-text); background: linear-gradient(135deg, rgba(196,120,90,0.12), rgba(168,85,247,0.12));
    border: 1px solid rgba(196,120,90,0.25); border-radius: 8px; cursor: pointer;
    transition: all 0.2s;
}
.bs-plan-exec-btn:hover {
    background: linear-gradient(135deg, rgba(196,120,90,0.25), rgba(168,85,247,0.25));
    border-color: rgba(196,120,90,0.5); transform: translateY(-1px);
}
.bs-plan-exec-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.bs-plan-exec-done {
    background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(52,211,153,0.1));
    border-color: rgba(16,185,129,0.25); color: #34d399;
}
.bs-plan-exec-needs-info {
    background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.15));
    border-color: rgba(251,191,36,0.4); color: #fbbf24;
}

/* Mock rendering in chat */
.bs-mock-container {
    margin: 8px 0; border: 1px solid var(--bs-border); border-radius: 8px;
    overflow: hidden; background: #1a1a2e;
}
.bs-mock-label {
    font-size: 11px; color: var(--bs-text-muted); padding: 6px 12px;
    border-bottom: 1px solid var(--bs-border); background: rgba(196,144,208,0.05); font-weight: 500;
}
.bs-mock-frame { width: 100%; min-height: 80px; border: none; background: transparent; display: block; }

/* Toast */
.bs-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--bs-surface-raised); border: 1px solid var(--bs-branch);
    color: var(--bs-text); padding: 10px 20px; border-radius: 8px; font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3); opacity: 0; transition: all 0.3s ease; z-index: 2000;
}
.bs-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* (ESC hint moved into input area)

/* Message section headers */
.bs-msg-connector {
    width: 1px; height: 16px; background: var(--bs-border);
    margin: 0 auto;
}
.bs-msg-section-header {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 6px;
    border-left: 2.5px solid var(--bs-accent-border);
    cursor: pointer; transition: background 0.15s;
}
.bs-msg-section-header.active {
    background: var(--bs-accent-soft);
    border-left-color: var(--bs-accent);
}
.bs-msg-section-label {
    font-size: 11.5px; font-weight: 600; flex: 1;
}
.bs-msg-section-count {
    font-size: 8px; font-family: 'SF Mono', 'Menlo', monospace; color: var(--bs-text-muted);
}

/* Green highlight overlay on selected text while branch input is open */
.bs-branch-highlight {
    position: absolute; z-index: 70;
    background: rgba(109, 207, 151, 0.25);
    border-radius: 2px;
    pointer-events: none;
}
/* Inline branch input (select-to-branch) */
.bs-branch-inline-input {
    position: absolute; z-index: 80;
    display: flex; align-items: center; gap: 6px;
    padding: 2px 4px; min-width: 260px; max-width: 400px;
    background: var(--bs-surface-raised);
    border: 1px solid rgba(109,207,151,0.35);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: bsBranchInputFadeIn 0.12s ease-out;
}
.bs-branch-inline-icon {
    color: var(--bs-branch); font-size: 14px; padding-left: 8px; flex-shrink: 0;
}
.bs-branch-inline-field {
    flex: 1; background: none; border: none; outline: none;
    color: var(--bs-text); font-size: 13px; font-family: 'Inter', sans-serif;
    padding: 7px 4px; min-width: 0;
}
.bs-branch-inline-field::placeholder {
    color: var(--bs-text-muted); font-size: 12px;
}
.bs-branch-inline-dismiss {
    background: none; border: none; color: var(--bs-text-muted);
    font-size: 14px; cursor: pointer; padding: 4px 8px; flex-shrink: 0;
}
.bs-branch-inline-dismiss:hover { color: var(--bs-text); }
@keyframes bsBranchInputFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Multi-agent: @mention dropdown */
.bs-mention-dropdown {
    position: absolute; bottom: 100%; left: 0; right: 0;
    margin-bottom: 6px; z-index: 100;
    background: #1e1e2a;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: bsBranchInputFadeIn 0.1s ease-out;
}
.bs-mention-header {
    padding: 6px 12px; border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 9px; color: var(--bs-text-muted); letter-spacing: 0.3px; text-transform: uppercase;
}
.bs-mention-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 12px; border: none; cursor: pointer;
    background: transparent; text-align: left; font-family: 'Inter', sans-serif;
    color: var(--bs-text); transition: background 0.08s;
}
.bs-mention-item:hover { background: rgba(255,255,255,0.04); }
.bs-mention-item.active { background: rgba(255,255,255,0.07); }
.bs-mention-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.bs-mention-info { display: flex; align-items: baseline; gap: 6px; }
.bs-mention-name { font-size: 13px; font-weight: 600; }
.bs-mention-role { font-size: 11px; color: var(--bs-text-muted); }
.bs-mention-item.disabled {
    opacity: 0.35; pointer-events: none;
}

/* @mention tag pill rendered in message text */
.bs-mention-tag {
    display: inline-flex; align-items: center;
    padding: 1px 7px; border-radius: 4px;
    font-size: 12px; font-weight: 600;
    vertical-align: baseline; white-space: nowrap;
}

/* Multi-agent: agent label above AI messages */
.bs-msg-agent-label {
    display: flex; align-items: center; gap: 4px;
    margin-bottom: 3px; padding-left: 2px;
}
.bs-msg-agent-label .bs-agent-av {
    width: 16px; height: 16px; border-radius: 50%;
    font-size: 8px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.bs-msg-agent-label .bs-agent-name {
    font-size: 10px; font-weight: 600;
}
.bs-msg-agent-label .bs-agent-role {
    font-size: 9px; color: var(--bs-text-muted);
}

/* Multi-agent: participants bar */
.bs-participants-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-bottom: 1px solid var(--bs-border);
    flex-shrink: 0; overflow-x: auto;
}
.bs-participants-bar::-webkit-scrollbar { height: 0; }
.bs-participant-label { font-size: 9px; color: var(--bs-text-muted); }
.bs-participant-pill {
    display: flex; align-items: center; gap: 3px;
    padding: 2px 8px 2px 4px; border-radius: 10px;
    font-size: 9px; font-weight: 500; flex-shrink: 0;
}
.bs-participant-pill .bs-part-av {
    width: 14px; height: 14px; border-radius: 50%;
    font-size: 7px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* Expand chat button */
.bs-expand-btn {
    width: auto; height: auto; font-size: 11px; padding: 3px 8px;
    border: 1px solid var(--bs-border); color: var(--bs-text-muted);
    background: none; letter-spacing: 1px;
}
.bs-expand-btn.active {
    background: rgba(196,120,90,0.1); border-color: rgba(196,120,90,0.3);
    color: #C4785A;
}

/* Visual toggle button */
#bs-slideout-visual-toggle {
    width: auto; height: auto; font-size: 9px; padding: 3px 8px;
    border: 1px solid var(--bs-border); color: var(--bs-text-muted);
    background: none;
}
#bs-slideout-visual-toggle.active {
    background: var(--bs-visual-soft); border-color: var(--bs-visual-border);
    color: var(--bs-visual);
}

/* ⋯ menu button */
.bs-slideout-menu-wrap > .bs-slideout-hdr-btn {
    width: auto; height: auto; border: 1px solid var(--bs-border);
    border-radius: 6px; padding: 4px 8px; font-size: 12px; line-height: 1;
}
.bs-slideout-menu-wrap:has(.bs-slideout-menu.open) > .bs-slideout-hdr-btn {
    background: var(--bs-surface);
}

/* Feature review modal */
/* ── Execution Plan Modal (two-panel) ── */
.feature-review-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.82);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.15s ease;
    backdrop-filter: blur(6px);
}

.fr-modal {
    background: #1a1b2e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    width: 780px;
    max-width: 95vw;
    height: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255,255,255,0.05);
    overflow: hidden;
    animation: modalSlideIn 0.2s ease;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.fr-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
}
.fr-header-top {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.fr-header-label {
    font-size: 11px; color: #6e7191; font-weight: 700;
    letter-spacing: 0.8px; text-transform: uppercase; margin: 0;
}
.fr-badge {
    background: rgba(196,120,90,0.12); color: #a5b4fc;
    font-size: 11px; padding: 4px 12px; border-radius: 20px; font-weight: 600;
    border: 1px solid rgba(196,120,90,0.15);
}
.fr-feature-name {
    font-size: 18px; color: #eef0ff; font-weight: 600;
    margin-bottom: 6px; outline: none; line-height: 1.3;
    border-radius: 4px; padding: 2px 4px; margin-left: -4px;
}
.fr-feature-name:hover { background: rgba(255,255,255,0.04); }
.fr-feature-name:focus { background: rgba(196,120,90,0.1); box-shadow: 0 0 0 2px rgba(196,120,90,0.15); }
.fr-feature-desc {
    font-size: 13px; color: #8b8fb0; line-height: 1.55;
    outline: none; border-radius: 4px; padding: 2px 4px; margin-left: -4px;
}
.fr-feature-desc:hover { background: rgba(255,255,255,0.04); }
.fr-feature-desc:focus { background: rgba(196,120,90,0.1); box-shadow: 0 0 0 2px rgba(196,120,90,0.15); }

/* Body - two panel */
.fr-body { display: flex; flex: 1; overflow: hidden; }

/* Left panel - task list */
.fr-task-list {
    width: 250px;
    border-right: 1px solid rgba(255,255,255,0.06);
    overflow-y: auto;
    padding: 6px 0;
    flex-shrink: 0;
    background: rgba(0,0,0,0.12);
}
.fr-task-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px;
    cursor: pointer;
    transition: all 0.1s;
    border-left: 3px solid transparent;
    user-select: none;
}
.fr-task-item:hover { background: rgba(255,255,255,0.035); }
.fr-task-item.active {
    background: rgba(196,120,90,0.1);
    border-left-color: #818cf8;
}
.fr-task-num {
    width: 20px; height: 20px;
    border-radius: 5px;
    background: rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: #6e7191; font-weight: 700;
    flex-shrink: 0;
}
.fr-task-item.active .fr-task-num { background: rgba(196,120,90,0.25); color: #c7d2fe; }
.fr-task-item input[type="checkbox"] {
    accent-color: #818cf8;
    width: 14px; height: 14px; flex-shrink: 0; cursor: pointer;
}
.fr-task-title-text {
    font-size: 12.5px; color: #A0A0A8; line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.fr-task-item.active .fr-task-title-text { color: #dde0f2; font-weight: 500; }

/* Right panel - detail */
.fr-detail {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}
.fr-detail-section { margin-bottom: 18px; }
.fr-detail-label {
    font-size: 10px; font-weight: 700; color: #5a5e80;
    text-transform: uppercase; letter-spacing: 0.7px;
    margin-bottom: 8px;
}
.fr-detail-title {
    font-size: 16px; color: #eef0ff; font-weight: 600;
    margin-bottom: 18px; line-height: 1.3;
    outline: none; border-radius: 6px; padding: 4px 6px; margin-left: -6px;
}
.fr-detail-title:hover { background: rgba(255,255,255,0.04); }
.fr-detail-title:focus { background: rgba(196,120,90,0.1); box-shadow: 0 0 0 2px rgba(196,120,90,0.15); }
.fr-detail-desc {
    font-size: 13px; color: #a0a4c4; line-height: 1.7;
    background: rgba(255,255,255,0.025);
    border-radius: 10px;
    padding: 14px 16px;
    border: 1px solid rgba(255,255,255,0.05);
    outline: none; white-space: pre-wrap;
}
.fr-detail-desc:focus {
    border-color: rgba(196,120,90,0.3);
    background: rgba(196,120,90,0.06);
    box-shadow: 0 0 0 2px rgba(196,120,90,0.1);
}

/* Test chips */
.fr-test-chips { display: flex; flex-direction: column; gap: 5px; }
.fr-test-chip {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 7px 11px;
    background: rgba(52,211,153,0.04);
    border-radius: 8px;
    border: 1px solid rgba(52,211,153,0.08);
    transition: all 0.1s;
}
.fr-test-chip:hover { background: rgba(52,211,153,0.07); border-color: rgba(52,211,153,0.12); }
.fr-test-chip input[type="checkbox"] {
    accent-color: #34d399;
    margin-top: 2px;
    width: 13px; height: 13px;
    flex-shrink: 0; cursor: pointer;
}
.fr-test-chip span {
    font-size: 12.5px; color: #98a0bf; line-height: 1.45;
}

/* Footer */
.fr-footer {
    padding: 14px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
}
.fr-footer-left { font-size: 12px; color: #6e7191; }
.fr-footer-left strong { color: #a5b4fc; }
.fr-footer-right { display: flex; gap: 10px; }
.fr-btn {
    padding: 9px 22px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.fr-btn-cancel { background: rgba(255,255,255,0.06); color: #A0A0A8; }
.fr-btn-cancel:hover { background: rgba(255,255,255,0.1); color: #EAEAED; }
.fr-btn-confirm {
    background: linear-gradient(135deg, #C4785A, #A8623F);
    color: white; font-weight: 600;
    box-shadow: 0 2px 12px rgba(196,120,90,0.3);
}
.fr-btn-confirm:hover { box-shadow: 0 4px 20px rgba(196,120,90,0.4); transform: translateY(-1px); }
.fr-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }


/* TL panel brainstorm button */
.tl-brainstorm-btn-row {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tl-brainstorm-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, rgba(167,139,250,0.1), rgba(96,165,250,0.08));
    border: 1px dashed rgba(167,139,250,0.3);
    border-radius: 8px;
    color: #DE9474;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.tl-brainstorm-btn:hover {
    background: linear-gradient(135deg, rgba(167,139,250,0.15), rgba(96,165,250,0.12));
    border-color: #DE9474;
}

/* === Brainstorm Threads (Slack-style inline replies) === */
.bs-msg { position: relative; }

.bs-thread-reply-btn {
    opacity: 0; position: absolute; right: -6px; bottom: -6px;
    background: #1e1e28; border: 1px solid rgba(255,255,255,0.1);
    color: var(--bs-text-muted, #666); cursor: pointer; font-size: 11px;
    padding: 2px 6px; border-radius: 6px; transition: opacity 0.15s;
    z-index: 2; line-height: 1.3;
}
.bs-msg:hover .bs-thread-reply-btn { opacity: 0.7; }
.bs-thread-reply-btn:hover { opacity: 1 !important; background: rgba(255,255,255,0.08); color: var(--bs-text, #ddd); }
.bs-msg-user .bs-thread-reply-btn { right: auto; left: -6px; }

.bs-thread-indicator {
    display: flex; align-items: center; gap: 6px;
    margin-left: 36px; padding: 2px 0; cursor: pointer;
}
.bs-thread-line {
    width: 2px; height: 14px; background: rgba(196,120,90,0.25); border-radius: 1px; flex-shrink: 0;
}
.bs-thread-count {
    font-size: 11px; color: var(--bs-accent, #C4785A); font-weight: 600;
    transition: color 0.15s;
}
.bs-thread-indicator:hover .bs-thread-count { text-decoration: underline; color: var(--bs-text, #ddd); }

.bs-thread-container {
    display: none; margin-left: 36px; padding-left: 12px;
    border-left: 2px solid rgba(196,120,90,0.2);
    margin-top: 4px; margin-bottom: 8px;
}
.bs-thread-container.open { display: block; }

.bs-thread-replies {
    display: flex; flex-direction: column; gap: 8px; padding: 6px 0;
}
.bs-thread-msg .bs-msg-bubble { font-size: 12.5px; max-width: 85%; }
.bs-thread-avatar { width: 20px !important; height: 20px !important; font-size: 10px !important; }

.bs-thread-collapse-btn {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px; color: var(--bs-text-muted, #666); cursor: pointer;
    padding: 2px 0; border: none; background: none; font-family: inherit;
    transition: color 0.15s;
}
.bs-thread-collapse-btn:hover { color: var(--bs-text, #ddd); }

.bs-thread-input-area { padding: 4px 0; }
.bs-thread-input-wrap {
    display: flex; align-items: center; gap: 4px; cursor: text;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px; padding: 2px 2px 2px 10px;
}
.bs-thread-input {
    flex: 1; background: none; border: none; color: var(--bs-text, #ddd); cursor: text;
    font-size: 12px; font-family: inherit; outline: none; padding: 5px 4px;
    min-height: 20px; max-height: 80px; overflow-y: auto; word-break: break-word;
}
.bs-thread-input:empty::before {
    content: attr(data-placeholder); color: var(--bs-text-muted, #666);
    pointer-events: none;
}
.bs-thread-input .bs-input-mention {
    display: inline-flex; align-items: center;
    padding: 1px 5px; border-radius: 4px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap; vertical-align: baseline;
    user-select: all; cursor: default;
}
.bs-thread-send {
    width: 24px; height: 24px; border: none; border-radius: 50%;
    background: var(--bs-accent, #C4785A); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    opacity: 0.8; transition: opacity 0.15s;
}
.bs-thread-send:hover { opacity: 1; }

/* === Brainstorm Hub === */
#view-brainstorm.top-view.active {
    flex-direction: column;
    height: calc(100vh - 42px);
    margin-top: 42px;
    overflow-y: auto;
    background: #1e1e22;
}
.bshub-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 32px 16px; flex-shrink: 0; }
.bshub-header h2 { margin: 0; font-size: 22px; color: var(--text-primary); }
.bshub-filters { display: flex; gap: 8px; padding: 0 32px 16px; flex-shrink: 0; }
.bshub-filter { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-muted); padding: 6px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; transition: all .15s; }
.bshub-filter:hover { color: var(--text-secondary); border-color: var(--border-light); }
.bshub-filter.active { background: #C4785A; color: #fff; border-color: #C4785A; }
.bshub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; padding: 8px 32px 32px; }
.bshub-card { background: var(--sc-bg); border: 1.5px solid var(--sc-border); border-radius: 10px; cursor: pointer; transition: all .2s; display: flex; flex-direction: column; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.bshub-card:hover { transform: translateY(-3px) rotate(-0.3deg); box-shadow: 0 8px 24px rgba(0,0,0,0.3); border-color: var(--sc-accent); }
.bshub-card-pin { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--sc-bg); z-index: 1; }
.bshub-card-body { padding: 18px 20px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.bshub-card-title { font-size: 16px; font-weight: 700; color: var(--text-primary); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bshub-card-summary { font-size: 12px; color: var(--sc-accent); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-style: italic; opacity: 0.65; }
.bshub-card-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); opacity: 0.6; margin-top: auto; }
.bshub-card-dot { font-size: 8px; }
.bshub-card-status { margin-left: auto; font-size: 10px; font-weight: 600; color: var(--sc-accent); opacity: 0.7; letter-spacing: 0.3px; }
.bshub-card-actions { display: flex; gap: 6px; padding: 6px 20px 14px; opacity: 0; transition: opacity 0.15s; }
.bshub-card:hover .bshub-card-actions { opacity: 1; }
.bshub-action { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 11px; padding: 2px 6px; border-radius: 4px; transition: all .15s; }
.bshub-action:hover { color: var(--sc-accent); background: rgba(255,255,255,0.05); }
.bshub-action-danger:hover { color: var(--red); background: rgba(248,113,113,.08); }
.bshub-empty { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 15px; }
.bshub-card-new { background: transparent; border: 2px dashed var(--border); box-shadow: none; display: flex; align-items: center; justify-content: center; min-height: 120px; }
.bshub-card-new:hover { background: rgba(255,255,255,0.03); border-color: var(--text-muted); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.bshub-card-new-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; }
.bshub-card-new-icon { font-size: 28px; color: var(--text-muted); line-height: 1; transition: color .2s; }
.bshub-card-new-label { font-size: 13px; color: var(--text-muted); font-weight: 500; transition: color .2s; }
.bshub-card-new:hover .bshub-card-new-icon,
.bshub-card-new:hover .bshub-card-new-label { color: var(--text-secondary); }

/* Brainstorm node entrance animation */
.bs-node-new {
    animation: bsNodeAppear 0.5s ease-out;
}
@keyframes bsNodeAppear {
    0% { opacity: 0; transform: scale(0.7); }
    100% { opacity: 1; transform: scale(1); }
}

/* Selected node styling handled inline by JS */

/* ============================================
   SETTINGS VIEW (st- prefix)
   ============================================ */
#view-settings {
    background: #1A1A1E; width: 100%;
    height: calc(100vh - 42px); overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: #35343B transparent;
}
.st-layout {
    width: 100%; min-height: 100%; background: #1A1A1E;
    display: flex; justify-content: center;
}
.st-page {
    width: 100%; max-width: 640px; padding: 56px 36px 80px;
}
.st-back {
    background: none; border: none; cursor: pointer; font-family: inherit;
    color: #928B7E; font-size: 13px; padding: 0; margin-bottom: 18px;
    display: inline-flex; align-items: center; gap: 4px; transition: color 0.12s;
}
.st-back:hover { color: #C4785A; }
.st-header {
    margin-bottom: 36px;
}
.st-title {
    font-size: 20px; font-weight: 800; color: #EAEAED; letter-spacing: -0.5px; margin-bottom: 4px;
}
.st-subtitle {
    font-size: 13px; color: #736C60;
}

/* Sections */
.st-section { margin-bottom: 36px; }
.st-section-label {
    font-size: 10px; font-weight: 700; color: #736C60;
    letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px;
}

/* Defaults section — default model + default agent reference */
.st-default-card {
    padding: 16px 18px; background: #222228; border: 1px solid #35343B;
    border-radius: 12px; margin-bottom: 12px;
}
.st-default-row { display: flex; align-items: center; gap: 14px; }
.st-default-text { flex: 1; min-width: 0; }
.st-default-title { font-size: 13px; font-weight: 600; color: #EAEAED; }
.st-default-sub { font-size: 11.5px; color: #736C60; margin-top: 2px; line-height: 1.4; }
.st-select {
    background: #1A1A1E; color: #EAEAED; border: 1px solid #403F48; flex-shrink: 0;
    border-radius: 8px; padding: 8px 10px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.st-select:focus { outline: none; border-color: rgba(196,120,90,0.4); }
.st-house-mark {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
    color: #C4785A; background: rgba(196,120,90,0.10); border: 1.5px solid rgba(196,120,90,0.30);
}
.st-defaults-hint { font-size: 12px; color: #928B7E; font-style: italic; }

/* Account card */
.st-account-card {
    display: flex; align-items: center; gap: 18px;
    padding: 22px 24px; background: #222228; border: 1px solid #35343B; border-radius: 12px;
}
.st-avatar {
    width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
    background: linear-gradient(135deg, #C4785A20, #C490D015);
    border: 2px solid #C4785A20;
    display: flex; align-items: center; justify-content: center;
}
.st-avatar-initials {
    font-size: 20px; font-weight: 800; color: #C4785A;
}
.st-account-info { flex: 1; min-width: 0; }
.st-account-name { font-size: 15px; font-weight: 700; color: #EAEAED; margin-bottom: 2px; }
.st-account-email { font-size: 12px; color: #736C60; }
.st-account-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Provider cards */
.st-provider-card {
    background: #222228; border: 1px solid #35343B; border-radius: 12px;
    padding: 16px 20px; margin-bottom: 8px; transition: all 0.15s;
}
.st-provider-card:hover { border-color: #45444B; }
.st-provider-card.connected { border-color: #7BC4A822; }
.st-provider-card.connected:hover { border-color: #7BC4A833; }
.st-provider-row {
    display: flex; align-items: center; gap: 14px;
}
.st-provider-icon {
    font-size: 18px; width: 38px; height: 38px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
}
.st-provider-info { flex: 1; min-width: 0; }
.st-provider-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.st-provider-name { font-size: 13px; font-weight: 600; color: #EAEAED; }
.st-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.st-status-dot.active { background: #7BC4A8; box-shadow: 0 0 8px #7BC4A860; }
.st-status-dot.inactive { background: #55555580; }
.st-status-dot.failed { background: #E06C75; box-shadow: 0 0 8px #E06C7560; }
.st-provider-detail {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.st-masked-key {
    font-family: var(--mono); font-size: 11px; color: #928B7E; letter-spacing: 0.3px;
}
.st-no-key { font-size: 11px; color: #736C60; }
.st-env-badge {
    font-size: 10px; color: #7BC4A8; background: #7BC4A80F;
    padding: 2px 8px; border-radius: 4px; font-weight: 500;
    border: 1px solid #7BC4A820;
}

/* Provider actions */
.st-provider-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Inline edit row */
.st-provider-edit-row {
    display: flex; align-items: center; gap: 8px;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid #35343B;
}
.st-key-input {
    flex: 1; padding: 9px 12px; border-radius: 8px;
    border: 1px solid #35343B; background: #1A1A1E; color: #EAEAED;
    font-family: var(--mono); font-size: 12px; outline: none;
    transition: border-color 0.15s; letter-spacing: 0.3px;
}
.st-key-input:focus { border-color: #C4785A; }
.st-key-input::placeholder { color: #736C60; }

/* Buttons */
.st-btn {
    font-size: 11px; font-weight: 500; font-family: var(--font);
    padding: 6px 14px; border-radius: 7px; cursor: pointer;
    border: 1px solid #35343B; background: transparent; color: #B8B0A4;
    transition: all 0.12s; white-space: nowrap;
}
.st-btn:hover { background: #302F36; color: #EAEAED; border-color: #45444B; }
.st-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.st-btn:disabled:hover { background: transparent; color: #B8B0A4; border-color: #35343B; }
.st-btn-accent {
    background: #C4785A; border-color: #C4785A; color: #fff; font-weight: 600;
}
.st-btn-accent:hover { background: #D4886A; border-color: #D4886A; }
.st-btn-save {
    background: #7BC4A818; border-color: #7BC4A840; color: #7BC4A8; font-weight: 600;
}
.st-btn-save:hover { background: #7BC4A828; }
.st-test-ok { color: #7BC4A8 !important; border-color: #7BC4A844 !important; }
.st-test-fail { color: #E06C75 !important; border-color: #E06C7544 !important; }
.st-test-error {
    font-size: 11px; color: #E06C75; margin-top: 10px; padding: 0 2px;
    display: flex; align-items: center; gap: 6px;
}
.st-test-error svg { flex-shrink: 0; }

/* Coming soon */
.st-coming-soon {
    border-style: dashed; background: transparent;
}
.st-coming-soon:hover { background: #222228; border-color: #45444B; }
.st-coming-soon-label { font-size: 11px; color: #736C60; font-style: italic; margin-left: 6px; }

/* Security note */
.st-security-note {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 14px 18px; background: #2C2C33; border: 1px solid #35343B;
    border-radius: 10px; font-size: 12px; color: #736C60; line-height: 1.6;
}
.st-security-note svg { flex-shrink: 0; margin-top: 1px; color: #736C60; }

/* Loading / error */
.st-loading { text-align: center; color: #736C60; padding: 80px 0; font-size: 13px; }
.st-error { color: #E06C75; padding: 40px; text-align: center; font-size: 13px; }

/* Streaming cursor */
.bs-typing-cursor {
    display: inline; color: #7B93DB; animation: blink-cursor 0.8s step-end infinite; font-weight: 300;
}
@keyframes blink-cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }


/* =====================================================
   KNOWLEDGE WIKI
   ===================================================== */

#view-wiki {
    /* column direction makes the child .wk-layout stretch to full width (cross
       axis), like #view-agents. Without it, .wk-layout sizes to its content and
       parks left — which left the wiki content visibly off-center. */
    flex-direction: column;
    background: #1A1A1E;
    height: calc(100vh - 42px);
    margin-top: 42px;
    overflow: hidden;
}
.wk-layout {
    display: flex;
    height: 100%;
    background: #1A1A1E;
}

/* --- Sidebar --- */
.wk-sidebar {
    width: 230px;
    flex-shrink: 0;
    border-right: 1px solid #26262D;
    background: #18181C;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.wk-sidebar-header {
    padding: 16px 14px 10px;
    border-bottom: 1px solid #26262D;
}
.wk-sidebar-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
    color: #5a5a68;
    margin-bottom: 10px;
    padding-left: 4px;
}
.wk-search-wrap { position: relative; }
.wk-search-input {
    width: 100%;
    padding: 7px 10px;
    background: #222228;
    border: 1px solid #2C2C33;
    border-radius: 7px;
    color: #C6C1B4;
    font-size: 12px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}
.wk-search-input:focus { border-color: #8BA4D4; }
.wk-search-input::placeholder { color: #55555f; }

.wk-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px 12px;
    scrollbar-width: thin;
    scrollbar-color: #2C2C33 transparent;
}

.wk-ideas-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    cursor: pointer;
    margin-bottom: 8px;
    border: 1px solid transparent;
    position: relative;
    transition: background 0.12s;
}
.wk-ideas-item:hover { background: rgba(212,168,83,0.05); }
.wk-ideas-item.active {
    background: rgba(212,168,83,0.07);
    border-color: rgba(212,168,83,0.22);
}
.wk-ideas-icon {
    font-size: 13px;
    color: #D4A853;
    width: 18px;
    text-align: center;
}
.wk-ideas-label {
    flex: 1;
    font-size: 12px;
    color: #C6C1B4;
    font-weight: 500;
}
.wk-ideas-badge {
    background: rgba(212,168,83,0.2);
    color: #D4A853;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.wk-sidebar-divider {
    height: 1px;
    background: #26262D;
    margin: 8px 10px 10px;
}

.wk-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.4px;
    color: #5a5a68;
    padding: 0 12px 6px;
    text-transform: uppercase;
}

.wk-topic-item {
    display: block;
    padding: 9px 12px 10px;
    border-radius: 7px;
    cursor: pointer;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
    transition: background 0.12s;
}
.wk-topic-item:hover { background: rgba(139,164,212,0.05); }
.wk-topic-item.active {
    background: rgba(139,164,212,0.06);
    border-left-color: #8BA4D4;
}
.wk-topic-item.archived { opacity: 0.5; }
.wk-topic-item-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #E0D9C7;
    font-weight: 500;
    line-height: 1.4;
}
.wk-topic-item-emoji {
    font-size: 13px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}
.wk-topic-item-meta {
    font-size: 9px;
    color: #5a5a68;
    margin-top: 2px;
    padding-left: 23px;
}

.wk-sidebar-empty {
    padding: 20px 14px;
    text-align: center;
    color: #5a5a68;
    font-size: 11px;
    line-height: 1.6;
    font-style: italic;
}

.wk-sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid #26262D;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #16161a;
}
.wk-archive-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: #8a8a9a;
    cursor: pointer;
    user-select: none;
}
.wk-archive-toggle input[type="checkbox"] {
    width: 12px;
    height: 12px;
    accent-color: #8BA4D4;
}
.wk-footer-counts {
    font-size: 10px;
    color: #5a5a68;
    font-variant-numeric: tabular-nums;
}

/* --- Main article area --- */
.wk-main {
    flex: 1;
    overflow-y: auto;
    padding: 40px 48px 80px;
    scrollbar-width: thin;
    scrollbar-color: #2C2C33 transparent;
}
.wk-article {
    max-width: 680px;
    margin: 0 auto;
    color: #C6C1B4;
    font-size: 14px;
    line-height: 1.85;
}

.wk-title {
    font-family: var(--wk-serif);
    font-size: 30px;
    font-weight: 600;
    letter-spacing: 0;
    color: #EAEAED;
    margin: 0 0 4px;
    line-height: 1.25;
}
.wk-subtitle {
    font-size: 11px;
    color: #5a5a68;
    font-style: italic;
    margin-bottom: 28px;
    padding-bottom: 12px;
    border-bottom: 1px solid #26262D;
}

/* Infobox (floated right) */
.wk-infobox {
    float: right;
    width: 220px;
    margin: 0 0 18px 24px;
    background: #1E1E23;
    border: 1px solid #2C2C33;
    border-radius: 10px;
    overflow: hidden;
    font-size: 11px;
}
.wk-infobox-header {
    padding: 10px 12px;
    background: rgba(139,164,212,0.05);
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #E0D9C7;
    border-bottom: 1px solid #2C2C33;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.wk-infobox-image {
    padding: 14px 10px;
    background: #141418;
    border-bottom: 1px solid #2C2C33;
    text-align: center;
}
.wk-infobox-image img,
.wk-infobox-image svg { max-width: 100%; height: auto; }
.wk-infobox-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
}
.wk-infobox-row { display: table-row; }
.wk-infobox-row + .wk-infobox-row .wk-infobox-cell {
    border-top: 1px solid #26262D;
}
.wk-infobox-cell {
    display: table-cell;
    padding: 7px 10px;
    vertical-align: middle;
    font-size: 11px;
    line-height: 1.4;
}
.wk-infobox-key {
    width: 85px;
    font-weight: 500;
    color: #8a8a9a;
    background: rgba(139,164,212,0.02);
}
.wk-infobox-val { color: #C6C1B4; }
.wk-infobox-val.active { color: #7BC4A8; }

/* Lead paragraph */
.wk-lead {
    font-size: 14px;
    color: #C6C1B4;
    line-height: 1.85;
    margin: 0 0 20px;
}
.wk-lead strong { color: #E0D9C7; font-weight: 600; }

/* Wikilinks */
.wk-link {
    color: #8BA4D4;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(139,164,212,0.28);
    cursor: pointer;
    transition: border-color 0.12s;
}
.wk-link:hover { border-bottom-color: #8BA4D4; }
.wk-link.dim {
    color: #6a6a7a;
    border-bottom-color: rgba(106,106,122,0.3);
    border-bottom-style: dashed;
    cursor: help;
}
.wk-link.archived {
    color: #6a6a7a;
    border-bottom-color: rgba(106,106,122,0.3);
}

/* Table of contents */
.wk-toc {
    clear: left;
    max-width: 320px;
    background: #1A1A1F;
    border: 1px solid #2C2C33;
    border-radius: 8px;
    padding: 10px 16px 12px;
    margin: 8px 0 28px;
}
.wk-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: #E0D9C7;
    margin-bottom: 6px;
}
.wk-toc-toggle {
    font-size: 11px;
    color: #8BA4D4;
    cursor: pointer;
    text-decoration: none;
}
.wk-toc-toggle:hover { text-decoration: underline; }
.wk-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: wk-toc;
}
.wk-toc-list li {
    counter-increment: wk-toc;
    padding: 2px 0;
    font-size: 12px;
    color: #8BA4D4;
    cursor: pointer;
}
.wk-toc-list li::before {
    content: counter(wk-toc) " ";
    color: #5a5a68;
    font-variant-numeric: tabular-nums;
}
.wk-toc-list li:hover { text-decoration: underline; }

.wk-section-clear { clear: both; height: 0; }

/* Sections */
.wk-section {
    margin: 38px 0 14px;
    scroll-margin-top: 52px;
}
.wk-section-header {
    padding-bottom: 6px;
    border-bottom: 1px solid #2E2E36;
    margin-bottom: 14px;
}
/* Section headings get their hierarchy from a serif face + size + the rule above,
   the way a real wiki does — not from an icon bullet. Icon hidden (kept in markup
   so the per-section semantic accents stay available if we want them back). */
.wk-section-icon { display: none; }
.wk-section-title {
    font-family: var(--wk-serif);
    font-size: 20px;
    font-weight: 600;
    color: #E8E3D6;
    letter-spacing: 0;
}

.wk-prose {
    font-size: 14px;
    color: #C6C1B4;
    line-height: 1.85;
    margin: 0 0 12px;
}

/* === Entry baseline (applies to all entry types) ===
   Each entry inside a section is treated as a sub-heading + body.
   The title reads as a clear h3-style heading; the body is tightly coupled below.
*/
.wk-entry {
    margin: 18px 0 0;
}
.wk-entry + .wk-entry { margin-top: 22px; }
.wk-entry .wk-entry-title {
    font-size: 14px;
    font-weight: 600;
    color: #D8D2C4;
    line-height: 1.4;
    margin: 0 0 5px;
    letter-spacing: 0;
    display: flex;
    align-items: baseline;
    gap: 7px;
}
.wk-entry .wk-entry-body {
    font-size: 14px;
    color: #C6C1B4;
    line-height: 1.8;
    margin: 0;
}

/* Decision entries — green diamond accent */
.wk-entry-decision .wk-entry-title::before {
    content: "◆";
    color: #7BC4A8;
    font-size: 10px;
    flex-shrink: 0;
}

/* Rejected entries — red ✕ accent + strikethrough title, dimmed body */
.wk-entry-rejected { opacity: 0.85; }
.wk-entry-rejected .wk-entry-title {
    color: #C49095;
    text-decoration: line-through;
    text-decoration-color: rgba(207,110,117,0.4);
}
.wk-entry-rejected .wk-entry-title::before {
    content: "✕";
    color: #CF6E6E;
    font-size: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.wk-entry-rejected .wk-entry-body { color: #9a8a8e; }

/* Open questions — gold dashed card */
.wk-entry-question {
    padding: 14px 18px;
    background: rgba(212,168,83,0.04);
    border: 1px dashed rgba(212,168,83,0.35);
    border-radius: 8px;
}
.wk-entry-question .wk-entry-title { color: #D4A853; }
.wk-entry-question .wk-entry-title::before {
    content: "?";
    color: #D4A853;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Inspiration — purple left border, italic body */
.wk-entry-inspiration {
    padding-left: 16px;
    border-left: 2px solid rgba(196,144,208,0.3);
}
.wk-entry-inspiration .wk-entry-title { color: #C490D0; }
.wk-entry-inspiration .wk-entry-body { font-style: italic; }
.wk-entry-inspiration .wk-entry-source {
    margin-top: 4px;
    font-size: 11px;
    color: #7a7a8a;
    font-style: normal;
}

/* Concept / prose entries — clean heading + body, no decoration */
/* (uses the baseline rules above) */

/* Archived state (for individual entries when "Show archived" is on) */
.wk-entry.archived {
    opacity: 0.5;
}
.wk-entry.archived .wk-entry-title::after {
    content: "archived";
    font-size: 9px;
    font-weight: 500;
    color: #8a8a9a;
    margin-left: 8px;
    padding: 1px 6px;
    border: 1px solid #2C2C33;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* See also list */
.wk-see-also ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.wk-see-also li {
    padding: 4px 0;
    font-size: 14px;
    color: #C6C1B4;
}
.wk-see-also li::before {
    content: "•";
    color: #5a5a68;
    margin-right: 10px;
}
.wk-see-also-type {
    font-size: 11px;
    color: #5a5a68;
    margin-left: 6px;
}

/* History timeline */
.wk-history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 4px 0;
    font-size: 12px;
    color: #C6C1B4;
    line-height: 1.7;
}
.wk-history-date {
    width: 80px;
    flex-shrink: 0;
    color: #8a8a9a;
    font-weight: 500;
    font-size: 11px;
}
.wk-history-desc { flex: 1; }

/* References */
.wk-references {
    margin-top: 32px;
    padding-top: 18px;
    border-top: 1px solid #26262D;
}
.wk-references h3 {
    font-family: var(--wk-serif);
    font-size: 18px;
    font-weight: 600;
    color: #E8E3D6;
    margin: 0 0 10px;
}
.wk-references ol {
    padding-left: 20px;
    margin: 0;
    font-size: 12px;
    color: #C6C1B4;
}
.wk-references li { padding: 3px 0; }

/* Categories */
.wk-categories {
    margin-top: 24px;
    padding: 10px 14px;
    background: #1E1E23;
    border: 1px solid #2C2C33;
    border-radius: 8px;
    font-size: 11px;
    color: #8a8a9a;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.wk-categories-label {
    font-weight: 600;
    color: #5a5a68;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 10px;
}
.wk-category-pill {
    padding: 2px 9px;
    background: rgba(139,164,212,0.06);
    border: 1px solid rgba(139,164,212,0.2);
    border-radius: 4px;
    color: #8BA4D4;
    font-size: 10px;
    font-weight: 500;
}

/* Empty state */
.wk-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #5a5a68;
    padding: 40px;
}
.wk-empty-icon {
    font-size: 52px;
    opacity: 0.35;
    margin-bottom: 18px;
}
.wk-empty-title {
    font-size: 17px;
    color: #C6C1B4;
    margin-bottom: 6px;
}
.wk-empty-sub {
    font-size: 12px;
    color: #5a5a68;
    max-width: 320px;
    line-height: 1.6;
}

/* Rich empty-wiki welcome (zero topics). Warm/copper, matching the landing.
   .wk-intro is the scroll page: a hero that fills the first screen over an
   example article below. */
.wk-intro { width: 100%; }
.wk-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* Fill the first viewport (nav 42 + wk-main padding 40 top / 80 bottom),
       so the example article sits just below the fold. */
    min-height: calc(100vh - 162px);
    text-align: center;
    padding: 40px 24px;
}
.wk-welcome-mark {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #C4785A;
    background: linear-gradient(135deg, rgba(196,120,90,0.20), rgba(155,143,222,0.12));
    border: 1px solid rgba(196,120,90,0.30);
}
.wk-welcome-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: #EAEAED;
    margin: 0 0 10px;
}
.wk-welcome-sub {
    font-size: 14px;
    color: #8C8C96;
    line-height: 1.65;
    max-width: 440px;
    margin: 0 0 28px;
}
.wk-welcome-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    margin-bottom: 24px;
}
.wk-welcome-step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #B8B0A4;
}
.wk-welcome-step b { color: #EAEAED; font-weight: 600; }
.wk-step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #C4785A;
    background: rgba(196,120,90,0.14);
    border: 1px solid rgba(196,120,90,0.30);
}
.wk-welcome-ideas {
    max-width: 440px;
    text-align: left;
    padding: 14px 16px;
    margin-bottom: 28px;
    border-radius: 12px;
    background: rgba(196,120,90,0.06);
    border: 1px solid rgba(196,120,90,0.22);
}
.wk-welcome-ideas-label {
    font-size: 12px;
    font-weight: 700;
    color: #C4785A;
    letter-spacing: 0.2px;
    margin-bottom: 6px;
}
.wk-welcome-ideas-text {
    font-size: 13px;
    color: #9A938A;
    line-height: 1.6;
}
.wk-welcome-cta {
    padding: 12px 28px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: #C4785A;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: filter 0.15s, transform 0.15s;
}
.wk-welcome-cta:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* Scroll cue at the bottom of the hero — "See an example ↓" */
.wk-intro-cue {
    margin-top: 34px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    color: #7E776E;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}
.wk-intro-cue:hover { color: #C4785A; }
.wk-intro-cue-arrow { display: inline-block; animation: wkCueBounce 1.8s ease-in-out infinite; }
@keyframes wkCueBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

/* Example article zone (below the fold). */
.wk-intro-example {
    padding-top: 36px;
    margin-top: 8px;
    border-top: 1px solid #26262D;
}
.wk-intro-example-head {
    max-width: 680px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.wk-intro-example-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #C4785A;
    background: rgba(196,120,90,0.14);
    border: 1px solid rgba(196,120,90,0.30);
    padding: 3px 9px;
    border-radius: 6px;
}
.wk-intro-example-cap { font-size: 12px; color: #6E6E76; }
/* The demo reuses .wk-article verbatim; a faint ring sets it apart as a preview
   without making it look broken or off-theme. */
.wk-article-demo {
    border: 1px solid #26262D;
    border-radius: 14px;
    padding: 28px 32px;
    background: rgba(255,255,255,0.012);
}
.wk-demo-flash { animation: wkDemoFlash 1.2s ease; }
@keyframes wkDemoFlash {
    0% { background: rgba(196,120,90,0.18); }
    100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
    .wk-intro-cue-arrow { animation: none; }
    .wk-demo-flash { animation: none; }
}

/* ============== IDEAS TO EXPLORE ============== */
.wk-ideas-page {
    max-width: 680px;
    margin: 0 auto;
    color: #C6C1B4;
}
.wk-ideas-title {
    font-size: 22px;
    font-weight: 800;
    color: #EAEAED;
    margin: 0 0 4px;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.wk-ideas-subtitle {
    font-size: 11px;
    color: #5a5a68;
    font-style: italic;
    margin-bottom: 16px;
}
.wk-ideas-desc {
    font-size: 13px;
    color: #8a8a9a;
    line-height: 1.7;
    margin-bottom: 20px;
}
.wk-ideas-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #1E1E23;
    border: 1px solid #2C2C33;
    border-radius: 8px;
    font-size: 11px;
    color: #8a8a9a;
    margin-bottom: 24px;
}
.wk-ideas-refresh {
    color: #8BA4D4;
    cursor: pointer;
    font-weight: 500;
    background: none;
    border: none;
    padding: 0;
    font-size: 11px;
    font-family: var(--font);
}
.wk-ideas-refresh:hover { text-decoration: underline; }
.wk-ideas-refresh:disabled { color: #5a5a68; cursor: wait; }

.wk-pinned-label {
    font-size: 11px;
    font-weight: 700;
    color: #8a8a9a;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 6px 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.wk-proposal-card {
    background: #1E1E23;
    border: 1px dashed rgba(212,168,83,0.28);
    border-left: 3px solid rgba(212,168,83,0.45);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 14px;
}
.wk-proposal-card.pinned {
    border-style: solid;
    border-left-width: 3px;
}
.wk-proposal-card.type-novel_combination { border-left-color: rgba(196,144,208,0.5); }
.wk-proposal-card.type-contradiction { border-left-color: rgba(207,110,117,0.5); }
.wk-proposal-card.type-open_question { border-left-color: rgba(212,168,83,0.5); }
.wk-proposal-card.type-gap { border-left-color: rgba(196,120,90,0.5); }

.wk-proposal-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.wk-proposal-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.wk-proposal-badge.type-novel_combination { color: #C490D0; background: rgba(196,144,208,0.1); }
.wk-proposal-badge.type-contradiction { color: #CF6E6E; background: rgba(207,110,117,0.1); }
.wk-proposal-badge.type-open_question { color: #D4A853; background: rgba(212,168,83,0.1); }
.wk-proposal-badge.type-gap { color: #C4785A; background: rgba(196,120,90,0.1); }
.wk-proposal-confidence {
    font-size: 9px;
    font-weight: 500;
    color: #7BC4A8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.wk-proposal-confidence.medium { color: #8a8a9a; }
.wk-proposal-confidence.low { color: #6a6a7a; }
.wk-proposal-title {
    font-size: 14px;
    font-weight: 600;
    color: #E0D9C7;
    margin-bottom: 8px;
}
.wk-proposal-reasoning {
    font-size: 12px;
    color: #C6C1B4;
    line-height: 1.7;
    margin-bottom: 12px;
}
.wk-proposal-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.wk-proposal-source-pill {
    padding: 3px 10px;
    background: rgba(139,164,212,0.08);
    border: 1px solid rgba(139,164,212,0.22);
    border-radius: 12px;
    color: #8BA4D4;
    font-size: 10px;
    cursor: pointer;
    font-weight: 500;
}
.wk-proposal-source-pill:hover { background: rgba(139,164,212,0.14); }
.wk-proposal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.wk-btn {
    padding: 6px 13px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #2C2C33;
    background: transparent;
    color: #C6C1B4;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.12s;
}
.wk-btn:hover { background: #26262C; border-color: #35343B; }
.wk-btn-accent {
    background: rgba(139,164,212,0.1);
    border-color: rgba(139,164,212,0.3);
    color: #8BA4D4;
    font-weight: 600;
}
.wk-btn-accent:hover { background: rgba(139,164,212,0.16); }

.wk-attribution {
    margin-top: 40px;
    padding-top: 14px;
    border-top: 1px solid #26262D;
    font-size: 10px;
    color: #5a5a68;
    text-align: center;
    font-style: italic;
}

/* ============== CMD+K SEARCH OVERLAY ============== */
.ck-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 18vh;
}
.ck-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
}
.ck-card {
    position: relative;
    width: 480px;
    max-width: calc(100vw - 40px);
    background: #1E1E23;
    border: 1px solid #2C2C33;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
    overflow: hidden;
}
.ck-input-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #26262D;
    gap: 10px;
}
.ck-icon {
    font-size: 15px;
    color: #5a5a68;
}
.ck-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #EAEAED;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font);
}
.ck-input::placeholder { color: #5a5a68; }
.ck-esc-badge {
    padding: 2px 7px;
    background: #26262C;
    border: 1px solid #35343B;
    border-radius: 4px;
    font-size: 9px;
    color: #8a8a9a;
    font-weight: 600;
    letter-spacing: 0.6px;
}
.ck-results {
    max-height: 380px;
    overflow-y: auto;
    padding: 6px;
}
.ck-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s;
}
.ck-result:hover,
.ck-result.selected {
    background: rgba(139,164,212,0.08);
}
.ck-result-emoji {
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.ck-result-main {
    flex: 1;
    min-width: 0;
}
.ck-result-title {
    font-size: 13px;
    color: #E0D9C7;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ck-result-sub {
    font-size: 10px;
    color: #5a5a68;
    margin-top: 1px;
}
.ck-result-badge {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ck-badge-topic { background: rgba(139,164,212,0.12); color: #8BA4D4; }
.ck-badge-decision { background: rgba(123,196,168,0.12); color: #7BC4A8; }
.ck-badge-concept { background: rgba(196,144,208,0.12); color: #C490D0; }
.ck-badge-rejected { background: rgba(207,110,117,0.12); color: #CF6E6E; }
.ck-badge-question { background: rgba(212,168,83,0.12); color: #D4A853; }

.ck-empty {
    padding: 30px 20px;
    text-align: center;
    color: #5a5a68;
    font-size: 12px;
}
.ck-footer {
    padding: 8px 14px;
    border-top: 1px solid #26262D;
    font-size: 10px;
    color: #5a5a68;
    text-align: center;
    letter-spacing: 0.3px;
}

/* ============== WIKILINK HOVER PREVIEW ============== */
.wl-preview {
    position: fixed;
    z-index: 9998;
    width: 300px;
    background: #1E1E23;
    border: 1px solid #35343B;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    padding: 14px 16px;
    font-size: 12px;
    color: #C6C1B4;
    line-height: 1.6;
    pointer-events: auto;
}
.wl-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid #26262D;
    margin-bottom: 10px;
}
.wl-preview-title {
    font-size: 13px;
    font-weight: 700;
    color: #E0D9C7;
    display: flex;
    align-items: center;
    gap: 6px;
}
.wl-preview-count {
    font-size: 10px;
    color: #5a5a68;
}
.wl-preview-summary {
    font-size: 12px;
    color: #C6C1B4;
    line-height: 1.65;
    margin-bottom: 10px;
}
.wl-preview-section-label {
    font-size: 9px;
    font-weight: 700;
    color: #5a5a68;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}
.wl-preview-decisions {
    margin-bottom: 10px;
    font-size: 11px;
    color: #C6C1B4;
}
.wl-preview-decisions li {
    list-style: none;
    padding: 2px 0;
    padding-left: 12px;
    position: relative;
}
.wl-preview-decisions li::before {
    content: "◆";
    color: #7BC4A8;
    font-size: 9px;
    position: absolute;
    left: 0;
    top: 4px;
}
.wl-preview-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}
.wl-preview-chip {
    padding: 2px 7px;
    background: rgba(139,164,212,0.08);
    border-radius: 3px;
    font-size: 9px;
    color: #8BA4D4;
}
.wl-preview-open {
    display: block;
    text-align: right;
    font-size: 11px;
    color: #8BA4D4;
    cursor: pointer;
    font-weight: 500;
    padding-top: 4px;
    border-top: 1px solid #26262D;
}
.wl-preview-open:hover { text-decoration: underline; }

/* ============== KNOWLEDGE REFS IN CHAT (inline wikilinks) ============== */
.bs-chat-wikilink {
    color: #8BA4D4;
    font-weight: 500;
    border-bottom: 1px solid rgba(139,164,212,0.28);
    cursor: pointer;
    transition: border-color 0.12s;
    text-decoration: none;
}
.bs-chat-wikilink:hover { border-bottom-color: #8BA4D4; }
.bs-chat-wikilink.dim {
    color: #6a6a7a;
    border-bottom-color: rgba(106,106,122,0.3);
    border-bottom-style: dashed;
    cursor: help;
}

/* ── In-app key recovery card (inside the brainstorm chat) ── */
.bs-key-recovery {
    display: flex; align-items: center; gap: 12px; margin: 8px 0;
    padding: 12px 14px; border-radius: 12px;
    background: var(--bs-accent-soft, rgba(196,120,90,0.08));
    border: 1px solid var(--bs-accent-border, rgba(196,120,90,0.25));
}
.bs-key-recovery-icon { font-size: 18px; flex-shrink: 0; }
.bs-key-recovery-text { flex: 1; min-width: 0; }
.bs-key-recovery-title { font-size: 13px; font-weight: 600; color: var(--bs-text); }
.bs-key-recovery-sub { font-size: 11.5px; color: var(--bs-text-secondary); margin-top: 2px; line-height: 1.4; }
.bs-key-recovery-btn {
    flex-shrink: 0; padding: 8px 16px; border-radius: 8px; border: none;
    background: var(--bs-accent); color: #fff; font-size: 12.5px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: filter 0.15s;
}
.bs-key-recovery-btn:hover { filter: brightness(1.08); }

/* ── Key modal (appended to body — outside .bs-view, so hardcode the tone) ── */
.bs-key-modal-backdrop {
    /* Above the brainstorm canvas (z-index:1000) — it's appended to <body>, so a
       lower z left it trapped behind the canvas (the "Add key does nothing" bug). */
    position: fixed; inset: 0; z-index: 2200; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.bs-key-modal {
    width: 420px; max-width: 100%; border-radius: 16px; padding: 24px;
    background: #222228; border: 1px solid rgba(196,120,90,0.30);
    box-shadow: 0 24px 80px rgba(0,0,0,0.6); font-family: var(--font);
}
.bs-key-modal-title { font-size: 17px; font-weight: 800; color: #EAEAED; letter-spacing: -0.3px; }
.bs-key-modal-sub { font-size: 12px; color: #A0A0A8; line-height: 1.6; margin: 8px 0 16px; }

/* Post-signup welcome header (reuses the .bs-key-modal shell). */
.welcome-head { text-align: center; margin-bottom: 14px; }
.welcome-glyph {
    font-size: 26px; color: #C4785A; line-height: 1;
    margin: 2px 0 10px;
}
.welcome-title { font-size: 19px; font-weight: 800; color: #EAEAED; letter-spacing: -0.3px; }
.welcome-sub { font-size: 12px; color: #8FB98F; margin-top: 6px; }
.welcome-privacy { font-size: 11px; color: #6E6E76; line-height: 1.5; margin-top: 8px; }
/* Plain-language explanation of what an API key is. */
.welcome-explain {
    font-size: 12px; color: #A0A0A8; line-height: 1.65;
    border-top: 1px solid #303036; padding-top: 14px; margin-bottom: 2px;
}
/* API-key label + provider-specific "get a key" deep link on one line. */
.welcome-keyrow { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.welcome-keylink {
    font-size: 11px; font-weight: 600; color: #C4785A; text-decoration: none;
    white-space: nowrap; margin-bottom: 6px;
}
.welcome-keylink:hover { text-decoration: underline; }
.bs-key-modal-label { display: block; font-size: 11px; font-weight: 600; color: #6E6E76; margin: 12px 0 6px; }
.bs-key-modal-select, .bs-key-modal-input {
    width: 100%; background: #1A1A1E; color: #EAEAED; border: 1px solid #38383F;
    border-radius: 9px; padding: 10px 12px; font-size: 13px; font-family: inherit;
}
.bs-key-modal-select { cursor: pointer; }
.bs-key-modal-select:focus, .bs-key-modal-input:focus { outline: none; border-color: rgba(196,120,90,0.55); }
.bs-key-modal-error {
    margin-top: 12px; padding: 9px 11px; border-radius: 8px; font-size: 12px; line-height: 1.5;
    color: #E6A6A6; background: rgba(224,108,117,0.10); border: 1px solid rgba(224,108,117,0.30);
}
.bs-key-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.bs-key-modal-cancel, .bs-key-modal-go {
    padding: 9px 18px; border-radius: 9px; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: filter 0.15s, background 0.15s;
}
.bs-key-modal-cancel { background: none; border: 1px solid #38383F; color: #A0A0A8; }
.bs-key-modal-cancel:hover { background: rgba(255,255,255,0.04); }
.bs-key-modal-go { background: #C4785A; border: none; color: #fff; }
.bs-key-modal-go:hover { filter: brightness(1.08); }
.bs-key-modal-go:disabled { opacity: 0.6; cursor: default; }

/* Auth modal (.auth-*) styles moved to nav.css so both the app and the landing
   page (which doesn't load style.css) can render the sign-in modal. */

/* Settings: inline-editable account name */
.st-name-input {
    background: transparent; border: 1px solid transparent; border-radius: 6px;
    color: #EAEAED; font-family: inherit; font-size: 15px; font-weight: 600;
    padding: 3px 6px; margin-left: -6px; width: 100%; max-width: 280px; outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.st-name-input:hover { border-color: #35343B; }
.st-name-input:focus { border-color: #C4785A; background: #161619; }

/* Guest free-message cap — replaces the composer with a sign-up prompt. */
.bs-guest-limit {
    display: flex; flex-direction: column; gap: 10px; padding: 14px 16px;
}
.bs-guest-limit-text { font-size: 13px; color: #C4785A; text-align: center; }
.bs-guest-limit-btn {
    width: 100%; padding: 12px; border: none; border-radius: 10px;
    background: #C4785A; color: #fff; font-family: var(--font); font-size: 14px;
    font-weight: 600; cursor: pointer; transition: filter 0.15s;
}
.bs-guest-limit-btn:hover { filter: brightness(1.07); }
