        body { overflow-x: hidden; }

        :root {
            --body-bg: #0b1111;
            --widget-title-color: #fff;
            --widget-link-color: #888;
            --widget-badge-bg: rgba(255,255,255,0.05);
            --widget-badge-color: #aaa;
            --exam-paper-bg: rgba(255,255,255,0.025);
            --exam-paper-border: rgba(92,225,230,0.09);
            --exam-text-color: #ddd;
            --exam-bold-color: #f4f4f4;
            --exam-title-color: #f0f0f0;
            --exam-divider-color: rgba(92,225,230,0.1);
        }

        body:not(.dark-mode) {
            --body-bg: #f8fafc;
            --widget-title-color: #1e293b;
            --widget-link-color: #64748b;
            --widget-badge-bg: rgba(0,0,0,0.05);
            --widget-badge-color: #475569;
            --exam-paper-bg: #ffffff;
            --exam-paper-border: rgba(15,23,42,0.08);
            --exam-text-color: #334155;
            --exam-bold-color: #0f172a;
            --exam-title-color: #1e293b;
            --exam-divider-color: rgba(15,23,42,0.08);
            --accent-cyan: #009eb3;
        }

        body {
            background-color: var(--body-bg);
            transition: background-color 0.3s ease;
        }

        .main-wrapper {
            position: relative;
            max-width: 2000px !important;
            width: 100% !important;
            margin: 0 auto !important;
            transform: none !important;
            left: 0 !important;
            transition: transform 0s !important;
        }

        .main-content-layout {
            display: grid;
            grid-template-columns: 200px 1fr;
            gap: 36px;
            margin-top: 20px;
            min-width: 0;
        }

        .tags-comment-sidebar {
            display: flex;
            flex-direction: column;
            gap: 36px;
            position: sticky;
            top: 100px;
            height: fit-content;
            z-index: 1;
        }

        .side-widget-title {
            font-family: 'Playfair Display', serif;
            font-size: 1.1rem;
            color: var(--widget-title-color);
            margin-bottom: 16px;
            padding-bottom: 8px;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            transition: color 0.3s ease;
        }

        body.light-mode .side-widget-title {
            border-bottom: 1px solid rgba(0,0,0,0.08);
        }

        .side-widget-list {
            list-style: none; padding: 0; margin: 0;
            display: flex; flex-direction: column; gap: 12px;
        }

        .side-widget-list a {
            display: flex; justify-content: space-between; align-items: center;
            color: var(--widget-link-color); text-decoration: none; font-size: 0.85rem; transition: all 0.2s;
        }

        .side-widget-list a:hover { color: var(--accent-cyan); transform: translateX(4px); }

        .side-widget-list a span {
            font-family: 'JetBrains Mono', monospace; font-size: 0.7rem;
            background: var(--widget-badge-bg); padding: 2px 8px;
            border-radius: 12px; color: var(--widget-badge-color);
            transition: background-color 0.3s ease, color 0.3s ease;
        }

        @media (max-width: 1100px) {
            .main-content-layout { grid-template-columns: 1fr; }
            .tags-comment-sidebar { position: static; }
        }

        .main-articles-body {
            min-width: 0;
            overflow: hidden;
        }

        .stats-strip {
            display: flex; gap: 0;
            border: 1px solid var(--border-light);
            border-radius: 8px; overflow: hidden;
            margin-bottom: 36px; margin-top: 50px;
            max-width: 100%; box-sizing: border-box;
        }
        .stat-item {
            flex: 1; padding: 18px 20px; text-align: center;
            border-right: 1px solid var(--border-light);
        }
        .stat-item:last-child { border-right: none; }
        .stat-number {
            font-family: 'JetBrains Mono', monospace; font-size: 1.6rem;
            font-weight: 700; color: var(--accent-cyan); line-height: 1; margin-bottom: 6px;
        }
        .stat-label { font-size: 0.72rem; color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase; }

        .exam-back-btn {
            display: inline-flex; align-items: center; gap: 8px;
            color: var(--accent-cyan, #5ce1e6); text-decoration: none;
            font-size: 0.8rem; font-family: 'JetBrains Mono', monospace;
            letter-spacing: 1px; text-transform: uppercase;
            margin-bottom: 22px; opacity: 0.65; transition: opacity 0.2s;
        }
        .exam-back-btn:hover { opacity: 1; }

        .exam-meta { display: flex; gap: 10px; margin-bottom: 28px; flex-wrap: wrap; }
        .exam-tag {
            font-size: 0.7rem; font-family: 'JetBrains Mono', monospace;
            padding: 4px 13px; border-radius: 20px;
            border: 1px solid rgba(92,225,230,0.35);
            color: var(--accent-cyan, #5ce1e6);
        }

        /* ── LaTeX Editor specific ── */
        .latex-hero { margin-bottom: 22px; }
        .latex-hero h1 {
            font-family: 'Playfair Display', serif;
            font-size: 1.6rem;
            color: var(--exam-title-color);
            margin: 0 0 5px 0;
        }
        .latex-hero p { font-size: 0.85rem; color: var(--exam-text-color); opacity: 0.7; margin: 0; }

        /* Snippet toolbar */
        .snippet-toolbar {
            display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px;
        }
        .snip-group-label {
            width: 100%;
            font-size: 0.66rem; font-family: 'JetBrains Mono', monospace;
            letter-spacing: 1.5px; text-transform: uppercase;
            color: var(--accent-cyan, #5ce1e6); opacity: 0.65;
            margin-top: 4px; margin-bottom: 2px;
        }
        .snip-btn {
            background: rgba(92,225,230,0.07);
            border: 1px solid rgba(92,225,230,0.15);
            border-radius: 6px; padding: 5px 11px;
            color: var(--exam-text-color);
            font-family: 'JetBrains Mono', monospace; font-size: 0.77rem;
            cursor: pointer; transition: all 0.18s; white-space: nowrap;
        }
        .snip-btn:hover {
            background: rgba(92,225,230,0.18);
            border-color: rgba(92,225,230,0.5);
            color: var(--accent-cyan, #5ce1e6);
            transform: translateY(-1px);
        }
        body:not(.dark-mode) .snip-btn { background: rgba(0,0,0,0.04); border-color: rgba(15,23,42,0.10); }

        /* Editor workspace */
        .latex-workspace {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 18px;
            align-items: start;
            min-width: 0;
            overflow: hidden;
        }
        .editor-pane, .preview-pane { min-width: 0; }
        @media (max-width: 860px) { .latex-workspace { grid-template-columns: 1fr; } }

        .editor-pane, .preview-pane { display: flex; flex-direction: column; }

        .pane-header {
            display: flex; align-items: center; justify-content: space-between;
            background: rgba(92,225,230,0.06);
            border: 1px solid rgba(92,225,230,0.12);
            border-bottom: none;
            border-radius: 10px 10px 0 0;
            padding: 9px 15px;
        }
        .pane-title {
            font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
            letter-spacing: 1.2px; text-transform: uppercase;
            color: var(--accent-cyan, #5ce1e6);
        }
        .pane-actions { display: flex; gap: 7px; }
        .pane-btn {
            background: rgba(92,225,230,0.09);
            border: 1px solid rgba(92,225,230,0.22);
            border-radius: 5px; padding: 4px 11px;
            color: var(--accent-cyan, #5ce1e6);
            font-family: 'JetBrains Mono', monospace; font-size: 0.70rem;
            letter-spacing: 0.8px; text-transform: uppercase;
            cursor: pointer; transition: all 0.2s;
        }
        .pane-btn:hover { background: rgba(92,225,230,0.2); border-color: rgba(92,225,230,0.55); }
        .pane-btn.danger { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.22); color: #f87171; }
        .pane-btn.danger:hover { background: rgba(248,113,113,0.2); }

        .CodeMirror {
            width: 100%; max-width: 100%; box-sizing: border-box;
            background: rgba(255,255,255,0.025);
            border: 1px solid rgba(92,225,230,0.10);
            border-top: none; border-radius: 0 0 10px 10px;
            font-family: 'JetBrains Mono', monospace; font-size: 0.86rem;
            line-height: 1.75; min-height: 400px; height: 100%;
            outline: none; transition: border-color 0.2s; tab-size: 2;
        }
        .CodeMirror-lines {
            padding: 16px 0;
        }
        .CodeMirror-scroll { min-height: 400px; }
        body:not(.dark-mode) .CodeMirror { background: #f1f5f9; border-color: rgba(15,23,42,0.08); }
        .CodeMirror-focused { border-color: rgba(92,225,230,0.38) !important; }

        #latex-preview {
            background: var(--exam-paper-bg);
            border: 1px solid var(--exam-paper-border);
            border-top: none; border-radius: 0 0 10px 10px;
            padding: 22px 26px;
            font-family: "Times New Roman", Times, serif; font-size: 1.01rem;
            color: var(--exam-text-color); line-height: 1.9;
            min-height: 400px; overflow-y: auto;
            
            overflow-x: auto;
            white-space: pre-wrap;

            transition: background 0.3s, border-color 0.3s;
        }
        #latex-preview.empty-state {
            display: flex; align-items: center; justify-content: center;
            color: rgba(150,150,150,0.3); font-family: 'Inter', sans-serif;
            font-style: italic; font-size: 0.88rem;
        }
        #latex-preview h1, #latex-preview h2 {
            font-family: "Times New Roman", serif; text-align: center;
            color: var(--exam-title-color);
        }
        #latex-preview h1 { font-size: 1.3rem; margin: 6px 0; }
        #latex-preview h2 { font-size: 1.1rem; font-weight: normal; margin: 5px 0; }
        #latex-preview h3 {
            font-size: 1.05rem; color: var(--accent-cyan, #5ce1e6);
            border-left: 3px solid var(--accent-cyan, #5ce1e6);
            padding-left: 10px; margin-top: 22px;
            font-family: "Times New Roman", serif;
        }
        #latex-preview p { margin: 8px 0; }

        .status-bar {
            display: flex; align-items: center; justify-content: space-between;
            margin-top: 8px;
            font-family: 'JetBrains Mono', monospace; font-size: 0.70rem;
            color: var(--exam-text-color); opacity: 0.45;
        }
        .status-dot {
            width: 6px; height: 6px; border-radius: 50%; background: #4ade80;
            display: inline-block; margin-right: 6px;
            animation: pulse-dot 2s ease-in-out infinite;
        }
        @keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.35} }

        .export-bar { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
        .export-btn {
            display: inline-flex; align-items: center; gap: 8px;
            background: linear-gradient(135deg, rgba(92,225,230,0.12), rgba(167,139,250,0.12));
            border: 1px solid rgba(92,225,230,0.28);
            border-radius: 9px; padding: 11px 20px;
            color: var(--accent-cyan, #5ce1e6);
            font-family: 'JetBrains Mono', monospace; font-size: 0.78rem;
            letter-spacing: 0.8px; text-transform: uppercase;
            cursor: pointer; transition: all 0.22s;
        }
        .export-btn:hover {
            background: linear-gradient(135deg, rgba(92,225,230,0.22), rgba(167,139,250,0.22));
            border-color: rgba(92,225,230,0.6);
            transform: translateY(-2px);
            box-shadow: 0 5px 16px rgba(92,225,230,0.12);
        }
        .export-btn.purple { border-color: rgba(167,139,250,0.3); color: #a78bfa; }
        .export-btn.purple:hover { border-color: rgba(167,139,250,0.65); box-shadow: 0 5px 16px rgba(167,139,250,0.12); }

        /* Snippet toolbar grid layout */
        .snippet-toolbar {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-bottom: 20px;
            align-items: start;
        }

        .snip-group-row {
            display: flex;
            align-items: center;
            background: rgba(255, 255, 255, 0.03);
            border-radius: 8px;
            padding: 6px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            transition: all 0.2s ease;
        }

        .snip-group-row:hover {
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(92, 225, 230, 0.3);
        }

        .snip-group-label {
            width: 130px;
            flex-shrink: 0;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--exam-primary-color);
            opacity: 0.8;
            padding-right: 10px;
            display: flex;
            align-items: center;
        }

        .drag-handle {
            cursor: grab;
            margin-right: 8px;
            opacity: 0.3;
            transition: opacity 0.2s;
            font-size: 1.1rem;
            line-height: 1;
        }
        .snip-group-row:hover .drag-handle {
            opacity: 1;
        }
        .drag-handle:active {
            cursor: grabbing;
        }

        .sortable-ghost {
            opacity: 0.4;
            background: rgba(92, 225, 230, 0.1);
            border: 1px dashed #5ce1e6;
        }
        .sortable-drag {
            cursor: grabbing !important;
        }

        .snip-group-btns {
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
            flex: 1;
            min-width: 0;
        }

        .exam-end {
            text-align: center; color: #999; font-style: italic;
            margin-top: 44px; padding-top: 20px;
            border-top: 1px solid rgba(255,255,255,0.06);
        }
        body.light-mode .exam-end { border-top: 1px solid rgba(0,0,0,0.06); }

        /* Split.js Gutter */
        .gutter {
            background-color: rgba(92,225,230,0.05);
            background-repeat: no-repeat;
            background-position: 50%;
            cursor: col-resize;
            border-radius: 4px;
            transition: background-color 0.2s;
        }
        .gutter:hover {
            background-color: rgba(92,225,230,0.2);
        }
        .latex-workspace {
            display: flex;
            flex-direction: row;
        }

        /* Zen Mode */
        body.zen-mode #sidebar-placeholder,
        body.zen-mode #topbar-placeholder,
        body.zen-mode .tags-comment-sidebar,
        body.zen-mode .exam-meta,
        body.zen-mode .exam-back-btn,
        body.zen-mode .latex-hero,
        body.zen-mode .giscus-section-outer,
        body.zen-mode .stats-strip,
        body.zen-mode .site-footer {
            display: none !important;
        }
        
        body.zen-mode .main-content-layout {
            grid-template-columns: 1fr;
            margin-top: 0;
            gap: 0;
        }
        
        body.zen-mode .main-wrapper {
            padding: 0;
            margin: 0;
            max-width: 100% !important;
        }

        body.zen-mode .latex-workspace {
            height: calc(100vh - 120px);
        }
        body.zen-mode .CodeMirror, body.zen-mode #latex-preview {
            height: 100%;
        }

        /* ── CodeMirror Hints (Autocomplete) Premium UI ── */
        .CodeMirror-hints {
            position: absolute;
            z-index: 10000;
            overflow: hidden;
            list-style: none;
            margin: 0;
            padding: 8px;
            background: rgba(16, 24, 32, 0.85) !important;
            backdrop-filter: blur(14px) saturate(180%);
            -webkit-backdrop-filter: blur(14px) saturate(180%);
            border: 1px solid rgba(178, 140, 255, 0.3) !important;
            border-radius: 12px !important;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5) !important;
            font-family: 'JetBrains Mono', monospace !important;
            font-size: 0.84rem !important;
            color: #e2e8f0;
            max-height: 250px;
            overflow-y: auto;
        }

        .CodeMirror-hint {
            margin: 0;
            padding: 8px 14px !important;
            border-radius: 6px !important;
            white-space: pre;
            color: rgba(255, 255, 255, 0.7) !important;
            cursor: pointer;
            transition: all 0.15s ease;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        li.CodeMirror-hint-active {
            background: rgba(178, 140, 255, 0.18) !important;
            color: #d8b4fe !important;
            font-weight: 500;
        }

        /* Tùy chỉnh thanh cuộn cho Hint */
        .CodeMirror-hints::-webkit-scrollbar { width: 6px; }
        .CodeMirror-hints::-webkit-scrollbar-track { background: transparent; }
        .CodeMirror-hints::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
        .CodeMirror-hints::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

        /* Light Mode Hints */
        body.light-mode .CodeMirror-hints, 
        body:not(.dark-mode) .CodeMirror-hints {
            background: rgba(255, 255, 255, 0.9) !important;
            border-color: rgba(15, 23, 42, 0.1) !important;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1) !important;
        }
        body.light-mode .CodeMirror-hint,
        body:not(.dark-mode) .CodeMirror-hint {
            color: #475569 !important;
        }
        body.light-mode li.CodeMirror-hint-active,
        body:not(.dark-mode) li.CodeMirror-hint-active {
            background: rgba(15, 23, 42, 0.06) !important;
            color: #0f172a !important;
        }

        /* ── LIGHT MODE OVERRIDES FOR CODEMIRROR THEME ── */
        body:not(.dark-mode) .CodeMirror {
            background-color: #f8fafc !important;
            color: #334155 !important;
        }
        body:not(.dark-mode) .CodeMirror-gutters {
            background-color: #f1f5f9 !important;
            border-right: 1px solid #e2e8f0 !important;
        }
        body:not(.dark-mode) .CodeMirror-linenumber {
            color: #94a3b8 !important;
        }
        body:not(.dark-mode) .CodeMirror-cursor {
            border-left-color: #0f172a !important;
        }
        body:not(.dark-mode) .CodeMirror-selected {
            background-color: #cbd5e1 !important;
        }
        body:not(.dark-mode) .CodeMirror-line::selection, 
        body:not(.dark-mode) .CodeMirror-line>span::selection, 
        body:not(.dark-mode) .CodeMirror-line>span>span::selection {
            background-color: #cbd5e1 !important;
        }
        body:not(.dark-mode) .CodeMirror-activeline-background {
            background-color: rgba(15, 23, 42, 0.04) !important;
        }

        /* Syntax highlighting overrides for Light Mode */
        body:not(.dark-mode) .cm-s-material-darker.CodeMirror { color: #334155 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-keyword { color: #2563eb !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-atom { color: #d946ef !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-number { color: #ea580c !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-def { color: #059669 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-variable { color: #334155 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-variable-2 { color: #0284c7 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-variable-3 { color: #16a34a !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-property { color: #4f46e5 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-operator { color: #9333ea !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-comment { color: #94a3b8 !important; font-style: italic; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-string { color: #15803d !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-string-2 { color: #b45309 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-meta { color: #64748b !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-qualifier { color: #0d9488 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-builtin { color: #ca8a04 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-bracket { color: #475569 !important; font-weight: bold; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-tag { color: #dc2626 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-attribute { color: #ea580c !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-header { color: #2563eb !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-quote { color: #059669 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-hr { color: #cbd5e1 !important; }
        body:not(.dark-mode) .cm-s-material-darker span.cm-link { color: #2563eb !important; }


        