@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        body { font-family: 'Inter', sans-serif; }
        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: #f8fafc; }
        ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
        ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
        #tabList::-webkit-scrollbar { height: 4px; width: 0; }
        #tabList { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
        #readerMain.reader-main-expanded { max-width: none !important; }
        /* Giảm khoảng cách dọc khi mở rộng */
        #readerMain.reader-main-expanded {
            padding-top: 0 !important;
            padding-bottom: 0 !important;
        }
        #readerMain.reader-main-expanded > :not([hidden]) ~ :not([hidden]) { margin-top: 0.25rem !important; }
        #readerMain.reader-main-expanded #tabSection > .space-y-5 { padding-top: 0.25rem !important; }
        #readerMain.reader-main-expanded #tabSection > .space-y-5 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.25rem !important; }

        /* Sticky tab bar container in expanded mode */
        #readerMain.reader-main-expanded #tabBarContainer {
            position: sticky;
            top: 0;
            z-index: 45;
            background-color: #ffffff;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
            
            /* Responsive full-width margins to align with readerMain edges */
            margin-left: -1rem;
            margin-right: -1rem;
            padding-left: 1rem;
            padding-right: 1rem;
            padding-top: 0.25rem;
            padding-bottom: 0.25rem;
        }
        @media (min-width: 640px) {
            #readerMain.reader-main-expanded #tabBarContainer {
                margin-left: -1.5rem;
                margin-right: -1.5rem;
                padding-left: 1.5rem;
                padding-right: 1.5rem;
            }
        }
        @media (min-width: 1024px) {
            #readerMain.reader-main-expanded #tabBarContainer {
                margin-left: -2rem;
                margin-right: -2rem;
                padding-left: 2rem;
                padding-right: 2rem;
            }
        }
        html.dark #readerMain.reader-main-expanded #tabBarContainer {
            background-color: #1e293b !important;
            box-shadow: none;
        }

        /* Focus mode: ẩn header/footer khi mở rộng */
        #siteHeader,
        #siteFooter {
            overflow: hidden;
            transition: opacity 0.25s ease, max-height 0.3s ease;
        }
        #siteHeader { max-height: 60px; }
        #siteFooter { max-height: 50px; }
        #siteHeader.navbar-hidden,
        #siteFooter.navbar-hidden {
            display: none !important;
        }
        /* Ẩn info banner khi mở rộng */
        #infoBanner {
            max-height: 200px;
            overflow: hidden;
            transition: opacity 0.25s ease, max-height 0.3s ease;
        }
        #infoBanner.navbar-hidden {
            display: none !important;
        }
        .reader-session-stat {
            align-items: center;
            background: rgba(99, 102, 241, 0.08);
            border: 1px solid rgba(99, 102, 241, 0.2);
            border-radius: 9999px;
            display: inline-flex;
            font-size: 0.6875rem;
            gap: 0.4rem;
            line-height: 1;
            padding: 0.35rem 0.55rem;
        }
        .reader-session-stat strong {
            color: #3730a3;
            font-variant-numeric: tabular-nums;
            font-weight: 700;
        }
        /* Floating button */
        #focusModeBtn { display: none; }
        #focusModeBtn.focus-visible-btn { display: flex; }
        
        /* Điều chỉnh TOC khi header ẩn */
        #readerMain.reader-main-expanded .md-toc-sidebar {
            top: 0;
            max-height: 100vh;
        }
        .reader-tab-pill { position: relative; }
        .reader-tab-pill.tab-dragging { opacity: 0.45; }
        .reader-tab-pill.tab-drop-before::before,
        .reader-tab-pill.tab-drop-after::after {
            background: #4f46e5;
            border-radius: 9999px;
            content: "";
            height: calc(100% - 0.5rem);
            position: absolute;
            top: 0.25rem;
            width: 3px;
            z-index: 20;
        }
        .reader-tab-pill.tab-drop-before::before { left: -3px; }
        .reader-tab-pill.tab-drop-after::after { right: -3px; }
        /* Safelist cho Tailwind scan các class dùng trong JS */
        .tw-safelist {
            --unused: border-b-2 border-indigo-500 border-transparent text-indigo-600
                      font-semibold text-slate-500 bg-slate-50 hover:bg-slate-100
                      hover:text-slate-700 text-emerald-600 text-amber-600 text-indigo-500
                      text-slate-400 rounded-t-md;
        }

