        :root {
            --bt-blue: #0082FC;
            --bt-blue-dark: #0066CC;
            --bg-primary: #FFFFFF;
            --bg-secondary: #F8FAFC;
            --bg-tertiary: #F1F5F9;
            --text-primary: #0F172A;
            --text-secondary: #131313;
            --text-muted: #94A3B8;
            --border-light: #E2E8F0;
            --border-medium: #CBD5E1;
            --success: #10B981;
            --color-spec: #8B5CF6;
            --color-spec-bg: rgba(139, 92, 246, 0.1);
            --color-kba: #EC4899;
            --color-kba-bg: rgba(236, 72, 153, 0.1);
            --color-ts: #0D9488;
            --color-ts-bg: rgba(13, 148, 136, 0.1);
            --color-ics: #EA580C;
            --color-ics-bg: rgba(234, 88, 12, 0.1);
            --color-guide: #16A34A;
            --color-guide-bg: rgba(22, 163, 74, 0.1);
            --color-process: #6B7280;
            --color-process-bg: rgba(107, 114, 128, 0.1);
            --color-doc: #6366F1;
            --color-doc-bg: rgba(99, 102, 241, 0.1);
        }

        [data-theme="dark"] {
            --bt-blue: #3B9FFF;
            --bt-blue-dark: #2B8AEE;
            --bg-primary: #1e2021;
            --bg-secondary: #181a1b;
            --bg-tertiary: #2b2d2e;
            --text-primary: #e8e6e3;
            --text-secondary: #b8b4ad;
            --text-muted: #7a756e;
            --border-light: #3b3836;
            --border-medium: #4e4a47;
            --success: #22C55E;
            --color-spec: #A78BFA;
            --color-spec-bg: rgba(167, 139, 250, 0.15);
            --color-kba: #F472B6;
            --color-kba-bg: rgba(244, 114, 182, 0.15);
            --color-ts: #2DD4BF;
            --color-ts-bg: rgba(45, 212, 191, 0.15);
            --color-ics: #FB923C;
            --color-ics-bg: rgba(251, 146, 60, 0.15);
            --color-guide: #4ADE80;
            --color-guide-bg: rgba(74, 222, 128, 0.15);
            --color-process: #9CA3AF;
            --color-process-bg: rgba(156, 163, 175, 0.15);
            --color-doc: #818CF8;
            --color-doc-bg: rgba(129, 140, 248, 0.15);
        }

        /* Smooth transition when toggling theme */
        html.theme-transitioning,
        html.theme-transitioning *,
        html.theme-transitioning *::before,
        html.theme-transitioning *::after {
            transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            height: 100vh;
            height: 100dvh; /* mobile-safe: shrinks when virtual keyboard opens */
            overflow: hidden; /* Prevent body scroll - messages scroll internally */
            display: flex;
            flex-direction: column;
            visibility: hidden; /* Hidden until auth confirmed */
        }

        html {
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
        }

        /* Atmosphere Background */
        .atmosphere {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            pointer-events: none;
            z-index: 0;
        }

        .atmosphere .layer {
            position: absolute;
            z-index: 1;
            left: calc(60% + var(--layer-x));
            top: calc(58% + var(--layer-y));
            transform: translate(-50%, -50%);
            width: var(--layer-w);
            height: var(--layer-h);
            background-color: var(--layer-color);
            border-radius: 100%;
            filter: blur(var(--layer-blur));
            opacity: var(--layer-opacity);
        }

        /* Header - shown after conversation starts */
        header {
            display: none;
            position: sticky;
            top: 0;
            z-index: 5;
            background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 100%);
            height: 130px;
            align-items: flex-start;
            padding: 20px 24px 0;
            justify-content: space-between;
            transition: padding-left 0.2s ease;
        }

        header.visible {
            display: flex;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .brand-logo {
            height: 40px;
        }

        .brand h1 {
            font-size: 1.5rem;
            font-weight: 600;
            color: var(--text-primary);
            padding-left: 4px;
        }
        .brand h1::first-letter {
            font-weight: 400;
            margin-right: 6px;
        }

        /* Top gradient overlay — welcome state only; hidden when chat header is visible */
        .page-top-gradient {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 130px;
            background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 100%);
            pointer-events: none;
            z-index: 4;
        }
        body:has(header.visible) .page-top-gradient {
            display: none;
        }

        /* Floating logout button - for welcome state */
        .floating-logout {
            position: fixed;
            top: 16px;
            right: 24px;
            z-index: 100;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .floating-logout.hidden {
            display: none;
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .user-name {
            font-size: 0.875rem;
            color: var(--text-secondary);
        }

        .btn-logout {
            text-decoration: none;
            color: #131313;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 100px;
            padding: 13px 22px;
            display: inline-flex;
            align-items: center;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
            font-size: 0.8125rem;
            border: none;
            cursor: pointer;
            transition: all 0.15s;
        }

        .btn-logout:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        /* Main Container */
        .main-container {
            width: 100%;
            margin: 0 auto;
            position: relative;
            z-index: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            flex: 1;
        }

        .main-container.with-header {
        }

        /* Welcome State */
        .welcome-state {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: flex-start;
            text-align: left;
            padding: min(25vh, 200px) 20px 40px 20px;
            max-width: 800px;
            width: 100%;
            margin: 0 auto;
        }

        .welcome-state.hidden {
            display: none;
        }

        .welcome-logo {
            width: 54px;
            height: 54px;
            margin-bottom: 24px;
        }

        .welcome-state h2 {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            font-size: 2rem;
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: 0;
        }

        /* Welcome input - left-aligned in welcome state */
        .welcome-input {
            width: 100%;
            margin-top: 40px;
            margin-bottom: 24px;
        }

        .suggestions {
            display: flex;
            flex-wrap: nowrap;
            gap: 8px;
            justify-content: center;
            padding: 0 24px;
        }

        .suggestion-btn {
            padding: 10px 16px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: 20px;
            font-size: 0.75rem;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .suggestion-btn:hover {
            border-color: var(--bt-blue);
            color: var(--bt-blue);
            background: rgba(0, 130, 252, 0.05);
        }

        /* Messages */
        .messages {
            flex: 1;
            overflow-y: auto;
            display: none;
            flex-direction: column;
            gap: 24px;
            padding: 24px 0;
            min-height: 0; /* Critical for flex scroll */
            scrollbar-width: thin;
            scrollbar-color: transparent transparent;
        }
        .messages:hover {
            scrollbar-color: var(--border-medium) transparent;
        }
        .messages::-webkit-scrollbar { width: 6px; }
        .messages::-webkit-scrollbar-track { background: transparent; }
        .messages::-webkit-scrollbar-thumb {
            background: transparent;
            border-radius: 3px;
        }
        .messages:hover::-webkit-scrollbar-thumb {
            background: var(--border-medium);
        }
        .messages::-webkit-scrollbar-thumb:hover {
            background: var(--text-muted);
        }

        .messages.active {
            display: flex;
        }

        .messages-inner {
            max-width: 1000px;
            width: 100%;
            margin: 0 auto;
            padding: 0 24px;
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .message {
            max-width: 100%;
            animation: fadeIn 0.2s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .message.user {
            display: flex;
            justify-content: flex-end;
        }

        .message.user .message-bubble {
            background: var(--bt-blue);
            color: white;
            padding: 12px 16px;
            border-radius: 18px 18px 4px 18px;
            max-width: 80%;
        }

        .message.assistant .message-bubble {
            background: #ffffffb8;
            padding: 40px;
            border-radius: 10px;
            color: var(--text-primary);
            line-height: 1.6;
        }

        .message-content {
            font-size: 0.9375rem;
            line-height: 1.6;
        }

        .message-content p {
            margin-bottom: 0.75em;
        }

        .message-content p:last-child {
            margin-bottom: 0;
        }

        .message-content ul, .message-content ol {
            margin: 0.5em 0;
            padding-left: 1.5em;
        }

        .message-content li {
            margin-bottom: 0.25em;
        }

        .message-content strong {
            font-weight: 600;
        }

        .message-content code {
            background: var(--bg-tertiary);
            padding: 0.15em 0.4em;
            border-radius: 4px;
            font-family: 'SF Mono', Monaco, monospace;
            font-size: 0.85em;
        }

        .message-content a {
            color: var(--bt-blue);
            text-decoration: none;
        }

        .message-content a:hover {
            text-decoration: underline;
        }

        /* Sources - subtle styling */
        .message-sources {
            margin-top: 12px;
        }

        .sources-toggle {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 0.75rem;
            color: var(--text-muted);
            background: none;
            border: none;
            cursor: pointer;
            padding: 0;
        }

        .sources-toggle:hover {
            color: var(--text-secondary);
        }

        .sources-toggle svg {
            width: 12px;
            height: 12px;
        }

        .sources-list {
            display: none;
            margin-top: 6px;
            padding: 8px 10px;
            background: var(--bg-tertiary);
            border-radius: 6px;
            font-size: 0.75rem;
        }

        .sources-list.open {
            display: block;
        }

        .source-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 4px 0;
            color: var(--text-secondary);
        }

        .source-item:not(:last-child) {
            border-bottom: 1px solid var(--border-light);
        }

        .source-info {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .source-type-badge {
            padding: 1px 4px;
            border-radius: 3px;
            font-size: 0.5rem;
            font-weight: 600;
            text-transform: uppercase;
        }

        .source-type-badge.spec {
            background: var(--color-spec-bg);
            color: var(--color-spec);
        }

        .source-type-badge.ts {
            background: var(--color-ts-bg);
            color: var(--color-ts);
        }

        .source-type-badge.ics {
            background: var(--color-ics-bg);
            color: var(--color-ics);
        }

        .source-type-badge.guide {
            background: var(--color-guide-bg);
            color: var(--color-guide);
        }

        .source-type-badge.process {
            background: var(--color-process-bg);
            color: var(--color-process);
        }

        .source-type-badge.doc {
            background: var(--color-doc-bg);
            color: var(--color-doc);
        }

        .source-type-badge.kba {
            background: var(--color-kba-bg);
            color: var(--color-kba);
        }

        .source-type-badge.tool {
            background: rgba(0, 130, 252, 0.1);
            color: var(--bt-blue);
            font-size: 0.6875rem;
            text-transform: none;
            padding: 2px 8px;
        }

        .source-name {
            color: var(--text-secondary);
            font-weight: 400;
        }

        .source-name a {
            color: var(--text-secondary);
            text-decoration: none;
        }

        .source-name a:hover {
            color: var(--bt-blue);
        }

        .source-version {
            font-size: 0.75rem;
            color: var(--bt-blue);
            opacity: 0.8;
            font-weight: 500;
        }

        a.source-info {
            display: flex;
            align-items: center;
            gap: 6px;
            text-decoration: none;
            color: inherit;
        }

        a.source-info:hover .source-name,
        a.source-info:hover .source-section-label {
            color: var(--bt-blue);
        }

        .source-relevance {
            color: var(--text-muted);
            font-size: 0.6875rem;
        }

        .source-section-label {
            color: var(--text-muted);
            font-size: 0.6875rem;
            margin-left: 2px;
        }

        /* Source image thumbnails */
        .source-images {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-top: 6px;
            padding: 4px 0 2px 0;
        }

        .source-images img {
            width: 64px;
            height: 48px;
            object-fit: cover;
            border-radius: 4px;
            border: 1px solid var(--border-light);
            cursor: pointer;
            transition: opacity 0.15s, box-shadow 0.15s;
        }

        .source-images img:hover {
            opacity: 0.85;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        }

        .source-images-more {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 64px;
            height: 48px;
            border-radius: 4px;
            border: 1px dashed var(--border-light);
            font-size: 0.65rem;
            color: var(--text-muted);
            cursor: pointer;
            background: var(--bg-tertiary);
        }

        .source-images-more:hover {
            color: var(--bt-blue);
            border-color: var(--bt-blue);
        }

        /* ── Terms of Use modal ── */
        .tou-overlay {
            position: fixed; inset: 0; z-index: 10000;
            background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
            display: flex; align-items: center; justify-content: center;
        }
        .tou-modal {
            background: var(--bg-primary); color: var(--text-primary);
            border-radius: 12px; max-width: 520px; width: 90%; padding: 2rem;
            box-shadow: 0 8px 32px rgba(0,0,0,0.25);
            max-height: 80vh; display: flex; flex-direction: column;
        }
        .tou-modal h2 { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; }
        .tou-body { overflow-y: auto; flex: 1; font-size: 0.9rem; line-height: 1.6; }
        .tou-body ul { padding-left: 1.25rem; margin: 0.5rem 0; }
        .tou-body li { margin-bottom: 0.5rem; }
        .tou-body a { color: var(--bt-blue); }
        .tou-accept-btn {
            margin-top: 1.5rem; width: 100%; padding: 0.75rem;
            background: var(--bt-blue); color: #fff; border: none;
            border-radius: 8px; font-size: 1rem; font-weight: 600;
            cursor: pointer; transition: background 0.2s;
        }
        .tou-accept-btn:hover { background: var(--bt-blue-dark); }

        /* Lightbox overlay */
        .image-lightbox {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 9999;
            background: rgba(0, 0, 0, 0.85);
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }

        .image-lightbox.open {
            display: flex;
        }

        .image-lightbox img {
            max-width: 90vw;
            max-height: 80vh;
            object-fit: contain;
            border-radius: 6px;
            box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
        }

        .lightbox-controls {
            display: flex;
            gap: 16px;
            margin-top: 16px;
            align-items: center;
        }

        .lightbox-btn {
            background: rgba(255, 255, 255, 0.15);
            border: none;
            color: #fff;
            font-size: 1.5rem;
            width: 44px;
            height: 44px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .lightbox-btn:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .lightbox-close {
            position: absolute;
            top: 16px;
            right: 16px;
        }

        .lightbox-counter {
            color: rgba(255, 255, 255, 0.7);
            font-size: 0.85rem;
        }

        /* Loading */
        .loading-dots {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 0;
        }

        .loading-spinner {
            width: 20px;
            height: 20px;
            border: 2.5px solid rgba(0, 130, 252, 0.2);
            border-top-color: var(--bt-blue);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        .loading-dots .loading-text {
            font-size: 0.85rem;
            color: var(--text-muted);
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .streaming-spinner {
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid rgba(0, 130, 252, 0.2);
            border-top-color: var(--bt-blue);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
            vertical-align: text-bottom;
            margin-left: 4px;
        }

        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0; }
        }

        /* Mermaid diagram containers */
        .mermaid-container {
            margin: 1em 0;
            padding: 1.25em;
            background: var(--bg-secondary);
            border: 1px solid var(--border-light);
            border-radius: 10px;
            overflow-x: auto;
            text-align: center;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06);
            position: relative;
        }
        .mermaid-container svg {
            max-width: 100%;
            height: auto;
        }
        .mermaid-container .actor {
            font-family: 'Inter', system-ui, sans-serif;
        }
        /* Diagram toolbar */
        .mermaid-toolbar {
            display: flex;
            justify-content: flex-end;
            gap: 6px;
            margin-bottom: 10px;
        }
        .mermaid-toolbar button {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-light);
            border-radius: 6px;
            padding: 4px 10px;
            font-size: 0.75rem;
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: all 0.15s ease;
        }
        .mermaid-toolbar button:hover {
            background: var(--bt-blue);
            color: white;
            border-color: var(--bt-blue);
        }
        .mermaid-toolbar button svg {
            width: 14px;
            height: 14px;
        }
        /* Fullscreen overlay - removed */

        /* Streaming text: smooth height transitions during markdown re-renders */
        .message-content.streaming {
            overflow: hidden;
        }

        /* Smooth crossfade when switching from streaming to final markdown */
        .message-content.stream-finalizing {
            animation: streamFadeIn 0.3s ease-out;
        }

        @keyframes streamFadeIn {
            from { opacity: 0.7; }
            to   { opacity: 1; }
        }

        /* Input Area - fixed at bottom */
        .input-area {
            padding: 16px 0 24px 0;
            background: transparent;
            position: relative;
            z-index: 10;
            flex-shrink: 0;
        }

        .input-area.with-gradient {
            background: linear-gradient(180deg, transparent 0%, rgba(0,130,252,0.08) 30%, rgba(0,130,252,0.25) 70%, rgba(0,130,252,0.45) 100%);
            padding-bottom: 32px;
        }

        @media (max-width: 768px) {
            .input-area {
                padding: 12px 0 env(safe-area-inset-bottom, 16px) 0;
            }
        }

        .input-area.hidden {
            display: none;
        }

        .input-area-inner {
            max-width: 1000px;
            width: 100%;
            margin: 0 auto;
            padding: 0 24px;
        }

        .input-wrapper {
            display: flex;
            align-items: flex-end;
            background: var(--bg-primary);
            border: 1px solid var(--border-medium);
            border-radius: 24px;
            padding: 4px 4px 4px 20px;
            min-height: 40px;
            margin-bottom: 10px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
            transition: all 0.15s;
        }

        .input-wrapper:focus-within {
            border-color: var(--bt-blue);
            box-shadow: 0 0 0 3px rgba(0, 130, 252, 0.1);
        }

        .input-wrapper input {
            flex: 1;
            border: none;
            background: transparent;
            font-size: 0.9375rem;
            color: var(--text-primary);
            outline: none;
            padding: 12px 0;
        }

        .input-wrapper input::placeholder {
            color: var(--text-muted);
        }

        .send-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--bt-blue);
            border: none;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s;
            flex-shrink: 0;
        }

        .send-btn:hover {
            background: var(--bt-blue-dark);
        }

        .send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* BT.com Footer - layer-based like bluetooth.com */
        .bt-footer {
            position: relative;
            margin-top: auto;
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            min-height: 200px;
        }
        .footer-bg {
            overflow: hidden;
            z-index: 0;
            left: 0;
            width: 100%;
            top: -1000px;
            bottom: 0;
            pointer-events: none;
        }
        .footer-bg-inner {
            position: absolute;
            left: calc(50% - 720px);
            top: 60px;
            width: 1440px;
        }
        .footer-bg .layer {
            position: absolute;
            border-radius: 50%;
        }
        .footer-bg .layer-1 {
            width: 1234px; height: 655px;
            left: -98px; top: 347px;
            background: #0082FC;
            opacity: 0.6;
            filter: blur(206px);
        }
        .footer-bg .layer-2 {
            width: 823px; height: 655px;
            left: -370px; top: 474px;
            background: #0082FC;
            opacity: 0.6;
            filter: blur(206px);
        }
        .footer-bg .layer-3 {
            width: 823px; height: 655px;
            left: -370px; top: 474px;
            background: #0055B8;
            opacity: 0.6;
            filter: blur(206px);
        }
        .footer-bg .layer-4 {
            width: 1320px; height: 714px;
            left: 483px; top: 689px;
            background: #0082FC;
            filter: blur(75px);
            transform: rotate(-15deg);
        }
        .footer-bg .layer-5 {
            width: 1320px; height: 714px;
            left: -246px; top: 739px;
            background: #0082FC;
            filter: blur(75px);
        }
        .footer-bg .layer-6 {
            width: 1320px; height: 714px;
            left: 483px; top: 552px;
            background: #0082FC;
            filter: blur(75px);
            transform: rotate(-15deg);
        }
        .footer-bg .layer-7 {
            width: 1320px; height: 714px;
            left: -246px; top: 602px;
            background: #0082FC;
            filter: blur(75px);
        }
        .footer-bg .layer-8 {
            width: 786px; height: 279px;
            left: 180px; top: 653px;
            background: #0055B8;
            opacity: 0.3;
            filter: blur(106px);
        }
        .footer-bg .layer-9 {
            width: 322px; height: 93px;
            left: 774px; top: 813px;
            background: #0055B8;
            opacity: 0.6;
            filter: blur(106px);
            transform: matrix(0.82, -0.57, 0.74, 0.67, 0, 0);
        }
        .footer-bg .layer-10 {
            z-index: -1;
            width: 100000px;
            left: calc(50% - 50000px);
            top: 340px;
            height: 100000px;
            background: linear-gradient(180deg, transparent 0%, #0082FC 0.8%);
            border-radius: 0;
        }
        .bt-footer-content {
            position: relative;
            z-index: 10;
            padding: 40px 64px 50px;
        }
        .bt-footer-bottom {
            display: flex;
            justify-content: flex-start;
            align-items: flex-end;
            flex-wrap: wrap;
            gap: 24px;
        }
        .bt-footer-left {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .bt-footer-logo img {
            height: 28px;
        }
        .bt-footer-links {
            font-size: 0.8125rem;
            color: rgba(255,255,255,0.85);
        }
        .bt-footer-links a {
            color: rgba(255,255,255,0.85);
            text-decoration: none;
        }
        .bt-footer-links a:hover {
            text-decoration: underline;
            color: #fff;
        }
        .bt-footer-copyright {
            font-size: 0.75rem;
            color: rgba(255,255,255,0.65);
            margin-top: 2px;
            text-transform: uppercase;
            letter-spacing: 0.02em;
        }
        @media (max-width: 640px) {
            .bt-footer-content {
                padding: 20px 16px 30px;
            }
            .bt-footer-bottom {
                flex-direction: column;
                align-items: flex-start;
            }
        }

        /* Footer note */
        /* Attach button */
        .attach-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            border-radius: 50%;
            cursor: pointer;
            flex-shrink: 0;
            transition: all 0.15s;
            margin-right: 4px;
        }
        .attach-btn:hover {
            color: var(--bt-blue);
            background: var(--bg-secondary);
        }
        .attach-btn.uploading {
            opacity: 0.5;
            pointer-events: none;
        }
        .attach-btn.uploading svg {
            animation: spin 1s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* Document pill */
        .doc-pill-row {
            padding: 0 0 6px 0;
        }
        .doc-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 4px 8px 4px 10px;
            font-size: 0.75rem;
            color: var(--text-sec);
            max-width: 100%;
        }
        .doc-pill svg { flex-shrink: 0; color: var(--bt-blue); }
        .doc-pill-remove {
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-size: 1rem;
            line-height: 1;
            cursor: pointer;
            padding: 0 2px;
            border-radius: 4px;
        }
        .doc-pill-remove:hover { color: var(--red); background: rgba(239,68,68,0.1); }
        #doc-pill-name { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
        #doc-pill-meta { color: var(--text-dim); }

        /* Response style toggle */
        .style-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 4px 0 0 0;
        }
        .style-label {
            font-size: 0.7rem;
            color: var(--text-muted);
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.03em;
        }
        .style-pills {
            display: flex;
            gap: 2px;
            background: var(--bg-secondary);
            border-radius: 8px;
            padding: 2px;
        }
        .style-pill {
            font-size: 0.7rem;
            padding: 3px 10px;
            border: none;
            border-radius: 6px;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            font-family: inherit;
            font-weight: 500;
            transition: all 0.15s;
        }
        .style-pill:hover {
            color: var(--text-primary);
            background: var(--bg-primary);
        }
        .style-pill.active {
            background: var(--bt-blue);
            color: #fff;
            box-shadow: 0 1px 3px rgba(0, 130, 252, 0.25);
        }

        .footer-note {
            text-align: center;
            padding: 12px;
            font-size: 0.75rem;
            color: #000000;
            opacity: 0.4;
        }

        /* Feedback buttons */
        .message-actions {
            display: flex;
            gap: 4px;
            margin-top: 12px;
        }

        .action-btn {
            background: none;
            border: 1px solid var(--border-light);
            border-radius: 6px;
            padding: 6px 8px;
            cursor: pointer;
            color: var(--text-muted);
            transition: all 0.15s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .action-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            border-color: var(--border-medium);
        }

        .action-btn.active {
            background: var(--bt-blue);
            color: white;
            border-color: var(--bt-blue);
        }

        .action-btn.copied {
            background: var(--success);
            color: white;
            border-color: var(--success);
        }

        /* Responsive */
        @media (max-width: 640px) {
            .main-container {
                padding: 16px;
            }

            .suggestions {
                flex-direction: column;
            }

            .suggestion-btn {
                width: 100%;
            }
        }
        /* Tables */
        .message-content table { width:100%; border-collapse:collapse; margin:0.75rem 0; font-size:0.9rem; background:var(--bg-primary); border-radius:8px; overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,0.08); }
        .message-content thead th { background:var(--bt-blue); color:#fff; padding:0.6rem 0.75rem; text-align:left; font-weight:600; font-size:0.85rem; }
        .message-content tbody td { padding:0.5rem 0.75rem; border-bottom:1px solid var(--border-light); color:var(--text-primary); background:var(--bg-primary); }
        .message-content tbody tr:last-child td { border-bottom:none; }
        .message-content tbody tr:nth-child(even) td { background:var(--bg-secondary); }

        /* Session Sidebar — always visible, BT SIG style */
        .app-layout {
            display: flex;
            height: 100vh;
            overflow: hidden;
        }

        .sidebar {
            width: 260px;
            min-width: 260px;
            height: 100vh;
            background: rgba(255, 255, 255, 0.85);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-right: 1px solid var(--border-light);
            display: flex;
            flex-direction: column;
            z-index: 50;
            flex-shrink: 0;
            transition: width 0.2s ease, min-width 0.2s ease;
        }
        .sidebar.collapsed {
            width: 0;
            min-width: 0;
            overflow: hidden;
            border-right: none;
        }

        .sidebar-top-bar {
            display: flex;
            align-items: center;
            padding: 10px 10px 6px;
        }
        .sidebar-collapse-btn {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 6px;
        }
        .sidebar-collapse-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }

        .sidebar-header {
            padding: 0 10px 10px;
            border-bottom: 1px solid var(--border-light);
        }

        .sidebar-header .btn-new-chat {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-secondary);
            color: var(--text-secondary);
            border: 1px solid var(--border-light);
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.8125rem;
            font-weight: 500;
            transition: all 0.15s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
        }
        .sidebar-header .btn-new-chat:hover { background: var(--bg-tertiary); color: var(--text-primary); }

        .session-list-label {
            padding: 12px 14px 6px;
            font-size: 0.6875rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
        }

        .session-list {
            flex: 1;
            overflow-y: auto;
            padding: 0 8px 8px;
            scrollbar-width: thin;
            scrollbar-color: transparent transparent;
        }
        .sidebar:hover .session-list {
            scrollbar-color: var(--border-medium) transparent;
        }
        .session-list::-webkit-scrollbar { width: 6px; }
        .session-list::-webkit-scrollbar-track { background: transparent; }
        .session-list::-webkit-scrollbar-thumb {
            background: transparent;
            border-radius: 3px;
            transition: background 0.2s;
        }
        .sidebar:hover .session-list::-webkit-scrollbar-thumb {
            background: var(--border-medium);
        }
        .session-list::-webkit-scrollbar-thumb:hover {
            background: var(--text-muted);
        }
        .session-item {
            display: flex;
            align-items: center;
            padding: 9px 10px;
            border-radius: 8px;
            cursor: pointer;
            color: var(--text-secondary);
            font-size: 0.8125rem;
            transition: background 0.15s;
            gap: 8px;
        }
        .session-item:hover { background: var(--bg-tertiary); }
        .session-item.active { background: rgba(0, 130, 252, 0.12); color: var(--bt-blue); font-weight: 500; }
        .session-item-title {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .session-item-delete {
            width: 22px;
            height: 22px;
            display: none;
            align-items: center;
            justify-content: center;
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 4px;
            font-size: 0.75rem;
            flex-shrink: 0;
        }
        .session-item:hover .session-item-delete { display: flex; }
        .session-item-delete:hover { color: #ef4444; background: rgba(239,68,68,0.08); }
        .session-item-time {
            font-size: 0.6875rem;
            color: var(--text-muted);
            flex-shrink: 0;
        }
        .session-group-label {
            padding: 10px 10px 4px;
            font-size: 0.6875rem;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .app-main {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            position: relative;
            overflow: hidden;
        }

        /* Feedback form */
        .feedback-form {
            margin-top: 6px;
            display: flex;
            gap: 6px;
            align-items: center;
        }
        .feedback-form input {
            flex: 1;
            padding: 6px 10px;
            border: 1px solid var(--border-light);
            border-radius: 6px;
            font-size: 0.8125rem;
            color: var(--text-primary);
            background: var(--bg-secondary);
            outline: none;
        }
        .feedback-form input:focus { border-color: var(--bt-blue); }
        .feedback-form button {
            padding: 6px 12px;
            background: var(--bt-blue);
            color: #fff;
            border: none;
            border-radius: 6px;
            font-size: 0.75rem;
            cursor: pointer;
        }
        .feedback-form button:hover { background: var(--bt-blue-dark); }

        /* Expand button — shown when sidebar is collapsed on desktop */
        .sidebar-expand-btn {
            position: fixed;
            top: 12px;
            left: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 8px;
            z-index: 300;
            opacity: 0;
            visibility: hidden;
            transform: translateX(-8px);
            transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease, background 0.15s, color 0.15s;
        }
        .sidebar-expand-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
        body.sidebar-collapsed .sidebar-expand-btn {
            opacity: 1;
            visibility: visible;
            transform: translateX(0);
        }
        body.sidebar-collapsed header {
            padding-left: 56px;
        }

        .sidebar-toggle { display: none; }
        .sidebar-overlay { display: none; }

        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                top: 0;
                left: 0;
                height: 100vh;
                height: 100dvh;
                transform: translateX(-100%);
                transition: transform 0.25s ease;
                z-index: 10000;
                box-shadow: 2px 0 12px rgba(0,0,0,0.1);
            }
            .sidebar.mobile-open { transform: translateX(0); }
            .sidebar-toggle {
                display: flex;
                width: 36px;
                height: 36px;
                align-items: center;
                justify-content: center;
                background: none;
                border: none;
                color: var(--text-muted);
                cursor: pointer;
                border-radius: 6px;
                margin-right: 8px;
            }
            .sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-tertiary); }
            .sidebar-overlay.mobile-open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.2); z-index: 9999; }
        }

        /* Theme toggle button */
        .theme-toggle {
            width: 34px;
            height: 34px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: none;
            border: 1px solid #e2e8f000;
            color: var(--text-secondary);
            cursor: pointer;
            border-radius: 50%;
            transition: all 0.15s;
            flex-shrink: 0;
        }
        .theme-toggle:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
            border-color: var(--border-medium);
        }
        .theme-toggle .icon-sun,
        .theme-toggle .icon-moon { display: none; }
        [data-theme="light"] .theme-toggle .icon-moon,
        :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
        [data-theme="dark"] .theme-toggle .icon-sun { display: block; }

        /* Dark mode: reduce atmosphere blob brightness */
        [data-theme="dark"] .atmosphere .layer { opacity: 0.18; }

        /* Dark mode: swap white gradient to dark bg color */
        [data-theme="dark"] header,
        [data-theme="dark"] .page-top-gradient {
            background: linear-gradient(180deg, rgba(24,26,27,0.95) 0%, rgba(24,26,27,0.5) 50%, rgba(24,26,27,0) 100%);
        }

        /* Dark mode: sidebar */
        [data-theme="dark"] .sidebar {
            background: rgba(24, 26, 27, 0.92);
            border-right-color: var(--border-light);
        }

        /* Dark mode: assistant message bubble */
        [data-theme="dark"] .message.assistant .message-bubble {
            background: rgba(43, 45, 46, 0.85);
        }

        /* Dark mode: user message bubble — toned down */
        [data-theme="dark"] .message.user .message-bubble {
            background: #1a6ab5;
        }

        /* Dark mode: input wrapper */
        [data-theme="dark"] .input-wrapper {
            background: var(--bg-primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        /* Dark mode: logout button */
        [data-theme="dark"] .btn-logout {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.06);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
        }
        [data-theme="dark"] .btn-logout:hover {
            background: rgba(255, 255, 255, 0.12);
        }

        /* Dark mode: footer note */
        [data-theme="dark"] .footer-note {
            color: #e8e6e3;
            opacity: 0.4;
        }

        /* Dark mode: input gradient */
        [data-theme="dark"] .input-area.with-gradient {
            background: linear-gradient(180deg, transparent 0%, rgba(0,80,160,0.06) 30%, rgba(0,80,160,0.15) 70%, rgba(0,80,160,0.25) 100%);
        }

        /* Dark mode: inline markdown table fix */
        [data-theme="dark"] .message-content table { box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
        [data-theme="dark"] .message-content thead th { background: #2b5ea7; }
        [data-theme="dark"] .message-content tbody td { background: var(--bg-primary); }
        [data-theme="dark"] .message-content tbody tr:nth-child(even) td { background: var(--bg-tertiary); }

        /* Dark mode: code blocks */
        [data-theme="dark"] .message-content code {
            background: #2b2d2e;
        }

        /* Dark mode: scrollbar */
        [data-theme="dark"] .messages:hover {
            scrollbar-color: #4e4a47 transparent;
        }

        /* Language switcher — matches bluetooth.com style */
        .lang-switcher {
            position: relative;
            margin-right: 8px;
        }
        .lang-switcher-btn {
            background: none;
            border: 1px solid var(--text-secondary);
            border-radius: 6px;
            padding: 4px 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 2px;
            color: var(--text-secondary, #555);
            font-size: 14px;
            font-weight: 600;
            line-height: 1;
        }
        .lang-switcher-btn:hover { border-color: #0082FC; color: #0082FC; }
        .lang-switcher-btn .lang-divider {
            width: 1px;
            height: 14px;
            background: var(--text-secondary);
            margin: 0 4px;
        }
        .lang-switcher-dropdown {
            display: none;
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 6px;
            background: var(--bg-primary, #fff);
            border: 1px solid var(--border-color, #ddd);
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.12);
            min-width: 160px;
            z-index: 200;
            overflow: hidden;
        }
        .lang-switcher-dropdown.open { display: block; }
        .lang-switcher-dropdown a {
            display: block;
            padding: 10px 16px;
            color: var(--text-primary, #333);
            text-decoration: none;
            font-size: 14px;
            white-space: nowrap;
        }
        .lang-switcher-dropdown a:hover { background: var(--bg-secondary, #f5f5f5); }
        .lang-switcher-dropdown a.active { font-weight: 600; color: #0082FC; }
