/* ===== CSS Variables & Themes ===== */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.2);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --header-height: 56px;
    --toc-width: 280px;
}

[data-theme="dark"] {
    --bg-primary: #0f0f14;
    --bg-secondary: #16161e;
    --bg-tertiary: #1e1e2a;
    --bg-elevated: #22223a;
    --bg-hover: #2a2a40;
    --bg-code: #1a1a2e;
    --bg-code-block: #12121c;
    --bg-glass: rgba(22, 22, 30, 0.75);
    --text-primary: #e8e8ef;
    --text-secondary: #a0a0b8;
    --text-tertiary: #6b6b85;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --accent-glow: rgba(99, 102, 241, 0.15);
    --link-color: #93c5fd;
    --link-hover: #bfdbfe;
    --scrollbar-thumb: rgba(255,255,255,0.1);
    --scrollbar-hover: rgba(255,255,255,0.18);
    --blockquote-border: #6366f1;
    --blockquote-bg: rgba(99, 102, 241, 0.06);
    --table-stripe: rgba(255,255,255,0.02);
    --table-border: rgba(255,255,255,0.06);
    --badge-bg: rgba(99, 102, 241, 0.12);
    --badge-text: #a5b4fc;
    --progress-bg: transparent;
    --toc-active-bg: rgba(99, 102, 241, 0.1);
    --toc-active-border: #6366f1;
}

[data-theme="light"] {
    --bg-primary: #fafbff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f8;
    --bg-elevated: #ffffff;
    --bg-hover: #eef0f6;
    --bg-code: #f4f5fa;
    --bg-code-block: #f8f9fc;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-tertiary: #8888a0;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.14);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --accent-glow: rgba(99, 102, 241, 0.1);
    --link-color: #4f46e5;
    --link-hover: #6366f1;
    --scrollbar-thumb: rgba(0,0,0,0.12);
    --scrollbar-hover: rgba(0,0,0,0.2);
    --blockquote-border: #6366f1;
    --blockquote-bg: rgba(99, 102, 241, 0.04);
    --table-stripe: rgba(0,0,0,0.02);
    --table-border: rgba(0,0,0,0.08);
    --badge-bg: rgba(99, 102, 241, 0.08);
    --badge-text: #6366f1;
    --progress-bg: transparent;
    --toc-active-bg: rgba(99, 102, 241, 0.06);
    --toc-active-border: #6366f1;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    transition: background var(--transition-normal), color var(--transition-normal);
    overflow-x: hidden;
}

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

/* ===== Reading Progress ===== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent-gradient);
    width: 0%;
    z-index: 1001;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ===== Header ===== */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: background var(--transition-normal), border var(--transition-normal);
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-text {
    font-weight: 700;
    font-size: 1.05rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    gap: 8px;
}

.file-icon { font-size: 0.9rem; }
.file-name {
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-primary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-size {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    padding: 2px 8px;
    background: var(--badge-bg);
    border-radius: 20px;
}

/* Buttons */
.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.header-btn.primary-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 7px 14px;
    font-weight: 500;
}

.header-btn.primary-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* ===== Main Content ===== */
#main-content {
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* ===== Drop Zone ===== */
.drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height));
    padding: 40px;
    position: relative;
    cursor: pointer;
}

.drop-zone-inner {
    text-align: center;
    max-width: 480px;
    animation: fadeInUp 0.6s var(--transition-slow) both;
}

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

.drop-icon-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 28px;
}

.drop-icon {
    color: var(--accent-primary);
    opacity: 0.7;
    transition: all var(--transition-normal);
}

.drop-icon-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: var(--accent-gradient);
    border-radius: 50%;
    opacity: 0.08;
    filter: blur(25px);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.08; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.14; }
}

.drop-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    letter-spacing: -0.03em;
}

.drop-subtitle {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    margin-bottom: 24px;
}