.file-badge {
    background: #f1f5f9;
    border-radius: 0.25rem;
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
}

.markdown-body {
    color: #334155;
    font-size: 0.925rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    scroll-margin-top: 80px;
    color: #0f172a;
    font-weight: 700;
    line-height: 1.3;
    margin: 1.5em 0 0.65em;
}
.markdown-body h1 { font-size: 2rem; }
.markdown-body h2 { font-size: 1.5rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.35em; }
.markdown-body h3 { font-size: 1.25rem; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font-size: 1rem; }
.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body p:first-child { margin-top: 0; }
.markdown-body p { margin: 0.8em 0; }
.markdown-body ul,
.markdown-body ol { margin: 0.8em 0; padding-left: 1.75rem; }
.markdown-body ul { list-style: disc; }
.markdown-body ol { list-style: decimal; }
.markdown-body li { margin: 0.25em 0; transition: color 0.15s ease; }
.markdown-body li:hover { color: #4f46e5; }
html.dark .markdown-body li:hover { color: #818cf8 !important; }
.markdown-body blockquote {
    border-left: 4px solid #818cf8;
    background: #eef2ff;
    color: #475569;
    margin: 1em 0;
    padding: 0.75rem 1rem;
}
.markdown-body code {
    background: #f1f5f9;
    border-radius: 0.3rem;
    color: #be123c;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85em;
    padding: 0.15em 0.35em;
}
.markdown-body pre {
    background: #0f172a;
    border-radius: 0.75rem;
    color: #e2e8f0;
    margin: 1rem 0;
    overflow: auto;
    padding: 1rem;
}
.markdown-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}
.markdown-body a { color: #4f46e5; text-decoration: underline; }
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    margin: 1.5rem 0;
    display: block;
}
.markdown-body hr { border: 0; border-top: 1px solid #cbd5e1; margin: 1.5rem 0; }
.markdown-body table { border-collapse: collapse; display: block; width: 100%; overflow-x: auto; margin: 1em 0; font-size: 0.875rem; }
.markdown-body table th, .markdown-body table td { border: 1px solid #e2e8f0; padding: 0.5rem 0.75rem; text-align: left; overflow-wrap: normal; word-break: normal; transition: border-color 0.15s ease; }
.markdown-body table th { white-space: nowrap; }
.markdown-body table thead { background: #f8fafc; font-weight: 600; color: #475569; }
.markdown-body table tbody tr:nth-child(even) { background: #f8fafc; }
.markdown-body table tbody tr:hover td { border-color: #4f46e5; }
.markdown-body table tbody tr:has(+ tr:hover) td { border-bottom-color: #4f46e5; }
.markdown-body table thead:has(+ tbody tr:first-child:hover) th { border-bottom-color: #4f46e5; }

html.dark .markdown-body table tbody tr:hover td { border-color: #818cf8 !important; }
html.dark .markdown-body table tbody tr:has(+ tr:hover) td { border-bottom-color: #818cf8 !important; }
html.dark .markdown-body table thead:has(+ tbody tr:first-child:hover) th { border-bottom-color: #818cf8 !important; }

/* overflow: clip giữ bo góc nhưng không phá position:sticky (khác overflow:hidden) */
#markdownView { overflow: clip; }

/* TOC sidebar */
.md-toc-sidebar {
    width: 210px;
    flex-shrink: 0;
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 1.25rem 0 1.5rem;
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    align-self: flex-start;
}
/* ePub TOC: same height as iframe (640px min-height), scrolls internally */
#ebookTOC {
    position: relative;
    top: auto;
    max-height: 640px;
    align-self: flex-start;
}
.toc-heading {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    padding: 0 0.75rem 0.5rem;
    margin: 0;
}
.toc-link {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    padding-top: 0.28rem;
    padding-bottom: 0.28rem;
    padding-right: 0.75rem;
    text-decoration: none;
    line-height: 1.4;
    border-left: 2px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.toc-link:hover { color: #4f46e5; background: #eff0fe; }
.toc-link.toc-active { color: #4f46e5; border-left-color: #4f46e5; font-weight: 600; background: #eff0fe; }
@media (max-width: 768px) { .md-toc-sidebar { display: none !important; } }

/* ===================================================
   Dark Mode
   =================================================== */
html.dark { color-scheme: dark; }

html.dark body {
    background-color: #0f172a !important;
    color: #e2e8f0;
}

/* Header */
html.dark header {
    background-color: #1e293b !important;
    border-bottom-color: #1e293b !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}
html.dark header h1 { color: #f1f5f9 !important; }
html.dark header .text-slate-900 { color: #f1f5f9 !important; }
html.dark header button {
    color: #94a3b8 !important;
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
html.dark header button:hover {
    background-color: #334155 !important;
}
/* Footer */
html.dark footer {
    background-color: #1e293b !important;
    border-top-color: #334155 !important;
    color: #64748b;
}
html.dark footer a { color: #818cf8 !important; }

/* Dropzone */
html.dark #dropzone {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #94a3b8;
}
html.dark #dropzone:hover,
html.dark #dropzone.border-indigo-500 {
    border-color: #6366f1 !important;
    background-color: rgba(79,70,229,0.08) !important;
}
html.dark #dropzone .text-slate-600 { color: #94a3b8 !important; }
html.dark #dropzone .text-indigo-600 { color: #818cf8 !important; }
html.dark #dropzone .text-slate-400 { color: #64748b !important; }
html.dark .file-badge {
    background: #334155;
    color: #94a3b8;
}

/* Loader */
html.dark #loader {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
html.dark #loaderText { color: #e2e8f0 !important; }
html.dark #loader .text-slate-400 { color: #64748b !important; }
html.dark #loader .border-slate-100 { border-color: #334155 !important; }
html.dark #loader .border-t-indigo-600 { border-top-color: #6366f1 !important; }

/* Info banner — dark mode */
html.dark #infoBanner {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}
html.dark #bannerToggleBtn {
    background-color: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
html.dark #bannerToggleBtn:hover {
    background-color: rgba(255,255,255,0.12) !important;
    border-color: rgba(255,255,255,0.2) !important;
}
html.dark .reader-session-stat {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
html.dark .reader-session-stat strong {
    color: #e2e8f0 !important;
}

/* Tab bar */
html.dark #tabList .reader-tab-pill.bg-white {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #818cf8 !important;
}
html.dark #tabList .reader-tab-pill:not([class*="text-indigo"]) {
    color: #94a3b8;
}
html.dark #tabList .reader-tab-pill:hover {
    background-color: rgba(255,255,255,0.06) !important;
}
html.dark #tabList .reader-tab-pill .close-btn:hover {
    background-color: #475569 !important;
    color: #f1f5f9 !important;
}
html.dark .border-b-2 { border-color: #334155 !important; }

/* Add file button */
html.dark #tabList > div:last-child {
    color: #64748b;
}
html.dark #tabList > div:last-child:hover {
    color: #818cf8 !important;
    background-color: rgba(255,255,255,0.06) !important;
}

/* Metadata cards */
html.dark #tabSection .bg-white {
    background-color: #1e293b !important;
}
html.dark #tabSection .border-slate-200 { border-color: #334155 !important; }
html.dark #tabSection .bg-slate-100 { background-color: #162032 !important; }
html.dark #tabSection .bg-violet-50 { background-color: rgba(109,40,217,0.15) !important; }
html.dark #tabSection .bg-emerald-50 { background-color: rgba(4,120,87,0.15) !important; }
html.dark #tabSection .bg-indigo-50 { background-color: rgba(67,56,202,0.15) !important; }
html.dark #tabSection .text-slate-900 { color: #f1f5f9 !important; }
html.dark #tabSection .text-slate-800 { color: #f1f5f9 !important; }
html.dark #tabSection .text-slate-700 { color: #cbd5e1 !important; }
html.dark #tabSection .text-slate-600 { color: #94a3b8 !important; }
html.dark #tabSection .text-slate-500 { color: #64748b !important; }
html.dark #tabSection .text-slate-400 { color: #475569 !important; }

/* Toolbar */
html.dark #tabSection .bg-slate-50,
html.dark #tabSection .bg-slate-50\/80 {
    background-color: #162032 !important;
}
html.dark #tabSection select,
html.dark #tabSection input[type="text"],
html.dark #tabSection input[type="number"] {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html.dark #tabSection select:focus,
html.dark #tabSection input:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 1px #6366f1 !important;
}
html.dark #tabSection input::placeholder { color: #64748b !important; }
html.dark #tabSection .text-slate-400.absolute { color: #64748b !important; }

/* Export buttons dark override */
html.dark #tabSection button.bg-emerald-50 {
    background-color: rgba(4,120,87,0.15) !important;
    color: #34d399 !important;
    border-color: rgba(4,120,87,0.35) !important;
}
html.dark #tabSection button.bg-emerald-50:hover {
    background-color: rgba(4,120,87,0.25) !important;
}
html.dark #tabSection button.bg-amber-50 {
    background-color: rgba(180,83,9,0.15) !important;
    color: #fbbf24 !important;
    border-color: rgba(180,83,9,0.35) !important;
}
html.dark #tabSection button.bg-amber-50:hover {
    background-color: rgba(180,83,9,0.25) !important;
}

/* Format badge dark */
html.dark #formatBadge {
    background-color: rgba(67,56,202,0.2) !important;
    border-color: rgba(99,102,241,0.4) !important;
    color: #818cf8 !important;
}

/* Table */
html.dark #tableHead {
    background-color: #162032 !important;
    border-bottom-color: #334155 !important;
}
html.dark #tableHead th {
    color: #64748b !important;
    background-color: #162032 !important;
}
html.dark #tableHead th.text-indigo-600 { color: #818cf8 !important; }
html.dark #tableHead th.bg-indigo-50\/60 { background-color: rgba(67,56,202,0.15) !important; }
html.dark #tableHead th:hover { background-color: #1e293b !important; }
html.dark #tableBody td {
    color: #94a3b8 !important;
    border-bottom-color: #1e293b !important;
}
html.dark #tableBody td:hover,
html.dark #tableBody tr:hover td {
    background-color: rgba(255,255,255,0.03) !important;
    color: #818cf8 !important;
}

