:root {
    --outline-width: 280px;

    /* Design system tokens — Orren Vibes */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-float: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-error: #EF4444;
    --color-info: #3B82F6;
}

/* Light theme — Orren Vibes warm beige */
:root, [data-theme="light"] {
    --bg-primary: #EBE9E4;
    --bg-secondary: #F5F4F1;
    --bg-tertiary: #FFFFFF;
    --text-primary: #111111;
    --text-secondary: #555555;
    --text-tertiary: #888888;
    --accent: #09090B;
    --accent-soft: #E4E4E7;
    --border: #DADADA;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --code-bg: #1A1A1A;
    --code-text: #FFFFFF;
}

/* Dark theme — Orren Vibes deep black */
[data-theme="dark"] {
    --bg-primary: #1A1A1A;
    --bg-secondary: #262626;
    --bg-tertiary: #333333;
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-tertiary: rgba(255, 255, 255, 0.4);
    --accent: #FFFFFF;
    --accent-soft: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --code-bg: #111111;
    --code-text: #FFFFFF;
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 16px;
    min-height: 100vh;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Layout */
.app {
    display: grid;
    grid-template-columns: var(--outline-width) 1fr;
    min-height: 100vh;
    transition: grid-template-columns 0.3s ease;
}

.app.outline-collapsed {
    grid-template-columns: 0 1fr;
}

/* Sidebar / Outline Panel */
.outline-panel {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.app.outline-collapsed .outline-panel {
    transform: translateX(-100%);
    opacity: 0;
}

.outline-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.outline-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.outline-content {
    padding: 16px 0;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.outline-content::-webkit-scrollbar {
    width: 4px;
}

.outline-content::-webkit-scrollbar-track {
    background: transparent;
}

.outline-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.outline-item {
    display: block;
    padding: 8px 24px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.outline-item:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.outline-item.active {
    color: var(--text-primary);
    border-left-color: var(--accent);
    background: var(--bg-primary);
    font-weight: 500;
}

.outline-item.h2 { padding-left: 24px; }
.outline-item.h3 { padding-left: 40px; font-size: 12px; }
.outline-item.h4 { padding-left: 56px; font-size: 12px; color: var(--text-tertiary); }
.outline-item.h5 { padding-left: 72px; font-size: 11px; color: var(--text-tertiary); }
.outline-item.h6 { padding-left: 88px; font-size: 11px; color: var(--text-tertiary); }

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 48px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.toggle-outline {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.toggle-outline:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.toggle-outline svg {
    width: 18px;
    height: 18px;
}

.document-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-input-wrapper {
    position: relative;
    flex-shrink: 0;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.open-file-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.open-file-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.open-file-btn svg {
    width: 16px;
    height: 16px;
}

.open-file-btn span {
    display: inline;
}

.export-pdf-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.export-pdf-btn:hover {
    border-color: var(--text-primary);
}

.export-pdf-btn svg {
    width: 16px;
    height: 16px;
}

.export-pdf-btn span {
    display: inline;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Reader Area */
.reader-container {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 60px 60px 120px;
    width: 100%;
    max-width: 100%;
}

.reader {
    width: 100%;
    max-width: 720px;
    min-width: 0;
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 40px;
    animation: fadeIn 0.6s ease;
}

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

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
}

.welcome-icon svg {
    width: 40px;
    height: 40px;
    color: var(--text-tertiary);
}

.welcome-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    max-width: 400px;
    line-height: 1.6;
}

.drop-zone {
    width: 100%;
    max-width: 400px;
    padding: 48px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-zone-text {
    font-size: 14px;
    color: var(--text-tertiary);
}

.drop-zone-text strong {
    color: var(--text-primary);
}

/* Markdown Content Styles */
.markdown-content {
    animation: contentFadeIn 0.5s ease;
    width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

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

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    color: var(--text-primary);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
    scroll-margin-top: 100px;
    font-weight: 600;
    overflow-wrap: break-word;
    word-wrap: break-word;
    letter-spacing: -0.02em;
}

.markdown-content h1 {
    font-size: 2.2em;
    margin-top: 0;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.03em;
}

.markdown-content h2 {
    font-size: 1.6em;
}

.markdown-content h3 {
    font-size: 1.3em;
}

.markdown-content h4 {
    font-size: 1.1em;
}

.markdown-content h5 {
    font-size: 1em;
}

.markdown-content h6 {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.markdown-content p {
    margin-bottom: 1.25em;
}

.markdown-content a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.2s ease;
}

.markdown-content a:hover {
    opacity: 0.7;
}

.markdown-content strong {
    font-weight: 600;
}

.markdown-content em {
    font-style: italic;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 1.25em;
    padding-left: 1.5em;
}

.markdown-content li {
    margin-bottom: 0.5em;
}

.markdown-content li > ul,
.markdown-content li > ol {
    margin-top: 0.5em;
    margin-bottom: 0;
}

.markdown-content blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 3px solid var(--accent);
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--text-secondary);
}

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

.markdown-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--bg-secondary);
    padding: 0.2em 0.5em;
    border-radius: var(--radius-sm);
    word-break: break-all;
}

.markdown-content pre {
    margin: 1.5em 0;
    padding: 1.25em 1.5em;
    background: var(--code-bg);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: var(--code-text);
    font-size: 0.85em;
    line-height: 1.6;
    word-break: normal;
}

.markdown-content hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 3em 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 1.5em 0;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
    display: block;
    overflow-x: auto;
}

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

.markdown-content th {
    font-weight: 600;
    background: var(--bg-secondary);
}

.markdown-content tr:hover {
    background: var(--bg-secondary);
}

/* Task Lists */
.markdown-content input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--accent);
}

