:root {
    /* Light theme — cosmic gold / warm neutrals */
    --bg-primary: #faf8f5;
    --bg-secondary: #eae6df;
    --bg-card: #ffffff;
    --bg-sidebar: #1c1728;
    --text-primary: #120e1c;
    --text-secondary: #3f3554;
    --text-muted: #6a5f7c;
    --text-sidebar: #d4cfe0;
    --text-sidebar-active: #ffffff;
    --accent: #8a6208;
    --accent-hover: #6e4e06;
    --accent-light: rgba(138, 98, 8, 0.14);
    --accent-glow: rgba(138, 98, 8, 0.35);
    --danger: #a82318;
    --danger-hover: #871c13;
    --success: #1c7a3e;
    --warning: #a06005;
    --info: #1a62a0;
    --border: #c0b8b0;
    --border-light: #d2cbc2;
    --shadow: rgba(26, 21, 37, 0.09);
    --shadow-lg: rgba(26, 21, 37, 0.18);
    --input-bg: #ffffff;
    --input-border: #8a8199;
    --sidebar-active-bg: rgba(138, 98, 8, 0.15);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --stat-gradient-1: linear-gradient(135deg, #8a6208 0%, #b07e0e 100%);
    --stat-gradient-2: linear-gradient(135deg, #1a62a0 0%, #2278c2 100%);
    --stat-gradient-3: linear-gradient(135deg, #1c7a3e 0%, #249950 100%);
    --stat-gradient-4: linear-gradient(135deg, #6c3285 0%, #8540a8 100%);
}

[data-theme="dark"] {
    --bg-primary: #0d0b14;
    --bg-secondary: #161320;
    --bg-card: #1c1728;
    --bg-sidebar: #0d0b14;
    --text-primary: #e8e4f0;
    --text-secondary: #a89dbe;
    --text-muted: #6e6485;
    --text-sidebar: #a89dbe;
    --text-sidebar-active: #f0e68c;
    --accent: #d4a017;
    --accent-hover: #e8b830;
    --accent-light: rgba(212, 160, 23, 0.15);
    --accent-glow: rgba(212, 160, 23, 0.4);
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #2ecc71;
    --warning: #f1c40f;
    --info: #3498db;
    --border: #2a2440;
    --border-light: #221d35;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --input-bg: #161320;
    --input-border: #2a2440;
    --sidebar-active-bg: rgba(212, 160, 23, 0.12);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.04);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-logo {
    width: 168px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.sidebar-brand .brand-icon {
    width: 44px;
    height: 44px;
    display: none;
    margin: 0 auto;
}

.sidebar-collapse-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.sidebar-collapse-btn:hover { opacity: 1; }

.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .brand-logo { display: none; }
.sidebar.collapsed .brand-icon { display: block; }
.sidebar.collapsed .sidebar-brand { padding: 1rem 0.5rem; }
.sidebar.collapsed .sidebar-collapse-btn { position: static; display: block; margin: 0 auto; transform: none; }

.sidebar.collapsed .sidebar-nav .nav-section { display: none; }
.sidebar.collapsed .sidebar-nav a {
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 0.5rem;
    justify-content: center;
    align-items: center;
    border-left: none;
    font-size: 0;
}
.sidebar.collapsed .sidebar-nav a svg.nav-icon { width: 1.5rem; height: 1.5rem; }
.sidebar.collapsed .sidebar-nav a.active { border-left: none; background: var(--sidebar-active-bg); }

.sidebar.collapsed .sidebar-footer { padding: 0.75rem 0.5rem; }
.sidebar.collapsed .sidebar-footer .theme-toggle {
    justify-content: center;
    padding: 0.5rem;
}
.sidebar.collapsed .sidebar-footer .theme-label { display: none; }
.sidebar.collapsed .sidebar-footer .theme-icon { font-size: 1.25rem; }
.sidebar.collapsed .signout-link {
    justify-content: center;
    padding: 0.5rem;
}
.sidebar.collapsed .signout-link .nav-label { display: none; }
.sidebar.collapsed .signout-link svg.nav-icon { width: 1.4rem; height: 1.4rem; }

.sidebar.collapsed + .main-content { margin-left: 72px; }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: var(--text-sidebar);
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

.sidebar-nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--text-sidebar-active);
    border-left-color: var(--accent);
}

svg.nav-icon { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
svg.btn-icon { width: 2rem; height: 2rem; flex-shrink: 0; vertical-align: -0.2em; }
svg.share-btn-icon { width: 1rem; height: 1rem; display: block; }
img.btn-mark { width: 2rem; height: 2rem; flex-shrink: 0; }
.sidebar-nav .nav-section {
    padding: 1.25rem 1.5rem 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.signout-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-sidebar);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: 1200px;
    transition: margin-left 0.3s;
}

/* Auth pages (no sidebar) */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: var(--bg-primary);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-card .brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .brand p { color: var(--text-secondary); font-size: 0.9rem; }

.auth-logo {
    display: none;
    width: 240px;
    height: auto;
    margin: 0 auto 0.75rem;
}
.auth-logo-dark { display: block; }
[data-theme="light"] .auth-logo-dark { display: none; }
[data-theme="light"] .auth-logo-light { display: block; }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.card-header h2 { font-size: 1.1rem; font-weight: 600; }

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    border-radius: 12px;
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card:nth-child(1) { background: var(--stat-gradient-1); }
.stat-card:nth-child(2) { background: var(--stat-gradient-2); }
.stat-card:nth-child(3) { background: var(--stat-gradient-3); }
.stat-card:nth-child(4) { background: var(--stat-gradient-4); }

.stat-card .stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; }
.stat-card .stat-sub { font-size: 0.8rem; opacity: 0.8; margin-top: 0.25rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    font-size: inherit;
    cursor: pointer;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-success { background: rgba(39,174,96,0.1); color: var(--success); border: 1px solid rgba(39,174,96,0.2); }
.alert-danger { background: rgba(192,57,43,0.1); color: var(--danger); border: 1px solid rgba(192,57,43,0.2); }
.alert-warning { background: rgba(243,156,18,0.1); color: var(--warning); border: 1px solid rgba(243,156,18,0.2); }
.alert-info { background: rgba(41,128,185,0.1); color: var(--info); border: 1px solid rgba(41,128,185,0.2); }

/* Archive library */
.main-content:has(.library-layout) { max-width: none; }
.library-layout { display: flex; gap: 0; min-height: calc(100vh - 4rem); margin: -2rem; }
.library-panel {
    width: 340px;
    min-width: 200px;
    max-width: 60vw;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    position: relative;
}
.library-panel .panel-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
}
.library-panel .panel-resize-handle:hover,
.library-panel .panel-resize-handle.dragging {
    background: var(--accent);
}
.library-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.library-search {
    display: flex;
    gap: 0.5rem;
}
.library-search input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
}
.library-search input:focus {
    outline: none;
    border-color: var(--accent);
}
.library-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.library-item {
    display: block;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    position: relative;
    transition: background 0.15s;
    cursor: pointer;
    border: 1px solid transparent;
}
.library-item:hover {
    background: var(--bg-card);
    border-color: var(--border-light);
}
.library-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
}
.library-item .item-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.library-item .item-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.library-item .item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.library-item .item-meta > span {
    white-space: nowrap;
}
.library-item .status-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-complete { background: rgba(39,174,96,0.15); color: var(--success); }
.status-downloading { background: rgba(41,128,185,0.15); color: var(--info); }
.status-pending { background: rgba(243,156,18,0.15); color: var(--warning); }
.status-failed { background: rgba(192,57,43,0.15); color: var(--danger); }

