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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    min-height: 100svh;
    overflow: hidden;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

button, input, select, textarea {
    font: inherit;
}

a, button, input {
    -webkit-tap-highlight-color: transparent;
}

/* Vector SVG Icons Styling */
.svg-icon,
svg.lucide {
    width: 15px;
    height: 15px;
    stroke-width: 2px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.svg-icon-sm {
    width: 13px;
    height: 13px;
}

.svg-icon-lg {
    width: 20px;
    height: 20px;
}

.svg-icon-xl {
    width: 32px;
    height: 32px;
}

/* Reading Progress Bar */
.reading-progress-track {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 100;
    background: transparent;
    pointer-events: none;
}

.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    transition: width 0.08s ease-out;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}

/* App Layout */
.app {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100svh;
    min-height: 0;
    position: relative;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100svh;
    flex: 0 0 var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
}

/* Brand Header */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: transparent;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-logo-img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: var(--radius-md);
    transition: transform 0.2s ease;
}

.brand-link:hover .brand-logo-img {
    transform: scale(1.05);
}

.brand h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.brand span {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Sidebar Search & Quick Command Pill */
.sidebar-search {
    padding: 12px 14px 8px 14px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 13px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 8px 58px 8px 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text);
    font-size: 12.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
    background: var(--surface);
    outline: none;
}

.search-shortcut-pill {
    position: absolute;
    right: 8px;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-active);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}

/* Sidebar Section & Tree Nav */
.sidebar-section {
    flex: 1;
    min-height: 0;
    padding: 12px 10px;
    overflow-y: auto;
}

.section-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    margin-bottom: 8px;
}

