/* platform-shell.css — Shell layout, chat, modals, cards */
/* Shared design tokens live in tokens.css (FIX-0017: single source of truth) */
/* This file adds shell-specific tokens + all component styles */

        :root {
            /* Shell-specific color tokens (not in tokens.css) */
            --color-accent-blue: #89CFF0;
            --carousel-dot-doc: var(--color-accent-blue);
            --carousel-dot-cad: #00ff00;
            --carousel-dot-slab: #84CC16;
            --carousel-dot-md: #1E3A8A;
            --color-link: #5ba3d9;
            --color-user-bubble: rgba(69, 69, 69, 0.6);
            --color-surface-elevated: #3a3a3a;
            --color-border-active: #5a5a5a;
            --color-header-bg: #111;
            /* Shell layout tokens */
            --header-height: 58px;
            --sidebar-width: 560px;
            /* Extended radii (beyond tokens.css sm/md/lg) */
            --radius-pill: 20px;
            --radius-circle: 50%;
            /* Z-index layers */
            --z-base: 1;
            --z-dropdown: 10;
            --z-header: 100;
            --z-modal-backdrop: 1999;
            --z-modal: 2000;
            --z-toast: 3000;
            --z-tooltip: 3100;
            --z-resizer: 9999;
            --z-overlay: 10000;
            /* Transition tokens */
            --transition-fast: 0.15s ease;
            --transition-medium: 0.3s ease;
            --transition-slow: 0.5s ease;
            /* Semantic colors */
            --color-focus-ring: rgba(137, 207, 240, 0.7);
            --color-backdrop: rgba(0, 0, 0, 0.3);
        }

        :root.light-mode,
        body.light-mode {
            /* Shell-specific light-mode overrides */
            --color-surface-elevated: #f3f4f6;
            --color-header-bg: #ffffff;
            --color-user-bubble: rgba(100, 100, 100, 0.7);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            scrollbar-width: thin;
            scrollbar-color: var(--color-border) var(--color-bg-secondary);
        }

        /* Utility classes */
        .u-hidden { display: none !important; }
        .u-visually-hidden {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
            background: var(--color-bg-primary);
            color: var(--color-text-primary);
            height: 100vh;
            overflow: hidden;
        }

        ::-webkit-scrollbar {
            width: 10px;
        }

        ::-webkit-scrollbar-track {
            background: var(--color-bg-secondary);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--color-border);
            border-radius: 5px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--color-border-hover);
        }

        header {
            padding: 0;
            background: var(--color-header-bg);
            border-bottom: 1px solid var(--color-border);
            height: var(--header-height);
            position: relative;
            z-index: var(--z-header);
            transition: transform 0.6s ease-in-out;
            display: flex;
            align-items: center;
        }

        header.hidden {
            transform: translateY(-100%);
        }

        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 30px;
            width: 100%;
            height: 100%;
        }

        .header-left-cluster {
            display: flex;
            align-items: center;
        }

        .logo {
            display: flex;
            flex-direction: column;
            gap: 2px;
            cursor: pointer;
            transition: opacity 0.2s;
        }

        .logo:focus-visible {
            outline: 2px solid rgba(137, 207, 240, 0.7);
            outline-offset: 4px;
            border-radius: var(--radius-sm);
        }

        .logo:hover {
            opacity: 0.8;
        }

        .logo-main {
            font-size: calc(18px + var(--font-offset, 0px));
            font-weight: 600;
        }

        .logo-sub {
            font-size: calc(9px + var(--font-offset, 0px));
            font-weight: 500;
            letter-spacing: 0.5px;
            color: var(--color-text-muted);
            cursor: pointer;
        }

        /* UX FEATURE - DO NOT REMOVE - Single pulse on load */
        .logo-sub.pulsing {
            animation: heartbeat 5s ease-in-out 1;
        }

        @keyframes heartbeat {
            0% { 
                color: var(--color-text-muted);
            }
            20% {
                color: var(--color-text-muted);
            }
            40% { 
                color: #FDB528;
            }
            100% { 
                color: var(--color-text-muted);
            }
        }

        .header-icons {
            display: flex;
            gap: 12px;
            align-items: center;
        }

        .admin-secret-btn {
            margin-left: 96px;
            background: transparent;
            border: 1px solid transparent;
            opacity: 0.08;
        }

        .admin-secret-btn:hover,
        .admin-secret-btn:focus-visible {
            opacity: 0.4;
            border-color: var(--color-border);
            background: transparent;
            color: var(--color-text-secondary);
        }

        .icon-btn {
            width: 32px;
            height: 32px;
            background: #1a1a1a;
            border: none;
            border-radius: var(--radius-circle);
            color: var(--color-text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s;
        }

        .icon-btn:hover {
            background: #2a2a2a;
            color: var(--color-accent-blue);
        }

        .icon-btn.active {
            background: rgba(137, 207, 240, 0.18);
            color: var(--color-accent-blue);
            border: 1px solid rgba(137, 207, 240, 0.4);
        }

        .icon-btn.focus-btn:hover {
            background: var(--color-border-hover);
            color: var(--color-accent-blue);
        }

        .icon-btn svg {
            width: 18px;
            height: 18px;
        }
        
        .icon-btn svg[fill="currentColor"] {
            fill: currentColor;
        }
        
        .icon-btn svg[stroke="currentColor"] {
            stroke: currentColor;
        }
        
        .icon-btn svg:not([fill]):not([stroke]):not(.icon-btn.focus-btn svg) {
            fill: currentColor;
        }

        .icon-btn.focus-btn svg {
            stroke: currentColor;
            stroke-width: 2;
            fill: none;
            transition: stroke 0.3s ease;
            width: 20px;
            height: 20px;
        }
        
        .icon-btn.focus-btn svg * {
            stroke: currentColor;
            fill: none;
        }
        
        .icon-btn.focus-btn svg *[fill="currentColor"] {
            fill: currentColor;
        }

        .icon-btn.focus-btn:hover svg {
            stroke: var(--color-accent-blue);
        }

        .icon-btn.focus-btn:active svg {
            stroke: var(--color-accent-blue);
        }

        /* Desktop Mode - Hide Main Content (Instant, No Transitions) */
        .main-content.desktop-mode-hidden {
            display: none;
        }

        .avatar {
            width: 24px;
            height: 24px;
            border-radius: var(--radius-circle);
            background: var(--color-border-hover);
            color: var(--color-text-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: calc(11px + var(--font-offset, 0px));
            font-weight: 600;
        }

        .dashboard {
            display: grid;
            grid-template-columns: var(--sidebar-width) 1fr;
            height: calc(100vh - var(--header-height));
            transition: margin 0.6s ease-in-out, height 0.6s ease-in-out;
            background: var(--color-bg-primary);
        }

        .dashboard.fullscreen {
            margin-top: calc(-1 * var(--header-height));
            height: 100vh;
        }

        .sidebar {
            background: linear-gradient(135deg, rgba(var(--color-persona), 0.06) 0%, #1e1e1e 50%);
            border-right: 2px solid var(--color-border-hover);
            display: flex;
            flex-direction: column;
            height: 100%;
            position: relative;
            min-height: 0;
            overflow: hidden;
        }

        body.light-mode .sidebar {
            background: linear-gradient(135deg, rgba(var(--color-persona), 0.06) 0%, var(--color-bg-secondary) 50%);
        }

        .sidebar.collapsed {
            min-width: 50px;
            max-width: 50px;
        }

        .sidebar.collapsed .sidebar-header,
        .sidebar.collapsed .conversation-area,
        .sidebar.collapsed .input-area,
        .sidebar.collapsed .resizer {
            display: none;
        }

        .collapse-indicator {
            display: none;
        }

        .sidebar.collapsed .collapse-indicator {
            display: flex;
            height: 100%;
            align-items: center;
            justify-content: center;
            writing-mode: vertical-rl;
            font-size: calc(11px + var(--font-offset, 0px));
            font-weight: 600;
            color: var(--color-text-secondary);
            cursor: pointer;
        }

        .resizer {
            position: absolute;
            right: -4px;
            top: 0;
            width: 8px;
            height: 100%;
            cursor: col-resize;
            z-index: var(--z-resizer);
            background: transparent;
            touch-action: none;
        }

        .resizer:hover {
            background: rgba(137, 207, 240, 0.3);
        }

        .resizer.active {
            background: rgba(137, 207, 240, 0.5);
        }

        /* Drag overlay prevents iframe/content from capturing mouse events */
        .resize-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 9998;
            cursor: col-resize;
            display: none;
        }

        .resize-overlay.active {
            display: block;
        }

        /* Disable transitions during resize for instant feedback */
        .resizing .sidebar,
        .resizing .dashboard,
        .resizing .main-content {
            transition: none !important;
        }

        /* Prevent text selection during resize */
        .resizing {
            user-select: none !important;
            -webkit-user-select: none !important;
        }

        /*
           IMPORTANT: During sidebar resize we disable pointer events only for the
           module iframe so it can't steal drag/mouse events.

           Do NOT disable pointer events for all iframes, otherwise the Preview
           Panel iframe becomes unscrollable/click-dead if the `resizing` state
           ever gets stuck.
        */
        .resizing #module-container {
            pointer-events: none !important;
        }

        .sidebar-header {
            padding: 27px 32px 32px 32px;
            border-bottom: 1px solid var(--color-border-hover);
            flex-shrink: 0;
        }

        .sidebar-title {
            font-size: calc(24px + var(--font-offset, 0px));
            font-weight: 500;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: opacity 0.6s ease-in-out;
        }

        .sidebar-title.fade-out {
            opacity: 0;
        }



        .sidebar-subtitle {
            font-size: calc(14px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
            margin-top: 6px;
        }

        .conversation-area {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 40px 32px;
            min-height: 0;
            max-height: calc(100vh - var(--header-height) - 180px);
        }

        /* Scroll-to-bottom button (like Claude) */
        .scroll-to-bottom-btn {
            position: absolute;
            bottom: 130px;
            left: 50%;
            transform: translateX(-50%) scale(0.9);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: rgba(42, 42, 42, 0.75);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: var(--color-text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease, background 0.15s ease;
            z-index: 10;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        }
        .scroll-to-bottom-btn:hover {
            background: rgba(58, 58, 58, 0.85);
            color: var(--color-text-primary);
            transform: translateX(-50%) scale(1);
        }
        .scroll-to-bottom-btn.visible {
            opacity: 1;
            visibility: visible;
            transform: translateX(-50%) scale(1);
        }
        .scroll-to-bottom-btn svg {
            width: 18px;
            height: 18px;
        }
        body.light-mode .scroll-to-bottom-btn {
            background: rgba(245, 245, 245, 0.75);
            border-color: rgba(0, 0, 0, 0.1);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }
        body.light-mode .scroll-to-bottom-btn:hover {
            background: rgba(232, 232, 232, 0.85);
        }

        .message {
            margin-bottom: 16px;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        .message.user {
            align-items: flex-end;
        }

        /* Thinking message (Haiku acknowledgment while Sonnet processes) */
        .message.thinking-message {
            opacity: 0.8;
        }
        .thinking-content {
            display: flex;
            align-items: center;
            gap: 2px;
        }
        .thinking-text {
            color: var(--color-text-secondary);
            font-style: italic;
        }
        .thinking-dots {
            display: inline-flex;
            gap: 2px;
            margin-left: 2px;
        }
        .thinking-dots span {
            animation: thinkingDot 1.4s infinite ease-in-out;
            color: var(--color-text-secondary);
        }
        .thinking-dots span:nth-child(1) { animation-delay: 0s; }
        .thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
        .thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
        @keyframes thinkingDot {
            0%, 80%, 100% { opacity: 0.3; }
            40% { opacity: 1; }
        }

        .message-label {
            font-size: calc(11px + var(--font-offset, 0px));
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--color-text-secondary);
            margin-bottom: 8px;
        }

        .message.user .message-label {
            display: none;
        }

        .message-content {
            color: var(--color-text-primary);
            line-height: 1.6;
            font-size: calc(15px + var(--font-offset, 0px));
        }

        /* Markdown styles for AI messages */
        .message-content p {
            margin: 0 0 12px 0;
        }
        /* Tighten spacing when a paragraph is directly followed by a link/video card */
        .message-content p.qb-link-card-intro {
            margin-bottom: 8px;
        }
        .message-content p:last-child {
            margin-bottom: 0;
        }
        .message-content h1, .message-content h2, .message-content h3, .message-content h4 {
            margin: 20px 0 10px 0;
            font-weight: 600;
            color: var(--color-text-primary);
        }
        .message-content h1 { font-size: calc(24px + var(--font-offset, 0px)); }
        .message-content h2 { font-size: calc(18px + var(--font-offset, 0px)); }
        .message-content h3 { font-size: calc(16px + var(--font-offset, 0px)); }
        .message-content h4 { font-size: calc(15px + var(--font-offset, 0px)); }
        .message-content h1:first-child,
        .message-content h2:first-child,
        .message-content h3:first-child,
        .message-content h4:first-child {
            margin-top: 0;
        }
        .message-content strong {
            font-weight: 600;
            color: var(--color-text-primary);
        }
        .message-content em {
            font-style: italic;
        }
        .message-content code {
            background: var(--color-bg-tertiary);
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
            font-size: calc(13px + var(--font-offset, 0px));
        }
        .message-content pre {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 12px 16px;
            margin: 12px 0;
            overflow-x: auto;
            position: relative;
        }
        .message-content pre .copy-btn {
            position: absolute;
            top: 6px;
            right: 6px;
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            border-radius: 4px;
            color: var(--color-text-muted);
            font-size: calc(10px + var(--font-offset, 0px));
            padding: 3px 6px;
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.15s;
        }
        .message-content pre:hover .copy-btn {
            opacity: 1;
        }
        .message-content pre .copy-btn:hover {
            color: var(--color-text-primary);
            border-color: var(--color-border-hover);
        }
        .message-content pre code {
            background: none;
            padding: 0;
            font-size: calc(13px + var(--font-offset, 0px));
            line-height: 1.5;
        }
        /* Chat lists: use injected bullet-container (chat.js) and disable browser markers */
        .message:not(.user) .message-content ul,
        .message:not(.user) .message-content ol {
            margin: 12px 0;
            padding-left: 0;
            list-style: none !important;
        }
        .message:not(.user) .message-content li {
            margin: 6px 0;
            display: flex;
            gap: 0.75rem;
            align-items: flex-start;
            list-style: none !important;
        }
        .message:not(.user) .message-content li::marker {
            content: none !important;
            color: transparent !important;
            display: none !important;
        }
        .message:not(.user) .message-content .bullet-container {
            flex-shrink: 0;
            min-width: 1.25rem;
            text-align: right;
            font-weight: 700;
            color: var(--color-text-primary);
            user-select: none;
        }
        .message:not(.user) .message-content .li-content {
            flex: 1;
            min-width: 0;
        }
        .message-content a {
            color: var(--color-link);
            text-decoration: none;
        }
        .message-content a:hover {
            text-decoration: underline;
        }
        .message-content hr {
            border: none;
            border-top: 1px solid var(--color-border);
            margin: 16px 0;
        }

        /* File Card in Chat */
        .file-card {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 12px 16px;
            margin: 12px 0;
            cursor: pointer;
            transition: border-color 0.15s, background 0.15s;
            max-width: 400px;
        }
        .file-card:hover {
            border-color: var(--color-border-hover);
            background: var(--color-bg-tertiary);
        }
        .file-card-title {
            font-size: calc(14px + var(--font-offset, 0px));
            font-weight: 600;
            color: var(--color-text-primary);
            margin-bottom: 4px;
        }
        .file-card-meta {
            font-size: calc(12px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            margin-bottom: 8px;
        }
        .file-card-summary {
            font-size: calc(13px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* Wrapper that right-aligns the whole todo block to the user-bubble edge */
        .qb-todo-section {
            max-width: 70%;
            margin-left: auto;
            margin-top: 0.75em;
        }

        .qb-todo-nudge {
            font-size: calc(13px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
            opacity: 0.9;
            text-align: left;
            margin-bottom: 4px;
        }

        .qb-todo-card {
            max-width: 100%;
            padding: 8px 12px 10px 12px;
            margin: 6px 0 0 0;
            cursor: default;
            position: relative;
            background: rgba(254, 243, 199, 0.06);
            border-color: rgba(254, 243, 199, 0.12);
        }
        .qb-todo-card-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 8px;
        }
        .qb-todo-card .file-card-title {
            margin: 0 0 2px 0;
            font-size: calc(13px + var(--font-offset, 0px));
            flex: 1;
        }
        .qb-todo-card-summary {
            margin-top: 2px;
            margin-bottom: 0;
            font-size: calc(13px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
            line-height: 1.45;
            padding-right: 52px;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
        }
        .qb-todo-card-detail {
            margin-top: 2px;
            margin-bottom: 0;
            font-size: calc(13px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
            line-height: 1.45;
            padding-right: 52px;
        }
        .qb-todo-card-actions {
            position: absolute;
            bottom: 10px;
            right: 12px;
        }
        .qb-todo-card-preview {
            border: 0;
            background: transparent;
            color: var(--color-text-secondary);
            font-size: calc(10px + var(--font-offset, 0px));
            cursor: pointer;
            padding: 0;
            text-decoration: none;
            white-space: nowrap;
            flex-shrink: 0;
            opacity: 0.5;
        }
        .qb-todo-card-preview:hover {
            color: var(--color-link);
            text-decoration: underline;
            opacity: 1;
        }

        /* Todo cards: solid bg in light mode (section wrapper handles alignment) */
        :root.light-mode .qb-todo-card,
        body.light-mode .qb-todo-card {
            background: var(--color-bg-secondary);
            border-color: var(--color-border);
        }

        /* QB Response Preview (first 5 lines before document card) */
        .qb-response-preview {
            margin-bottom: 12px;
            line-height: 1.5;
        }
        .qb-response-preview p {
            margin: 0 0 8px 0;
        }
        .qb-response-preview p:last-child {
            margin-bottom: 0;
        }

        .message.user .message-content {
            background: var(--color-user-bubble);
            color: rgba(224, 224, 224, 0.85);
            padding: 12px 16px;
            border-radius: 16px;
            max-width: 70%;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }

        /* Word-by-word fade-in effect for AI messages */
        .word-fade {
            opacity: 0;
            display: inline;
            transition: opacity 0.3s ease-in;
        }
        .word-fade.visible {
            opacity: 1;
        }

        .message-spacer {
            height: 8px;
        }

        /* ========================================
           SESSION FEED STYLES
           ======================================== */
        
        /* Session Divider */
        .session-divider {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px 0;
            margin: 8px 0;
        }
        
        .session-divider-line {
            flex: 1;
            height: 1px;
            background: linear-gradient(90deg, transparent, var(--color-border), transparent);
        }
        
        .session-divider-text {
            font-size: 11px;
            color: var(--color-text-muted);
            text-transform: uppercase;
            letter-spacing: 1px;
            white-space: nowrap;
        }
        
        /* Collapsed Session Block */
        .session-collapsed {
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 12px 16px;
            margin: 8px 0 32px;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .session-collapsed:hover {
            border-color: var(--color-accent-blue);
            background: rgba(137, 207, 240, 0.08);
        }
        
        .session-collapsed-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }
        
        .session-collapsed-title {
            font-size: 13px;
            font-weight: 600;
            color: var(--color-text-primary);
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .session-collapsed-meta {
            font-size: 11px;
            color: var(--color-text-muted);
        }
        
        .session-collapsed-summary {
            font-size: 12px;
            color: var(--color-text-secondary);
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .session-collapsed-expand {
            font-size: 11px;
            color: var(--color-accent-blue);
            margin-top: 8px;
        }
        
        /* Continuation Card */
        .continuation-card {
            background: linear-gradient(135deg, rgba(137, 207, 240, 0.14) 0%, rgba(96, 165, 250, 0.1) 100%);
            border: 1px solid rgba(137, 207, 240, 0.35);
            border-radius: 10px;
            padding: 16px;
            margin: 12px 0;
        }
        
        .continuation-card-header {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            font-weight: 600;
            color: var(--color-accent-blue);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 10px;
        }
        
        .continuation-card-content {
            font-size: 13px;
            color: var(--color-text-secondary);
            line-height: 1.5;
            font-style: italic;
            margin-bottom: 12px;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .continuation-card-btn {
            background: rgba(137, 207, 240, 0.2);
            color: var(--color-accent-blue);
            border: 1px solid rgba(137, 207, 240, 0.45);
            padding: 8px 16px;
            border-radius: var(--radius-sm);
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .continuation-card-btn:hover {
            background: rgba(137, 207, 240, 0.3);
            transform: translateY(-1px);
        }
        
        .continuation-card-btn.loaded {
            background: rgba(137, 207, 240, 0.24);
            color: var(--color-accent-blue);
            cursor: default;
        }

        /* Contact Card Preview */
        .contact-preview-card {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            overflow: hidden;
            margin-bottom: 16px;
        }
        .contact-preview-header {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 20px;
            background: var(--color-bg-tertiary);
            border-bottom: 1px solid var(--color-border);
        }
        .contact-preview-avatar {
            width: 64px;
            height: 64px;
            border-radius: var(--radius-circle);
            background: var(--color-bg-primary);
            border: 2px solid var(--color-border);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            font-weight: 600;
            color: var(--color-text-secondary);
            flex-shrink: 0;
            text-transform: uppercase;
        }
        .contact-preview-name-group {
            flex: 1;
            min-width: 0;
        }
        .contact-preview-name {
            font-size: calc(20px + var(--font-offset, 0px));
            font-weight: 600;
            color: var(--color-text-primary);
            margin-bottom: 4px;
        }
        .contact-preview-status {
            display: inline-block;
            font-size: 10px;
            padding: 3px 8px;
            border-radius: 4px;
            text-transform: uppercase;
            letter-spacing: 0.3px;
            font-weight: 600;
        }
        .contact-preview-status.customer { background: rgba(124, 179, 66, 0.15); color: var(--color-accent); }
        .contact-preview-status.vip { background: rgba(124, 179, 66, 0.25); color: var(--color-accent); font-weight: 700; }
        .contact-preview-status.prospect { background: var(--color-bg-tertiary); color: var(--color-text-secondary); }
        .contact-preview-status.lead { background: var(--color-bg-tertiary); color: var(--color-text-muted); }
        .contact-preview-status.vendor { background: var(--color-bg-tertiary); color: var(--color-link); }
        .contact-preview-org {
            font-size: 13px;
            color: var(--color-text-secondary);
            margin-top: 4px;
        }
        .contact-preview-body {
            padding: 20px;
        }
        .contact-preview-section {
            margin-bottom: 16px;
        }
        .contact-preview-section:last-child {
            margin-bottom: 0;
        }
        .contact-preview-label {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--color-text-muted);
            margin-bottom: 6px;
            font-weight: 600;
        }
        .contact-preview-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 0;
            color: var(--color-text-primary);
            font-size: 14px;
        }
        .contact-preview-row svg {
            width: 16px;
            height: 16px;
            color: var(--color-text-muted);
            flex-shrink: 0;
        }
        .contact-preview-row a {
            color: var(--color-accent);
            text-decoration: none;
        }
        .contact-preview-row a:hover {
            text-decoration: underline;
        }
        .contact-preview-notes {
            font-size: 13px;
            color: var(--color-text-secondary);
            line-height: 1.5;
            white-space: pre-wrap;
        }
        .contact-preview-links {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        .contact-preview-link {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            font-size: 12px;
            color: var(--color-text-secondary);
            text-decoration: none;
            transition: all 0.15s;
        }
        .contact-preview-link:hover {
            border-color: var(--color-accent);
            color: var(--color-accent);
        }
        .contact-preview-link svg {
            width: 14px;
            height: 14px;
        }
        .contact-preview-actions {
            display: flex;
            gap: 10px;
            padding: 16px 20px;
            border-top: 1px solid var(--color-border);
            background: var(--color-bg-tertiary);
        }
        .contact-preview-btn {
            padding: 10px 20px;
            border-radius: var(--radius-md);
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.15s;
            border: 1px solid var(--color-border);
            background: transparent;
            color: var(--color-text-primary);
        }
        .contact-preview-btn.primary {
            background: rgba(137, 207, 240, 0.3);
            border-color: rgba(137, 207, 240, 0.5);
        }
        .contact-preview-btn:hover {
            background: var(--color-bg-secondary);
        }
        .contact-preview-btn.primary:hover {
            background: rgba(137, 207, 240, 0.45);
        }

        .slab-preview-card {
            --slab-preview-surface: var(--color-bg-secondary);
            --slab-preview-shell: #141414;
            background: var(--slab-preview-shell);
            border: 1px solid var(--color-border);
            border-radius: 10px;
            padding: 12px;
            margin-top: 12px;
            display: grid;
            gap: 12px;
        }
        body.light-mode .slab-preview-card {
            --slab-preview-surface: var(--color-bg-tertiary);
            --slab-preview-shell: var(--color-bg-secondary);
        }
        .slab-preview-toolbar {
            display: flex;
            align-items: flex-end;
            gap: 12px;
            padding: 12px 16px 10px;
            background: var(--slab-preview-surface);
            border-radius: 8px;
        }
        .slab-preview-toolbar-info {
            flex: 1;
            min-width: 0;
            padding-top: 6px;
        }
        .slab-preview-toolbar-name {
            font-size: calc(18px + var(--font-offset));
            font-weight: 600;
            color: var(--color-text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .slab-preview-toolbar-meta {
            margin-top: 3px;
            font-size: calc(12px + var(--font-offset));
            color: var(--color-text-secondary);
        }
        .slab-preview-toolbar-uid {
            font-weight: 600;
            color: var(--color-text-primary);
        }
        .slab-preview-toolbar-right {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            justify-content: flex-end;
            gap: 6px;
            min-width: 140px;
        }
        .slab-preview-status-pill {
            padding: 6px 10px;
            border-radius: 6px;
            font-size: calc(12px + var(--font-offset));
            border: 1px solid var(--color-border);
            background: var(--slab-preview-surface);
            color: var(--color-text-primary);
            font-weight: 600;
        }
        .slab-preview-status-pill.on-hold {
            color: var(--color-warning);
        }
        .slab-preview-status-pill.consumed {
            color: var(--color-text-muted);
        }
        .slab-preview-hold-note {
            font-size: 11px;
            color: var(--color-warning);
            text-align: right;
            white-space: nowrap;
            max-width: 220px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .slab-preview-pricing {
            display: flex;
            gap: 16px;
            padding: 12px 16px;
            background: var(--slab-preview-surface);
            border-radius: 8px;
            justify-content: space-between;
            align-items: center;
        }
        .slab-preview-pricing-items {
            display: flex;
            gap: 16px;
            align-items: center;
            flex: 1;
            min-width: 0;
        }
        .slab-preview-pricing-item {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
        .slab-preview-pricing-label {
            font-size: 10px;
            color: var(--color-text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .slab-preview-pricing-value {
            font-size: calc(16px + var(--font-offset));
            font-weight: 600;
            color: var(--color-accent);
        }
        .slab-preview-pricing-value.muted {
            color: var(--color-text-secondary);
            font-weight: 400;
        }
        .slab-preview-photo-area {
            background: var(--slab-preview-surface);
            border: 1px solid var(--color-border);
            border-radius: 8px;
            padding: 10px;
        }
        .slab-preview-main-photo {
            width: 100%;
            min-height: 220px;
            border-radius: 8px;
            overflow: hidden;
            background: var(--slab-preview-surface);
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .slab-preview-photo {
            width: 100%;
            max-height: 460px;
            object-fit: cover;
            display: block;
        }
        .slab-preview-photo-empty {
            color: var(--color-text-muted);
            font-size: 13px;
        }
        .slab-preview-summary {
            font-size: 13px;
            color: var(--color-text-secondary);
            padding: 0 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .slab-preview-notes {
            border: 1px solid var(--color-border);
            border-radius: 8px;
            background: var(--slab-preview-surface);
            color: var(--color-text-secondary);
            font-size: 13px;
            line-height: 1.45;
            padding: 10px 12px;
            white-space: pre-wrap;
        }
        .slab-preview-data-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px 10px;
        }
        .slab-preview-data-row {
            display: flex;
            justify-content: space-between;
            gap: 10px;
            background: var(--slab-preview-surface);
            border: 1px solid var(--color-border);
            border-radius: 6px;
            padding: 8px 10px;
        }
        .slab-preview-data-row span {
            color: var(--color-text-muted);
            font-size: 12px;
        }
        .slab-preview-data-row strong {
            color: var(--color-text-primary);
            font-size: 12px;
            font-weight: 600;
            text-align: right;
            word-break: break-word;
        }
        
        /* Load More Sessions Button */
        .load-older-sessions {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 12px;
            margin: 8px 0;
            background: transparent;
            border: 1px dashed var(--color-border);
            border-radius: var(--radius-md);
            color: var(--color-text-muted);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
            width: 100%;
        }
        
        .load-older-sessions:hover {
            border-color: var(--color-accent-blue);
            color: var(--color-accent-blue);
            background: rgba(137, 207, 240, 0.08);
        }
        
        .load-older-sessions.loading {
            opacity: 0.5;
            cursor: wait;
        }
        
        /* Feed Context Loaded Indicator */
        .context-loaded-indicator {
            background: rgba(137, 207, 240, 0.1);
            border: 1px solid rgba(137, 207, 240, 0.35);
            border-radius: var(--radius-md);
            padding: 10px 14px;
            margin: 8px 0;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            color: var(--color-accent-blue);
        }

        .input-area {
            padding: 24px 32px;
            flex-shrink: 0;
            border-top: 1px solid var(--color-border-hover);
            margin: 0 -32px;
            padding-left: 32px;
            padding-right: 32px;
            position: relative;
        }

        /* ADR-0116: Workspace Context Pill */
        .workspace-context-pill {
            display: flex;
            align-items: center;
            gap: 6px;
            max-width: 750px;
            margin: 0 auto 6px;
            padding: 4px 12px;
            background: rgba(96, 165, 250, 0.1);
            border: 1px solid rgba(96, 165, 250, 0.3);
            border-radius: 16px;
            font-size: 12px;
            color: #60a5fa;
        }
        .workspace-pill-icon { font-size: 14px; }
        .workspace-pill-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .workspace-pill-close {
            background: none;
            border: none;
            color: #60a5fa;
            cursor: pointer;
            font-size: 16px;
            padding: 0 2px;
            line-height: 1;
            opacity: 0.6;
        }
        .workspace-pill-close:hover { opacity: 1; }
        body.light-mode .workspace-context-pill {
            background: rgba(37, 99, 235, 0.08);
            border-color: rgba(37, 99, 235, 0.25);
            color: #2563eb;
        }
        body.light-mode .workspace-pill-close { color: #2563eb; }

        /* ADR-0116: Workspace Instruction Proposal Actions */
        .workspace-instruction-actions {
            margin-top: 12px;
            padding: 10px 14px;
            background: rgba(96, 165, 250, 0.08);
            border: 1px solid rgba(96, 165, 250, 0.25);
            border-radius: 10px;
        }
        .instruction-actions-label {
            font-size: 13px;
            color: #94a3b8;
            margin-bottom: 8px;
        }
        .instruction-actions-label strong { color: #60a5fa; }
        .instruction-actions-buttons {
            display: flex;
            gap: 8px;
        }
        .instruction-action-btn {
            padding: 6px 16px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.15s ease;
        }
        .instruction-action-btn.save {
            background: rgba(96, 165, 250, 0.15);
            border: 1px solid #60a5fa;
            color: #60a5fa;
        }
        .instruction-action-btn.save:hover {
            background: rgba(96, 165, 250, 0.25);
        }
        .instruction-action-btn.edit {
            background: transparent;
            border: 1px solid rgba(148, 163, 184, 0.3);
            color: #94a3b8;
        }
        .instruction-action-btn.edit:hover {
            border-color: rgba(148, 163, 184, 0.5);
            color: #e2e8f0;
        }
        .instruction-action-btn:disabled {
            cursor: default;
            opacity: 0.7;
        }
        body.light-mode .workspace-instruction-actions {
            background: rgba(37, 99, 235, 0.06);
            border-color: rgba(37, 99, 235, 0.2);
        }
        body.light-mode .instruction-actions-label { color: #64748b; }
        body.light-mode .instruction-actions-label strong { color: #2563eb; }
        body.light-mode .instruction-action-btn.save {
            background: rgba(37, 99, 235, 0.1);
            border-color: #2563eb;
            color: #2563eb;
        }
        body.light-mode .instruction-action-btn.edit {
            border-color: rgba(100, 116, 139, 0.3);
            color: #64748b;
        }
        body.light-mode .instruction-action-btn.edit:hover {
            color: #334155;
        }

        .input-actions {
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            align-items: center;
            max-width: 750px;
            margin: 0 auto 8px;
            padding: 0 91px 0 83px;
            position: relative;
        }

        .input-actions-left {
            justify-self: start;
            display: flex;
            gap: 12px;
            align-items: center;
        }

        .input-actions-center {
            justify-self: center;
            display: flex;
            align-items: center;
        }

        .input-actions-right {
            justify-self: end;
            display: flex;
            gap: 12px;
            align-items: center;
        }

        .input-action-link {
            font-size: 9pt;
            color: var(--color-text-muted);
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            font-family: inherit;
        }

        .input-action-link:hover {
            color: var(--color-text-secondary);
        }

        /* Settings Panel - slides up from input area */
        .settings-panel {
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%) translateY(10px);
            width: 280px;
            margin-bottom: 8px;
            padding: 0 16px;
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            max-height: 0;
            overflow: hidden;
            opacity: 0;
            transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease, transform 0.25s ease;
            z-index: var(--z-header);
        }

        .settings-panel.open {
            max-height: calc(100vh - 120px);
            opacity: 1;
            padding: 16px 16px 32px 16px;
            transform: translateX(-50%) translateY(0);
            overflow-y: auto;
        }

        .settings-content {
            display: flex;
            gap: 32px;
            align-items: flex-start;
        }

        .settings-section {
            margin-bottom: 16px;
        }

        .settings-section:last-child {
            margin-bottom: 0;
        }

        .settings-label {
            font-size: calc(11px + var(--font-offset, 0px));
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--color-text-secondary);
            font-weight: 600;
            margin-bottom: 8px;
        }

        .settings-dropdown {
            position: relative;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: calc(14px + var(--font-offset, 0px));
            color: var(--color-text-primary);
            cursor: pointer;
            padding: 8px 12px;
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
        }

        .settings-dropdown:hover {
            border-color: var(--color-border-hover);
        }

        .settings-dropdown-arrow {
            font-size: calc(10px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            margin-left: auto;
        }

        .settings-dropdown-menu {
            display: none;
            position: absolute;
            left: 0;
            right: 0;
            top: 100%; /* Open downwards */
            bottom: auto;
            margin-top: 4px;
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            overflow-y: auto;
            max-height: 300px;
            z-index: var(--z-dropdown);
        }

        .settings-dropdown-menu::-webkit-scrollbar {
            width: 6px;
        }
        
        .settings-dropdown-menu::-webkit-scrollbar-track {
            background: var(--color-bg-secondary);
        }
        
        .settings-dropdown-menu::-webkit-scrollbar-thumb {
            background: var(--color-border);
            border-radius: 3px;
        }

        .settings-dropdown-menu.open {
            display: block;
        }

        .settings-dropdown-header {
            padding: 8px 12px;
            font-size: calc(11px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            background: var(--color-bg-tertiary);
            position: sticky;
            top: 0;
            border-bottom: 1px solid var(--color-border);
        }

        .settings-dropdown-item {
            padding: 10px 12px;
            font-size: calc(14px + var(--font-offset, 0px));
            color: var(--color-text-primary);
            cursor: pointer;
        }

        .settings-dropdown-item:hover {
            background: var(--color-bg-tertiary);
        }

        .settings-dropdown-item.active {
            color: var(--color-accent-blue);
            background: rgba(137, 207, 240, 0.10);
        }
        
        .settings-dropdown-item.unavailable {
            opacity: 0.4;
            pointer-events: none;
            background: rgba(0,0,0,0.2);
            cursor: not-allowed;
        }

        .settings-section.disabled {
            opacity: 0.35;
            pointer-events: none;
        }

        /* Pathary-off warning modal */
        .pathary-warn-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.6);
            z-index: 9999;
            align-items: center;
            justify-content: center;
        }
        .pathary-warn-overlay.open {
            display: flex;
        }
        .pathary-warn-card {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md, 12px);
            max-width: 380px;
            width: 90%;
            padding: 28px 24px 20px;
            text-align: center;
        }
        .pathary-warn-card h3 {
            margin: 0 0 12px;
            color: var(--color-text-primary);
            font-size: calc(16px + var(--font-offset, 0px));
        }
        .pathary-warn-card p {
            margin: 0 0 20px;
            color: var(--color-text-muted);
            font-size: calc(13px + var(--font-offset, 0px));
            line-height: 1.5;
        }
        .pathary-warn-actions {
            display: flex;
            gap: 10px;
            justify-content: center;
        }
        .pathary-warn-actions button {
            padding: 10px 20px;
            border-radius: var(--radius-sm, 8px);
            font-size: calc(13px + var(--font-offset, 0px));
            cursor: pointer;
            border: 1px solid var(--color-border);
        }
        .pathary-warn-cancel {
            background: var(--color-bg-tertiary);
            color: var(--color-text-primary);
        }
        .pathary-warn-confirm {
            background: var(--color-accent-blue);
            color: #fff;
            border-color: var(--color-accent-blue) !important;
        }

        .settings-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 0;
        }

        .settings-row-label {
            font-size: calc(13px + var(--font-offset, 0px));
            color: var(--color-text-primary);
        }

        .settings-toggle {
            position: relative;
            width: 32px;
            height: 18px;
            background: var(--color-border);
            border-radius: 9px;
            cursor: pointer;
            transition: background 0.2s;
        }

        .settings-toggle::after {
            content: '';
            position: absolute;
            width: 14px;
            height: 14px;
            background: var(--color-text-muted);
            border-radius: var(--radius-circle);
            top: 2px;
            left: 2px;
            transition: transform 0.2s, background 0.2s;
        }

        body.light-mode .settings-toggle {
            background: #d1d5db;
        }

        body.light-mode .settings-toggle::after {
            background: #ffffff;
        }

        .settings-toggle.on {
            background: var(--color-accent-blue);
        }

        body.light-mode .settings-toggle.on {
            background: var(--color-accent-blue) !important;
        }

        .settings-toggle.on::after {
            transform: translateX(14px);
            background: #fff;
        }

        .settings-pills {
            display: flex;
            gap: 8px;
        }

        .settings-pill {
            font-size: calc(12px + var(--font-offset, 0px));
            padding: 6px 12px;
            border-radius: 16px;
            color: var(--color-text-secondary);
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            cursor: pointer;
            transition: all 0.15s;
        }

        .settings-pill:hover {
            border-color: var(--color-border-hover);
            color: var(--color-text-primary);
        }

        .settings-pill.active {
            border-color: var(--color-accent-blue);
            color: var(--color-accent-blue);
        }

        .settings-pill.disabled {
            opacity: 0.4;
            pointer-events: none;
            cursor: default;
        }

        /* Settings hint text (small muted description below toggles) */
        .settings-hint {
            font-size: calc(11px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            margin-top: 4px;
        }

        .settings-row-hint {
            font-size: calc(11px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            margin-top: -4px;
            padding-left: 2px;
        }

        .settings-row-hint.mb-8 {
            margin-bottom: 8px;
        }

        /* Settings link button (full-width action button in settings panel) */
        .settings-link-button {
            width: 100%;
            padding: 8px 12px;
            background: var(--color-surface-elevated);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            color: var(--color-text-secondary);
            font-size: calc(12px + var(--font-offset, 0px));
            cursor: pointer;
            text-align: left;
        }

        .settings-link-button:hover {
            border-color: var(--color-border-hover);
            color: var(--color-text-primary);
        }

        /* Small right-aligned link inside settings sections */
        .settings-inline-link-row {
            display: flex;
            justify-content: flex-end;
            padding: 2px 0 0;
        }

        .settings-inline-link {
            font-size: calc(12px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
            font-family: inherit;
        }

        .settings-inline-link:hover {
            color: var(--color-text-secondary);
        }

        .settings-section.mb-24 {
            margin-bottom: 24px;
        }

        .settings-label-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }

        .input-wrapper {
            display: flex;
            gap: 12px;
            max-width: 750px;
            margin: 0 auto;
            padding: 0 20px;
            align-items: flex-end;
        }

        .archive-button {
            background: var(--color-border-hover);
            border: none;
            color: var(--color-text-primary);
            border-radius: var(--radius-circle);
            cursor: pointer;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
        }

        .archive-button:hover {
            background: var(--color-border);
            transform: scale(1.1);
        }

        .archive-button svg {
            width: 18px;
            height: 18px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
        }

        .input-wrapper.drag-over {
            background: rgba(100, 181, 246, 0.15);
            border: 2px dashed #64b5f6;
            border-radius: var(--radius-lg);
        }
        .attach-button {
            background: none;
            border: none;
            color: #888;
            cursor: pointer;
            padding: 8px;
            border-radius: var(--radius-circle);
            transition: color 0.2s, background 0.2s;
            flex-shrink: 0;
        }
        .attach-button:hover {
            color: #64b5f6;
            background: rgba(100, 181, 246, 0.1);
        }

        .input-field {
            flex: 1;
            background: var(--color-bg-primary);
            border: 1px solid var(--color-border-hover);
            border-radius: 24px;
            color: var(--color-text-primary);
            padding: 12px 20px;
            font-size: calc(14px + var(--font-offset, 0px));
            font-family: inherit;
            resize: none;
            height: 44px;
            max-height: 300px;
            overflow: hidden;
            overflow-y: auto;
            scrollbar-width: none;
        }

        .input-field::-webkit-scrollbar {
            display: none;
        }

        .input-field:focus {
            outline: 2px solid transparent;
        }
        .input-field:focus-visible {
            outline: 2px solid var(--color-focus-ring);
            outline-offset: 2px;
        }

        .input-field.recording {
            color: #7cb342;
        }

        .input-field.recording::placeholder {
            color: #7cb342;
        }

        .send-button {
            background: var(--color-border-hover);
            border: none;
            color: var(--color-text-primary);
            border-radius: var(--radius-circle);
            cursor: pointer;
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
        }

        .send-button:hover {
            background: var(--color-border);
        }

        .send-button.recording {
            background: rgba(124, 179, 66, 0.3);
        }

        .send-button.thinking {
            background: rgba(255, 140, 0, 0.3);
        }

        .send-button svg {
            width: 20px;
            height: 20px;
            fill: currentColor;
        }

        .main-content {
            background: var(--color-bg-primary);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-height: 0;
            position: relative;
            max-width: 100%;
        }

        .note-header {
            background: var(--color-bg-secondary);
            padding: 10px 20px;
            border-bottom: 1px solid var(--color-border-hover);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
            position: sticky;
            top: 0;
            left: 0;
            z-index: var(--z-dropdown);
        }

        .content-title {
            font-size: calc(20px + var(--font-offset, 0px));
            font-weight: 400;
        }

        .content-subtitle {
            font-size: calc(12px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
        }

        .header-btns {
            display: flex;
            gap: 6px;
        }

        .header-icon-btn {
            width: 44px;
            height: 44px;
            background: transparent;
            border: 1px solid var(--color-border-hover);
            border-radius: 5px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            cursor: pointer;
            color: var(--color-text-secondary);
            padding: 4px 2px;
            transition: all 0.2s;
        }

        .header-icon-btn:hover {
            background: transparent;
            border-color: var(--color-border-hover);
            color: var(--color-text-primary);
        }

        .header-icon-btn.active {
            background: rgba(137, 207, 240, 0.10);
            border-color: rgba(137, 207, 240, 0.35);
            color: var(--color-accent-blue);
        }

        /* ── Build-status tints (dev mental map) ── */
        /* Only visible when admin toolbar is open (body.dev-tints) */
        /* GREEN = built */
        body.dev-tints .header-icon-btn[data-module="action"],
        body.dev-tints .header-icon-btn[data-module="email"],
        body.dev-tints .header-icon-btn[data-module="files"],
        body.dev-tints .header-icon-btn[data-module="inventory"] {
            background: rgba(76, 175, 80, 0.18);
            border-color: rgba(76, 175, 80, 0.40);
        }
        /* YELLOW = in progress */
        body.dev-tints .header-icon-btn[data-module="people"],
        body.dev-tints .header-icon-btn[data-module="office"],
        body.dev-tints .header-icon-btn[data-module="media"],
        body.dev-tints .header-icon-btn[data-module="countercad"],
        body.dev-tints .header-icon-btn[data-module="maps"],
        body.dev-tints .header-icon-btn[data-module="website"] {
            background: rgba(255, 193, 7, 0.18);
            border-color: rgba(255, 193, 7, 0.40);
        }
        /* RED = not built / mockup */
        body.dev-tints .header-icon-btn[data-module="calendar"],
        body.dev-tints .header-icon-btn[data-module="projects"] {
            background: rgba(244, 67, 54, 0.18);
            border-color: rgba(244, 67, 54, 0.40);
        }
        /* Active overrides all status tints */
        .header-icon-btn.active[data-module] {
            background: rgba(137, 207, 240, 0.10);
            border-color: rgba(137, 207, 240, 0.35);
            color: var(--color-accent-blue);
        }

        .header-icon-btn svg {
            width: 16px;
            height: 16px;
            stroke: currentColor;
            stroke-width: 1.5;
            fill: none;
        }

        .header-date-icon {
            width: 16px;
            height: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: calc(13px + var(--font-offset, 0px));
            font-weight: 500;
            line-height: 1;
            letter-spacing: 0.02em;
        }

        .header-toolbar-divider {
            width: 1px;
            height: 34px;
            background: var(--color-border-hover);
            opacity: 0.8;
            margin: 0 3px;
            flex: 0 0 auto;
            transform: translateY(2px);
        }

        .icon-label {
            font-size: calc(8px + var(--font-offset, 0px));
            font-weight: 600;
            letter-spacing: 0.5px;
            opacity: 0.7;
        }

        /* Carousel - slides down under note-header */
        .carousel-wrapper {
            display: flex;
            flex-direction: column;
        }
        
        .carousel-wrapper.visible {
            display: flex;
        }
        
        .carousel {
            background: #252525;
            padding: 4px 12px;
            display: flex;
            align-items: center;
            max-height: 36px;
            overflow: hidden;
            transition: max-height 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
            border-bottom: 1px solid var(--color-border);
        }

        /* Carousel collapsed - tabs hidden, pinned tools remain */
        .carousel-wrapper.collapsed .carousel {
            max-height: 28px;
            padding: 2px 10px;
            opacity: 1;
        }

        .carousel-wrapper.collapsed .carousel-inner {
            display: none;
        }

        /* When carousel is collapsed, hide Split button as requested */
        .carousel-wrapper.collapsed #splitViewBtn {
            display: none;
        }

        .carousel-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-left: auto;
            flex: 0 0 auto;
        }

        .carousel-actions::before {
            content: none;
        }

        /* Split control in carousel: icon-only (no bordered button) */
        .carousel-actions #splitViewBtn {
            width: 26px;
            height: 26px;
            padding: 0;
            border: none;
            background: transparent;
            border-radius: var(--radius-sm);
        }

        .carousel-actions #splitViewBtn:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--color-text-primary);
        }

        .carousel-actions #splitViewBtn.active {
            background: rgba(137, 207, 240, 0.14);
            color: var(--color-accent-blue);
        }

        .carousel-actions #splitViewBtn svg {
            width: 16px;
            height: 16px;
        }

        .carousel-actions .icon-label {
            display: none;
        }
        
        /* Carousel divider - minimal click target, no visual handle */
        .carousel-divider {
            height: 4px;
            background: transparent;
            cursor: pointer;
            position: relative;
        }
        
        .carousel-divider::after {
            content: none;
        }
        
        .carousel-divider:hover {
            background: rgba(137, 207, 240, 0.12);
        }
        
        .carousel-divider:hover::after {
            content: none;
        }
        
        /* When collapsed, divider is minimal */
        .carousel-wrapper.collapsed .carousel-divider {
            height: 4px;
        }
        
        .carousel-wrapper.collapsed .carousel-divider::after {
            content: none;
        }
        
        .carousel-wrapper.collapsed .carousel-divider:hover::after {
            content: none;
        }

        /* ========== SHELL SPLIT VIEW (universal) ========== */
        .shell-split {
            display: flex;
            width: 100%;
            height: 100%;
            flex: 1 1 0;
            min-width: 0;
            min-height: 0;
        }

        .shell-split-left {
            display: flex;
            flex: 1 1 0;
            min-width: 0;
            min-height: 0;
        }

        .shell-split-left iframe {
            width: 100%;
            height: 100%;
            border: none;
        }

        .shell-split-divider {
            width: 6px;
            cursor: col-resize;
            background: transparent;
            position: relative;
            flex: 0 0 auto;
            display: none;
            user-select: none;
        }

        .shell-split-divider::before {
            content: '';
            position: absolute;
            top: 0;
            bottom: 0;
            left: 50%;
            width: 2px;
            transform: translateX(-50%);
            background: rgba(255,255,255,0.10);
            border-left: 1px solid rgba(0,0,0,0.35);
        }

        body.shell-split-resizing .shell-split-divider::before,
        .shell-split-divider:hover::before {
            background: rgba(96, 165, 250, 0.55);
        }

        body.shell-split-open .shell-split-divider {
            display: block;
        }

        .shell-split-right {
            display: none;
            flex-direction: column;
            flex: 1 1 0;
            min-width: 0;
            min-height: 0;
            border-left: 1px solid var(--color-border);
            background: var(--color-bg-primary);
        }

        body.shell-split-open .shell-split-right {
            display: flex;
        }

        .shell-split-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 10px 10px;
            background: var(--color-bg-tertiary);
            border-bottom: 1px solid var(--color-border);
            user-select: none;
        }

        /* Reuse the shared split-toolbar look (qb-split-*) inside shell */
        .qb-split-title {
            font-size: 12px;
            font-weight: 650;
            color: var(--color-text-primary);
            letter-spacing: 0.2px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .qb-split-actions {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .qb-split-tools {
            display: inline-flex;
            gap: 6px;
        }

        .qb-split-divider {
            width: 1px;
            height: 22px;
            background: var(--color-border-hover);
            opacity: 0.8;
            margin: 0 2px;
            flex: 0 0 auto;
        }

        .qb-split-toolbtn {
            width: 34px;
            height: 34px;
            background: transparent;
            border: 1px solid var(--color-border-hover);
            border-radius: var(--radius-sm);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--color-text-secondary);
            padding: 0;
        }

        .qb-split-toolbtn:hover {
            border-color: var(--color-border-hover);
            color: var(--color-text-primary);
        }

        .qb-split-toolbtn.is-active {
            background: rgba(137, 207, 240, 0.10);
            border-color: rgba(137, 207, 240, 0.35);
            color: var(--color-accent-blue);
        }

        .qb-split-toolbtn svg {
            display: block;
            width: 16px;
            height: 16px;
            stroke: currentColor;
            stroke-width: 1.5;
            fill: none;
        }

        .shell-split-iframe {
            width: 100%;
            height: 100%;
            min-height: 0;
            border: none;
            display: block;
            background: var(--color-bg-primary);
        }

        .carousel-inner {
            display: flex;
            align-items: center;
            gap: 2px;
            overflow-x: auto;
            white-space: nowrap;
            flex: 1 1 auto;
            min-width: 0;
        }

        .carousel-inner::-webkit-scrollbar {
            height: 4px;
        }

        .carousel-inner::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.15);
            border-radius: 2px;
        }

        .carousel-tab {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 4px 8px;
            background: none;
            border: none;
            color: rgba(255,255,255,0.45);
            font-size: calc(12px + var(--font-offset, 0px));
            cursor: pointer;
            transition: color 0.15s;
            flex-shrink: 0;
            user-select: none;
            -webkit-user-select: none;
        }

        .carousel-tab:hover {
            color: rgba(255,255,255,0.85);
        }

        .carousel-tab.active {
            color: #fff;
        }

        .carousel-tab-title {
            max-width: 120px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .carousel-tab-dot {
            width: 6px;
            height: 6px;
            border-radius: var(--radius-circle);
            flex-shrink: 0;
        }

        .carousel-tab-close {
            width: 16px;
            height: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 3px;
            font-size: calc(14px + var(--font-offset, 0px));
            line-height: 1;
            opacity: 0.4;
            transition: opacity 0.1s;
            background: transparent;
            border: none;
            color: inherit;
            cursor: pointer;
            padding: 0;
        }

        .carousel-tab:hover .carousel-tab-close {
            opacity: 0.6;
        }

        .carousel-tab-close:hover {
            opacity: 1 !important;
            background: rgba(255,255,255,0.1);
        }

        /* Light mode carousel */
        body.light-mode .carousel {
            background: #fff;
            border-bottom: 1px solid rgba(0,0,0,0.1);
        }
        
        body.light-mode .carousel-tab {
            color: rgba(0,0,0,0.45);
        }
        
        body.light-mode .carousel-tab:hover {
            color: rgba(0,0,0,0.85);
        }
        
        body.light-mode .carousel-tab.active {
            color: #000;
        }
        
        body.light-mode .carousel-divider:hover {
            background: rgba(137, 207, 240, 0.12);
        }

        /* Light mode header icon buttons */
        body.light-mode .header-icon-btn {
            color: var(--color-text-secondary);
        }
        
        body.light-mode .header-icon-btn:hover {
            color: var(--color-text-primary);
        }
        
        body.light-mode .header-icon-btn.active {
            background: rgba(137, 207, 240, 0.10);
            border-color: rgba(137, 207, 240, 0.35);
            color: var(--color-accent-blue);
        }
        
        body.light-mode .icon-btn {
            background: #e0e0e0;
            color: #666;
        }
        
        body.light-mode .icon-btn:hover {
            background: #d0d0d0;
            color: var(--color-accent-blue);
        }

        body.light-mode .icon-btn.active {
            background: rgba(137, 207, 240, 0.14);
            color: var(--color-accent-blue);
            border: 1px solid rgba(137, 207, 240, 0.35);
        }

        /* Light mode user message bubble - brighter text */
        body.light-mode .message.user .message-content {
            color: #fff;
        }

        /* ========== PREVIEW PANEL ========== */
        .preview-backdrop {
            position: fixed;
            inset: 0;
            background: var(--color-backdrop);
            z-index: var(--z-modal-backdrop);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.85s;
        }
        .preview-backdrop.visible {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }
        
        .preview-panel {
            position: fixed;
            top: 0;
            right: 0;
            width: 50vw;
            height: 100%;
            background: var(--color-bg-primary);
            border-left: 1px solid var(--color-border);
            z-index: var(--z-modal);
            display: flex;
            flex-direction: column;
            transform: translateX(100%);
            will-change: transform;
            transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.85s cubic-bezier(0.22, 1, 0.36, 1);
        }

        /*
            Docked preview mode
            - Used for website previews so the panel can expand “full width” up to the chat sidebar edge.
            - The left edge is set dynamically (px) from JS based on the live sidebar width.
        */
        .preview-panel.preview-docked {
            left: 0;
            right: 0;
            width: auto;
        }
        /* Wide preview mode — 2/3 width for comms admin and feed detail */
        .preview-panel.preview-wide {
            width: 66vw;
        }
        .preview-panel.visible { 
            transform: translateX(0);
            box-shadow: -4px 0 20px rgba(0,0,0,0.3);
        }
        .preview-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px;
            border-bottom: 1px solid var(--color-border);
            background: var(--color-bg-secondary);
        }
        .preview-header-left {
            flex: 1;
            min-width: 0;
            margin-right: 12px;
            display: flex;
            flex-direction: column;
            gap: 4px;
        }
        .preview-header-title {
            font-size: calc(14px + var(--font-offset, 0px));
            font-weight: 600;
            color: var(--color-text-primary);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            line-height: 1.2;
        }
        .preview-header-subtitle {
            font-size: calc(12px + var(--font-offset, 0px));
            color: var(--color-text-muted);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .preview-actions {
            display: flex;
            gap: 8px;
            align-items: center;
        }
        .preview-icon-btn {
            width: 32px;
            height: 32px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            background: var(--color-bg-tertiary);
            color: var(--color-text-primary);
            cursor: pointer;
            transition: all 0.15s;
        }
        .preview-icon-btn:hover { color: var(--color-text-primary); background: var(--color-bg-secondary); border-color: var(--color-text-muted); }
        .preview-icon-btn.danger:hover { color: #e57373; border-color: #e57373; background: rgba(229, 115, 115, 0.1); }
        .preview-icon-btn svg { width: 16px; height: 16px; stroke-width: 1.5; }
        .preview-content {
            flex: 1 1 0;
            min-height: 0;
            overflow-y: auto;
            padding: 20px;
        }

        /* QB Selection Toolbar - Claude-style text selection actions */
        .qb-selection-toolbar {
            position: fixed;
            display: none;
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 4px;
            box-shadow: 0 4px 16px rgba(0,0,0,0.3);
            z-index: var(--z-toast);
            gap: 4px;
            flex-direction: row;
            align-items: center;
        }
        .qb-selection-toolbar.visible {
            display: flex;
        }
        .qb-selection-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            border: none;
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--color-text-primary);
            font-size: 12px;
            cursor: pointer;
            white-space: nowrap;
            transition: background 0.15s;
        }
        .qb-selection-btn:hover {
            background: var(--color-bg-tertiary);
        }
        .qb-selection-btn svg {
            width: 14px;
            height: 14px;
            stroke-width: 1.5;
        }
        .qb-selection-btn.primary {
            background: #60a5fa;
            color: #fff;
        }
        .qb-selection-btn.primary:hover {
            background: #3b82f6;
        }
        .qb-selection-divider {
            width: 1px;
            height: 20px;
            background: var(--color-border);
            margin: 0 4px;
        }

        /* AI Transform Service Modal (ADR-0015) */
        .qb-transform-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: var(--z-tooltip);
            display: none;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(2px);
        }
        .qb-transform-overlay.visible {
            display: flex;
        }
        .qb-transform-modal {
            background: var(--color-bg-primary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            width: 90%;
            max-width: 500px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
            overflow: hidden;
        }
        .qb-transform-header {
            padding: 16px 20px;
            border-bottom: 1px solid var(--color-border);
        }
        .qb-transform-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--color-text-primary);
            margin: 0;
        }
        .qb-transform-subtitle {
            font-size: 12px;
            color: var(--color-text-muted);
            margin-top: 4px;
        }
        .qb-transform-presets {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            padding: 16px 20px;
            border-bottom: 1px solid var(--color-border);
        }
        .qb-transform-preset {
            padding: 8px 14px;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-pill);
            background: var(--color-bg-secondary);
            color: var(--color-text-primary);
            font-size: 13px;
            cursor: pointer;
            transition: all 0.15s;
        }
        .qb-transform-preset:hover {
            border-color: #60a5fa;
            background: rgba(96, 165, 250, 0.1);
        }
        .qb-transform-preset.selected {
            border-color: #60a5fa;
            background: #60a5fa;
            color: #fff;
        }
        .qb-transform-custom {
            padding: 16px 20px;
        }
        .qb-transform-input {
            width: 100%;
            padding: 12px;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            background: var(--color-bg-secondary);
            color: var(--color-text-primary);
            font-size: 14px;
            resize: none;
            outline: 2px solid transparent;
            min-height: 60px;
        }
        .qb-transform-input:focus {
            outline: 2px solid transparent;
        }
        .qb-transform-input:focus-visible {
            outline: 2px solid var(--color-focus-ring);
            outline-offset: 2px;
            border-color: #60a5fa;
        }
        .qb-transform-input::placeholder {
            color: var(--color-text-muted);
        }
        .qb-transform-actions {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            padding: 16px 20px;
            border-top: 1px solid var(--color-border);
            background: var(--color-bg-secondary);
        }
        .qb-transform-btn {
            padding: 10px 20px;
            border-radius: var(--radius-md);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.15s;
        }
        .qb-transform-btn.cancel {
            background: transparent;
            border: 1px solid var(--color-border);
            color: var(--color-text-primary);
        }
        .qb-transform-btn.cancel:hover {
            background: var(--color-bg-tertiary);
        }
        .qb-transform-btn.submit {
            background: #60a5fa;
            border: none;
            color: #fff;
        }
        .qb-transform-btn.submit:hover {
            background: #3b82f6;
        }
        .qb-transform-btn.submit:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Todo Proposal Modal (Two-Phase Todo Generation) */
        .qb-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.6);
            z-index: var(--z-tooltip);
            display: flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(4px);
        }
        .qb-modal-content {
            background: var(--color-bg-primary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            width: 90%;
            max-width: 480px;
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
            overflow: hidden;
        }
        .qb-modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 20px;
            border-bottom: 1px solid var(--color-border);
        }
        .qb-modal-header h3 {
            margin: 0;
            font-size: 16px;
            font-weight: 600;
            color: var(--color-text-primary);
        }
        .qb-modal-close {
            background: none;
            border: none;
            font-size: 24px;
            color: var(--color-text-muted);
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }
        .qb-modal-close:hover {
            color: var(--color-text-primary);
        }
        .qb-modal-subtitle {
            margin: 0;
            padding: 12px 20px;
            font-size: 13px;
            color: var(--color-text-secondary);
            border-bottom: 1px solid var(--color-border);
        }
        .todo-proposal-list {
            max-height: 320px;
            overflow-y: auto;
            padding: 8px 0;
        }
        .todo-proposal-item {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            padding: 12px 20px;
            cursor: pointer;
            transition: background 0.15s;
        }
        .todo-proposal-item:hover {
            background: var(--color-bg-hover);
        }
        .todo-proposal-item input[type="checkbox"] {
            margin-top: 3px;
            width: 18px;
            height: 18px;
            accent-color: var(--color-accent-blue, #89CFF0);
            cursor: pointer;
        }
        .todo-proposal-item-content {
            flex: 1;
            min-width: 0;
        }
        .todo-proposal-item-title {
            font-size: 14px;
            font-weight: 500;
            color: var(--color-text-primary);
            margin-bottom: 4px;
        }
        .todo-proposal-item-desc {
            font-size: 12px;
            color: var(--color-text-muted);
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .todo-proposal-item-badges {
            display: flex;
            gap: 6px;
            margin-top: 6px;
        }
        .todo-proposal-badge {
            font-size: 10px;
            padding: 2px 8px;
            border-radius: var(--radius-pill);
            background: var(--color-bg-tertiary);
            color: var(--color-text-secondary);
            text-transform: capitalize;
        }
        .todo-proposal-badge.priority-urgent {
            background: rgba(239, 68, 68, 0.15);
            color: #ef4444;
        }
        .todo-proposal-badge.priority-high {
            background: rgba(245, 158, 11, 0.15);
            color: #f59e0b;
        }
        .qb-modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            padding: 16px 20px;
            border-top: 1px solid var(--color-border);
            background: var(--color-bg-secondary);
        }
        .qb-modal-btn {
            padding: 10px 20px;
            border-radius: var(--radius-md);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.15s;
        }
        .qb-modal-btn.cancel {
            background: transparent;
            border: 1px solid var(--color-border);
            color: var(--color-text-primary);
        }
        .qb-modal-btn.cancel:hover {
            background: var(--color-bg-tertiary);
        }
        .todo-proposal-modal .qb-modal-btn.primary {
            background: rgba(96, 165, 250, 0.2);
            border: 1px solid rgba(96, 165, 250, 0.45);
            color: #dbeafe;
            backdrop-filter: blur(2px);
        }
        .todo-proposal-modal .qb-modal-btn.primary:hover {
            background: rgba(96, 165, 250, 0.32);
            border-color: rgba(96, 165, 250, 0.62);
        }
        .todo-proposal-modal .qb-modal-btn.primary:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .todo-proposal-action {
            margin-top: 16px;
            padding-top: 12px;
            border-top: 1px solid var(--color-border);
        }
        .todo-proposal-btn {
            background: rgba(96, 165, 250, 0.2);
            border: 1px solid rgba(96, 165, 250, 0.45);
            color: #dbeafe;
            padding: 10px 18px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
            backdrop-filter: blur(2px);
        }
        .todo-proposal-btn:hover {
            background: rgba(96, 165, 250, 0.32);
            border-color: rgba(96, 165, 250, 0.62);
        }
        .todo-proposal-btn:disabled {
            opacity: 0.6;
            cursor: default;
        }
        .todo-proposal-btn-icon {
            margin-right: 6px;
        }

        /* Inline todo proposals reuse .qb-go-link / .qb-summary-offer-done */

        /* Proactive session summary offer link */
        .qb-summary-offer {
            display: inline-block;
            margin-top: 6px;
            color: #60a5fa;
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
            transition: color 0.15s ease;
        }
        .qb-summary-offer:hover {
            color: #93c5fd;
            text-decoration: underline;
        }
        .qb-summary-offer-loading {
            color: #94a3b8;
            cursor: default;
        }
        .qb-summary-offer-done {
            color: #6ee7b7;
            cursor: default;
        }
        .qb-summary-offer-done:hover {
            color: #6ee7b7;
            text-decoration: none;
        }
        :root.light-mode .qb-summary-offer,
        body.light-mode .qb-summary-offer {
            color: #2563eb;
        }
        :root.light-mode .qb-summary-offer:hover,
        body.light-mode .qb-summary-offer:hover {
            color: #1d4ed8;
        }
        :root.light-mode .qb-summary-offer-done,
        body.light-mode .qb-summary-offer-done {
            color: #16a34a;
        }

        :root.light-mode .todo-proposal-modal .qb-modal-btn.primary,
        body.light-mode .todo-proposal-modal .qb-modal-btn.primary,
        :root.light-mode .todo-proposal-btn,
        body.light-mode .todo-proposal-btn {
            background: rgba(59, 130, 246, 0.12);
            border-color: rgba(59, 130, 246, 0.38);
            color: #1d4ed8;
        }
        :root.light-mode .todo-proposal-modal .qb-modal-btn.primary:hover,
        body.light-mode .todo-proposal-modal .qb-modal-btn.primary:hover,
        :root.light-mode .todo-proposal-btn:hover,
        body.light-mode .todo-proposal-btn:hover {
            background: rgba(59, 130, 246, 0.18);
            border-color: rgba(59, 130, 246, 0.52);
        }

        /* AI Transform Diff Preview */
        .qb-transform-preview {
            padding: 16px 20px;
            max-height: 300px;
            overflow-y: auto;
            display: none;
        }
        .qb-transform-preview.visible {
            display: block;
        }
        .qb-transform-original {
            color: var(--color-text-muted);
            text-decoration: line-through;
            opacity: 0.6;
            margin-bottom: 12px;
            padding: 12px;
            background: var(--color-bg-secondary);
            border-radius: var(--radius-md);
            font-size: 13px;
            line-height: 1.5;
        }
        .qb-transform-result {
            padding: 12px;
            background: rgba(96, 165, 250, 0.1);
            border: 1px solid rgba(96, 165, 250, 0.3);
            border-radius: var(--radius-md);
            font-size: 13px;
            line-height: 1.5;
            color: var(--color-text-primary);
            min-height: 40px;
        }
        .qb-transform-cursor {
            display: inline-block;
            width: 2px;
            height: 1em;
            background: #60a5fa;
            margin-left: 1px;
            animation: qb-cursor-blink 1s infinite;
        }
        @keyframes qb-cursor-blink {
            0%, 50% { opacity: 1; }
            51%, 100% { opacity: 0; }
        }
        .qb-transform-spinner {
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid rgba(255,255,255,0.3);
            border-top-color: #fff;
            border-radius: var(--radius-circle);
            animation: qb-spin 0.8s linear infinite;
            margin-right: 8px;
        }
        @keyframes qb-spin {
            to { transform: rotate(360deg); }
        }

        /*
            Browser viewport mode (HTML/Sites preview)
            - The iframe owns scrolling.
            - The shell must not be a competing scroll container for the preview region.
            - Flex layouts require min-height:0 on the chain so the iframe gets a real viewport.
        */
        .preview-panel.preview-viewport .preview-content {
            overflow: hidden;
            display: flex;
            flex-direction: column;
            min-height: 0;
            padding: 8px 12px 12px 12px;
        }

        /* Meta card stays visible but doesn't grow */
        .preview-panel.preview-viewport .pagent-meta-card {
            flex: 0 0 auto;
            margin-bottom: 8px;
        }

        .preview-editor {
            width: 100%;
            height: calc(100vh - 100px);
            background: var(--color-bg-primary);
            color: var(--color-text-primary);
            border: none;
            padding: 20px;
            font-family: monospace;
            font-size: 14px;
            resize: none;
            outline: 2px solid transparent;
        }
        .preview-raw-textarea:focus-visible {
            outline: 2px solid var(--color-focus-ring);
            outline-offset: -2px;
        }

        .preview-html-iframe {
            width: 100%;
            height: 100%;
            min-height: 0;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            background: var(--color-bg-secondary);
            display: block;
        }

        .preview-panel.preview-viewport .preview-html-iframe {
            flex: 1 1 0;
            min-height: 0;
            height: auto;
            border: none;
            border-radius: 0;
        }

        .preview-empty {
            color: var(--color-text-muted);
        }

        .preview-empty-block {
            padding: 40px;
            text-align: center;
            color: var(--color-text-muted);
        }

        .preview-error-block {
            padding: 40px;
            text-align: center;
            color: #e57373;
        }

        .preview-cad-clickcard {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
            background: #1a1a1a;
            border-radius: var(--radius-md);
            cursor: pointer;
        }

        .preview-cad-svg {
            width: 100%;
            max-width: 500px;
            height: auto;
            min-height: 300px;
        }

        .preview-cad-hint {
            color: #888;
            font-size: calc(12px + var(--font-offset, 0px));
            margin-top: 12px;
        }

        .preview-description {
            margin-top: 24px;
            padding-top: 16px;
            border-top: 1px solid var(--color-border);
        }

        .preview-description h2 {
            font-size: calc(16px + var(--font-offset, 0px));
            font-weight: 600;
            margin-bottom: 8px;
            color: var(--color-text-primary);
        }

        .preview-description p {
            color: var(--color-text-secondary);
            line-height: 1.5;
        }
        
        /* Pagent Metadata Card (matches files.html exactly) */
        .pagent-meta-card {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            margin-bottom: 20px;
            overflow: hidden;
        }
        .pagent-meta-header {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px 20px;
            border-bottom: 1px solid var(--color-border);
            background: var(--color-bg-tertiary);
        }
        .pagent-type-badge {
            width: 32px;
            height: 32px;
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        .pagent-type-badge svg { width: 23px; height: 23px; stroke-width: 1.5; }
        .pagent-type-badge.icon-blue { color: #3B82F6; }
        .pagent-type-badge.icon-green { color: #22C55E; }
        .pagent-type-badge.icon-purple { color: #A855F7; }
        .pagent-type-badge.icon-orange { color: #F97316; }
        .pagent-type-badge.icon-red { color: #DC2626; }
        .pagent-type-badge.icon-brown { color: #8B7355; }
        .pagent-type-badge.icon-lightblue { color: #88cffe; }
        .pagent-type-badge.icon-lime { color: #84CC16; }
        .pagent-type-badge.icon-cyan { color: #14B8A6; }
        .pagent-meta-title-group {
            display: flex;
            flex-direction: column;
            gap: 2px;
            flex: 1;
            min-width: 0;
        }
        .pagent-meta-title {
            font-size: calc(18px + var(--font-offset, 0px));
            font-weight: 600;
            color: var(--color-text-primary);
        }
        .pagent-meta-subtitle {
            font-size: calc(11px + var(--font-offset, 0px));
            color: #888;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            cursor: pointer;
            transition: color 0.15s;
        }
        .pagent-meta-subtitle:hover { color: var(--color-text-primary); }
        .pagent-hidden-reset-btn {
            width: 42px;
            height: 42px;
            border: 1px solid transparent;
            border-radius: 6px;
            background: transparent;
            color: transparent;
            opacity: 0.015;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
        }
        .pagent-hidden-reset-btn.is-locked {
            opacity: 0.09;
        }
        .pagent-meta-header:hover .pagent-hidden-reset-btn,
        .pagent-hidden-reset-btn:hover,
        .pagent-hidden-reset-btn:focus,
        .pagent-hidden-reset-btn:focus-visible {
            opacity: 0.22;
            color: var(--color-text-muted);
            border-color: var(--color-border);
            background: var(--color-bg-secondary);
            outline: none;
        }
        .pagent-hidden-reset-btn .glyph {
            font-size: 14px;
            line-height: 1;
            user-select: none;
            pointer-events: none;
        }
        .pagent-send-to-btn {
            width: 44px;
            height: 44px;
            background: transparent;
            border: 1px solid transparent;
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: #999;
            padding: 4px;
            transition: all 0.2s;
            flex-shrink: 0;
        }
        .pagent-send-to-btn.labeled {
            width: auto;
            height: auto;
            flex-direction: column;
            padding: 8px 12px;
            gap: 4px;
        }
        .pagent-send-to-btn .btn-label {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: inherit;
        }
        .pagent-send-to-btn:hover { color: var(--color-accent); }
        .pagent-send-to-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
        .pagent-panel-actions {
            display: flex;
            gap: 8px;
            margin-left: auto;
            margin-right: 8px;
        }
        .pagent-panel-btn {
            padding: 8px 16px;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .pagent-panel-btn.primary {
            background: #1a1a1a;
            color: #fff;
        }
        .pagent-panel-btn.primary:hover {
            background: #333;
        }
        .pagent-panel-btn.secondary {
            background: #e5e7eb;
            color: #374151;
        }
        .pagent-panel-btn.secondary:hover {
            background: #d1d5db;
        }
        .pagent-meta-sections {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }
        .pagent-meta-sections.expanded { max-height: 500px; }
        .pagent-meta-section {
            padding: 16px 20px;
            border-bottom: 1px solid var(--color-border);
        }
        .pagent-meta-section:last-child { border-bottom: none; }
        .pagent-meta-label {
            font-size: calc(10px + var(--font-offset, 0px));
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: var(--color-text-muted);
            margin-bottom: 8px;
        }
        .pagent-meta-value {
            font-size: calc(13px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
            line-height: 1.5;
        }

        .pagent-meta-empty {
            color: var(--color-text-muted);
            font-size: calc(12px + var(--font-offset, 0px));
        }

        .pagent-meta-empty-italic {
            color: var(--color-text-muted);
            font-style: italic;
        }

        .pagent-meta-ok {
            color: var(--color-accent);
            font-size: calc(12px + var(--font-offset, 0px));
        }
        .pagent-meta-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }
        .pagent-meta-tag {
            padding: 3px 8px;
            background: var(--color-bg-primary);
            border: 1px solid var(--color-border);
            border-radius: 4px;
            font-size: calc(11px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
        }
        .pagent-security-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
        }
        .pagent-security-item {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: calc(12px + var(--font-offset, 0px));
            color: var(--color-text-secondary);
        }
        .pagent-security-icon {
            width: 14px;
            height: 14px;
            color: var(--color-accent);
        }
        .pagent-security-icon.locked { color: var(--color-text-muted); }
        
        /* Markdown body styling */
        .markdown-body {
            font-size: calc(14px + var(--font-offset, 0px));
            line-height: 1.5;
            color: var(--color-text-primary);
        }
        .markdown-body h1 {
            margin-top: 0;
            margin-bottom: 8px;
            color: var(--color-text-primary);
        }
        .markdown-body h2, .markdown-body h3 {
            margin-top: 14px;
            margin-bottom: 8px;
            color: var(--color-text-primary);
        }
        .markdown-body a {
            color: var(--color-accent);
        }
        .markdown-body a.qb-go-link {
            color: #6ab0de;
            text-decoration: none;
            cursor: pointer;
        }
        .markdown-body a.qb-go-link:hover {
            text-decoration: underline;
        }
        .markdown-body p {
            margin: 0 0 8px 0;
        }
        .markdown-body ul, .markdown-body ol {
            margin: 0 0 8px 0;
            padding-left: 24px;
        }
        .markdown-body li {
            margin-bottom: 4px;
        }
        .markdown-body li > p {
            margin: 0;
        }

        /* CCC Warning Modal */
        .ccc-warning-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: var(--z-overlay);
            opacity: 0;
            transition: opacity 0.2s;
        }
        .ccc-warning-overlay.visible { opacity: 1; }
        .ccc-warning-modal {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 24px;
            max-width: 400px;
            text-align: center;
            transform: scale(0.95);
            transition: transform 0.2s;
        }
        .ccc-warning-overlay.visible .ccc-warning-modal { transform: scale(1); }
        .ccc-warning-icon {
            width: 48px;
            height: 48px;
            margin: 0 auto 16px;
            color: #F59E0B;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .ccc-warning-icon svg { 
            width: 48px; 
            height: 48px; 
            stroke-width: 2;
            display: block;
        }
        .ccc-warning-modal h3 {
            margin: 0 0 12px;
            color: var(--color-text-primary);
            font-size: calc(18px + var(--font-offset, 0px));
        }
        .ccc-warning-modal p {
            margin: 0 0 8px;
            color: var(--color-text-secondary);
            font-size: calc(14px + var(--font-offset, 0px));
            line-height: 1.5;
        }
        .ccc-warning-subtext {
            font-size: 12px !important;
            color: var(--color-text-muted) !important;
            margin-bottom: 20px !important;
        }
        .ccc-warning-actions {
            display: flex;
            gap: 12px;
            justify-content: center;
        }
        .ccc-warning-cancel, .ccc-warning-confirm {
            padding: 10px 20px;
            border-radius: var(--radius-sm);
            font-size: calc(14px + var(--font-offset, 0px));
            cursor: pointer;
            transition: all 0.15s;
        }
        .ccc-warning-cancel {
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            color: var(--color-text-secondary);
        }
        .ccc-warning-cancel:hover {
            background: var(--color-bg-secondary);
            border-color: var(--color-text-muted);
        }
        .ccc-warning-confirm {
            background: #F59E0B;
            border: none;
            color: #000;
            font-weight: 500;
        }
        .ccc-warning-confirm:hover {
            background: #D97706;
        }

        /* Session Choice Modal - Continue Chain vs Fresh Start */
        .session-choice-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: var(--z-overlay);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
        }
        .session-choice-overlay.visible {
            opacity: 1;
            pointer-events: auto;
        }
        .session-choice-modal {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 24px;
            max-width: 420px;
            text-align: center;
            transform: scale(0.95);
            transition: transform 0.2s;
        }
        .session-choice-overlay.visible .session-choice-modal {
            transform: scale(1);
        }
        .session-choice-icon {
            width: 48px;
            height: 48px;
            margin: 0 auto 16px;
            color: var(--color-accent);
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .session-choice-icon svg {
            width: 48px;
            height: 48px;
            stroke-width: 1.5;
        }
        .session-choice-modal h3 {
            margin: 0 0 8px;
            color: var(--color-text-primary);
            font-size: calc(18px + var(--font-offset, 0px));
        }
        .session-choice-modal p {
            margin: 0 0 20px;
            color: var(--color-text-secondary);
            font-size: calc(14px + var(--font-offset, 0px));
        }
        .session-choice-buttons {
            display: flex;
            gap: 12px;
            justify-content: center;
        }
        .session-choice-btn {
            flex: 1;
            padding: 12px 16px;
            border-radius: var(--radius-md);
            font-size: calc(14px + var(--font-offset, 0px));
            cursor: pointer;
            transition: all 0.15s;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
        }
        .session-choice-btn .btn-label {
            font-weight: 600;
        }
        .session-choice-btn .btn-desc {
            font-size: calc(11px + var(--font-offset, 0px));
            opacity: 0.7;
        }
        .session-choice-btn.continue {
            background: var(--color-accent);
            border: none;
            color: #000;
        }
        .session-choice-btn.continue:hover {
            background: #8bc34a;
        }
        .session-choice-btn.fresh {
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            color: var(--color-text-secondary);
        }
        .session-choice-btn.fresh:hover {
            background: var(--color-bg-secondary);
            border-color: var(--color-text-muted);
            color: var(--color-text-primary);
        }

        /* AI Doc Rewrite Modal */
        .ai-rewrite-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: var(--z-overlay);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
        }
        .ai-rewrite-overlay.visible {
            opacity: 1;
            pointer-events: auto;
        }
        .ai-rewrite-modal {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 24px;
            width: 90%;
            max-width: 500px;
            transform: scale(0.95);
            transition: transform 0.2s;
        }
        .ai-rewrite-overlay.visible .ai-rewrite-modal {
            transform: scale(1);
        }
        .ai-rewrite-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }
        .ai-rewrite-icon {
            width: 40px;
            height: 40px;
            color: #60a5fa;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .ai-rewrite-icon svg {
            width: 40px;
            height: 40px;
            stroke-width: 1.5;
        }
        .ai-rewrite-title {
            font-size: calc(18px + var(--font-offset, 0px));
            font-weight: 600;
            color: var(--color-text-primary);
        }
        .ai-rewrite-subtitle {
            font-size: calc(12px + var(--font-offset, 0px));
            color: var(--color-text-muted);
        }
        .ai-rewrite-textarea {
            width: 100%;
            height: 120px;
            padding: 12px;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            background: var(--color-bg-primary);
            color: var(--color-text-primary);
            font-family: inherit;
            font-size: calc(14px + var(--font-offset, 0px));
            resize: vertical;
            margin-bottom: 16px;
        }
        .ai-rewrite-textarea:focus {
            outline: 2px solid transparent;
            border-color: var(--color-accent);
        }
        .ai-rewrite-textarea:focus-visible {
            outline: 2px solid var(--color-focus-ring);
            outline-offset: 2px;
        }
        .ai-rewrite-textarea::placeholder {
            color: var(--color-text-muted);
        }
        .ai-rewrite-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
        }
        .ai-rewrite-btn {
            padding: 10px 20px;
            border-radius: var(--radius-sm);
            font-size: calc(14px + var(--font-offset, 0px));
            cursor: pointer;
            transition: all 0.15s;
        }
        .ai-rewrite-btn.cancel {
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            color: var(--color-text-secondary);
        }
        .ai-rewrite-btn.cancel:hover {
            background: var(--color-bg-secondary);
            border-color: var(--color-text-muted);
        }
        .ai-rewrite-btn.submit {
            background: #60a5fa;
            border: none;
            color: #000;
            font-weight: 500;
        }
        .ai-rewrite-btn.submit:hover {
            filter: brightness(1.1);
        }
        .ai-rewrite-btn.submit:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        /* Blue Save button in edit mode */
        .preview-save-btn {
            background: #60a5fa !important;
            color: #000 !important;
            border-radius: var(--radius-sm);
        }
        .preview-save-btn:hover {
            background: #3b82f6 !important;
        }
        .ai-rewrite-btn.submit .spinner {
            display: none;
            width: 16px;
            height: 16px;
            border: 2px solid transparent;
            border-top-color: #000;
            border-radius: var(--radius-circle);
            animation: qb-spin 0.8s linear infinite;
            margin-right: 8px;
        }
        .ai-rewrite-btn.submit.loading .spinner {
            display: inline-block;
        }
        .ai-rewrite-btn.submit.loading .btn-text {
            opacity: 0.7;
        }
        /* Spinner animation - use qb-spin (defined elsewhere) */

        #clerk-auth-wrapper {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #1a1a1a;

            /* Non-blocking auth overlay: shell renders immediately, auth UI overlays when needed */
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: var(--z-resizer);
        }

        /* Auth gate: keep app hidden until Clerk state is known */
        #app-content {
            display: none;
        }

        /* ==================== Link Cards ==================== */
        .link-cards-container {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: 16px;
        }

        .link-card {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border-hover);
            border-radius: var(--radius-lg);
            overflow: hidden;
            transition: all 0.2s ease;
            cursor: pointer;
        }

        .link-card:hover {
            border-color: var(--color-border-active);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

        /* oEmbed Cards (YouTube, Vimeo, Spotify, etc.) */
        .link-card--oembed {
            display: flex;
            flex-direction: column;
            max-width: 480px;
            width: 100%;
            border-radius: var(--radius-lg);
            overflow: hidden;
            border: 2px solid var(--color-border, #444);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        }

        .link-card--oembed .link-card__thumbnail-wrap {
            position: relative;
            width: 100%;
            height: 270px;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            cursor: pointer;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* Fallback text when no thumbnail */
        .link-card--oembed .link-card__thumbnail-wrap::before {
            content: 'VIDEO';
            position: absolute;
            font-size: 24px;
            font-weight: 700;
            letter-spacing: 8px;
            color: rgba(255, 255, 255, 0.15);
            z-index: var(--z-base);
        }

        .link-card--oembed .link-card__thumbnail-wrap::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 60px;
            background: linear-gradient(transparent, rgba(0,0,0,0.6));
            pointer-events: none;
            z-index: var(--z-base);
        }

        .link-card__embed-wrapper {
            position: relative;
            width: 640px;
            height: 360px;
            flex-shrink: 0;
            background: #000;
        }

        .link-card--playing {
            max-width: 100%;
            height: auto;
        }

        .link-card--playing .link-card__meta {
            width: 100%;
        }

        .link-card--oembed .link-card__thumbnail {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .link-card--oembed .link-card__play {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(255, 0, 0, 0.9);
            color: white;
            width: 68px;
            height: 68px;
            border-radius: var(--radius-circle);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
            padding-left: 5px;
            transition: all 0.2s ease;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
            z-index: var(--z-dropdown);
        }

        .link-card--oembed:hover .link-card__play {
            background: rgba(255, 0, 0, 1);
            transform: translate(-50%, -50%) scale(1.1);
            box-shadow: 0 6px 25px rgba(255, 0, 0, 0.4);
        }

        .link-card__meta {
            background: var(--color-bg-tertiary);
            padding: 12px 16px;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .link-card__provider {
            font-size: 11px;
            text-transform: uppercase;
            color: var(--color-text-secondary);
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .link-card__title,
        a.link-card__title {
            font-size: 14px;
            font-weight: 600;
            color: var(--color-link);
            line-height: 1.3;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            text-decoration: none;
        }

        .link-card__author {
            font-size: 12px;
            color: var(--color-text-secondary);
        }

        /* Open Graph Cards (general websites) */
        .link-card--opengraph {
            display: flex;
            flex-direction: row;
            align-items: stretch;
            width: 400px;
            max-width: 100%; /* Prevent overflow on mobile */
            height: 85px;    /* Fixed height to prevent large images from expanding the card */
            overflow: hidden; /* Ensure nothing spills out */
        }

        .link-card__image-wrap {
            width: 120px;
            min-width: 120px;
            flex-shrink: 0;
            overflow: hidden;
        }

        .link-card__image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .link-card__content {
            padding: 12px 16px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            gap: 4px;
            flex: 1;
            min-width: 0;  /* Allow text truncation */
            overflow: hidden;
        }

        .link-card__site {
            font-size: 11px;
            text-transform: uppercase;
            color: var(--color-text-secondary);
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        .link-card__desc {
            font-size: 13px;
            color: var(--color-text-secondary);
            line-height: 1.4;
            margin: 0;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* Tighten spacing when a paragraph is directly followed by a link/video card */
        .message-content p.qb-link-card-intro {
            margin-bottom: 8px;
        }

        /* Consistent spacing for cards inserted into message flow */
        .message-content .link-card {
            margin-top: 10px;
            margin-bottom: 20px;
        }
        .message-content .link-card + .link-card {
            margin-top: 10px;
        }

        /* Search Fallback Text */
        .message-content .search-fallback {
            font-size: 12px; /* 2 points smaller than standard 14px */
            color: #999;
            display: block;
            margin-top: 6px;
            font-style: italic;
        }

        .message-content .search-fallback a {
            color: var(--color-link) !important;
            text-decoration: none;
        }

        .message-content .search-fallback a:hover {
            text-decoration: underline;
        }

        /* If the hint comes right after a card, keep it tight */
        .message-content .link-card + .search-fallback {
            margin-top: 6px;
        }

        /* Save Timeout Modal (ADR-0101 H1) */
        .save-timeout-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: var(--z-overlay);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
        }
        .save-timeout-overlay.visible {
            opacity: 1;
            pointer-events: auto;
        }
        .save-timeout-modal {
            background: var(--color-bg-secondary);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 24px;
            max-width: 400px;
            text-align: center;
            transform: scale(0.95);
            transition: transform 0.2s;
        }
        .save-timeout-overlay.visible .save-timeout-modal {
            transform: scale(1);
        }
        .save-timeout-icon {
            width: 48px;
            height: 48px;
            margin: 0 auto 16px;
            color: #F59E0B;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .save-timeout-icon svg {
            width: 48px;
            height: 48px;
            stroke-width: 2;
            display: block;
        }
        .save-timeout-modal h3 {
            margin: 0 0 12px;
            color: var(--color-text-primary);
            font-size: calc(18px + var(--font-offset, 0px));
        }
        .save-timeout-modal p {
            margin: 0 0 20px;
            color: var(--color-text-secondary);
            font-size: calc(14px + var(--font-offset, 0px));
            line-height: 1.5;
        }
        .save-timeout-actions {
            display: flex;
            gap: 12px;
            justify-content: center;
        }
        .save-timeout-btn {
            padding: 10px 16px;
            border-radius: var(--radius-sm);
            font-size: calc(14px + var(--font-offset, 0px));
            cursor: pointer;
            transition: all 0.15s;
        }
        .save-timeout-btn.cancel {
            background: var(--color-bg-tertiary);
            border: 1px solid var(--color-border);
            color: var(--color-text-secondary);
        }
        .save-timeout-btn.cancel:hover {
            background: var(--color-bg-secondary);
            border-color: var(--color-text-muted);
        }
        .save-timeout-btn.retry {
            background: var(--color-accent);
            border: none;
            color: #000;
            font-weight: 500;
        }
        .save-timeout-btn.retry:hover {
            filter: brightness(1.1);
        }
        .save-timeout-btn.switch {
            background: #F59E0B;
            border: none;
            color: #000;
            font-weight: 500;
        }
        .save-timeout-btn.switch:hover {
            background: #D97706;
        }

        /* ── Phase 4: CSS tokens ── */
        :root {
            --color-danger: #dc2626;
            --color-success: #22c55e;
            --color-success-bg: rgba(34, 197, 94, 0.2);
            --color-border-subtle: rgba(255, 255, 255, 0.16);
        }
        :root.light-mode,
        body.light-mode {
            --color-success-bg: rgba(34, 197, 94, 0.15);
            --color-border-subtle: rgba(0, 0, 0, 0.08);
        }

        /* ── Phase 4a: Security overlay (moved from chat.js qbEnsureSecurityOverlayStyle) ── */
        .qb-security-overlay {
            position: fixed;
            inset: 0;
            z-index: 30000;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(220, 38, 38, 0.22);
            backdrop-filter: blur(2px);
            animation: qbSecurityPulse 1.8s ease-in-out infinite;
        }
        .qb-security-card {
            width: min(560px, 92vw);
            background: rgba(23, 23, 23, 0.94);
            border: 1px solid rgba(248, 113, 113, 0.7);
            border-radius: 12px;
            color: #f3f4f6;
            padding: 20px 18px;
            box-shadow: 0 20px 50px rgba(0,0,0,0.35);
            font-family: inherit;
        }
        .qb-security-title {
            font-size: 18px;
            font-weight: 700;
            color: #fca5a5;
            margin-bottom: 10px;
        }
        .qb-security-body {
            font-size: 14px;
            line-height: 1.45;
            color: #e5e7eb;
            margin: 0;
            white-space: pre-line;
        }
        .qb-security-event {
            margin-top: 10px;
            font-size: 12px;
            color: #fecaca;
            opacity: 0.95;
        }
        .qb-security-row {
            margin-top: 12px;
            display: flex;
            gap: 8px;
            align-items: center;
        }
        .qb-security-input {
            flex: 1;
            min-width: 0;
            padding: 9px 10px;
            border-radius: 8px;
            border: 1px solid rgba(248, 113, 113, 0.65);
            background: rgba(0,0,0,0.32);
            color: #fff;
            font-family: inherit;
            outline: none;
        }
        .qb-security-input.qb-security-input-breach {
            border-color: rgba(239, 68, 68, 0.95);
            background: rgba(127, 29, 29, 0.4);
            box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
        }
        .qb-security-btn {
            padding: 9px 12px;
            border-radius: 8px;
            border: 1px solid rgba(248, 113, 113, 0.72);
            background: rgba(127, 29, 29, 0.55);
            color: #fff;
            cursor: pointer;
            font-family: inherit;
        }
        .qb-security-timer {
            margin-top: 10px;
            font-size: 13px;
            color: #fecaca;
        }
        .qb-security-countdown-wrap {
            margin-top: 12px;
            border: 1px solid rgba(248, 113, 113, 0.5);
            background: rgba(127, 29, 29, 0.25);
            border-radius: 10px;
            padding: 10px;
        }
        .qb-security-count-big {
            font-size: 38px;
            line-height: 1;
            font-weight: 800;
            letter-spacing: 1px;
            color: #fecaca;
            text-align: center;
            text-shadow: 0 0 18px rgba(239, 68, 68, 0.35);
        }
        .qb-security-progress {
            margin-top: 8px;
            height: 8px;
            border-radius: 999px;
            overflow: hidden;
            background: rgba(0,0,0,0.35);
            border: 1px solid rgba(248, 113, 113, 0.35);
        }
        .qb-security-progress-bar {
            height: 100%;
            width: 100%;
            background: linear-gradient(90deg, rgba(248,113,113,0.95), rgba(220,38,38,0.95));
            transform-origin: left center;
            transition: width 120ms linear;
        }
        .qb-security-overlay.qb-security-urgent .qb-security-count-big {
            color: #fee2e2;
            animation: qbSecurityUrgentBlink 0.7s steps(2, end) infinite;
        }
        .qb-security-overlay.qb-security-urgent .qb-security-progress-bar {
            background: linear-gradient(90deg, rgba(252,165,165,1), rgba(239,68,68,1));
            box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
        }
        .qb-security-error {
            margin-top: 8px;
            font-size: 12px;
            color: #fca5a5;
        }
        @keyframes qbSecurityPulse {
            0%, 100% { background: rgba(220, 38, 38, 0.20); }
            50% { background: rgba(220, 38, 38, 0.30); }
        }
        @keyframes qbSecurityUrgentBlink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.55; }
        }

        /* ── Phase 4c: Extracted CSS classes (replaces style.cssText in JS) ── */
        .qb-chat-image-preview {
            position: relative;
            margin-bottom: 8px;
            max-width: 200px;
        }
        .qb-chat-image-preview img {
            max-width: 200px;
            max-height: 150px;
            border-radius: 8px;
            border: 1px solid var(--color-border);
        }
        .clear-pending-image-btn {
            position: absolute;
            top: -8px;
            right: -8px;
            background: var(--color-danger);
            color: white;
            border: none;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            cursor: pointer;
            font-size: 12px;
        }
        .qb-chat-image-thumb {
            display: block;
            margin-top: 8px;
            max-width: 220px;
            max-height: 160px;
            border-radius: 10px;
            border: 1px solid var(--color-border-subtle);
        }
        .qb-chat-debug-panel {
            position: fixed;
            right: 12px;
            bottom: 12px;
            background: #111;
            color: #eee;
            padding: 8px;
            border-radius: 6px;
            z-index: 9999;
            min-width: 240px;
            max-width: 420px;
            font-size: 12px;
        }
        .qb-recall-msg {
            background: linear-gradient(135deg, var(--color-surface-elevated) 0%, var(--color-bg-secondary) 100%);
            border-left: 4px solid #6366f1;
            padding: 12px;
            border-radius: 4px;
            margin: 8px 0;
        }
        .qb-recall-msg .message-label {
            color: #a78bfa;
            font-size: 12px;
            font-weight: bold;
            margin-bottom: 4px;
        }
        .qb-recall-msg .message-content {
            color: var(--color-text-primary);
            font-size: 14px;
        }
        .qb-recall-results-msg {
            background: linear-gradient(135deg, var(--color-surface-elevated) 0%, var(--color-bg-secondary) 100%);
            border-left: 4px solid #10b981;
            padding: 12px;
            border-radius: 4px;
            margin: 8px 0;
        }
        .qb-recall-results-msg .message-label {
            color: #6ee7b7;
            font-size: 12px;
            font-weight: bold;
            margin-bottom: 8px;
        }
        .qb-recall-results-msg .message-content {
            color: var(--color-text-primary);
            font-size: 14px;
        }
        .qb-recall-highlight {
            color: #60a5fa;
        }
        .qb-recall-session {
            margin: 8px 0;
            padding: 8px;
            background: rgba(79, 70, 229, 0.1);
            border-radius: 3px;
        }
        .qb-recall-session-id {
            color: #93c5fd;
        }
        .qb-recall-summary {
            font-size: 13px;
            color: var(--color-text-secondary);
        }
        .qb-recall-topics {
            font-size: 12px;
            color: #a78bfa;
        }
        .qb-recall-keywords {
            font-size: 12px;
            color: #fbbf24;
        }
        .qb-recall-meta {
            font-size: 12px;
            color: var(--color-text-muted);
        }
        .qb-session-expanded {
            padding: 12px;
            border: 1px solid var(--color-border);
            border-radius: 10px;
            background: var(--color-surface-elevated);
            margin: 12px 0;
        }
        .qb-session-expanded-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .link-card__image-wrap--fallback {
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--color-bg-tertiary);
        }