/* Keyboard Shortcuts Hint */
.shortcuts-hint {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shortcut kbd {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

/* Theme Toggle */
.theme-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .top-bar {
        padding: 16px 32px;
    }

    .reader-container {
        padding: 48px 32px 100px;
    }

    .shortcuts-hint {
        display: none;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    :root {
        --outline-width: 280px;
    }

    body {
        font-size: 16px;
    }

    .app,
    .app.outline-collapsed {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .outline-panel {
        position: fixed;
        left: 0;
        top: 0;
        width: var(--outline-width);
        max-width: 85vw;
        z-index: 200;
        transform: translateX(-100%);
        box-shadow: none;
    }

    .app:not(.outline-collapsed) .outline-panel {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .app:not(.outline-collapsed) .mobile-overlay {
        display: block;
        opacity: 1;
    }

    .app.outline-collapsed .outline-panel {
        transform: translateX(-100%);
    }

    .main-content {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .top-bar {
        padding: 12px 16px;
        width: 100%;
    }

    .document-title {
        font-size: 14px;
    }

    .open-file-btn {
        padding: 10px 16px;
    }

    .open-file-btn span {
        display: none;
    }

    .open-file-btn svg {
        width: 18px;
        height: 18px;
    }

    .export-pdf-btn {
        padding: 10px 16px;
    }

    .export-pdf-btn span {
        display: none;
    }

    .export-pdf-btn svg {
        width: 18px;
        height: 18px;
    }

    .top-bar-right {
        gap: 8px;
    }

    /* App shell icon buttons: 36px on mobile */
    .toggle-outline,
    .theme-toggle,
    .gear-btn,
    .back-btn,
    .refresh-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    /* Hide Export PDF on mobile */
    .export-pdf-btn {
        display: none !important;
    }

    .reader-container {
        padding: 24px 20px 80px;
        width: 100%;
        max-width: 100%;
    }

    .reader {
        width: 100%;
        max-width: 100%;
    }

    .welcome-state {
        padding: 40px 16px;
    }

    .welcome-icon {
        width: 64px;
        height: 64px;
        border-radius: var(--radius-lg);
        margin-bottom: 24px;
    }

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

    .welcome-title {
        font-size: 24px;
    }

    .welcome-subtitle {
        font-size: 15px;
        margin-bottom: 32px;
        padding: 0 8px;
    }

    .drop-zone {
        padding: 32px 20px;
        max-width: 100%;
    }

    .markdown-content {
        width: 100%;
    }

    .markdown-content h1 {
        font-size: 1.5em;
        line-height: 1.3;
    }

    .markdown-content h2 {
        font-size: 1.3em;
    }

    .markdown-content h3 {
        font-size: 1.15em;
    }

    .markdown-content h4 {
        font-size: 1.05em;
    }

    .markdown-content p,
    .markdown-content li {
        font-size: 16px;
        line-height: 1.7;
    }

    .markdown-content ul,
    .markdown-content ol {
        padding-left: 1.25em;
    }

    .markdown-content pre {
        padding: 1em;
        border-radius: var(--radius-md);
        font-size: 13px;
        margin: 1em 0;
    }

    .markdown-content blockquote {
        padding: 0.75em 1em;
        margin: 1em 0;
    }

    .markdown-content table {
        font-size: 14px;
    }

    .markdown-content th,
    .markdown-content td {
        padding: 8px 10px;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .top-bar {
        padding: 10px 12px;
    }

    .top-bar-left {
        gap: 10px;
    }

    .document-title {
        font-size: 13px;
    }

    .open-file-btn {
        padding: 8px 12px;
    }

    .reader-container {
        padding: 20px 20px 60px;
    }

    .markdown-content h1 {
        font-size: 1.4em;
    }

    .markdown-content h2 {
        font-size: 1.2em;
    }

    .markdown-content h3 {
        font-size: 1.1em;
    }

    .outline-item {
        padding: 10px 20px;
        font-size: 14px;
    }

    .outline-item.h3 { padding-left: 32px; }
    .outline-item.h4 { padding-left: 44px; }
    .outline-item.h5 { padding-left: 56px; }
    .outline-item.h6 { padding-left: 68px; }
}

/* =========================================================================
   Settings Modal
   ========================================================================= */

.settings-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.settings-modal-overlay.visible {
    display: flex;
}

.settings-modal {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.settings-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

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

.settings-close svg {
    width: 18px;
    height: 18px;
}

.settings-body {
    padding: 24px;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.settings-avatar {
    border-radius: 50%;
}

.settings-username {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.settings-select,
.settings-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.settings-select:focus,
.settings-input:focus {
    border-color: var(--accent);
}

.settings-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
}

.settings-connected-repo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.settings-repo-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-repo-branch {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--accent-soft);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 8px;
}

.settings-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.settings-btn-primary {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.settings-btn-primary:hover:not(:disabled) {
    opacity: 0.85;
    transform: translateY(-1px);
}

.settings-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.settings-btn-secondary:hover {
    border-color: var(--text-primary);
}

.settings-btn-danger {
    background: none;
    color: var(--text-tertiary);
    padding: 10px 12px;
}

.settings-btn-danger:hover {
    color: var(--color-error);
}

.settings-status {
    font-size: 13px;
    margin-top: 10px;
    color: var(--text-secondary);
}

.settings-status.success {
    color: var(--color-success);
}

.settings-status.error {
    color: var(--color-error);
}

.settings-actions {
    display: flex;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.settings-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Gear icon button */
.gear-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

.gear-btn svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 768px) {
    .settings-modal {
        position: fixed;
        inset: 0;
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        width: 100%;
        border-radius: 0;
        margin: 0;
        animation: none;
    }

    .settings-body {
        padding: 24px 20px;
    }
}

/* =========================================================================
   Landing Page
   ========================================================================= */

.view-landing {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Landing page typography overrides */
.view-landing h1 {
    font-family: 'Merriweather', Georgia, serif;
    font-weight: 700;
}

.view-landing h2,
.view-landing h3 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 800;
}

.view-landing p,
.view-landing .landing-description,
.view-landing .landing-try-description,
.view-landing .landing-footer p {
    font-family: 'Geist Mono', 'JetBrains Mono', monospace;
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 48px;
    border-bottom: 1px solid var(--border);
}

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

.landing-logo-icon {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

.landing-logo {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.landing-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.landing-signin-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.landing-signin-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.landing-signin-btn svg {
    width: 18px;
    height: 18px;
}

.landing-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Hero */
.landing-hero {
    text-align: center;
    padding: 100px 48px 80px;
    max-width: 720px;
    animation: fadeIn 0.6s ease;
}

.landing-title {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: -0.03em;
}

.landing-description {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 40px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.landing-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.landing-cta:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.landing-cta svg {
    width: 20px;
    height: 20px;
}

/* Hero Image */
.landing-hero-image {
    padding: 0 80px 60px;
    width: 100%;
    animation: fadeIn 0.6s ease;
}

.hero-img {
    width: 100%;
}

.hero-img img {
    width: 100%;
    height: auto;
    border-radius: 0;
}

.hero-img-light { display: block; }
.hero-img-dark { display: none; }

[data-theme="dark"] .hero-img-light { display: none; }
[data-theme="dark"] .hero-img-dark { display: block; }

/* Value Props */
.landing-value-props {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 0 48px 80px;
    max-width: 960px;
    width: 100%;
}

.landing-value-prop {
    display: flex;
    align-items: center;
    gap: 10px;
}

.landing-value-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.6;
}

.landing-value-prop span {
    font-family: 'Geist Mono', 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Try It Now */
.landing-try {
    text-align: center;
    padding: 60px 48px 80px;
    width: 100%;
    max-width: 960px;
    position: relative;
}

.landing-try::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 1px;
    background: var(--border);
}

.view-landing .landing-try-title {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.landing-try-description {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.landing-drop-zone {
    max-width: 100%;
    margin: 0 auto;
}

/* Try-it heading text toggle (desktop vs mobile) */
.try-title-mobile { display: none; }
.try-title-desktop { display: inline; }

/* Footer */
.landing-footer {
    padding: 24px 48px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.landing-footer p {
    font-size: 13px;
    color: var(--text-tertiary);
}

.landing-footer a {
    color: var(--text-primary);
    text-decoration: none;
}

.landing-footer a:hover {
    text-decoration: underline;
}

/* Landing Responsive */
@media (max-width: 768px) {
    .landing-header {
        padding: 16px 20px;
    }

    .landing-signin-btn span {
        display: none;
    }

    .view-landing .theme-toggle {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }

    .landing-hero {
        padding: 60px 20px 50px;
    }

    .landing-title {
        font-size: 32px;
    }

    .landing-description {
        font-size: 16px;
    }

    .landing-cta {
        font-size: 15px;
        padding: 12px 24px;
    }

    .landing-hero-image {
        padding: 0 16px 40px;
    }

    .landing-value-props {
        flex-direction: column;
        align-items: center;
        gap: 16px;
        padding: 0 20px 50px;
    }

    .landing-try {
        padding: 80px 20px;
    }

    .try-title-desktop { display: none; }
    .try-title-mobile { display: inline; }

    .landing-try .landing-drop-zone,
    .landing-try #landingFileInput {
        display: none !important;
    }

    .landing-footer {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .landing-title {
        font-size: 32px;
    }
}

/* =========================================================================
   Library View
   ========================================================================= */

.library-container {
    flex: 1;
    padding: 0;
    width: 100%;
    position: relative;
}

.library-content {
    padding: 24px 48px 120px;
    max-width: 960px;
    margin: 0 auto;
    position: relative;
}

/* Library Category Sidebar */
.library-categories {
    padding: 16px 0;
    height: calc(100vh - 80px - 44px);
    overflow-y: auto;
}

.library-category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.library-category-item:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.library-category-item.active {
    color: var(--text-primary);
    border-left-color: var(--accent);
    background: var(--bg-primary);
    font-weight: 500;
}

.library-category-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.library-category-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-category-count {
    font-size: 12px;
    color: var(--text-tertiary);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.library-category-item.active .library-category-count {
    background: var(--accent-soft);
    color: var(--text-secondary);
}

/* Sidebar Footer (sync status) */
.sidebar-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
}

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

/* Refresh Button */
.refresh-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    transition: border-color 0.2s ease;
}

.search-bar:focus-within {
    border-color: var(--accent);
}

.search-bar-icon {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-bar:focus-within .search-bar-icon {
    color: var(--text-primary);
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    min-width: 0;
}

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

.search-clear-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
}

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

.search-clear-btn svg {
    width: 14px;
    height: 14px;
}

.search-shortcut {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 3px 7px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    flex-shrink: 0;
    pointer-events: none;
}

/* Search Results */
.search-results-group {
    margin-bottom: 16px;
}

.search-results-header {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 8px 4px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

/* Skeleton Loaders */
.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.skeleton-file-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
}

.skeleton-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-text-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-text {
    height: 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-text-name {
    width: 60%;
}

.skeleton-text-path {
    width: 35%;
    height: 10px;
}

/* Stagger the animation for each row */
.skeleton-file-row:nth-child(2) .skeleton-icon,
.skeleton-file-row:nth-child(2) .skeleton-text { animation-delay: 0.1s; }
.skeleton-file-row:nth-child(3) .skeleton-icon,
.skeleton-file-row:nth-child(3) .skeleton-text { animation-delay: 0.2s; }
.skeleton-file-row:nth-child(4) .skeleton-icon,
.skeleton-file-row:nth-child(4) .skeleton-text { animation-delay: 0.3s; }
.skeleton-file-row:nth-child(5) .skeleton-icon,
.skeleton-file-row:nth-child(5) .skeleton-text { animation-delay: 0.4s; }
.skeleton-file-row:nth-child(6) .skeleton-icon,
.skeleton-file-row:nth-child(6) .skeleton-text { animation-delay: 0.5s; }

@keyframes skeletonPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Reader Loading Bar */
.reader-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1000;
    overflow: hidden;
}

.reader-loading-bar::after {
    content: '';
    display: block;
    width: 40%;
    height: 100%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    animation: loadingSlide 1.2s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Continue Reading */
.continue-reading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 20px;
    transition: all 0.15s ease;
}

.continue-reading:hover {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.continue-reading:hover .continue-reading-label {
    color: var(--bg-primary);
    opacity: 0.8;
}

.continue-reading-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.continue-reading-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.continue-reading svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.continue-reading:hover svg {
    color: var(--bg-primary);
}

/* Recent Section */
.recent-section {
    margin-bottom: 20px;
}

.recent-section-header {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 0 4px 8px;
}

.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.recent-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s ease;
}

.recent-item:hover {
    border-color: var(--text-primary);
    background: var(--accent-soft);
}

.recent-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.recent-item-path {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* File list area */
.library-file-area {
    min-height: 100px;
}

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

.library-file-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.library-file-item:hover {
    background: var(--bg-secondary);
}

.library-file-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
}

.library-file-item:hover .library-file-icon {
    color: var(--text-primary);
    background: var(--accent-soft);
}

.library-file-icon svg {
    width: 18px;
    height: 18px;
}

.library-file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

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

.library-file-path {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Library Empty States */
.library-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 40px;
    color: var(--text-secondary);
    animation: fadeIn 0.4s ease;
}

.library-empty-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    color: var(--text-tertiary);
}

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

.library-empty h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.library-empty p {
    font-size: 14px;
    max-width: 360px;
    line-height: 1.6;
}

.library-error {
    color: var(--color-error);
}

.library-error-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
}

/* Library Drop Overlay */
.library-drop-overlay {
    position: absolute;
    inset: 0;
    background: var(--accent-soft);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}

.library-drop-overlay p {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Library Responsive */
@media (max-width: 768px) {
    .library-content {
        padding: 16px 16px 80px;
    }

    .library-file-item {
        padding: 12px 12px;
    }
}

/* =========================================================================
   Back Button (reader → library)
   ========================================================================= */

.back-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

.back-btn svg {
    width: 18px;
    height: 18px;
}

/* =========================================================================
   Upload Button
   ========================================================================= */

.upload-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.upload-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.upload-btn svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 768px) {
    .upload-btn span {
        display: none;
    }

    .upload-btn {
        padding: 10px 14px;
    }
}

/* =========================================================================
   Upload Destination Picker
   ========================================================================= */

.upload-folder-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    background: var(--bg-secondary);
}

.upload-folder-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.upload-folder-option:hover {
    background: var(--bg-primary);
}

.upload-folder-option input[type="radio"] {
    accent-color: var(--accent);
}

.upload-folder-option svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.upload-new-folder {
    margin-top: 12px;
}

.upload-new-folder-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
}

.upload-new-folder-btn:hover {
    text-decoration: underline;
    color: var(--text-primary);
}

.upload-new-folder-input {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.upload-new-folder-input .settings-input {
    flex: 1;
}

/* =========================================================================
   Reader Loading State
   ========================================================================= */

.reader-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 40px;
    gap: 16px;
    color: var(--text-tertiary);
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

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

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

/* Reader Error */
.reader-error {
    text-align: center;
    padding: 80px 40px;
}

.reader-error h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.reader-error p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.back-to-library-btn {
    display: inline-flex;
    padding: 10px 20px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-to-library-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.reader-error .back-to-library-btn + .back-to-library-btn {
    margin-left: 10px;
}

/* =========================================================================
   Toast Notifications
   ========================================================================= */

.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: auto;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-info {
    background: #1A1A1A;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-success {
    background: #DEF7EC;
    color: #03543F;
    border: 1px solid #10B981;
}

.toast-error {
    background: #FDE8E8;
    color: #9B1C1C;
    border: 1px solid #EF4444;
}

/* =========================================================================
   Phase 3 — File Manager Styles
   ========================================================================= */

/* File row wrapper (file item + dots button) */
.library-file-row {
    display: flex;
    align-items: center;
    position: relative;
}

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

/* Keyboard-focused file row */
.library-file-row.kb-focused {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: var(--radius-md);
}

.library-file-row.kb-focused .library-file-item {
    background: var(--bg-secondary);
}

.library-file-row.kb-focused .library-file-icon {
    color: var(--text-primary);
    background: var(--accent-soft);
}

.library-file-row.kb-focused .fm-dots-btn {
    opacity: 1;
}

/* Three-dot action button */
.fm-dots-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    opacity: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.fm-dots-btn svg {
    width: 16px;
    height: 16px;
}

.library-file-row:hover .fm-dots-btn,
.fm-dots-btn:focus {
    opacity: 1;
}

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

/* Folder category row */
.library-category-row {
    display: flex;
    align-items: center;
    position: relative;
}

.library-category-row .library-category-item {
    flex: 1;
    min-width: 0;
}

.fm-folder-dots {
    margin-right: 8px;
}

.library-category-row:hover .fm-folder-dots {
    opacity: 1;
}

/* Mobile: always show dots + larger tap targets */
@media (max-width: 768px) {
    .fm-dots-btn {
        opacity: 1;
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .fm-menu-item {
        padding: 14px 16px;
        min-height: 44px;
    }

    .fm-confirm-actions {
        flex-direction: column;
    }

    .fm-confirm-actions .settings-btn {
        width: 100%;
        text-align: center;
        margin-right: 0;
    }

    .library-category-item {
        min-height: 44px;
        padding: 12px 24px;
    }
}

/* Action Menu (floating panel) */
.fm-action-menu {
    position: fixed;
    z-index: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 4px;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.15s ease;
}

.fm-action-menu.visible {
    opacity: 1;
    transform: translateY(0);
}

.fm-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s ease;
    text-align: left;
}

.fm-menu-item:hover {
    background: var(--bg-primary);
}

.fm-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.fm-menu-item-danger {
    color: var(--color-error);
}

.fm-menu-item-danger svg {
    color: var(--color-error);
}

.fm-menu-item-danger:hover {
    background: #FEF2F2;
}

[data-theme="dark"] .fm-menu-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Inline Rename Input */
.fm-inline-rename {
    width: 100%;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    outline: none;
}

/* Confirmation Modal */
.fm-confirm-modal {
    max-width: 400px;
}

.fm-confirm-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.fm-confirm-text strong {
    color: var(--text-primary);
}

.fm-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.fm-delete-btn {
    background: var(--color-error) !important;
    color: #fff !important;
    border: none;
    border-radius: var(--radius-md) !important;
}

.fm-delete-btn:hover {
    background: #dc2626 !important;
}

/* Affected files list (folder delete confirmation) */
.fm-affected-files {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    list-style: none;
}

.fm-affected-files li {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.fm-affected-files li:last-child {
    border-bottom: none;
}

/* Current folder in move modal (dimmed) */
.fm-current-folder {
    opacity: 0.5;
}

/* Undo Toast */
.fm-undo-toast {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fm-undo-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.fm-undo-btn:hover {
    color: #FFFFFF;
}

/* New Folder Button (sidebar) */
.fm-new-folder-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 24px;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.fm-new-folder-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.fm-new-folder-btn svg {
    width: 14px;
    height: 14px;
}

/* New Folder Inline Input (sidebar) */
.fm-new-folder-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
}

.fm-new-folder-input input {
    flex: 1;
    min-width: 0;
}

.fm-new-folder-confirm {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.fm-new-folder-confirm:hover {
    opacity: 0.8;
}

.fm-new-folder-confirm svg {
    width: 16px;
    height: 16px;
}

/* =========================================================================
   Offline Banner
   ========================================================================= */

.offline-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--color-warning);
    color: #000;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.offline-banner svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