.section-title {
    color: var(--text-tertiary);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tree-stats-badge {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 600;
}

/* Tree Navigation Styling */
.tree-container {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tree-folder {
    margin-bottom: 2px;
}

.tree-folder-header {
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tree-folder-header:hover {
    background: var(--surface-hover);
}

.folder-arrow {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tree-folder.open > .tree-folder-header > .folder-arrow {
    transform: rotate(90deg);
}

.folder-icon {
    font-size: 14px;
}

.folder-name {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.folder-count-badge {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-hover);
    color: var(--text-tertiary);
}

.tree-folder-contents {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding-left: 12px;
    margin-top: 2px;
    margin-left: 0;
}

.tree-folder.open > .tree-folder-contents {
    display: flex;
}

.document-button {
    width: 100%;
    min-height: 34px;
    border: none;
    background: transparent;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    color: var(--text-secondary);
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.document-button:hover {
    background: var(--surface-hover);
    color: var(--text);
    transform: translateX(2px);
}

.document-button.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.doc-badge {
    flex-shrink: 0;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-hover);
    color: var(--text-tertiary);
}

.doc-badge.md {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent);
}

.document-name {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
}

.sidebar-action {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 12.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.sidebar-action:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px var(--accent-ring);
    transform: translateY(-1px);
}

.theme-toggle-btn {
    width: 100%;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

/* Main Area */
.main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    height: 100svh;
    display: flex;
    flex-direction: column;
    background: var(--background);
}

/* Topbar Header */
.topbar {
    min-height: 64px;
    padding: 10px 24px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 20;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-tertiary);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.breadcrumb-item {
    color: var(--text-secondary);
    font-weight: 500;
}

.breadcrumb-item.active {
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-separator {
    color: var(--text-tertiary);
    font-size: 11px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

.action-btn-icon-only {
    padding: 6px 9px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Viewer Container & Layout */
.viewer-container {
    position: relative;
    flex: 1;
    min-height: 0;
    padding: var(--space-page);
    overflow: hidden;
    display: flex;
}

.reader-layout {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 24px;
}

/* Markdown Reader Container */
.markdown-wrapper {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 48px;
    display: none;
    box-shadow: var(--shadow-sm);
    position: relative;
}

/* Document Meta Badge Bar */
.doc-meta-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
}

.doc-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--background);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.markdown-body {
    max-width: 820px;
    margin: 0 auto;
    color: var(--text);
    line-height: 1.75;
    font-size: 15.5px;
}

/* Typography & Headings */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    position: relative;
}

.markdown-body h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 18px;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

.markdown-body h2 {
    font-size: 23px;
    font-weight: 700;
    margin-top: 36px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.015em;
}

.markdown-body h3 {
    font-size: 18px;
    font-weight: 650;
    margin-top: 28px;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.markdown-body h4 {
    font-size: 15px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
}

/* Heading Anchor Links */
.heading-anchor {
    opacity: 0;
    margin-left: 6px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-weight: 400;
    transition: opacity 0.15s ease, color 0.15s ease;
    cursor: pointer;
}

.markdown-body h1:hover .heading-anchor,
.markdown-body h2:hover .heading-anchor,
.markdown-body h3:hover .heading-anchor {
    opacity: 1;
}

.heading-anchor:hover {
    color: var(--accent);
}

.markdown-body p {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.markdown-body strong {
    color: var(--text);
    font-weight: 600;
}

.markdown-body ul,
.markdown-body ol {
    margin-bottom: 18px;
    padding-left: 24px;
    color: var(--text-secondary);
}

.markdown-body li {
    margin-bottom: 6px;
}

.markdown-body li > p {
    margin-bottom: 6px;
}

.markdown-body hr {
    height: 1px;
    background: var(--border);
    border: none;
    margin: 32px 0;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

.markdown-body a:hover {
    color: var(--accent-hover);
}

/* Admonition / Callout Banners */
.callout {
    margin: 24px 0;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent);
    background: var(--note-bg);
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.callout-icon {
    font-size: 18px;
    line-height: 1.4;
    flex-shrink: 0;
}

.callout-content {
    flex: 1;
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.6;
}

.callout-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-family: Georgia, "Times New Roman", serif;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
}

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

.callout.callout-note {
    border-left-color: var(--note-border);
    background: var(--note-bg);
    color: var(--text);
}
.callout.callout-note .callout-title {
    color: var(--note-text);
}

.callout.callout-tip {
    border-left-color: var(--tip-border);
    background: var(--tip-bg);
    color: var(--text);
}
.callout.callout-tip .callout-title {
    color: var(--tip-text);
}

.callout.callout-warning {
    border-left-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--text);
}
.callout.callout-warning .callout-title {
    color: var(--warning-text);
}

.callout.callout-important {
    border-left-color: var(--important-border);
    background: var(--important-bg);
    color: var(--text);
}
.callout.callout-important .callout-title {
    color: var(--important-text);
}

.callout.callout-danger,
.callout.callout-caution {
    border-left-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--text);
}
.callout.callout-danger .callout-title,
.callout.callout-caution .callout-title {
    color: var(--danger-text);
}

/* Generic Blockquotes */
.markdown-body blockquote {
    margin: 20px 0;
    padding: 12px 18px;
    border-left: 3px solid var(--border-strong);
    background: var(--background);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

/* Inline and Block Code */
.markdown-body code {
    padding: 3px 6px;
    border-radius: 5px;
    background: var(--surface-hover);
    color: var(--accent);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    border: 1px solid var(--border);
}

.code-block-wrapper {
    position: relative;
    margin: 24px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #0b0f19;
    border: 1px solid #1e293b;
    box-shadow: var(--shadow-md);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #111827;
    border-bottom: 1px solid #1f2937;
    font-size: 11.5px;
    font-family: 'JetBrains Mono', monospace;
    color: #9ca3af;
}

.markdown-body pre {
    margin: 0;
    padding: 16px 20px;
    background: transparent;
    color: #e2e8f0;
    overflow-x: auto;
}

.markdown-body pre code {
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: 13.5px;
    line-height: 1.65;
    border: none;
}

.copy-code-btn {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.copy-code-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
}

/* Mermaid Diagrams Container */
.mermaid-diagram-container {
    margin: 24px 0;
    padding: 24px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.mermaid {
    max-width: 100%;
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 14px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.markdown-body th,
.markdown-body td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-body th {
    background: var(--surface-hover);
    color: var(--text);
    font-weight: 650;
    font-family: Georgia, "Times New Roman", serif;
}

.markdown-body tr:nth-child(even) {
    background: var(--background);
}

/* Previous / Next Document Navigation Cards */
.doc-pagination {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.pagination-card {
    display: flex;
    flex-direction: column;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-card:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.pagination-card.next {
    text-align: right;
    grid-column: 2;
}

.pagination-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.pagination-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Table of Contents (TOC) Sidebar */
.toc-sidebar {
    width: var(--toc-width);
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    overflow-y: auto;
    display: none;
    height: 100%;
    box-shadow: var(--shadow-sm);
}

.toc-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    list-style: none;
    position: relative;
}

.toc-link {
    display: block;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--text-secondary);
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
}

.toc-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.toc-link.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.toc-link.indent-2 {
    padding-left: 14px;
    font-size: 12px;
}

.toc-link.indent-3 {
    padding-left: 22px;
    font-size: 11.5px;
    color: var(--text-tertiary);
}

/* Empty State */
.empty-state {
    width: 100%;
    height: 100%;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 32px;
}

.empty-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    border-radius: var(--radius-lg);
    background: var(--surface-hover);
    color: var(--accent);
    font-size: 24px;
}

.empty-state h3 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.empty-state p {
    margin-top: 8px;
    max-width: 360px;
    color: var(--text-secondary);
    font-size: 13.5px;
}

/* Back to Top Floating Button */
.back-to-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 30;
}

.back-to-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Site Footer */
.site-footer {
    padding: 12px 28px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--text-tertiary);
    font-size: 11.5px;
    text-align: center;
}

/* ==========================================================================
   SPOTLIGHT SEARCH MODAL (Ctrl + K)
   ========================================================================== */
.spotlight-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 20px 20px 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.spotlight-backdrop.open {
    display: flex;
    opacity: 1;
}

.spotlight-modal {
    width: 100%;
    max-width: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPopIn {
    from {
        transform: scale(0.95) translateY(-10px);
    }
    to {
        transform: scale(1) translateY(0);
    }
}

.spotlight-search-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.spotlight-icon {
    font-size: 16px;
    color: var(--text-tertiary);
}

.spotlight-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.spotlight-input::placeholder {
    color: var(--text-tertiary);
}

.spotlight-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.spotlight-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease;
}

.spotlight-item:hover,
.spotlight-item.selected {
    background: var(--surface-hover);
}

.spotlight-item.selected {
    outline: 2px solid var(--accent);
}

.spotlight-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.spotlight-item-title {
    font-weight: 600;
    font-size: 13.5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.spotlight-item-folder {
    font-size: 11px;
    color: var(--text-tertiary);
}

.spotlight-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: var(--background);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-tertiary);
}

.spotlight-shortcuts {
    display: flex;
    gap: 12px;
}

.spotlight-shortcuts kbd {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-secondary);
}

/* ==========================================================================
   UPLOAD / CONVERTER STUDIO PAGE
   ========================================================================== */
.upload-page {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
}

.upload-page .app {
    min-height: 100vh;
    height: auto;
}

.upload-page .viewer-container {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    align-content: start;
    align-items: start;
    gap: 24px;
    overflow: visible;
}

.upload-card {
    width: 100%;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.upload-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 20px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.upload-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 4px 12px var(--accent-ring);
}

.upload-header h3 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 17px;
    font-weight: 700;
}