/* Pagination */
html.dark #tabSection .border-t { border-top-color: #334155 !important; }
html.dark #tabSection #pageStart,
html.dark #tabSection #pageEnd,
html.dark #tabSection #totalRowsCount,
html.dark #tabSection #totalPages { color: #e2e8f0 !important; }
html.dark #tabSection #btnPrev,
html.dark #tabSection #btnNext {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
}
html.dark #tabSection #btnPrev:hover:not(:disabled),
html.dark #tabSection #btnNext:hover:not(:disabled) {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* Stats table */
html.dark #statsBody td { color: #94a3b8 !important; }
html.dark #statsBody tr:hover td { background-color: rgba(255,255,255,0.03) !important; }
html.dark #statsBody .font-semibold.text-slate-700 { color: #cbd5e1 !important; }
html.dark #statsBody .text-amber-600 { color: #fbbf24 !important; }
html.dark #statsBody .bg-slate-50 {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
html.dark #statsBody .text-slate-700 { color: #cbd5e1 !important; }
html.dark #statsBody .text-slate-400 { color: #475569 !important; }

/* Type badges dark */
html.dark .bg-blue-50   { background-color: rgba(29,78,216,0.15) !important; }
html.dark .bg-purple-50 { background-color: rgba(109,40,217,0.15) !important; }
html.dark .bg-amber-50  { background-color: rgba(180,83,9,0.15) !important; }
html.dark .bg-rose-50   { background-color: rgba(190,18,60,0.15) !important; }
html.dark .border-blue-200   { border-color: rgba(29,78,216,0.35) !important; }
html.dark .border-purple-200 { border-color: rgba(109,40,217,0.35) !important; }
html.dark .border-amber-200  { border-color: rgba(180,83,9,0.35) !important; }
html.dark .border-rose-200   { border-color: rgba(190,18,60,0.35) !important; }
html.dark .border-indigo-200 { border-color: rgba(99,102,241,0.35) !important; }
html.dark .text-blue-700   { color: #60a5fa !important; }
html.dark .text-purple-700 { color: #a78bfa !important; }
html.dark .text-amber-700  { color: #fbbf24 !important; }
html.dark .text-rose-500   { color: #f87171 !important; }
html.dark .text-indigo-700 { color: #818cf8 !important; }
html.dark .text-emerald-600 { color: #34d399 !important; }
html.dark .text-indigo-600  { color: #818cf8 !important; }
html.dark .text-slate-300  { color: #475569 !important; }

/* Stats section header */
html.dark #statsColCount {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
}

/* Markdown view */
html.dark #markdownView {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
html.dark #markdownView .bg-slate-50 { background-color: #162032 !important; }
html.dark #markdownView .border-slate-200 { border-color: #334155 !important; }
html.dark .markdown-body { color: #cbd5e1 !important; }
html.dark .markdown-body h1,
html.dark .markdown-body h2,
html.dark .markdown-body h3,
html.dark .markdown-body h4,
html.dark .markdown-body h5,
html.dark .markdown-body h6 { color: #f1f5f9 !important; }
html.dark .markdown-body h2 { border-bottom-color: #334155 !important; }
html.dark .markdown-body p { color: #cbd5e1 !important; }
html.dark .markdown-body code { background: #162032 !important; color: #f87171 !important; }
html.dark .markdown-body pre { background: #0f172a !important; }
html.dark .markdown-body blockquote {
    background: rgba(67,56,202,0.12) !important;
    border-left-color: #6366f1 !important;
    color: #94a3b8 !important;
}
html.dark .markdown-body a { color: #818cf8 !important; }
html.dark .markdown-body table th,
html.dark .markdown-body table td { border-color: #334155 !important; }
html.dark .markdown-body table thead { background: #162032 !important; color: #94a3b8 !important; }
html.dark .markdown-body table tbody tr:nth-child(even) { background: #162032 !important; }
html.dark .markdown-body hr { border-top-color: #334155 !important; }
html.dark #markdownSource {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}
html.dark #markdownView details summary {
    color: #94a3b8 !important;
    background-color: #162032 !important;
}
html.dark #markdownView details summary:hover { color: #818cf8 !important; }
html.dark #markdownView .text-slate-600 { color: #94a3b8 !important; }

/* Word export button in markdown */
html.dark #markdownView button {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
}
html.dark #markdownView button:hover {
    background-color: rgba(29,78,216,0.15) !important;
    color: #818cf8 !important;
    border-color: rgba(99,102,241,0.4) !important;
}

/* TOC sidebar */
html.dark .md-toc-sidebar {
    background: #162032 !important;
    border-right-color: #334155 !important;
}
html.dark .toc-heading { color: #475569 !important; }
html.dark .toc-link { color: #64748b !important; }
html.dark .toc-link:hover {
    color: #818cf8 !important;
    background: rgba(67,56,202,0.12) !important;
}
html.dark .toc-link.toc-active {
    color: #818cf8 !important;
    border-left-color: #6366f1 !important;
    background: rgba(67,56,202,0.12) !important;
}

/* Scrollbars */
html.dark ::-webkit-scrollbar-track { background: #0f172a; }
html.dark ::-webkit-scrollbar-thumb { background: #334155; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* Floating focus mode button dark */
html.dark #focusModeBtn {
    background-color: rgba(30,41,59,0.92) !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
html.dark #focusModeBtn:hover {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* PWA install button — giữ nguyên indigo */

/* Reload button dark */
html.dark header button[title="Tải lại trang"],
html.dark header button[onclick="window.location.reload()"] {
    color: #94a3b8 !important;
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Shadow tweaks */
html.dark #tabSection .shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.4) !important; }

/* Sheet selector dark */
html.dark #sheetSelector {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* Row number column */
html.dark #tableBody .select-none.text-slate-400 { color: #334155 !important; }

/* Hover states for table rows */
html.dark #tableBody tr:hover { background-color: rgba(255,255,255,0.03) !important; }

/* Hover states for table rows in light mode */
#tableBody tr { transition: background-color 0.15s ease; }
#tableBody tr:hover { background-color: #f1f5f9 !important; }
#statsBody tr { transition: background-color 0.15s ease; }
#statsBody tr:hover { background-color: #f1f5f9 !important; }

/* Copy button wrapper and button styles */
.copy-wrapper {
    position: relative;
}
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    pointer-events: auto;
    transition: opacity 0.2s ease, background-color 0.15s ease, transform 0.1s ease;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 10px;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background-color: rgba(255, 255, 255, 0.9);
    color: #475569;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.copy-wrapper:hover .copy-btn {
    opacity: 1;
}
.copy-btn:hover {
    background-color: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}
.copy-btn:active {
    transform: scale(0.95);
}

/* Dark mode copy button overrides */
html.dark .copy-btn {
    background-color: rgba(30, 41, 59, 0.9);
    color: #cbd5e1;
    border-color: #475569;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
html.dark .copy-btn:hover {
    background-color: #334155;
    color: #f8fafc;
    border-color: #475569;
}

/* Go to top button styling */
#goToTopBtn {
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, scale 0.15s ease;
}
html.dark #goToTopBtn {
    background-color: rgba(30, 41, 59, 0.9) !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}
html.dark #goToTopBtn:hover {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* Keyboard keycap styling */
.kb-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-bottom-width: 3px;
    border-radius: 0.375rem;
    padding: 0.15rem 0.45rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #334155;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    min-width: 1.5rem;
    line-height: 1.1;
    text-transform: uppercase;
}

html.dark .kb-key {
    background-color: #334155;
    border-color: #475569;
    color: #cbd5e1;
}

/* Modal transitions */
#shortcutsModalPanel {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

/* OS-specific shortcut visibility */
.mac-only { display: none !important; }
.win-only { display: none !important; }

.os-mac .mac-only { display: inline-flex !important; }
.os-win .win-only { display: inline-flex !important; }

/* Vertically Resizable Table Container */
#tableContainer {
    overflow: auto;
}

/* Custom Resize Grip Styles */
#tableResizerGrip svg {
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease;
}
#tableResizerGrip:hover svg {
    opacity: 1;
    color: #4f46e5; /* Indigo-600 */
}
html.dark #tableResizerGrip:hover svg {
    color: #818cf8; /* Indigo-400 */
}

/* ===================================================
   Edit Mode Styles
   =================================================== */

/* ── Tab dirty dot & edit badge ─────────────────── */
.tab-dirty-dot {
    color: #f59e0b;
    font-size: 0.6rem;
    line-height: 1;
    margin-right: 1px;
    animation: dirty-pulse 2s ease-in-out infinite;
}
@keyframes dirty-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}
.tab-edit-badge {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.25rem;
    color: #2563eb;
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.3rem;
}
html.dark .tab-edit-badge {
    background: rgba(29,78,216,0.2);
    border-color: rgba(59,130,246,0.4);
    color: #60a5fa;
}

/* ── Edit toolbar ────────────────────────────────── */
.edit-toolbar {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}
.edit-toolbar button {
    align-items: center;
    border-radius: 0.5rem;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.6875rem;
    font-weight: 600;
    gap: 0.25rem;
    padding: 0.3rem 0.65rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}
.edit-toolbar button:active { transform: scale(0.96); }

.edit-toggle-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
}
.edit-toggle-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}
.edit-toggle-btn.edit-btn-active {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.edit-save-btn {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #15803d;
}
.edit-save-btn:hover {
    background: #dcfce7;
    border-color: #4ade80;
}
.edit-saveas-btn {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}
.edit-saveas-btn:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}
.edit-overwrite-btn {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
}
.edit-overwrite-btn:hover:not(:disabled) {
    background: #ffe4e6;
    border-color: #fda4af;
}
.edit-overwrite-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

/* Dark overrides for edit toolbar */
html.dark .edit-toggle-btn {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}
html.dark .edit-toggle-btn:hover {
    background: #334155;
    color: #e2e8f0;
}
html.dark .edit-toggle-btn.edit-btn-active {
    background: rgba(29,78,216,0.2);
    border-color: rgba(59,130,246,0.5);
    color: #60a5fa;
}
html.dark .edit-save-btn {
    background: rgba(4,120,87,0.15);
    border-color: rgba(4,120,87,0.4);
    color: #34d399;
}
html.dark .edit-saveas-btn {
    background: rgba(180,83,9,0.15);
    border-color: rgba(180,83,9,0.4);
    color: #fbbf24;
}
html.dark .edit-overwrite-btn {
    background: rgba(190,18,60,0.15);
    border-color: rgba(190,18,60,0.4);
    color: #fb7185;
}

/* ── Text / Code editor ──────────────────────────── */
.edit-textarea {
    background: #0f172a;
    border: none;
    border-radius: 0;
    box-sizing: border-box;
    color: #e2e8f0;
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.7;
    min-height: 480px;
    outline: none;
    padding: 1.25rem 1.5rem;
    resize: vertical;
    tab-size: 4;
    white-space: pre;
    width: 100%;
}
.edit-textarea:focus {
    box-shadow: inset 0 0 0 2px #6366f1;
}
html.dark .edit-textarea {
    background: #020617;
    color: #e2e8f0;
}

#markdownContent.edit-mode-active {
    padding: 0 !important;
}

/* ── Markdown split-pane ─────────────────────────── */
.md-split-pane {
    display: flex;
    height: 600px;
    min-height: 400px;
    overflow: hidden;
}
.md-edit-left,
.md-edit-right {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.md-edit-divider {
    background: #e2e8f0;
    flex-shrink: 0;
    width: 3px;
    cursor: col-resize;
}
html.dark .md-edit-divider { background: #334155; }
.md-pane-label {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.375rem 0.75rem;
    text-transform: uppercase;
}
html.dark .md-pane-label {
    background: #162032;
    border-bottom-color: #334155;
    color: #475569;
}
.md-edit-textarea {
    border: none !important;
    box-shadow: none !important;
    flex: 1;
    min-height: 0;
    resize: none;
}
.md-preview-pane {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}
@media (max-width: 640px) {
    .md-split-pane { flex-direction: column; height: auto; }
    .md-edit-divider { height: 3px; width: 100%; }
    .md-edit-textarea { min-height: 200px; }
}

/* ── Table editor ────────────────────────────────── */
.table-edit-toolbar {
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
}
html.dark .table-edit-toolbar {
    background: #162032;
    border-bottom-color: #334155;
}
.table-edit-btn {
    align-items: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.4rem;
    color: #4f46e5;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.6875rem;
    font-weight: 600;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    transition: background-color 0.15s, border-color 0.15s;
}
.table-edit-btn:hover {
    background: #eff0fe;
    border-color: #a5b4fc;
}
html.dark .table-edit-btn {
    background: #1e293b;
    border-color: #475569;
    color: #818cf8;
}
html.dark .table-edit-btn:hover {
    background: rgba(67,56,202,0.2);
    border-color: #6366f1;
}
.table-edit-wrapper {
    max-height: 560px;
    overflow: auto;
}
.table-edit-table {
    border-collapse: collapse;
    font-size: 0.75rem;
    min-width: 100%;
}
.table-edit-th {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    min-width: 120px;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 5;
}
.table-edit-th-act {
    min-width: 56px;
    width: 56px;
    text-align: center;
    color: #94a3b8;
    font-weight: 600;
}
html.dark .table-edit-th {
    background: #162032;
    border-color: #334155;
}
.table-edit-th-inner {
    align-items: center;
    display: flex;
    gap: 0;
}
.table-edit-header-input {
    background: transparent;
    border: none;
    color: #374151;
    flex: 1;
    font-size: 0.6875rem;
    font-weight: 700;
    min-width: 0;
    outline: none;
    padding: 0.4rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    width: 100%;
}
.table-edit-header-input:focus {
    background: #eff6ff;
}
html.dark .table-edit-header-input {
    color: #94a3b8;
}
html.dark .table-edit-header-input:focus {
    background: rgba(29,78,216,0.1);
}
.table-edit-del-col {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.875rem;
    line-height: 1;
    padding: 0.25rem 0.35rem;
    transition: color 0.15s, background-color 0.15s;
}
.table-edit-del-col:hover {
    background: #fee2e2;
    color: #dc2626;
}
html.dark .table-edit-del-col:hover {
    background: rgba(190,18,60,0.2);
    color: #f87171;
}
.table-edit-tr:nth-child(even) { background: #f8fafc; }
.table-edit-tr:hover { background: #eff0fe !important; }
html.dark .table-edit-tr:nth-child(even) { background: rgba(255,255,255,0.02); }
html.dark .table-edit-tr:hover { background: rgba(67,56,202,0.08) !important; }
.table-edit-td {
    border: 1px solid #e2e8f0;
    padding: 0;
}
html.dark .table-edit-td { border-color: #334155; }
.table-edit-td-act {
    border: 1px solid #e2e8f0;
    padding: 0.15rem 0.25rem;
    text-align: center;
    white-space: nowrap;
    width: 56px;
}
html.dark .table-edit-td-act { border-color: #334155; }
.table-edit-rownum {
    color: #94a3b8;
    display: block;
    font-size: 0.6rem;
    margin-top: 0.1rem;
}
.table-edit-del-row {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.4;
    padding: 0.1rem 0.2rem;
    transition: opacity 0.15s, transform 0.1s;
}
.table-edit-del-row:hover {
    opacity: 1;
    transform: scale(1.15);
}
.table-edit-cell {
    background: transparent;
    border: none;
    box-sizing: border-box;
    color: #374151;
    font-size: 0.75rem;
    outline: none;
    padding: 0.35rem 0.5rem;
    width: 100%;
}
.table-edit-cell:focus {
    background: #fffbeb;
    box-shadow: inset 0 0 0 2px #fbbf24;
}
html.dark .table-edit-cell { color: #cbd5e1; }
html.dark .table-edit-cell:focus {
    background: rgba(180,83,9,0.1);
    box-shadow: inset 0 0 0 2px #f59e0b;
}

/* =====================================================
   Word / Rich-Text Editor Styles
   ===================================================== */

/* ── Formatting toolbar ──────────────────────────── */
.word-edit-toolbar {
    align-items: center;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    padding: 0.45rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
html.dark .word-edit-toolbar {
    background: #162032;
    border-bottom-color: #334155;
}
.word-edit-toolbar-sep {
    background: #e2e8f0;
    border-radius: 9999px;
    flex-shrink: 0;
    height: 1.4rem;
    margin: 0 0.25rem;
    width: 1px;
}
html.dark .word-edit-toolbar-sep { background: #334155; }

.word-edit-fmt-btn {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.35rem;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.7rem;
    font-weight: 700;
    height: 1.85rem;
    justify-content: center;
    min-width: 1.85rem;
    padding: 0.2rem 0.35rem;
    transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s;
}
.word-edit-fmt-btn:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
    color: #4338ca;
}
.word-edit-fmt-btn:active { transform: scale(0.92); }
.word-edit-fmt-btn.word-fmt-btn-active {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
html.dark .word-edit-fmt-btn {
    color: #94a3b8;
}
html.dark .word-edit-fmt-btn:hover {
    background: rgba(99,102,241,0.15);
    border-color: #6366f1;
    color: #a5b4fc;
}
html.dark .word-edit-fmt-btn.word-fmt-btn-active {
    background: rgba(29,78,216,0.2);
    border-color: rgba(59,130,246,0.5);
    color: #60a5fa;
}

/* Color picker label/button */
.word-edit-color-label {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.35rem;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.875rem;
    height: 1.85rem;
    justify-content: center;
    min-width: 1.85rem;
    padding: 0.2rem 0.35rem;
    position: relative;
    transition: background 0.12s, border-color 0.12s;
}
.word-edit-color-label:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
}
.word-edit-color-input {
    height: 0;
    left: 50%;
    opacity: 0;
    position: absolute;
    top: 100%;
    width: 0;
    cursor: pointer;
}

/* ── Editor content area ─────────────────────────── */
.word-editor-wrap {
    min-height: 520px;
    overflow-y: auto;
    padding: 0;
}
.word-rich-editor {
    background: #fff;
    box-sizing: border-box;
    caret-color: #4f46e5;
    min-height: 520px;
    outline: none;
    padding: 2rem 2.5rem;
    width: 100%;
    line-height: 1.8;
}
html.dark .word-rich-editor {
    background: #0f172a;
    color: #e2e8f0;
    caret-color: #818cf8;
}
.word-rich-editor:focus {
    box-shadow: inset 0 0 0 2px rgba(99,102,241,0.3);
}
/* Style links inside editor */
.word-rich-editor a {
    color: #4f46e5;
    text-decoration: underline;
}
html.dark .word-rich-editor a {
    color: #818cf8;
}
/* Cursor highlight inside editor */
.word-rich-editor::selection,
.word-rich-editor *::selection {
    background: rgba(99,102,241,0.2);
}

@media (max-width: 640px) {
    .word-rich-editor {
        padding: 1.25rem 1rem;
    }
    .word-edit-toolbar {
        gap: 0.15rem;
        padding: 0.35rem 0.5rem;
    }
}

