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

        :root {
            --primary:       #2563eb;
            --primary-light: #eff6ff;
            --primary-hover: #1d4ed8;
            --bg:            #f8fafc;
            --surface:       #ffffff;
            --text:          #0f172a;
            --text-light:    #64748b;
            --border:        #e2e8f0;
            --shadow:        0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
            --shadow-lg:     0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
            --file-panel-w:  220px;
            --chat-panel-w:  360px;
            --header-h:      56px;
            --tabbar-h:      52px;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg);
            color: var(--text);
            height: 100vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        /* ── Buttons ── */
        .btn {
            padding: 0.4rem 0.875rem;
            border-radius: 0.5rem;
            border: 1px solid var(--border);
            background: white;
            cursor: pointer;
            font-size: 0.8125rem;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            gap: 0.375rem;
            transition: all 0.2s;
            color: var(--text);
            white-space: nowrap;
        }
        .btn:hover          { background: var(--bg); border-color: var(--text-light); }
        .btn-primary        { background: var(--primary); color: white; border-color: var(--primary); }
        .btn-primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); }
        .btn-icon           { padding: 0.4rem; border-radius: 0.375rem; }
        .btn-ghost          { border-color: transparent; background: transparent; }
        .btn-ghost:hover    { background: var(--bg); border-color: var(--border); }

        /* ── Header ── */
        .header {
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            height: var(--header-h);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 0.875rem;
            box-shadow: var(--shadow);
            z-index: 200;
            flex-shrink: 0;
        }
        .header-left { display: flex; align-items: center; gap: 0.625rem; }
        .logo {
            display: flex; align-items: center; gap: 0.4rem;
            font-weight: 700; font-size: 1.125rem; color: var(--primary);
        }
        .nav-actions { display: flex; gap: 0.375rem; align-items: center; }

        /* ── App Body ── */
        .app-body { display: flex; flex: 1; overflow: hidden; }

        /* ── File Library Panel ── */
        .file-panel {
            width: var(--file-panel-w);
            background: var(--surface);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            z-index: 50;
            transition: width 0.25s ease;
            overflow: hidden;
        }
        .file-panel.collapsed { width: 0; }

        .file-panel-header {
            padding: 0.75rem 0.875rem;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-shrink: 0;
            min-width: var(--file-panel-w);
        }
        .file-panel-title {
            font-size: 0.75rem; font-weight: 600;
            color: var(--text-light); text-transform: uppercase; letter-spacing: 0.06em;
        }

        .file-list { flex: 1; overflow-y: auto; padding: 0.5rem; min-width: var(--file-panel-w); }

        .file-list-empty {
            display: flex; flex-direction: column; align-items: center;
            justify-content: center; height: 100%; gap: 0.625rem;
            color: var(--text-light); font-size: 0.8125rem; text-align: center; padding: 1rem;
        }

        .file-item {
            display: flex; align-items: center; gap: 0.625rem;
            padding: 0.5rem 0.625rem; border-radius: 0.5rem; cursor: pointer;
            transition: all 0.15s; border: 1px solid transparent;
            position: relative; margin-bottom: 0.25rem;
        }
        .file-item:hover  { background: var(--bg); border-color: var(--border); }
        .file-item.active { background: var(--primary-light); border-color: var(--primary); }

        .file-thumb-wrap {
            width: 38px; height: 50px; flex-shrink: 0;
            border-radius: 3px; overflow: hidden; border: 1px solid var(--border);
            background: #f5f5f5; display: flex; align-items: center; justify-content: center;
        }
        .file-thumb-wrap canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
        .file-thumb-icon { color: var(--primary); }

        .file-info { flex: 1; min-width: 0; }
        .file-name {
            font-size: 0.8125rem; font-weight: 500; color: var(--text);
            display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .file-meta { font-size: 0.75rem; color: var(--text-light); display: block; margin-top: 0.125rem; }

        .file-remove {
            opacity: 0; position: absolute; top: 4px; right: 4px;
            width: 17px; height: 17px; border-radius: 50%;
            background: rgba(0,0,0,0.18); border: none; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 10px; color: white; transition: opacity 0.15s, background 0.15s;
            line-height: 1;
        }
        .file-item:hover .file-remove { opacity: 1; }
        .file-remove:hover { background: #ef4444; }

        /* ── Content Viewer ── */
        .content-main {
            flex: 1; display: flex; flex-direction: column;
            background: var(--bg); overflow: hidden; position: relative; min-width: 0;
        }

        .content-toolbar {
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            padding: 0.5rem 1rem;
            display: flex; align-items: center;
            justify-content: space-between; gap: 0.75rem;
            flex-shrink: 0; min-height: 44px;
        }

        .doc-title {
            font-size: 0.875rem; font-weight: 500; color: var(--text-light);
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
        }

        /* Content view area wraps body + TOC panel side by side */
        .content-view-area {
            flex: 1; display: flex; overflow: hidden;
        }

        .content-body {
            flex: 1; overflow-y: auto;
            padding: 2.5rem 2rem;
        }

        /* ── Table of Contents Panel ── */
        .toc-panel {
            width: 250px; flex-shrink: 0;
            background: var(--surface);
            border-left: 1px solid var(--border);
            display: flex; flex-direction: column;
            overflow: hidden;
            transition: width 0.25s ease;
        }
        .toc-panel.collapsed { width: 0; }

        .toc-header {
            padding: 0.5rem 0.75rem 0.5rem 0.875rem;
            border-bottom: 1px solid var(--border);
            font-size: 0.7rem; font-weight: 700;
            color: var(--text-light); text-transform: uppercase; letter-spacing: 0.08em;
            display: flex; align-items: center; justify-content: space-between;
            flex-shrink: 0; min-width: 250px; white-space: nowrap;
        }

        .toc-nav {
            flex: 1; overflow-y: auto; padding: 0.375rem 0;
            min-width: 250px;
        }

        .toc-empty {
            padding: 1rem 0.875rem;
            font-size: 0.8rem; color: var(--text-light); line-height: 1.5;
        }

        .toc-page-divider {
            padding: 0.5rem 0.875rem 0.2rem;
            font-size: 0.65rem; font-weight: 700;
            color: var(--text-light); text-transform: uppercase; letter-spacing: 0.08em;
            opacity: 0.55; margin-top: 0.25rem; white-space: nowrap;
        }
        .toc-page-divider:first-child { margin-top: 0; }

        .toc-item {
            display: flex; align-items: center; gap: 0.375rem;
            padding: 0.28rem 0.75rem 0.28rem 0.875rem;
            font-size: 0.8rem; color: var(--text);
            text-decoration: none; cursor: pointer;
            border-left: 2px solid transparent;
            transition: background 0.15s, color 0.15s, border-color 0.15s;
            white-space: nowrap; overflow: hidden;
        }
        .toc-item:hover { background: var(--bg); color: var(--primary); }
        .toc-item.active {
            color: var(--primary); background: var(--primary-light);
            border-left-color: var(--primary); font-weight: 600;
        }

        .toc-h2 { padding-left: 0.875rem; }
        .toc-h3 { padding-left: 1.625rem; font-size: 0.75rem; color: var(--text-light); }
        .toc-h3:hover, .toc-h3.active { color: var(--primary); }

        .toc-item-text {
            flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .toc-pg {
            font-size: 0.65rem; color: var(--text-light);
            flex-shrink: 0; opacity: 0.7;
        }

        /* ── Page Navigator ── */
        .page-nav {
            display: flex; align-items: center; gap: 0.125rem;
        }
        .page-indicator {
            display: flex; align-items: center;
            font-size: 0.75rem; font-weight: 600; color: var(--text-light);
            white-space: nowrap; user-select: none;
        }
        .page-input {
            width: 32px;
            border: 1px solid transparent;
            background: transparent;
            font-size: 0.75rem; font-weight: 600;
            color: var(--text-light); text-align: center;
            outline: none; padding: 0.15rem 0.2rem;
            border-radius: 0.3rem; font-family: inherit;
            cursor: default;
            transition: border-color 0.15s, background 0.15s, color 0.15s;
        }
        .page-input:not([disabled]):hover {
            border-color: var(--border); cursor: text;
        }
        .page-input:focus {
            border-color: var(--primary); background: var(--bg);
            color: var(--text); cursor: text;
        }

        /* ── Zoom Controls ── */
        .zoom-controls {
            display: flex; align-items: center; gap: 0.125rem;
        }
        .zoom-display {
            font-size: 0.75rem; font-weight: 600; color: var(--text-light);
            min-width: 38px; text-align: center; cursor: pointer;
            padding: 0.2rem 0.25rem; border-radius: 0.3rem;
            transition: background 0.15s, color 0.15s; user-select: none;
        }
        .zoom-display:hover { background: var(--bg); color: var(--primary); }
        .toolbar-sep {
            width: 1px; height: 18px;
            background: var(--border); margin: 0 0.125rem;
        }

        /* ── Hand Tool cursors ── */
        .content-body.hand-tool             { cursor: grab; }
        .content-body.hand-tool.panning     { cursor: grabbing; }
        .content-body.hand-tool .pdf-page-canvas,
        .content-body.hand-tool .pdf-page-wrapper { cursor: inherit; }

        /* Active state for btn-ghost (e.g. TOC toggle button when panel open) */
        .btn-ghost.active {
            background: var(--primary-light);
            border-color: var(--primary);
            color: var(--primary);
        }

        .content-empty {
            display: flex; flex-direction: column; align-items: center;
            justify-content: center; height: 100%; gap: 1rem;
            color: var(--text-light); text-align: center; font-size: 0.9rem;
        }

        /* ── Page sections ── */
        .page-section {
            max-width: 780px; margin: 0 auto 3rem;
            padding-bottom: 2.5rem;
            border-bottom: 1px solid var(--border);
        }
        .page-section:last-child { border-bottom: none; }

        /* ── Canvas-rendered PDF pages ── */
        .canvas-page-section {
            max-width: none;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .pdf-page-wrapper {
            position: relative;            /* needed so text layer + highlights sit on top */
            background: #ffffff;
            box-shadow: 0 2px 8px rgba(0,0,0,0.14), 0 0 0 1px rgba(0,0,0,0.06);
            border-radius: 2px;
            overflow: hidden;
            line-height: 0; /* eliminates gap beneath canvas */
        }

        .pdf-page-canvas {
            display: block;
            max-width: 100%;
        }

        /* ── Text layer (transparent spans for selection & search highlighting) ── */
        .pdf-text-layer {
            position: absolute;
            top: 0; left: 0;
            overflow: hidden;
            line-height: 1;
            user-select: text;
            cursor: text;
        }

        .pdf-text-layer span,
        .pdf-text-layer br {
            color: transparent;
            position: absolute;
            white-space: pre;
            cursor: text;
            transform-origin: 0% 0%;
            -webkit-text-stroke: 0;
        }

        /* Canvas overlay painted by drawHighlightsOnPage() */
        .search-hl-canvas {
            position: absolute;
            top: 0; left: 0;
            pointer-events: none;
        }

        .pdf-page-error {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 200px;
            min-width: 300px;
            padding: 2rem;
            color: var(--text-light);
            font-size: 0.875rem;
            background: var(--bg);
            border: 1px dashed var(--border);
            border-radius: 4px;
        }

        body.dark .pdf-page-wrapper {
            box-shadow: 0 2px 12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.08);
        }

        .page-label {
            display: inline-block;
            background: var(--primary-light); color: var(--primary);
            font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em;
            padding: 0.2rem 0.65rem; border-radius: 999px;
            margin-bottom: 1.25rem; text-transform: uppercase;
        }

        /* ── Markdown typography ── */
        .page-content { line-height: 1.8; color: var(--text); font-size: 0.9375rem; }

        .page-content h1 {
            font-size: 1.6rem; font-weight: 800; margin: 0 0 1rem;
            color: var(--text); line-height: 1.25; border-bottom: 2px solid var(--border);
            padding-bottom: 0.5rem;
        }
        .page-content h2 {
            font-size: 1.25rem; font-weight: 700; margin: 1.75rem 0 0.75rem;
            color: var(--text); line-height: 1.3;
        }
        .page-content h3 {
            font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 0.5rem;
            color: var(--text);
        }
        .page-content h4, .page-content h5, .page-content h6 {
            font-size: 0.9375rem; font-weight: 600; margin: 1.25rem 0 0.375rem;
            color: var(--text-light);
        }
        .page-content p { margin-bottom: 1rem; }

        .page-content ul, .page-content ol {
            margin: 0.5rem 0 1rem 1.5rem;
        }
        .page-content li { margin-bottom: 0.35rem; }

        .page-content strong { font-weight: 700; }
        .page-content em     { font-style: italic; color: var(--text-light); }

        .page-content code {
            background: #f1f5f9;
            border: 1px solid var(--border);
            padding: 0.15em 0.4em;
            border-radius: 4px;
            font-size: 0.85em;
            font-family: 'Courier New', Courier, monospace;
            color: #c7254e;
        }
        .page-content pre {
            background: #1e293b; color: #e2e8f0;
            border-radius: 0.625rem; padding: 1.25rem;
            overflow-x: auto; margin: 1.25rem 0;
            font-size: 0.85rem; line-height: 1.6;
        }
        .page-content pre code {
            background: none; border: none; padding: 0; color: inherit; font-size: inherit;
        }
        .page-content blockquote {
            border-left: 3px solid var(--primary);
            padding: 0.5rem 1rem; margin: 1rem 0;
            background: var(--primary-light);
            border-radius: 0 0.375rem 0.375rem 0;
            color: var(--text-light); font-style: italic;
        }
        .page-content table {
            width: 100%; border-collapse: collapse; margin: 1.25rem 0;
            font-size: 0.875rem; border-radius: 0.5rem; overflow: hidden;
            box-shadow: 0 0 0 1px var(--border);
        }
        .page-content th {
            background: var(--primary-light); color: var(--primary);
            padding: 0.625rem 0.875rem; text-align: left;
            border-bottom: 1px solid var(--border); font-weight: 600;
        }
        .page-content td {
            padding: 0.5rem 0.875rem; border-bottom: 1px solid var(--border);
        }
        .page-content tr:last-child td { border-bottom: none; }
        .page-content tr:nth-child(even) td { background: var(--bg); }

        .page-content hr {
            border: none; border-top: 1px solid var(--border); margin: 1.5rem 0;
        }

        /* ── Find Overlay ── */
        .find-overlay {
            position: absolute; top: 54px; right: 16px;
            background: var(--surface); padding: 0.875rem;
            border-radius: 0.75rem; box-shadow: var(--shadow-lg);
            border: 1px solid var(--border);
            display: none; flex-direction: column; gap: 0.5rem; z-index: 60; min-width: 270px;
        }
        .find-overlay.active { display: flex; }
        .find-input-row  { display: flex; gap: 0.375rem; }
        .find-input {
            flex: 1; padding: 0.4rem 0.625rem;
            border: 1px solid var(--border); border-radius: 0.375rem;
            outline: none; font-size: 0.875rem;
        }
        .find-input:focus { border-color: var(--primary); }
        .find-count { font-size: 0.75rem; color: var(--text-light); text-align: right; }

        /* ── Chat Sidebar ── */
        .sidebar {
            width: var(--chat-panel-w);
            background: var(--surface); border-left: 1px solid var(--border);
            display: flex; flex-direction: column;
            flex-shrink: 0; z-index: 50;
            transition: width 0.25s ease; overflow: hidden;
        }
        .sidebar.collapsed { width: 0; }

        .chat-header {
            padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
            background: linear-gradient(to right, var(--primary-light), var(--surface));
            flex-shrink: 0; display: flex; align-items: flex-start;
            justify-content: space-between; min-width: var(--chat-panel-w);
        }
        .chat-header-info h2 {
            font-size: 0.9375rem; display: flex; align-items: center; gap: 0.5rem;
        }
        .chat-header-info p {
            font-size: 0.75rem; color: var(--text-light); margin-top: 0.25rem; margin-left: 26px;
        }

        .chat-messages {
            flex: 1; overflow-y: auto; padding: 1rem;
            display: flex; flex-direction: column; gap: 0.875rem;
            background: #fafafa; min-width: var(--chat-panel-w);
        }
        .message {
            max-width: 88%; padding: 0.75rem 1rem; border-radius: 1rem;
            font-size: 0.875rem; line-height: 1.5; animation: msgIn 0.25s ease-out;
        }
        @keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

        .message.user {
            align-self: flex-end; background: var(--primary); color: white;
            border-bottom-right-radius: 0.25rem;
        }
        .message.assistant {
            align-self: flex-start; background: white; border: 1px solid var(--border);
            border-bottom-left-radius: 0.25rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        }
        .message-time { font-size: 0.6875rem; opacity: 0.7; margin-top: 0.25rem; text-align: right; }

        .chat-input-container {
            padding: 0.875rem; border-top: 1px solid var(--border);
            background: white; flex-shrink: 0; min-width: var(--chat-panel-w);
        }
        .input-wrapper {
            display: flex; align-items: flex-end; gap: 0.5rem;
            background: var(--bg); border: 1px solid var(--border);
            border-radius: 1rem; padding: 0.5rem 0.5rem 0.5rem 0.875rem; transition: all 0.2s;
        }
        .input-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
        .chat-input {
            flex: 1; border: none; background: transparent; outline: none; resize: none;
            max-height: 100px; font-family: inherit; font-size: 0.875rem; line-height: 1.5; padding: 0.25rem 0;
        }
        .send-btn {
            background: var(--primary); color: white; border: none;
            width: 32px; height: 32px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer; transition: all 0.2s; flex-shrink: 0;
        }
        .send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }

        /* ── Upload Modal ── */
        .upload-modal {
            position: fixed; inset: 0;
            background: rgba(255,255,255,0.97); backdrop-filter: blur(10px);
            display: flex; align-items: center; justify-content: center;
            z-index: 300; transition: opacity 0.3s; padding: 1.5rem;
        }
        .upload-modal.hidden { opacity: 0; pointer-events: none; }
        .upload-content { width: 100%; max-width: 520px; text-align: center; }
        .upload-zone {
            border: 2px dashed var(--border); border-radius: 1.25rem;
            padding: 2.5rem 1.5rem; background: white; transition: all 0.3s;
            cursor: pointer; margin-top: 1.5rem; box-shadow: var(--shadow);
        }
        .upload-zone:hover, .upload-zone.dragover {
            border-color: var(--primary); background: var(--primary-light);
            transform: translateY(-2px); box-shadow: var(--shadow-lg);
        }
        .upload-title    { font-size: 1.25rem; font-weight: 700; margin-top: 0.75rem; }
        .upload-subtitle { color: var(--text-light); font-size: 0.875rem; }

        /* ── Loading ── */
        .loading-screen {
            position: fixed; inset: 0; background: rgba(255,255,255,0.94);
            display: none; flex-direction: column; align-items: center;
            justify-content: center; gap: 1rem; z-index: 290;
        }
        .loading-screen.active { display: flex; }
        .spinner {
            width: 40px; height: 40px; border: 3px solid var(--border);
            border-top-color: var(--primary); border-radius: 50%;
            animation: spin 0.9s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* ── Mobile Tab Bar ── */
        .mobile-tabs {
            display: none; background: var(--surface);
            border-top: 1px solid var(--border); flex-shrink: 0;
        }
        .mobile-tab {
            flex: 1; padding: 0.5rem 0.25rem; border: none; background: none; cursor: pointer;
            display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
            font-size: 0.6875rem; color: var(--text-light); transition: color 0.2s;
        }
        .mobile-tab.active { color: var(--primary); }

        /* ── Mobile Panel Backdrop ── */
        .panel-backdrop {
            display: none; position: fixed; inset: 0;
            background: rgba(0,0,0,0.38); z-index: 149;
        }
        .panel-backdrop.active { display: block; }

        /* ── Scrollbar ── */
        ::-webkit-scrollbar       { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

        /* ── Streaming typing indicator ── */
        .stream-cursor {
            display: inline-flex; align-items: center;
            gap: 4px; margin-left: 6px; vertical-align: middle;
        }
        .stream-cursor .dot {
            display: inline-block; width: 6px; height: 6px;
            border-radius: 50%; background: var(--text-light);
            animation: typing-dot 1.2s ease-in-out infinite;
        }
        .stream-cursor .dot:nth-child(1) { animation-delay: 0s; }
        .stream-cursor .dot:nth-child(2) { animation-delay: 0.2s; }
        .stream-cursor .dot:nth-child(3) { animation-delay: 0.4s; }
        @keyframes typing-dot {
            0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
            30%            { transform: translateY(-5px); opacity: 1; }
        }

        /* ── Markdown in chat messages ── */
        .message.assistant code {
            background: #f1f5f9; border: 1px solid var(--border);
            padding: 0.1em 0.35em; border-radius: 3px;
            font-size: 0.82em; font-family: 'Courier New', Courier, monospace;
            color: #c7254e;
        }
        .message.assistant strong { font-weight: 600; }
        .message.assistant em     { font-style: italic; }

        /* ═══════════════════════════
           DARK THEME
        ═══════════════════════════ */
        body.dark {
            --primary:       #3b82f6;
            --primary-light: #1e3a5f;
            --primary-hover: #60a5fa;
            --bg:            #0f172a;
            --surface:       #1e293b;
            --text:          #e2e8f0;
            --text-light:    #94a3b8;
            --border:        #334155;
            --shadow:        0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
            --shadow-lg:     0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
        }

        body.dark .btn                     { background: var(--surface); }
        body.dark .btn:hover               { background: #273344; }
        body.dark .btn-primary             { background: var(--primary); color: #fff; }
        body.dark .btn-primary:hover       { background: var(--primary-hover); }
        body.dark .btn-ghost               { background: transparent; }
        body.dark .btn-ghost:hover         { background: #273344; border-color: var(--border); }
        body.dark .btn-ghost.active        { background: #1e3a5f; }

        body.dark .chat-messages           { background: var(--bg); }
        body.dark .message.assistant       { background: var(--surface); border-color: var(--border); }
        body.dark .chat-input-container    { background: var(--surface); }

        body.dark .upload-modal            { background: rgba(15,23,42,0.97); }
        body.dark .upload-zone             { background: var(--surface); }
        body.dark .upload-zone:hover,
        body.dark .upload-zone.dragover    { background: var(--primary-light); }
        body.dark .loading-screen          { background: rgba(15,23,42,0.94); }

        body.dark .file-thumb-wrap         { background: #273344; }

        body.dark .page-content code       { background: #273344; color: #f87171; border-color: var(--border); }
        body.dark .message.assistant code  { background: #273344; color: #f87171; border-color: var(--border); }

        body.dark .stream-cursor .dot      { background: var(--text-light); }

        /* ═══════════════════════════
           RESPONSIVE BREAKPOINTS
        ═══════════════════════════ */

        @media (max-width: 1024px) {
            :root { --chat-panel-w: 300px; }
        }

        @media (max-width: 768px) {
            .file-panel {
                position: fixed;
                top: var(--header-h); left: 0; bottom: var(--tabbar-h);
                width: 260px !important;
                transform: translateX(-100%);
                box-shadow: var(--shadow-lg); z-index: 150;
                transition: transform 0.3s ease;
            }
            .file-panel.mobile-open { transform: translateX(0); }

            .sidebar {
                position: fixed;
                top: var(--header-h); right: 0; bottom: var(--tabbar-h);
                width: min(340px, 100vw) !important;
                transform: translateX(110%);
                box-shadow: var(--shadow-lg); z-index: 150;
                transition: transform 0.3s ease;
            }
            .sidebar.mobile-open { transform: translateX(0); }

            .content-main { width: 100%; }
            .content-body { padding: 1.25rem 1rem; }
            .mobile-tabs  { display: flex; }
            .hide-mobile  { display: none; }
            .toc-panel    { display: none; }
            #tocBtn       { display: none; }
        }

        @media (max-width: 480px) {
            .logo-text    { display: none; }
            .find-overlay { left: 8px; right: 8px; min-width: unset; }
        }