.upload-header p {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 12.5px;
}

/* Drag and Drop Zone */
.dropzone-container {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--background);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
    position: relative;
}

.dropzone-container:hover,
.dropzone-container.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.005);
}

.dropzone-icon {
    font-size: 32px;
    color: var(--accent);
    margin-bottom: 8px;
}

.dropzone-text {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.dropzone-subtext {
    font-size: 11.5px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.dropzone-input {
    display: none;
}

/* Quick Category Tags / Chips */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.category-chip {
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.category-chip:hover,
.category-chip.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-section {
    margin-bottom: 18px;
}

.form-section label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
}

.form-section input[type="text"],
.form-section input[type="password"],
.form-section select,
.form-section textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-section input:focus,
.form-section select:focus,
.form-section textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.token-help-link {
    font-size: 11px;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}

.token-help-link:hover {
    text-decoration: underline;
}

.input-help {
    margin-top: 5px;
    color: var(--text-tertiary);
    font-size: 11.5px;
}

/* Conversion Live Preview Box */
.conversion-preview-container {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--background);
    overflow: hidden;
    display: none;
}

.preview-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: 0 10px;
}

.preview-tabs-left {
    display: flex;
}

.preview-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease;
}

.preview-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.editor-stats {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}

.preview-pane {
    padding: 18px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.preview-pane.active {
    display: block;
}

.markdown-editor {
    width: 100%;
    height: 320px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
}

.upload-button-group {
    display: flex;
    gap: 12px;
    margin-top: 14px;
}

.upload-button {
    flex: 1;
    min-height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.upload-button:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px var(--accent-ring);
}

.upload-button.secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.upload-button.secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.upload-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-status {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.5;
}

.upload-status.success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.upload-status.error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.upload-status.info {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-muted);
}