.drop-formats {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.format-badge {
    padding: 4px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--font-mono);
    background: var(--badge-bg);
    color: var(--badge-text);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Drag Overlay */
.drop-zone-overlay {
    position: fixed;
    inset: 0;
    background: rgba(99, 102, 241, 0.08);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    border: 3px dashed var(--accent-primary);
    margin: 8px;
    border-radius: var(--radius-xl);
}

.drop-zone-overlay.active {
    display: flex;
}

.overlay-content {
    text-align: center;
    color: var(--accent-primary);
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: fadeInUp 0.2s ease both;
}

.overlay-content svg {
    opacity: 0.6;
}

/* ===== Viewer ===== */
.viewer-container {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    animation: fadeIn 0.4s ease both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== TOC Sidebar ===== */
.toc-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--toc-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
}

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

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.toc-header h2 {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

.toc-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.toc-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.toc-nav {
    padding: 0 12px 20px;
}

.toc-nav a {
    display: block;
    padding: 6px 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
    line-height: 1.5;
    margin-bottom: 1px;
}

.toc-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.toc-nav a.active {
    color: var(--accent-primary);
    background: var(--toc-active-bg);
    border-left-color: var(--toc-active-border);
    font-weight: 500;
}

.toc-nav a.toc-h2 { padding-left: 12px; }
.toc-nav a.toc-h3 { padding-left: 28px; font-size: 0.78rem; }
.toc-nav a.toc-h4 { padding-left: 44px; font-size: 0.76rem; }
.toc-nav a.toc-h5 { padding-left: 56px; font-size: 0.74rem; }
.toc-nav a.toc-h6 { padding-left: 64px; font-size: 0.72rem; }

/* ===== Markdown Body ===== */
.markdown-body {
    flex: 1;
    max-width: 820px;
    margin: 0 auto;
    padding: 48px 40px 100px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    transition: padding-left var(--transition-slow);
    width: 100%;
}

.toc-sidebar.open ~ .markdown-body {
    margin-left: var(--toc-width);
}

/* Headings */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 2em;
    margin-bottom: 0.6em;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    position: relative;
    scroll-margin-top: calc(var(--header-height) + 24px);
}

.markdown-body h1 {
    font-size: 2.2rem;
    margin-top: 0;
    padding-bottom: 0.4em;
    border-bottom: 2px solid var(--border-color);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.markdown-body h2 {
    font-size: 1.65rem;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border-color);
}

.markdown-body h3 { font-size: 1.35rem; }
.markdown-body h4 { font-size: 1.15rem; }
.markdown-body h5 { font-size: 1rem; color: var(--text-secondary); }
.markdown-body h6 { font-size: 0.9rem; color: var(--text-tertiary); }

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

.heading-anchor {
    position: absolute;
    left: -1.5em;
    color: var(--accent-primary);
    text-decoration: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    font-weight: 400;
}

/* Paragraphs */
.markdown-body p {
    margin-bottom: 1.2em;
    color: var(--text-primary);
}

/* Links */
.markdown-body a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-fast);
}

.markdown-body a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

/* Strong & Emphasis */
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }

/* Inline Code */
.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 2px 7px;
    background: var(--bg-code);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    color: var(--accent-secondary);
}

/* Code Blocks */
.markdown-body pre {
    position: relative;
    margin: 1.5em 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-code-block) !important;
}

.markdown-body pre code {
    display: block;
    padding: 20px 24px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.65;
    background: transparent !important;
    border: none;
    color: var(--text-primary);
    border-radius: 0;
}

/* Code block language label */
.code-lang-label {
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px 12px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-bottom-left-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}

/* Copy button */
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-family: var(--font-sans);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 2;
}

.markdown-body pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.code-copy-btn.copied {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}

/* Blockquotes */
.markdown-body blockquote {
    margin: 1.5em 0;
    padding: 14px 20px;
    border-left: 3px solid var(--blockquote-border);
    background: var(--blockquote-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

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

/* Lists */
.markdown-body ul, .markdown-body ol {
    margin: 1em 0;
    padding-left: 1.8em;
}

.markdown-body li {
    margin-bottom: 0.35em;
}

.markdown-body li > p { margin-bottom: 0.4em; }

/* Task Lists */
.markdown-body input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-hover);
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 6px;
    position: relative;
    cursor: default;
    transition: all var(--transition-fast);
}

.markdown-body input[type="checkbox"]:checked {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
}

.markdown-body input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: 700;
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--table-border);
    font-size: 0.92rem;
}

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

.markdown-body th {
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

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

.markdown-body tr:hover td {
    background: var(--bg-hover);
}

/* Horizontal Rule */
.markdown-body hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 2.5em 0;
}

/* Images */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 1.5em 0;
    border: 1px solid var(--border-color);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.markdown-body img:hover {
    transform: scale(1.01);
    box-shadow: var(--shadow-lg);
}

/* Definition Lists & Misc */
.markdown-body del {
    color: var(--text-tertiary);
}