/* Folder breadcrumbs */
.folder-breadcrumbs {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.folder-breadcrumbs a { color: var(--accent); }
.folder-breadcrumbs a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); opacity: 0.5; }

/* Folder actions */
.folder-actions {
    padding: 0.5rem 1rem;
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.btn-xs {
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 4px;
}
.folder-inline-form {
    padding: 0.5rem 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.folder-inline-form .form-control-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    flex: 1;
}
.hidden { display: none !important; }

/* Folder items */
.folder-item {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
}
.folder-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    overflow: hidden;
    color: var(--text-primary);
}
.folder-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--accent);
    flex-shrink: 0;
}
.folder-name {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.folder-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: auto;
    padding-right: 0.5rem;
}
.folder-item-actions {
    display: none;
    gap: 0.25rem;
}
.folder-item:hover .folder-item-actions { display: flex; }
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-secondary); }

/* Bulk select mode */
.item-checkbox {
    display: none;
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}
.item-checkbox input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
    display: block;
}
.library-list.selecting .item-checkbox { display: flex; }
.library-list.selecting .library-item { padding-left: 2.25rem; cursor: pointer; }
.library-list.selecting .library-item.selected { background: var(--accent-light); border-color: var(--accent); }
.library-list.selecting .archive-link { pointer-events: none; }
.library-list.selecting .folder-link { pointer-events: none; }
.library-list.selecting .folder-item-actions { display: none !important; }
.library-list.selecting .move-to-btn { display: none !important; }