/* Existing Documents Item */
.existing-document {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: background 0.15s ease;
    border-radius: var(--radius-sm);
}

.existing-document:hover {
    background: var(--surface-hover);
}

.existing-document:last-child {
    border-bottom: none;
}

.existing-document-info {
    flex: 1;
    min-width: 0;
}

.existing-document-name {
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text);
}

.existing-document-meta {
    font-size: 11.5px;
    color: var(--text-tertiary);
    margin-top: 3px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.existing-doc-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.existing-document:hover .existing-doc-actions {
    opacity: 1;
}

.doc-action-btn {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 11.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.doc-action-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

.doc-action-btn.edit-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.doc-action-btn.delete-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-soft);
}

.doc-manager-search {
    margin-bottom: 14px;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media print {
    [data-theme="dark"] {
        --text: #0f172a;
        --text-secondary: #475569;
        --surface: #fff;
        --surface-hover: #f1f5f9;
        --border: #cbd5e1;
    }

    html, body, .app, .main, .viewer-container, .reader-layout, .markdown-wrapper {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    body, .app, .main, .viewer-container, .reader-layout, .markdown-wrapper {
        display: block !important;
        width: 100%;
        background: #fff;
    }

    .sidebar, .sidebar-backdrop, .topbar, .toc-sidebar, .site-footer,
    .reading-progress-track, .back-to-top-btn, .spotlight-backdrop,
    .toast-container, #docMetaHeader, #docPagination, .copy-code-btn {
        display: none !important;
    }

    .viewer-container, .markdown-wrapper {
        padding: 0 !important;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .markdown-body {
        max-width: none;
        color: #0f172a;
    }

    .markdown-body h1, .markdown-body h2, .markdown-body h3,
    .markdown-body h4, .markdown-body th {
        color: #0f172a;
    }

    .markdown-body pre, .markdown-body pre code {
        color: #0f172a;
        background: #f1f5f9;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .markdown-body h1, .markdown-body h2, .markdown-body h3,
    .markdown-body h4 {
        break-after: avoid;
        page-break-after: avoid;
    }

    .markdown-body table {
        overflow: visible;
        break-inside: auto;
        page-break-inside: auto;
    }

    .markdown-body thead {
        display: table-header-group;
    }

    .markdown-body tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .markdown-body img, .markdown-body svg, .markdown-body pre {
        max-width: 100%;
        break-inside: avoid;
    }
}

@media (max-width: 1080px) {
    .upload-page .viewer-container {
        grid-template-columns: 1fr;
    }
    .toc-sidebar {
        display: none !important;
    }
    .markdown-wrapper {
        padding: 32px 28px;
    }
}

@media (max-width: 820px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100svh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .doc-pagination {
        grid-template-columns: 1fr;
    }

    .pagination-card.next {
        grid-column: 1;
        text-align: left;
    }

    .viewer-container {
        padding: 14px;
    }

    .markdown-wrapper {
        padding: 24px 18px;
    }

    .upload-button-group {
        flex-direction: column;
    }
}