.markdown-body mark {
    background: rgba(250, 204, 21, 0.2);
    color: var(--text-primary);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ===== Scroll to Top ===== */
.scroll-top-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    opacity: 0;
    transform: translateY(12px);
    transition: all var(--transition-normal);
    z-index: 500;
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root { --toc-width: 260px; }

    .header-center { display: none !important; }

    .header-btn span { display: none; }

    .markdown-body {
        padding: 24px 20px 80px;
        font-size: 0.94rem;
    }

    .markdown-body h1 { font-size: 1.7rem; }
    .markdown-body h2 { font-size: 1.35rem; }
    .markdown-body h3 { font-size: 1.15rem; }

    .markdown-body pre code {
        font-size: 0.8rem;
        padding: 16px;
    }

    .drop-title { font-size: 1.3rem; }
    .drop-subtitle { font-size: 0.85rem; }

    .toc-sidebar.open ~ .markdown-body {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .markdown-body {
        padding: 20px 16px 60px;
    }
}

/* ===== Animations ===== */
.markdown-body > * {
    animation: contentFadeIn 0.4s ease both;
}

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

.markdown-body > *:nth-child(1) { animation-delay: 0.02s; }
.markdown-body > *:nth-child(2) { animation-delay: 0.04s; }
.markdown-body > *:nth-child(3) { animation-delay: 0.06s; }
.markdown-body > *:nth-child(4) { animation-delay: 0.08s; }
.markdown-body > *:nth-child(5) { animation-delay: 0.10s; }
.markdown-body > *:nth-child(n+6) { animation-delay: 0.12s; }

/* Alert boxes (GitHub-style) */
.markdown-body .alert-note,
.markdown-body .alert-tip,
.markdown-body .alert-important,
.markdown-body .alert-warning,
.markdown-body .alert-caution {
    padding: 14px 18px;
    margin: 1.5em 0;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    font-size: 0.92rem;
}

.markdown-body .alert-note { border-color: #3b82f6; background: rgba(59, 130, 246, 0.06); }
.markdown-body .alert-tip { border-color: #22c55e; background: rgba(34, 197, 94, 0.06); }
.markdown-body .alert-important { border-color: #a855f7; background: rgba(168, 85, 247, 0.06); }
.markdown-body .alert-warning { border-color: #eab308; background: rgba(234, 179, 8, 0.06); }
.markdown-body .alert-caution { border-color: #ef4444; background: rgba(239, 68, 68, 0.06); }

/* ===== File Browser ===== */
.file-browser {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 32px 60px;
    min-height: calc(100vh - var(--header-height));
    animation: fadeIn 0.3s ease both;
}

.browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.browser-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.88rem;
    flex-wrap: wrap;
    min-width: 0;
}

.breadcrumb-item {
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: none;
    background: none;
    font-family: var(--font-sans);
    font-size: 0.88rem;
}

.breadcrumb-item:hover {
    color: var(--accent-primary);
    background: var(--accent-glow);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
    cursor: default;
}

.breadcrumb-item.active:hover {
    background: transparent;
    color: var(--text-primary);
}

.breadcrumb-sep {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    user-select: none;
}

.browser-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
    min-width: 200px;
}

.browser-search:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.browser-search svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.browser-search input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}

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

/* File List */
.browser-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.file-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
    transform: translateX(4px);
}

.file-item:active {
    transform: translateX(2px);
}

.file-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    font-size: 1.2rem;
}

.file-item-icon.folder {
    background: rgba(250, 204, 21, 0.1);
    color: #facc15;
}

.file-item-icon.file {
    background: var(--accent-glow);
    color: var(--accent-primary);
}

.file-item-info {
    flex: 1;
    min-width: 0;
}

.file-item-name {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-meta {
    font-size: 0.76rem;
    color: var(--text-tertiary);
    margin-top: 2px;
    display: flex;
    gap: 12px;
}

.file-item-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-4px);
    transition: all var(--transition-fast);
}

.file-item:hover .file-item-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Empty state */
.browser-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-tertiary);
}

.browser-empty svg {
    opacity: 0.3;
    margin-bottom: 16px;
}

.browser-empty p {
    font-size: 0.95rem;
}

/* Loading spinner */
.browser-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Server mode indicator */
.server-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border-radius: 20px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.server-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: blink 2s ease-in-out infinite;
}

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

@media (max-width: 768px) {
    .file-browser {
        padding: 16px 16px 60px;
    }

    .browser-header {
        flex-direction: column;
        align-items: stretch;
    }

    .browser-search {
        min-width: unset;
    }

    .file-item-meta {
        flex-direction: column;
        gap: 2px;
    }
}

/* Print styles */
@media print {
    #app-header, .toc-sidebar, .scroll-top-btn, .reading-progress, .code-copy-btn { display: none !important; }
    .markdown-body { max-width: 100%; padding: 0; margin: 0; }
    body { background: white; color: black; }
}