/* Floating bulk action bar */
.bulk-action-bar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    opacity: 0;
    pointer-events: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem 1.25rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: transform 0.22s ease, opacity 0.22s ease;
    min-width: 260px;
}
.bulk-action-bar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Archive items in library */
.archive-link {
    display: block;
    overflow: hidden;
    color: inherit;
}
.move-to-btn {
    display: none;
    margin-top: 0.4rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}
.archive-item:hover .move-to-btn { display: inline-block; }
.move-to-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.view-move-btn {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    margin-left: 0.4rem;
}
.view-move-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.folder-move-btn {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}
.folder-move-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.move-select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    cursor: pointer;
}
/* Drag and drop */
.archive-item.dragging, .folder-item.dragging {
    opacity: 0.4;
}
.folder-item.drag-over {
    background: var(--accent-light, rgba(52,152,219,0.1));
    border-color: var(--accent);
    border-style: dashed;
}
.breadcrumb-drop.drag-over {
    background: var(--accent-light, rgba(52,152,219,0.1));
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
}

.item-folder-badge {
    background: rgba(var(--accent-rgb, 52,152,219), 0.15);
    color: var(--accent);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.65rem;
}

.library-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.library-content-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}
.library-iframe-wrapper {
    flex: 1;
    overflow: auto;
}
.library-iframe-wrapper iframe {
    display: block;
    width: 100%;
    min-width: 900px;
    height: 100%;
    border: none;
}
.library-screenshot-wrapper {
    flex: 1;
    overflow: auto;
    background: var(--bg-secondary);
    display: flex;
    justify-content: center;
    padding: 1rem;
}
.library-screenshot-img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.view-mode-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}
.view-toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    padding: 0.22rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.view-toggle-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.view-toggle-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.library-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Table */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
}
th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Progress bar */
.progress-bar-wrapper {
    background: var(--bg-secondary);
    border-radius: 8px;
    height: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 8px;
    background: var(--accent);
    transition: width 0.5s ease;
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}
.theme-toggle:hover { background: var(--sidebar-hover-bg); }
.theme-toggle span { font-size: 0.85rem; }

