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

        /* ===== THEME CSS VARIABLES ===== */
        :root {
            --bg-primary: #1a1a2e;
            --bg-secondary: #16213e;
            --bg-tertiary: #0f3460;
            --bg-hover: #1a4a7a;
            --border-color: #0f3460;
            --text-primary: #eee;
            --text-secondary: #cbd5e1;
            --text-muted: #94a3b8;
            --text-faint: #64748b;
            --accent-primary: #e94560;
            --accent-hover: #d63850;
            --accent-secondary: #60a5fa;
            --tag-bg: #0f3460;
            --tag-text: #60a5fa;
        }

        /* Dark Themes */
        [data-theme="midnight"] {
            --bg-primary: #1a1a2e; --bg-secondary: #16213e; --bg-tertiary: #0f3460;
            --bg-hover: #1a4a7a; --border-color: #0f3460; --text-primary: #eee;
            --text-secondary: #cbd5e1; --text-muted: #94a3b8; --text-faint: #64748b;
            --accent-primary: #e94560; --accent-hover: #d63850; --accent-secondary: #60a5fa;
            --tag-bg: #0f3460; --tag-text: #60a5fa;
        }

        [data-theme="ocean"] {
            --bg-primary: #0d1b2a; --bg-secondary: #1b263b; --bg-tertiary: #415a77;
            --bg-hover: #778da9; --border-color: #415a77; --text-primary: #e0e1dd;
            --text-secondary: #c5c6c2; --text-muted: #a0a1a0; --text-faint: #778da9;
            --accent-primary: #00b4d8; --accent-hover: #0096c7; --accent-secondary: #90e0ef;
            --tag-bg: #415a77; --tag-text: #90e0ef;
        }

        [data-theme="forest"] {
            --bg-primary: #1a2f1a; --bg-secondary: #2d4a2d; --bg-tertiary: #3d6b3d;
            --bg-hover: #4a8c4a; --border-color: #3d6b3d; --text-primary: #e8f5e8;
            --text-secondary: #c8e6c8; --text-muted: #a8d4a8; --text-faint: #7ab87a;
            --accent-primary: #4ade80; --accent-hover: #22c55e; --accent-secondary: #86efac;
            --tag-bg: #3d6b3d; --tag-text: #86efac;
        }

        [data-theme="ember"] {
            --bg-primary: #1f1315; --bg-secondary: #2d1b1e; --bg-tertiary: #4a2c31;
            --bg-hover: #6b3d44; --border-color: #4a2c31; --text-primary: #fce8e8;
            --text-secondary: #f5d0d0; --text-muted: #d4a5a5; --text-faint: #a67070;
            --accent-primary: #f97316; --accent-hover: #ea580c; --accent-secondary: #fdba74;
            --tag-bg: #4a2c31; --tag-text: #fdba74;
        }

        [data-theme="violet"] {
            --bg-primary: #1e1b2e; --bg-secondary: #2a2640; --bg-tertiary: #3d3760;
            --bg-hover: #524a80; --border-color: #3d3760; --text-primary: #f0eeff;
            --text-secondary: #d8d4f0; --text-muted: #b8b0d8; --text-faint: #8a80b0;
            --accent-primary: #a78bfa; --accent-hover: #8b5cf6; --accent-secondary: #c4b5fd;
            --tag-bg: #3d3760; --tag-text: #c4b5fd;
        }

        /* Additional Dark Themes (Gray/Neutral) */
        [data-theme="slate"] {
            --bg-primary: #1e1e1e; --bg-secondary: #2d2d2d; --bg-tertiary: #3d3d3d;
            --bg-hover: #4d4d4d; --border-color: #404040; --text-primary: #e5e5e5;
            --text-secondary: #d4d4d4; --text-muted: #a3a3a3; --text-faint: #737373;
            --accent-primary: #a1a1aa; --accent-hover: #d4d4d8; --accent-secondary: #71717a;
            --tag-bg: #404040; --tag-text: #d4d4d4;
        }

        [data-theme="charcoal"] {
            --bg-primary: #252525; --bg-secondary: #333333; --bg-tertiary: #444444;
            --bg-hover: #555555; --border-color: #4a4a4a; --text-primary: #f0f0f0;
            --text-secondary: #e0e0e0; --text-muted: #b0b0b0; --text-faint: #808080;
            --accent-primary: #9ca3af; --accent-hover: #d1d5db; --accent-secondary: #6b7280;
            --tag-bg: #4a4a4a; --tag-text: #e0e0e0;
        }

        [data-theme="obsidian"] {
            --bg-primary: #0d1117; --bg-secondary: #161b22; --bg-tertiary: #21262d;
            --bg-hover: #30363d; --border-color: #30363d; --text-primary: #c9d1d9;
            --text-secondary: #b1bac4; --text-muted: #8b949e; --text-faint: #6e7681;
            --accent-primary: #58a6ff; --accent-hover: #79b8ff; --accent-secondary: #1f6feb;
            --tag-bg: #1f6feb33; --tag-text: #58a6ff;
        }

        [data-theme="wine"] {
            --bg-primary: #1a0d0d; --bg-secondary: #2e1a1a; --bg-tertiary: #4a2d2d;
            --bg-hover: #5c3a3a; --border-color: #4a2d2d; --text-primary: #fecaca;
            --text-secondary: #fca5a5; --text-muted: #f87171; --text-faint: #b91c1c;
            --accent-primary: #f87171; --accent-hover: #ef4444; --accent-secondary: #dc2626;
            --tag-bg: #7f1d1d; --tag-text: #fca5a5;
        }

        [data-theme="mono"] {
            --bg-primary: #000000; --bg-secondary: #0a0a0a; --bg-tertiary: #171717;
            --bg-hover: #262626; --border-color: #262626; --text-primary: #fafafa;
            --text-secondary: #e5e5e5; --text-muted: #a3a3a3; --text-faint: #737373;
            --accent-primary: #ffffff; --accent-hover: #e5e5e5; --accent-secondary: #d4d4d4;
            --tag-bg: #262626; --tag-text: #fafafa;
        }

        /* Light Themes */
        [data-theme="paper"] {
            --bg-primary: #faf8f5; --bg-secondary: #f5f0e8; --bg-tertiary: #e8e0d5;
            --bg-hover: #ddd5c8; --border-color: #d5cdc0; --text-primary: #2c2825;
            --text-secondary: #3d3835; --text-muted: #4a4540; --text-faint: #5a554f;
            --accent-primary: #b04020; --accent-hover: #903018; --accent-secondary: #3d3835;
            --tag-bg: #e8e0d5; --tag-text: #1d4ed8;
        }

        [data-theme="cloud"] {
            --bg-primary: #f8fafc; --bg-secondary: #f1f5f9; --bg-tertiary: #e2e8f0;
            --bg-hover: #cbd5e1; --border-color: #cbd5e1; --text-primary: #1e293b;
            --text-secondary: #2d3a4d; --text-muted: #3d4a5c; --text-faint: #4a5568;
            --accent-primary: #1d4ed8; --accent-hover: #1e40af; --accent-secondary: #2d3a4d;
            --tag-bg: #e2e8f0; --tag-text: #1d4ed8;
        }

        [data-theme="mint"] {
            --bg-primary: #f0fdf4; --bg-secondary: #dcfce7; --bg-tertiary: #bbf7d0;
            --bg-hover: #86efac; --border-color: #86efac; --text-primary: #14532d;
            --text-secondary: #1a5c34; --text-muted: #1f6b3d; --text-faint: #256b42;
            --accent-primary: #047857; --accent-hover: #065f46; --accent-secondary: #1a5c34;
            --tag-bg: #bbf7d0; --tag-text: #065f46;
        }

        [data-theme="rose"] {
            --bg-primary: #fff1f2; --bg-secondary: #ffe4e6; --bg-tertiary: #fecdd3;
            --bg-hover: #fda4af; --border-color: #fda4af; --text-primary: #4c0519;
            --text-secondary: #6b0f2a; --text-muted: #7f1d3a; --text-faint: #881337;
            --accent-primary: #9f1239; --accent-hover: #881337; --accent-secondary: #6b0f2a;
            --tag-bg: #fecdd3; --tag-text: #9f1239;
        }

        [data-theme="sand"] {
            --bg-primary: #fefce8; --bg-secondary: #fef9c3; --bg-tertiary: #fef08a;
            --bg-hover: #fde047; --border-color: #fde047; --text-primary: #422006;
            --text-secondary: #5c3a1a; --text-muted: #6b4520; --text-faint: #78500f;
            --accent-primary: #92400e; --accent-hover: #78350f; --accent-secondary: #5c3a1a;
            --tag-bg: #fef08a; --tag-text: #78350f;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            height: 100vh;
            overflow: hidden;
            transition: background-color 0.3s, color 0.3s;
        }

        /* Auth Screen */
        .auth-screen {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            padding: 20px;
        }

        .auth-logo {
            font-size: 14px;
            font-weight: 600;
            letter-spacing: 0.1em;
            color: var(--accent-primary);
            text-transform: uppercase;
            margin-bottom: 8px;
        }

        .auth-title {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 32px;
        }

        .auth-btn {
            width: 100%;
            max-width: 300px;
            padding: 16px;
            background: var(--accent-primary);
            color: #fff;
            border: none;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
        }

        .auth-btn:active {
            opacity: 0.8;
        }

        .auth-error {
            margin-top: 16px;
            color: #ef4444;
            font-size: 14px;
            text-align: center;
        }

        /* Sync Status */
        .sync-status {
            display: flex;
            align-items: center;
            gap: 4px;
            font-size: 0.65rem;
            color: var(--text-faint);
            padding: 2px 6px;
            border-radius: 8px;
            cursor: pointer;
        }

        .sync-status:hover {
            background: var(--bg-tertiary);
        }

        .sync-status.saving { color: #f59e0b; }
        .sync-status.saved { color: #22c55e; }
        .sync-status.offline { color: var(--text-muted); }
        .sync-status.error { color: #ef4444; }

        .sync-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: currentColor;
        }

        .sync-status.saving .sync-dot {
            animation: pulse 1s infinite;
        }

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

        /* Document Manager */
        .doc-manager {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.85);
            z-index: 200;
            align-items: center;
            justify-content: center;
        }

        .doc-manager.show { display: flex; }

        .doc-manager-modal {
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 12px;
            width: 90%;
            max-width: 500px;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
        }

        .doc-manager-header {
            padding: 16px 20px;
            border-bottom: 1px solid var(--bg-tertiary);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .doc-manager-header h2 {
            font-size: 1.1rem;
            color: var(--accent-primary);
        }

        .doc-manager-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 1.5rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }

        .doc-manager-close:hover { color: var(--text-primary); }

        .doc-manager-actions {
            padding: 12px 20px;
            border-bottom: 1px solid var(--bg-tertiary);
            display: flex;
            gap: 10px;
        }

        .doc-manager-list {
            flex: 1;
            overflow-y: auto;
            padding: 12px;
        }

        .doc-item {
            display: flex;
            align-items: center;
            padding: 12px 14px;
            background: var(--bg-primary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 8px;
            margin-bottom: 8px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .doc-item:hover { border-color: var(--accent-primary); }
        .doc-item.active {
            border-color: var(--accent-primary);
            background: rgba(233, 69, 96, 0.1);
        }

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

        .doc-item-name {
            font-size: 0.95rem;
            color: var(--text-primary);
            margin-bottom: 4px;
        }

        .doc-item-meta {
            font-size: 0.75rem;
            color: var(--text-faint);
        }

        .doc-item-delete {
            background: none;
            border: none;
            color: var(--text-faint);
            font-size: 1.1rem;
            cursor: pointer;
            padding: 8px;
            border-radius: 6px;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .doc-item:hover .doc-item-delete,
        .doc-item:hover .doc-item-edit { opacity: 1; }
        .doc-item-delete:hover {
            background: #7f1d1d;
            color: #fca5a5;
        }

        .doc-item-edit {
            background: none;
            border: none;
            color: var(--text-faint);
            font-size: 1rem;
            cursor: pointer;
            padding: 8px;
            border-radius: 6px;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .doc-item-edit:hover {
            background: var(--bg-tertiary);
            color: var(--accent-secondary);
        }

        .doc-item-actions {
            display: flex;
            gap: 4px;
        }

        .doc-item-name-input {
            background: var(--bg-primary);
            border: 1px solid var(--accent-primary);
            color: var(--text-primary);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.95rem;
            width: 100%;
            margin-bottom: 4px;
        }

        .doc-item-name-input:focus {
            outline: none;
            border-color: var(--accent-secondary);
        }

        .doc-item-edit-actions {
            display: flex;
            gap: 8px;
            margin-top: 4px;
        }

        .doc-item-edit-actions button {
            padding: 4px 12px;
            border-radius: 4px;
            font-size: 0.75rem;
            cursor: pointer;
            border: none;
        }

        .doc-item-save-btn {
            background: var(--accent-primary);
            color: white;
        }

        .doc-item-save-btn:hover {
            background: var(--accent-hover);
        }

        .doc-item-cancel-btn {
            background: var(--bg-tertiary);
            color: var(--text-muted);
        }

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

        .no-docs {
            text-align: center;
            padding: 40px 20px;
            color: var(--text-faint);
        }

        .doc-trash-section {
            border-top: 1px solid var(--bg-tertiary);
            margin-top: 8px;
        }

        .doc-trash-header {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 12px 14px 8px;
            cursor: pointer;
            user-select: none;
        }

        .doc-trash-header:hover {
            opacity: 0.8;
        }

        .doc-trash-toggle {
            font-size: 0.65rem;
            color: var(--text-faint);
            transition: transform 0.2s;
        }

        .doc-trash-section.expanded .doc-trash-toggle {
            transform: rotate(90deg);
        }

        .doc-trash-label {
            font-size: 0.8rem;
            color: var(--text-muted);
            font-weight: 500;
        }

        .doc-trash-count {
            font-size: 0.7rem;
            color: var(--text-faint);
        }

        .doc-trash-list {
            display: none;
            padding: 0 4px 8px;
        }

        .doc-trash-section.expanded .doc-trash-list {
            display: block;
        }

        .doc-item.trashed {
            opacity: 0.6;
        }

        .doc-item.trashed .doc-item-name {
            text-decoration: line-through;
            color: var(--text-muted);
        }

        .doc-item-restore {
            background: none;
            border: none;
            color: #22c55e;
            font-size: 0.85rem;
            cursor: pointer;
            padding: 8px;
            border-radius: 6px;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .doc-item:hover .doc-item-restore { opacity: 1; }
        .doc-item-restore:hover {
            background: #14532d;
            color: #4ade80;
        }

        .doc-item-permanent-delete {
            background: none;
            border: none;
            color: #ef4444;
            font-size: 0.85rem;
            cursor: pointer;
            padding: 8px;
            border-radius: 6px;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .doc-item:hover .doc-item-permanent-delete { opacity: 1; }
        .doc-item-permanent-delete:hover {
            background: #7f1d1d;
            color: #fca5a5;
        }

        .current-doc-name {
            font-size: 0.85rem;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            cursor: pointer;
            padding: 2px 8px;
            border-radius: 4px;
        }

        .current-doc-name:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }

        .doc-status-container {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            margin-left: 12px;
            min-width: 0;
        }

        .new-doc-input {
            flex: 1;
            background: var(--bg-primary);
            border: 1px solid var(--bg-tertiary);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 0.9rem;
        }

        .new-doc-input:focus {
            outline: none;
            border-color: var(--accent-primary);
        }

        .new-doc-input::placeholder {
            color: var(--text-faint);
        }

        .container {
            position: relative;
            height: 100vh;
        }

        header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 60px;
            background: var(--bg-secondary);
            padding: 12px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--bg-tertiary);
            z-index: 10;
        }

        h1 {
            font-size: 1.1rem;
            font-weight: 600;
            color: var(--accent-primary);
        }

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

        .header-buttons {
            display: flex;
            gap: 8px;
        }

        .btn {
            background: var(--accent-primary);
            color: white;
            border: none;
            padding: 6px 14px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: 500;
            transition: background 0.2s;
        }

        .btn:hover {
            background: var(--accent-hover);
        }

        .btn-secondary {
            background: var(--bg-tertiary);
            color: var(--text-muted);
        }

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

        .btn-secondary.active {
            background: var(--accent-primary);
            color: white;
        }

        .btn-icon {
            padding: 6px 10px;
            font-size: 0.9rem;
        }

        /* Desktop hamburger menu */
        .desktop-menu-btn {
            display: none;
            background: var(--bg-tertiary);
            border: none;
            color: var(--text-muted);
            font-size: 1.3rem;
            padding: 6px 12px;
            border-radius: 6px;
            cursor: pointer;
        }

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

        @media (min-width: 769px) {
            .desktop-menu-btn {
                display: block;
            }
        }

        .desktop-menu-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 99;
        }

        .desktop-menu-overlay.show {
            display: block;
        }

        .desktop-menu {
            display: none;
            position: absolute;
            top: 100%;
            left: 0;
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 8px;
            min-width: 200px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.3);
            z-index: 100;
            margin-top: 8px;
        }

        .desktop-menu.show {
            display: block;
        }

        .desktop-menu-item {
            padding: 12px 16px;
            cursor: pointer;
            color: var(--text-secondary);
            font-size: 0.9rem;
        }

        .desktop-menu-item:hover {
            background: var(--bg-tertiary);
        }

        .desktop-menu-item:first-child {
            border-radius: 8px 8px 0 0;
        }

        .desktop-menu-item:last-child {
            border-radius: 0 0 8px 8px;
        }

        .desktop-menu-divider {
            height: 1px;
            background: var(--bg-tertiary);
            margin: 4px 0;
        }

        .desktop-menu-theme-section {
            cursor: default;
            pointer-events: none;
            color: var(--text-muted);
            font-size: 0.8rem;
        }

        .desktop-menu-theme-section:hover {
            background: transparent;
        }

        .export-dropdown {
            position: relative;
            display: inline-block;
        }

        .export-menu {
            display: none;
            position: absolute;
            top: 100%;
            left: 0;
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 6px;
            min-width: 200px;
            z-index: 100;
            margin-top: 4px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        }

        .export-menu.show {
            display: block;
        }

        .export-menu button {
            display: block;
            width: 100%;
            padding: 10px 14px;
            background: none;
            border: none;
            color: var(--text-primary);
            text-align: left;
            cursor: pointer;
            font-size: 0.85rem;
        }

        .export-menu button:hover {
            background: var(--bg-tertiary);
        }

        .export-menu button:first-child {
            border-radius: 6px 6px 0 0;
        }

        .export-menu button:last-child {
            border-radius: 0 0 6px 6px;
        }

        .import-dropdown {
            position: relative;
            display: inline-block;
        }

        .import-menu {
            display: none;
            position: absolute;
            top: 100%;
            left: 0;
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 6px;
            min-width: 180px;
            z-index: 100;
            margin-top: 4px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        }

        .import-menu.show {
            display: block;
        }

        .import-menu button {
            display: block;
            width: 100%;
            padding: 10px 14px;
            background: none;
            border: none;
            color: var(--text-primary);
            text-align: left;
            cursor: pointer;
            font-size: 0.85rem;
        }

        .import-menu button:hover {
            background: var(--bg-tertiary);
        }

        .import-menu button:first-child {
            border-radius: 6px 6px 0 0;
        }

        .import-menu button:last-child {
            border-radius: 0 0 6px 6px;
        }

        .stats {
            display: flex;
            flex-wrap: wrap;
            gap: 8px 16px;
            font-size: 0.75rem;
            color: var(--text-muted);
            justify-content: flex-end;
            max-width: 600px;
        }

        .stats-row {
            display: flex;
            gap: 16px;
            align-items: center;
        }

        .stat {
            display: flex;
            align-items: center;
            gap: 5px;
            white-space: nowrap;
        }

        .stat-value {
            color: var(--text-secondary);
            font-weight: 600;
        }

        .stat-clickable {
            cursor: pointer;
            border-bottom: 1px dashed var(--text-muted);
        }

        .stat-clickable:hover {
            opacity: 0.8;
        }

        .stat-divider {
            width: 1px;
            height: 14px;
            background: var(--bg-tertiary);
        }

        .main {
            position: fixed;
            top: 60px;
            left: 0;
            right: 0;
            bottom: 0;
        }

        /* Sidebar */
        .sidebar {
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            width: 280px;
            background: var(--bg-secondary);
            border-right: 1px solid var(--bg-tertiary);
            display: flex;
            flex-direction: column;
        }

        .sidebar-header {
            padding: 12px;
            border-bottom: 1px solid var(--bg-tertiary);
            background: var(--bg-secondary);
            position: relative;
            z-index: 10;
        }

        .search-box {
            width: 100%;
            background: var(--bg-primary);
            border: 1px solid var(--bg-tertiary);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 0.8rem;
            margin-bottom: 10px;
        }

        .search-box:focus {
            outline: none;
            border-color: var(--accent-primary);
        }

        .search-box::placeholder {
            color: var(--text-faint);
        }

        .tags-section {
            margin-top: 10px;
            position: relative;
            z-index: 10;
        }

        .tags-header {
            display: flex;
            align-items: center;
            gap: 6px;
            cursor: pointer;
            padding: 6px 0;
            user-select: none;
        }

        .tags-header:hover {
            opacity: 0.8;
        }

        .tags-toggle {
            font-size: 0.65rem;
            color: var(--text-faint);
            transition: transform 0.2s;
        }

        .tags-section.expanded .tags-toggle {
            transform: rotate(90deg);
        }

        .tags-label {
            font-size: 0.75rem;
            color: var(--text-muted);
            font-weight: 500;
        }

        .active-filter-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            background: var(--accent-primary);
            color: white;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 0.65rem;
            font-weight: 500;
        }

        .active-filter-badge:empty {
            display: none;
        }

        .active-filter-badge .clear-badge {
            cursor: pointer;
            margin-left: 2px;
        }

        .active-filter-badge .clear-badge:hover {
            opacity: 0.7;
        }

        .filter-tags {
            display: none;
            flex-wrap: wrap;
            gap: 6px;
            align-items: center;
            padding: 8px 0 4px 0;
            background: var(--bg-secondary);
        }

        .tags-section.expanded .filter-tags {
            display: flex;
        }

        .tags-section.expanded .show-hidden-toggle {
            display: flex;
        }

        .filter-tag {
            background: var(--bg-tertiary);
            color: var(--text-faint);
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.7rem;
            font-weight: 500;
            cursor: pointer;
            border: 1px solid transparent;
            transition: all 0.2s;
        }

        .filter-tag:hover {
            color: var(--text-muted);
            border-color: var(--bg-hover);
        }

        .filter-tag.active {
            background: var(--accent-primary);
            color: white;
        }

        .filter-status {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            background: rgba(233, 69, 96, 0.1);
            border-bottom: 1px solid var(--bg-tertiary);
            font-size: 0.75rem;
        }

        .filter-status-text {
            color: var(--accent-primary);
        }

        .clear-filters {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 0.75rem;
            padding: 2px 6px;
            border-radius: 4px;
        }

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

        .show-hidden-toggle {
            display: none;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            cursor: pointer;
            font-size: 0.8rem;
            color: var(--text-faint);
        }

        .show-hidden-toggle:hover {
            color: var(--text-muted);
            background: rgba(15, 52, 96, 0.3);
        }

        .show-hidden-checkbox {
            font-size: 1rem;
        }

        .show-hidden-toggle.active {
            color: var(--accent-secondary);
        }

        .show-hidden-toggle.active .show-hidden-checkbox {
            color: var(--accent-secondary);
        }

        .block-list {
            position: absolute;
            top: 100px; /* below sidebar-header */
            left: 0;
            right: 0;
            bottom: 0;
            overflow-y: auto;
            padding: 8px;
        }

        .block-item {
            position: relative;
            background: var(--bg-primary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 8px;
            padding: 10px 12px;
            margin-bottom: 6px;
            cursor: grab;
            transition: all 0.2s;
        }

        .block-item:hover {
            border-color: var(--accent-primary);
        }

        .block-item.active {
            border-color: var(--accent-primary);
            background: var(--bg-tertiary);
        }

        .block-item.selected {
            border-color: var(--accent-secondary);
            background: var(--bg-hover);
        }

        .block-item.active.selected {
            border-color: var(--accent-primary);
            background: var(--bg-tertiary);
        }

        .block-item.dragging {
            opacity: 0.5;
            cursor: grabbing;
        }

        .block-item.drag-over {
            border-color: var(--accent-primary);
            border-style: dashed;
            background: #251530;
        }

        .block-header {
            display: flex;
            align-items: flex-start;
            gap: 8px;
        }

        .sidebar-block-number {
            position: absolute;
            bottom: 6px;
            right: 8px;
            color: var(--text-faint);
            font-size: 0.65rem;
            font-weight: 500;
            opacity: 0.7;
        }

        .block-item.active .sidebar-block-number {
            color: var(--accent-primary);
            opacity: 1;
        }

        .block-content {
            flex: 1;
            min-width: 0;
        }

        .block-preview {
            font-size: 0.8rem;
            color: var(--text-secondary);
            line-height: 1.4;
            word-break: break-word;
        }

        .block-item.excluded {
            opacity: 0.5;
        }

        .block-item.excluded .block-preview {
            font-style: italic;
        }

        .block-meta {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 6px;
        }

        .block-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            flex: 1;
        }

        .tag {
            background: var(--bg-tertiary);
            color: var(--accent-secondary);
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 0.65rem;
            font-weight: 500;
        }

        .delete-btn {
            color: var(--text-faint);
            background: none;
            border: none;
            cursor: pointer;
            padding: 2px 6px;
            border-radius: 4px;
            font-size: 0.85rem;
            line-height: 1;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .block-item:hover .delete-btn {
            opacity: 1;
        }

        .delete-btn:hover {
            background: #7f1d1d;
            color: #fca5a5;
        }

        .delete-btn.confirm-delete {
            opacity: 1;
            color: #ef4444;
            font-size: 1rem;
        }

        .delete-btn.confirm-delete:hover {
            background: #dc2626;
            color: #fff;
        }

        .block-actions {
            display: flex;
            flex-direction: column;
            gap: 2px;
            margin-right: 6px;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .block-item:hover .block-actions {
            opacity: 1;
        }

        .reorder-btn {
            background: none;
            border: none;
            color: var(--text-faint);
            cursor: pointer;
            padding: 2px 4px;
            font-size: 0.7rem;
            line-height: 1;
            border-radius: 3px;
        }

        .reorder-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-muted);
        }

        .reorder-btn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        .no-blocks {
            text-align: center;
            padding: 40px 20px;
            color: var(--text-faint);
        }

        .no-blocks p {
            margin-bottom: 8px;
        }

        /* Editor Panel */
        .editor-panel {
            position: absolute;
            top: 0;
            left: 280px;
            right: 0;
            bottom: 0;
            display: flex;
            flex-direction: column;
        }

        .editor-toolbar {
            background: var(--bg-secondary);
            padding: 10px 16px;
            border-bottom: 1px solid var(--bg-tertiary);
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .tag-input {
            background: var(--bg-primary);
            border: 1px solid var(--bg-tertiary);
            color: var(--text-primary);
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 0.8rem;
            width: 120px;
        }

        .tag-input:focus {
            outline: none;
            border-color: var(--accent-primary);
        }

        .current-tags {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            flex: 1;
        }

        .current-tag {
            background: var(--bg-tertiary);
            color: var(--accent-secondary);
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.75rem;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .current-tag button {
            background: none;
            border: none;
            color: var(--accent-secondary);
            cursor: pointer;
            font-size: 0.9rem;
            line-height: 1;
            padding: 0;
        }

        .current-tag button:hover {
            color: #fca5a5;
        }

        .toolbar-hint {
            color: var(--text-faint);
            font-size: 0.7rem;
        }

        .document-view {
            position: absolute;
            top: 50px; /* below toolbar */
            left: 0;
            right: 0;
            bottom: 0;
            overflow-y: auto;
            padding: 20px 24px;
        }

        .block-editor {
            position: relative;
            margin-bottom: 16px;
            border-radius: 8px;
            transition: all 0.2s;
        }

        .block-number {
            position: absolute;
            top: 8px;
            left: 8px;
            font-size: 0.65rem;
            color: var(--text-faint);
            opacity: 0.6;
            z-index: 1;
            pointer-events: none;
        }

        .block-editor.active .block-number {
            color: var(--accent-primary);
            opacity: 1;
        }

        .block-editor.active {
            background: rgba(233, 69, 96, 0.05);
        }

        .block-editor.excluded {
            opacity: 0.4;
        }

        .block-editor.excluded textarea {
            font-style: italic;
        }

        /* Focus mode - dim non-active blocks */
        .document-view.focus-mode .block-editor {
            opacity: 0.15;
            transition: opacity 0.2s, transform 0.2s;
        }

        .document-view.focus-mode .block-editor.active {
            opacity: 1 !important;
        }

        .document-view.focus-mode .block-editor.active textarea {
            font-size: 1.25rem;
            line-height: 1.8;
        }

        .document-view.focus-mode .block-editor:hover:not(.active) {
            opacity: 0.3;
        }

        .document-view.focus-mode .block-divider {
            opacity: 0.1;
        }

        /* Focus mode spacer - allows scrolling typing area to middle of screen */
        .focus-spacer {
            height: 50vh;
        }

        .document-view.focus-mode .add-block-btn {
            opacity: 0.15;
        }

        .document-view.focus-mode .add-block-btn:hover {
            opacity: 1;
        }

        .block-editor textarea {
            width: 100%;
            background: transparent;
            border: 1px solid transparent;
            color: var(--text-primary);
            font-size: 1rem;
            line-height: 1.7;
            resize: none;
            font-family: inherit;
            padding: 12px 14px;
            border-radius: 8px;
            min-height: 80px;
            max-height: 65vh;
            overflow-y: auto;
        }

        .block-editor textarea:focus {
            outline: none;
            border-color: var(--bg-tertiary);
            background: rgba(15, 52, 96, 0.2);
        }

        .block-editor textarea::placeholder {
            color: var(--text-faint);
        }

        .block-divider {
            height: 1px;
            background: var(--bg-tertiary);
            margin: 8px 14px;
        }

        .add-block-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            width: 100%;
            padding: 12px;
            background: transparent;
            border: 1px dashed var(--bg-tertiary);
            border-radius: 8px;
            color: var(--text-faint);
            cursor: pointer;
            font-size: 0.85rem;
            transition: all 0.2s;
        }

        .add-block-btn:hover {
            border-color: var(--accent-primary);
            color: var(--accent-primary);
        }

        .start-writing {
            color: var(--text-faint);
            text-align: center;
            padding: 60px 40px;
        }

        .start-writing p {
            margin-bottom: 16px;
        }

        /* Markdown Preview */
        .markdown-preview {
            padding: 0 14px;
        }

        .preview-block {
            margin-bottom: 24px;
            padding-bottom: 24px;
            border-bottom: 1px solid var(--bg-tertiary);
        }

        .preview-block:last-child {
            border-bottom: none;
        }

        .markdown-preview h1, 
        .markdown-preview h2, 
        .markdown-preview h3,
        .markdown-preview h4 {
            color: var(--accent-primary);
            margin: 0.5em 0 0.5em 0;
        }

        .markdown-preview h1:first-child,
        .markdown-preview h2:first-child,
        .markdown-preview h3:first-child {
            margin-top: 0;
        }

        .markdown-preview h1 { font-size: 1.6rem; }
        .markdown-preview h2 { font-size: 1.35rem; }
        .markdown-preview h3 { font-size: 1.15rem; }

        .markdown-preview p {
            margin-bottom: 1em;
        }

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

        .markdown-preview ul, 
        .markdown-preview ol {
            margin: 1em 0;
            padding-left: 2em;
        }

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

        .markdown-preview code {
            background: var(--bg-tertiary);
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'SF Mono', Monaco, monospace;
            font-size: 0.9em;
        }

        .markdown-preview pre {
            background: var(--bg-tertiary);
            padding: 16px;
            border-radius: 8px;
            overflow-x: auto;
            margin: 1em 0;
        }

        .markdown-preview pre code {
            background: none;
            padding: 0;
        }

        .markdown-preview blockquote {
            border-left: 3px solid var(--accent-primary);
            margin: 1em 0;
            padding-left: 1em;
            color: var(--text-muted);
        }

        .markdown-preview strong {
            color: #fff;
        }

        .markdown-preview a {
            color: var(--accent-secondary);
        }

        .markdown-preview hr {
            border: none;
            border-top: 1px solid var(--bg-tertiary);
            margin: 2em 0;
        }

        /* Help Modal */
        .help-modal {
            display: none;
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 320px;
            max-height: 70vh;
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.4);
            z-index: 1000;
            overflow: hidden;
        }

        .help-modal.show {
            display: block;
        }

        .help-header {
            padding: 12px 16px;
            background: var(--bg-tertiary);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .help-header h3 {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--accent-primary);
        }

        .help-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 1.2rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }

        .help-close:hover {
            color: var(--text-primary);
        }

        .help-content {
            padding: 16px;
            overflow-y: auto;
            max-height: calc(70vh - 50px);
        }

        .help-section {
            margin-bottom: 16px;
        }

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

        .help-section h4 {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-faint);
            margin-bottom: 8px;
        }

        .help-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 0;
            border-bottom: 1px solid var(--bg-tertiary);
        }

        .help-row:last-child {
            border-bottom: none;
        }

        .help-syntax {
            font-family: 'SF Mono', Monaco, monospace;
            font-size: 0.8rem;
            color: var(--accent-secondary);
            background: var(--bg-tertiary);
            padding: 2px 6px;
            border-radius: 4px;
        }

        .help-result {
            font-size: 0.85rem;
            color: var(--text-secondary);
        }

        /* Version History Modal */
        .version-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            z-index: 2000;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .version-modal-overlay.show {
            display: flex;
        }

        .version-modal {
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 16px;
            width: 100%;
            max-width: 900px;
            max-height: 85vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
        }

        .version-modal-header {
            padding: 16px 24px;
            background: var(--bg-tertiary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }

        .version-modal-header h2 {
            font-size: 1.2rem;
            color: #fff;
            margin: 0;
        }

        .version-modal-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 1.5rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }

        .version-modal-close:hover {
            color: var(--accent-primary);
        }

        .version-modal-body {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        .version-list {
            width: 280px;
            border-right: 1px solid var(--bg-tertiary);
            overflow-y: auto;
            flex-shrink: 0;
        }

        .version-group-header {
            padding: 12px 16px 8px;
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--text-faint);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            background: var(--bg-primary);
            position: sticky;
            top: 0;
        }

        .version-item {
            padding: 12px 16px;
            border-bottom: 1px solid var(--bg-tertiary);
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .version-item:hover {
            background: var(--bg-tertiary);
        }

        .version-time {
            color: var(--text-primary);
            font-size: 0.9rem;
        }

        .version-info {
            color: var(--text-faint);
            font-size: 0.8rem;
        }

        .version-preview-panel {
            flex: 1;
            display: none;
            flex-direction: column;
            overflow: hidden;
        }

        .version-preview-panel.show {
            display: flex;
        }

        .version-preview-header {
            padding: 16px;
            background: var(--bg-primary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--bg-tertiary);
        }

        #version-preview-info {
            color: var(--text-muted);
            font-size: 0.85rem;
        }

        .version-preview-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .preview-block {
            background: var(--bg-primary);
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 8px;
            color: var(--text-secondary);
            font-size: 0.9rem;
            white-space: pre-wrap;
        }

        .preview-more {
            color: var(--text-faint);
            font-style: italic;
            padding: 12px;
            text-align: center;
        }

        .no-versions {
            padding: 40px 20px;
            text-align: center;
            color: var(--text-faint);
        }

        /* Theme Swatches */
        .theme-swatch {
            border-radius: 6px;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.15s;
            position: relative;
        }

        .theme-swatch:hover {
            transform: scale(1.1);
            z-index: 1;
        }

        .theme-swatch.active {
            border-color: var(--text-primary);
            box-shadow: 0 0 0 2px var(--accent-primary);
        }

        /* Mobile adjustments for version modal */
        @media (max-width: 768px) {
            .version-modal {
                max-width: 100%;
                max-height: 90vh;
                margin: 10px;
            }

            .version-modal-body {
                flex-direction: column;
            }

            .version-list {
                width: 100%;
                max-height: 40vh;
                border-right: none;
                border-bottom: 1px solid var(--bg-tertiary);
            }

            .version-preview-panel {
                max-height: 50vh;
            }
        }

        /* Disabled state for mobile menu items */
        .mobile-menu-item.disabled {
            opacity: 0.5;
            pointer-events: none;
        }

        /* Welcome Modal */
        .welcome-modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            z-index: 2000;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .welcome-modal-overlay.show {
            display: flex;
        }

        .welcome-modal {
            background: var(--bg-secondary);
            border: 1px solid var(--bg-tertiary);
            border-radius: 16px;
            width: 100%;
            max-width: 600px;
            max-height: 85vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 60px rgba(0,0,0,0.5);
        }

        .welcome-header {
            padding: 20px 24px;
            background: var(--bg-tertiary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }

        .welcome-header h2 {
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--accent-primary);
            margin: 0;
        }

        .welcome-close {
            background: none;
            border: none;
            color: var(--text-muted);
            font-size: 1.5rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }

        .welcome-close:hover {
            color: var(--text-primary);
        }

        .welcome-content {
            padding: 24px;
            overflow-y: auto;
            flex: 1;
        }

        .welcome-intro {
            font-size: 1rem;
            color: var(--text-muted);
            margin-bottom: 20px;
            line-height: 1.5;
        }

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

        .welcome-section h3 {
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--accent-primary);
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .welcome-section h3 .emoji {
            font-size: 1.1rem;
        }

        .welcome-section ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .welcome-section li {
            font-size: 0.9rem;
            color: var(--text-secondary);
            padding: 6px 0;
            padding-left: 16px;
            position: relative;
            line-height: 1.4;
        }

        .welcome-section li::before {
            content: "•";
            position: absolute;
            left: 0;
            color: var(--text-faint);
        }

        .welcome-section strong {
            color: var(--accent-secondary);
        }

        .welcome-getting-started {
            background: rgba(233, 69, 96, 0.1);
            border: 1px solid rgba(233, 69, 96, 0.3);
            border-radius: 8px;
            padding: 16px;
            margin-top: 20px;
        }

        .welcome-getting-started h3 {
            color: var(--accent-primary);
            margin-bottom: 8px;
            font-size: 1rem;
        }

        .welcome-getting-started p {
            color: var(--text-secondary);
            font-size: 0.9rem;
            margin: 0;
            line-height: 1.5;
        }

        .welcome-footer {
            padding: 16px 24px;
            background: var(--bg-tertiary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
            gap: 12px;
        }

        .welcome-checkbox-label {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.85rem;
            color: var(--text-muted);
            cursor: pointer;
        }

        .welcome-checkbox-label input {
            cursor: pointer;
        }

        .welcome-btn {
            background: var(--accent-primary);
            color: white;
            border: none;
            padding: 10px 24px;
            border-radius: 8px;
            font-size: 0.95rem;
            font-weight: 500;
            cursor: pointer;
        }

        .welcome-btn:hover {
            background: var(--accent-hover);
        }

        /* ===========================================
           MOBILE STYLES - Completely isolated
           =========================================== */
        @media (max-width: 768px) {
            /* Hide desktop elements */
            .sidebar,
            .stats,
            .editor-toolbar,
            .block-divider,
            .add-block-btn {
                display: none !important;
            }

            /* Simplified header */
            header {
                padding: 8px 12px;
            }

            .header-left {
                width: 100%;
            }

            .header-left h1 {
                font-size: 0.9rem;
                display: none;
            }

            .mobile-header-menu-btn {
                display: flex;
                align-items: center;
                justify-content: center;
                background: var(--bg-tertiary);
                border: none;
                color: var(--text-muted);
                width: 40px;
                height: 40px;
                border-radius: 8px;
                font-size: 1.4rem;
                cursor: pointer;
                flex-shrink: 0;
                position: relative;
            }

            .mobile-header-menu-btn:active {
                background: var(--bg-hover);
            }

            .menu-badge {
                display: none;
                position: absolute;
                top: 6px;
                right: 6px;
                width: 8px;
                height: 8px;
                background: var(--accent-primary);
                border-radius: 50%;
            }

            .menu-badge.active {
                display: block;
            }

            /* Mobile Menu Overlay */
            .mobile-menu-overlay {
                display: none;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: rgba(0, 0, 0, 0.7);
                z-index: 150;
            }

            .mobile-menu-overlay.show {
                display: block;
            }

            .mobile-menu {
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                width: 85%;
                max-width: 320px;
                background: var(--bg-secondary);
                overflow-y: auto;
                animation: slideIn 0.2s ease-out;
            }

            @keyframes slideIn {
                from { transform: translateX(-100%); }
                to { transform: translateX(0); }
            }

            .mobile-menu-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 16px;
                border-bottom: 1px solid var(--bg-tertiary);
                position: sticky;
                top: 0;
                background: var(--bg-secondary);
            }

            .mobile-menu-header h3 {
                margin: 0;
                font-size: 1.1rem;
                color: var(--accent-primary);
            }

            .mobile-menu-close {
                background: none;
                border: none;
                color: var(--text-muted);
                font-size: 1.5rem;
                cursor: pointer;
                padding: 0;
                line-height: 1;
            }

            .mobile-menu-content {
                padding: 8px 0;
            }

            .mobile-menu-section {
                padding: 8px 0;
                border-bottom: 1px solid var(--bg-tertiary);
            }

            .mobile-menu-section:last-child {
                border-bottom: none;
            }

            .mobile-menu-section-title {
                padding: 8px 16px;
                font-size: 0.75rem;
                color: var(--text-faint);
                text-transform: uppercase;
                letter-spacing: 0.05em;
                font-weight: 600;
                display: flex;
                justify-content: space-between;
                align-items: center;
                cursor: pointer;
            }

            .mobile-menu-expand {
                font-size: 0.7rem;
                transition: transform 0.2s;
            }

            .mobile-menu-expand.expanded {
                transform: rotate(90deg);
            }

            .mobile-menu-item {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 12px 16px;
                color: var(--text-primary);
                cursor: pointer;
                font-size: 0.95rem;
            }

            .mobile-menu-item:active {
                background: var(--bg-tertiary);
            }

            .mobile-menu-toggle {
                font-size: 0.75rem;
                padding: 2px 8px;
                border-radius: 10px;
                background: var(--bg-tertiary);
                color: var(--text-faint);
            }

            .mobile-menu-toggle.on {
                background: var(--accent-primary);
                color: #fff;
            }

            .mobile-menu-tags {
                padding: 8px 16px;
                display: flex;
                flex-wrap: wrap;
                gap: 8px;
            }

            .mobile-menu-tag {
                background: var(--bg-tertiary);
                color: var(--text-faint);
                padding: 6px 12px;
                border-radius: 16px;
                font-size: 0.8rem;
                cursor: pointer;
            }

            .mobile-menu-tag.active {
                background: var(--accent-primary);
                color: #fff;
            }

            .mobile-menu-stats {
                padding: 8px 16px;
            }

            .mobile-stat-row {
                display: flex;
                align-items: center;
                gap: 4px;
                padding: 4px 0;
                font-size: 0.8rem;
                color: var(--text-muted);
                flex-wrap: wrap;
            }

            .mobile-stat-value {
                color: var(--text-secondary);
                font-weight: 600;
            }

            .mobile-speed-toggle {
                font-size: 0.7rem;
                color: var(--text-secondary);
                cursor: pointer;
                text-transform: none;
                font-weight: normal;
            }

            .mobile-speed-label {
                color: var(--text-secondary);
                font-size: 0.75rem;
            }

            .header-buttons {
                gap: 4px;
            }

            .header-buttons .btn {
                display: none;
            }

            /* Show only essential buttons */
            .header-buttons .sync-status,
            .header-buttons .current-doc-name {
                display: flex;
            }

            /* Mobile navigation bar */
            .mobile-nav {
                display: flex;
                align-items: center;
                padding: 10px 12px;
                background: var(--bg-secondary);
                border-bottom: 1px solid var(--bg-tertiary);
                gap: 8px;
            }

            .mobile-nav-btn {
                background: var(--bg-tertiary);
                border: none;
                color: var(--text-muted);
                width: 44px;
                height: 44px;
                border-radius: 8px;
                font-size: 1.4rem;
                cursor: pointer;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .mobile-nav-btn:active {
                background: var(--bg-hover);
                color: var(--text-primary);
            }

            .mobile-nav-btn:disabled {
                opacity: 0.3;
            }

            .mobile-nav-btn.active {
                background: var(--accent-primary);
                color: #fff;
            }

            .mobile-nav-info {
                flex: 1;
                min-width: 0; /* Allow shrinking */
                text-align: center;
                cursor: pointer;
                padding: 8px;
                border-radius: 8px;
            }

            .mobile-nav-btn {
                flex-shrink: 0; /* Prevent buttons from shrinking */
            }

            .mobile-nav-info:active {
                background: var(--bg-tertiary);
            }

            .mobile-nav-info .block-num {
                font-size: 0.7rem;
                color: var(--text-faint);
            }

            .mobile-nav-info .block-title {
                font-size: 0.85rem;
                color: var(--text-primary);
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            /* Mobile search overlay */
            .mobile-search-overlay {
                display: none;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: var(--bg-primary);
                z-index: 100;
            }

            .mobile-search-overlay.show {
                display: block;
            }

            .mobile-search-header {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                height: 60px;
                padding: 12px;
                background: var(--bg-secondary);
                border-bottom: 1px solid var(--bg-tertiary);
                display: flex;
                gap: 10px;
                align-items: center;
            }

            .mobile-search-header input {
                flex: 1;
                background: var(--bg-primary);
                border: 1px solid var(--bg-tertiary);
                color: var(--text-primary);
                padding: 12px 14px;
                border-radius: 8px;
                font-size: 16px;
            }

            .mobile-search-header input:focus {
                outline: none;
                border-color: var(--accent-primary);
            }

            .mobile-search-cancel {
                background: none;
                border: none;
                color: var(--accent-primary);
                font-size: 1rem;
                padding: 12px;
                cursor: pointer;
            }

            .mobile-block-list {
                position: absolute;
                top: 60px;
                left: 0;
                right: 0;
                bottom: 0;
                overflow-y: auto;
                padding: 8px;
            }

            .mobile-block-item {
                background: var(--bg-secondary);
                border: 1px solid var(--bg-tertiary);
                border-radius: 8px;
                padding: 14px;
                margin-bottom: 8px;
                cursor: pointer;
            }

            .mobile-block-item:active {
                background: var(--bg-tertiary);
                border-color: var(--accent-primary);
            }

            .mobile-block-item.selected {
                background: var(--bg-tertiary);
                border-color: var(--accent-primary);
            }

            .mobile-block-item .block-preview {
                font-size: 0.95rem;
                color: var(--text-primary);
                line-height: 1.4;
            }

            .mobile-block-item .mobile-reorder-btns {
                display: flex;
                align-items: center;
                gap: 8px;
                margin-top: 10px;
                padding-top: 10px;
                border-top: 1px solid var(--bg-tertiary);
            }

            .mobile-block-item .mobile-reorder-btn {
                background: var(--bg-tertiary);
                border: none;
                color: var(--text-muted);
                padding: 8px 16px;
                border-radius: 6px;
                font-size: 0.8rem;
                cursor: pointer;
            }

            .mobile-block-item .mobile-reorder-btn:active {
                background: var(--bg-hover);
            }

            .mobile-block-item .mobile-reorder-btn:disabled {
                opacity: 0.3;
            }

            .mobile-block-item .mobile-block-number {
                font-size: 0.75rem;
                color: var(--text-faint);
                margin-left: 4px;
                min-width: 30px;
            }

            .mobile-block-item .mobile-delete-btn {
                background: var(--bg-tertiary);
                border: none;
                color: var(--text-muted);
                padding: 8px 16px;
                border-radius: 6px;
                font-size: 0.8rem;
                cursor: pointer;
                margin-left: auto;
            }

            .mobile-block-item .mobile-delete-btn:active {
                background: #7f1d1d;
                color: #fca5a5;
            }

            .mobile-block-item .mobile-delete-btn.confirm-delete {
                background: #dc2626;
                color: #fff;
            }

            /* Main content area */
            .main {
                position: fixed;
                top: 60px;
                left: 0;
                right: 0;
                bottom: 0;
            }

            .editor-panel {
                position: absolute;
                top: 64px; /* below mobile-nav */
                left: 0;
                right: 0;
                bottom: 0;
            }

            .document-view {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                padding: 12px 24px;
                overflow-y: auto;
            }

            /* Only show active block */
            .block-editor {
                display: none;
            }

            .block-editor.active {
                display: block;
            }

            /* Mobile Read Mode - show all blocks as rendered markdown */
            .document-view.mobile-read-mode .block-editor {
                display: none !important;
            }

            .document-view.mobile-read-mode .mobile-read-block {
                display: block;
                background: var(--bg-secondary);
                border: 1px solid var(--bg-tertiary);
                border-radius: 8px;
                padding: 16px;
                margin-bottom: 12px;
                cursor: pointer;
            }

            .document-view.mobile-read-mode .mobile-read-block.active {
                border-color: var(--accent-primary);
                background: var(--bg-tertiary);
            }

            .document-view.mobile-read-mode .mobile-read-block.excluded {
                opacity: 0.5;
            }

            .document-view.mobile-read-mode .mobile-read-block .block-label {
                font-size: 0.7rem;
                color: var(--text-faint);
                margin-bottom: 8px;
            }

            .document-view.mobile-read-mode .mobile-read-block .block-content {
                font-size: 1rem;
                line-height: 1.6;
                color: var(--text-primary);
            }

            .document-view.mobile-read-mode .mobile-read-block .block-content h1,
            .document-view.mobile-read-mode .mobile-read-block .block-content h2,
            .document-view.mobile-read-mode .mobile-read-block .block-content h3 {
                color: #fff;
                margin-bottom: 0.5em;
            }

            .document-view.mobile-read-mode .mobile-read-block .block-content p {
                margin-bottom: 0.75em;
            }

            .document-view.mobile-read-mode .mobile-read-block .block-content p:last-child {
                margin-bottom: 0;
            }

            .document-view.mobile-read-mode .add-block-btn {
                display: none;
            }

            .block-editor textarea {
                font-size: 16px;
                line-height: 1.7;
                min-height: 200px;
                padding: 12px;
            }

            /* Mobile Block Tags */
            .mobile-block-tags {
                display: flex;
                flex-wrap: wrap;
                align-items: center;
                gap: 8px;
                padding: 12px;
                background: var(--bg-tertiary);
                border-radius: 0 0 8px 8px;
                margin-top: -4px;
            }

            .mobile-tags-label {
                font-size: 0.8rem;
                color: var(--text-faint);
            }

            .mobile-tag-chip {
                background: var(--bg-secondary);
                color: var(--accent-secondary);
                padding: 4px 10px;
                border-radius: 12px;
                font-size: 0.8rem;
                cursor: pointer;
            }

            .mobile-tag-chip:active {
                background: #7f1d1d;
                color: #fca5a5;
            }

            .mobile-add-tag-btn {
                background: var(--bg-primary);
                border: 1px dashed var(--bg-tertiary);
                color: var(--text-faint);
                padding: 4px 10px;
                border-radius: 12px;
                font-size: 0.8rem;
                cursor: pointer;
            }

            .mobile-add-tag-btn:active {
                background: var(--bg-tertiary);
                color: var(--text-muted);
            }

            .mobile-tag-input-container {
                display: flex;
                gap: 8px;
                width: 100%;
                margin-top: 8px;
            }

            .mobile-tag-input {
                flex: 1;
                background: var(--bg-primary);
                border: 1px solid var(--bg-tertiary);
                color: var(--text-primary);
                padding: 8px 12px;
                border-radius: 6px;
                font-size: 16px;
            }

            .mobile-tag-input:focus {
                outline: none;
                border-color: var(--accent-primary);
            }

            .mobile-tag-suggestions {
                display: flex;
                flex-wrap: wrap;
                gap: 6px;
                width: 100%;
                margin-top: 8px;
            }

            .mobile-tag-suggestion {
                background: var(--bg-primary);
                color: var(--text-muted);
                padding: 6px 12px;
                border-radius: 12px;
                font-size: 0.8rem;
                cursor: pointer;
            }

            .mobile-tag-suggestion:active {
                background: var(--accent-primary);
                color: #fff;
            }

            /* Mobile nav positioning */
            .mobile-nav {
                position: fixed;
                top: 60px;
                left: 0;
                right: 0;
                z-index: 5;
            }

            /* Floating add button */
            .mobile-fab {
                display: flex;
                position: fixed;
                top: 140px;
                right: 12px;
                width: 44px;
                height: 44px;
                background: var(--accent-primary);
                border: none;
                border-radius: 50%;
                color: white;
                font-size: 1.5rem;
                cursor: pointer;
                box-shadow: 0 2px 8px rgba(233, 69, 96, 0.3);
                align-items: center;
                justify-content: center;
                z-index: 50;
            }

            .mobile-fab:active {
                transform: scale(0.95);
                background: var(--accent-hover);
            }

            /* Help modal mobile adjustments */
            .help-modal {
                left: 10px;
                right: 10px;
                bottom: 10px;
                width: auto;
                max-height: 60vh;
            }

            .help-content {
                padding: 16px;
            }

            .help-section h4 {
                padding-left: 0;
            }

            .help-row {
                padding-left: 8px;
                padding-right: 8px;
            }

            /* Welcome modal mobile adjustments */
            .welcome-modal-overlay {
                padding: 12px;
            }

            .welcome-modal {
                max-height: 90vh;
            }

            .welcome-header {
                padding: 16px;
            }

            .welcome-header h2 {
                font-size: 1.1rem;
            }

            .welcome-content {
                padding: 16px;
            }

            .welcome-section h3 {
                font-size: 0.9rem;
            }

            .welcome-section li {
                font-size: 0.85rem;
            }

            .welcome-footer {
                padding: 12px 16px;
                flex-direction: column;
                gap: 12px;
            }

            .welcome-btn {
                width: 100%;
                padding: 12px;
            }
        }

        /* Hide mobile elements on desktop */
        @media (min-width: 769px) {
            .mobile-nav,
            .mobile-search-overlay,
            .mobile-fab,
            .mobile-header-menu-btn,
            .mobile-menu-overlay,
            .mobile-block-tags {
                display: none !important;
            }
        }

        /* ===== PRESENTATION MODE ===== */
        .present-overlay {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 9999;
            background: var(--bg-primary);
            flex-direction: column;
        }
        .present-overlay.active {
            display: flex;
        }

        /* Thin progress bar at very top */
        .present-progress-bar {
            height: 3px;
            background: var(--bg-tertiary);
            flex-shrink: 0;
        }
        .present-progress-fill {
            height: 100%;
            background: var(--accent-primary);
            transition: width 0.3s ease;
        }

        /* Main content area - takes all remaining space */
        .present-main {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            cursor: pointer;
            position: relative;
            /* Use a wrapper div inside to handle centering without breaking scroll */
        }
        .present-main:active {
            background: rgba(255,255,255,0.02);
        }
        .present-main-inner {
            min-height: 100%;
            display: flex;
            justify-content: center;
            padding: 6vh 10vw 4vh;
        }

        .present-content {
            max-width: 820px;
            width: 100%;
            font-size: var(--present-font-size, 1.5rem);
            line-height: 1.65;
            color: var(--text-primary);
            pointer-events: none;
            align-self: flex-start;
        }
        /* Markdown rendered styles inside present */
        .present-content h1 { font-size: 1.8em; margin-bottom: 0.4em; color: var(--text-primary); }
        .present-content h2 { font-size: 1.4em; margin-bottom: 0.4em; color: var(--text-primary); }
        .present-content h3 { font-size: 1.15em; margin-bottom: 0.3em; color: var(--text-secondary); }
        .present-content p { margin-bottom: 0.8em; }
        .present-content ul, .present-content ol { padding-left: 1.4em; margin-bottom: 0.8em; }
        .present-content li { margin-bottom: 0.3em; }
        .present-content strong { color: var(--accent-secondary); }
        .present-content em { color: var(--text-secondary); font-style: italic; }
        .present-content blockquote {
            border-left: 3px solid var(--accent-primary);
            padding-left: 1em;
            margin: 0.5em 0;
            color: var(--text-muted);
        }
        .present-content code {
            background: var(--bg-secondary);
            padding: 0.1em 0.4em;
            border-radius: 3px;
            font-size: 0.85em;
        }
        .present-content pre {
            background: var(--bg-secondary);
            padding: 1em;
            border-radius: 6px;
            overflow-x: auto;
        }

        /* HUD bar at bottom */
        .present-hud {
            flex-shrink: 0;
            height: 52px;
            background: var(--bg-secondary);
            border-top: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 20px;
            gap: 12px;
        }
        .present-hud-left, .present-hud-right, .present-hud-center {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .present-hud-center { flex: 1; justify-content: center; gap: 8px; flex-wrap: wrap; }
        .present-hud-prior { display: flex; align-items: center; }
        .present-prior-time { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

        .present-nav-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            border-radius: 6px;
            width: 34px;
            height: 34px;
            font-size: 1rem;
            cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: background 0.15s;
        }
        .present-nav-btn:hover { background: var(--bg-hover); }
        .present-nav-btn:disabled { opacity: 0.3; cursor: default; }

        .present-counter {
            font-size: 0.8rem;
            color: var(--text-muted);
            min-width: 48px;
            text-align: center;
        }

        .present-time-remaining {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--accent-secondary);
            letter-spacing: 0.02em;
        }
        .present-time-remaining.warning { color: #f59e0b; }
        .present-time-remaining.urgent  { color: var(--accent-primary); }

        .present-block-time {
            font-size: 0.78rem;
            color: var(--text-muted);
        }
        .present-time-divider {
            color: var(--text-faint);
            font-size: 0.7rem;
        }
        .present-speed-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-muted);
            border-radius: 4px;
            padding: 2px 8px;
            font-size: 0.72rem;
            cursor: pointer;
            letter-spacing: 0.03em;
            text-transform: uppercase;
            transition: background 0.15s, color 0.15s;
        }
        .present-speed-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

        .present-zoom-group {
            display: flex;
            align-items: center;
            gap: 2px;
        }
        .present-zoom-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-muted);
            border-radius: 4px;
            width: 28px;
            height: 26px;
            font-size: 0.8rem;
            cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: background 0.15s, color 0.15s;
            line-height: 1;
        }
        .present-zoom-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
        .present-zoom-btn:disabled { opacity: 0.3; cursor: default; }
        .present-zoom-label {
            font-size: 0.7rem;
            color: var(--text-faint);
            min-width: 28px;
            text-align: center;
        }

        .present-close-btn {
            background: transparent;
            border: none;
            color: var(--text-faint);
            font-size: 1.1rem;
            cursor: pointer;
            padding: 6px;
            border-radius: 4px;
            transition: color 0.15s, background 0.15s;
        }
        .present-close-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

        /* Slide-in animation for block transitions */
        @keyframes presentFadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .present-content.animating {
            animation: presentFadeIn 0.25s ease forwards;
        }

        /* Mobile adjustments */
        @media (max-width: 768px) {
            .present-main-inner { padding: 4vh 6vw 3vh; }
            .present-hud { padding: 0 12px; gap: 6px; }
            .present-hud-center { gap: 5px; }
        }
/* ===== COPY BLOCK BUTTON ===== */
/* Add these rules to your blockwriter-css.css file */

.mobile-copy-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 11px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.02em;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-copy-btn:active,
.mobile-copy-btn:hover {
    background: var(--accent, #e07b39);
    color: #fff;
    border-color: transparent;
}

.mobile-copy-btn.copied {
    background: var(--accent, #e07b39);
    color: #fff;
    border-color: transparent;
}
/* ===== END COPY BLOCK BUTTON ===== */