/* Pagination */
.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}
.pagination a:hover { background: var(--accent-light); }
.pagination .active-page {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 16px 48px var(--shadow-lg);
    border: 1px solid var(--border);
}
.modal h3 { margin-bottom: 0.75rem; }
.modal p { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* Domain list */
.domain-list { list-style: none; }
.domain-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
.domain-list li:last-child { border-bottom: none; }
.domain-count {
    background: var(--accent-light);
    color: var(--accent);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Wizard */
.wizard-card {
    max-width: 600px;
    margin: 2rem auto;
}
.wizard-card .url-input-group {
    display: flex;
    gap: 0.75rem;
}
.wizard-card .url-input-group input { flex: 1; font-size: 1rem; padding: 0.8rem 1rem; }
.wizard-card .url-input-group .btn { padding: 0.8rem 1.5rem; }

/* QR code */
.qr-container { text-align: center; margin: 1.5rem 0; }
.qr-container img { border-radius: 8px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .library-layout { flex-direction: column; }
    .library-panel { width: 100%; max-height: 40vh; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 101;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
    cursor: pointer;
}
@media (max-width: 768px) {
    .mobile-toggle { display: block; }
}

/* Version timeline */
.version-timeline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.version-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    flex-shrink: 0;
    transition: all 0.15s;
}
.version-nav-btn:hover:not(.disabled) {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}
.version-nav-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}
.version-timeline-track {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    overflow-x: auto;
    position: relative;
}
.version-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    padding: 0.25rem 0.75rem;
    position: relative;
    flex-shrink: 0;
}
.version-node::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    width: 100%;
    height: 2px;
    background: var(--border);
    transform: translateY(-4px);
}
.version-node:last-child::after { display: none; }
.version-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--bg-secondary);
    transition: all 0.15s;
}
.version-node.active .version-dot {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.version-node:not(.active):hover .version-dot {
    background: var(--text-muted);
}
.version-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    white-space: nowrap;
}
.version-node.active .version-date {
    color: var(--accent);
    font-weight: 600;
}
.version-node.version-pending .version-dot,
.version-node.version-downloading .version-dot {
    background: var(--warning, #f39c12);
    border-color: var(--warning, #f39c12);
}
.version-node.version-failed .version-dot {
    background: var(--danger);
    border-color: var(--danger);
}

/* Audit log */
.audit-entry .audit-action { font-weight: 500; }
.audit-entry .audit-time { color: var(--text-muted); font-size: 0.8rem; }
.audit-entry .audit-detail { color: var(--text-secondary); font-size: 0.85rem; }

/* ========================
   Bookmark Manager
   ======================== */
.main-content:has(.bm-layout) { max-width: none; }
.bm-layout { display: flex; min-height: calc(100vh - 4rem); margin: -2rem; background: var(--bg-primary); }

/* Tree panel */
.bm-tree-panel {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.bm-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
}
.bm-resize-handle:hover,
.bm-resize-handle.dragging {
    background: var(--accent);
}
.bm-tree-header {
    padding: 0.65rem 1rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.bm-tree-scroll { flex: 1; overflow-y: auto; padding: 0.4rem 0; }

.bm-tree-node { list-style: none; margin: 0; padding: 0; }
.bm-tree-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    border-radius: 5px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    user-select: none;
    margin: 1px 4px;
}
.bm-tree-item:hover { background: var(--accent-light); color: var(--text-primary); }
.bm-tree-item.selected { background: var(--sidebar-active-bg); color: var(--accent); font-weight: 500; }
.bm-tree-item.drag-over { outline: 2px dashed var(--accent); background: var(--accent-light); }
.bm-tree-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}
.bm-tree-chevron.open { transform: rotate(90deg); }
.bm-tree-chevron.leaf { opacity: 0; pointer-events: none; }
.bm-tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-tree-children { display: none; padding-left: 14px; }
.bm-tree-children.open { display: block; }

/* Content panel */
.bm-content-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.bm-toolbar {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    flex-shrink: 0;
}
.bm-breadcrumb { flex: 1; display: flex; align-items: center; gap: 0.2rem; font-size: 0.83rem; min-width: 0; flex-wrap: wrap; }
.bm-breadcrumb-item { color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.bm-breadcrumb-item:hover { color: var(--accent); }
.bm-breadcrumb-item.current { color: var(--text-primary); font-weight: 500; cursor: default; }
.bm-breadcrumb-sep { color: var(--border); }

.bm-search-bar {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    flex-shrink: 0;
}
.bm-search-bar input {
    width: 100%;
    padding: 0.38rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.83rem;
    outline: none;
    box-sizing: border-box;
}
.bm-search-bar input:focus { border-color: var(--accent); }

.bm-list { flex: 1; overflow-y: auto; padding: 0.5rem; }

.bm-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.4rem 0.6rem 0.2rem;
}

/* Individual items in the right panel */
.bm-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.42rem 0.6rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: default;
    user-select: none;
    position: relative;
}
.bm-item.is-folder { cursor: pointer; }
.bm-item:hover { background: var(--accent-light); }
.bm-item.drag-over { outline: 2px dashed var(--accent); background: var(--accent-light); }
.bm-item.dragging { opacity: 0.35; }

.bm-icon { flex-shrink: 0; }
.bm-icon.folder-col { color: var(--accent); }
.bm-icon.archive-col { color: var(--text-muted); }

.bm-body { flex: 1; min-width: 0; }
.bm-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bm-name-input {
    width: 100%;
    padding: 0.1rem 0.3rem;
    background: var(--input-bg);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    outline: none;
    display: none;
}
.bm-name-input.editing { display: block; }
.bm-name.editing { display: none; }
.bm-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bm-count { font-size: 0.7rem; color: var(--text-muted); background: var(--bg-primary); border-radius: 10px; padding: 0.08rem 0.4rem; flex-shrink: 0; border: 1px solid var(--border-light); }

.bm-actions { display: none; align-items: center; gap: 0.15rem; flex-shrink: 0; }
.bm-item:hover .bm-actions { display: flex; }
.bm-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    line-height: 1;
}
.bm-btn:hover { color: var(--text-primary); background: var(--bg-secondary); }
.bm-btn.danger:hover { color: var(--danger); background: rgba(168,35,24,0.08); }

.bm-empty { text-align: center; padding: 4rem 1rem; color: var(--text-muted); font-size: 0.875rem; }

@media (max-width: 768px) {
    .bm-layout { flex-direction: column; }
    .bm-tree-panel { width: 100%; max-height: 35vh; border-right: none; border-bottom: 1px solid var(--border); }
}
