/* ============================================================
   CloudDrive Web UI — Design System
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    /* Colors */
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-light: rgba(13, 110, 253, 0.1);
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #595f66;
    --text-muted: #6b7280;
    --border: #dee2e6;
    --border-light: #e9ecef;
    --bg-card: #e9ecef;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #0dcaf0;
    --folder-icon: #3478F6;

    /* Shadows — matching reference BlazorWasm */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --shadow-hover: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.2);

    /* Layout */
    --header-height: 48px;
    --sidebar-width: 260px;
    --border-radius: 0.375rem;
    --border-radius-lg: 0.5rem;
    --transition: 0.2s ease;

    /* Mobile safe areas */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --tab-bar-height: 56px;
}

/* Dark theme — iOS system dark color palette */
[data-theme="dark"] {
    --primary: #4dabf7;
    --primary-hover: #74c0fc;
    --primary-light: rgba(77, 171, 247, 0.15);
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-card: #2C2C2E;
    --bg-file-container: #000000;
    --bg-sidebar: #000000;
    --text-primary: #f8f9fa;
    --text-secondary: #98989F;
    --text-muted: #8E8E93;
    --border: #38383A;
    --border-light: #2C2C2E;
    --success: #30D158;
    --danger: #FF453A;
    --warning: #FFD60A;
    --info: #66d9ef;
    --folder-icon: #3478F6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.7);
}

/* Desktop dark: slightly gray backgrounds for sidebar and file browser */
@media (min-width: 769px) {
    [data-theme="dark"] {
        --bg-sidebar: #161618;
        --bg-file-container: #161618;
    }
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Custom Scrollbars ---------- */
/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- App Layout ---------- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
}

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

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    text-decoration: none;
}
.header-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.header-logo {
    display: flex;
    align-items: center;
    height: 36px;
}
.logo-img {
    height: 32px;
    width: auto;
}
.device-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    gap: 4px;
    cursor: default;
}

/* ── Header dropdowns ─────────────────────────────── */
.header-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    align-self: stretch;
}
.header-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
}
/* On non-touch (hover-capable) devices, hide backdrops — mouseleave handles closing */
html:not(.touch-device) .header-dropdown-backdrop,
html:not(.touch-device) .add-dropdown .context-menu-backdrop {
    display: none;
}
.header-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 1001;
    padding: 4px 0;
    /* A popup's length is the data's; never let it clip its own tail. */
    max-height: min(70vh, 520px);
    overflow-y: auto;
}
.header-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    text-decoration: none;
    transition: var(--transition);
}
.header-dropdown-item:hover { background: var(--bg-secondary); text-decoration: none; }
.header-dropdown-item.active { color: var(--primary); }
.header-dropdown-item.danger { color: var(--danger); }
.header-dropdown-item.danger:hover { background: rgba(220,53,69,0.08); }
.header-dropdown-item i { width: 16px; text-align: center; font-size: 13px; color: var(--text-secondary); }
.header-dropdown-item.active i,
.header-dropdown-item.danger i { color: inherit; }
.header-dropdown-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ── Inline performance bar ───────────────────────── */
.perf-bar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 10px;
    height: 28px;
    font-size: 11px;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
}
.perf-bar:hover { background: var(--bg-tertiary); text-decoration: none; }
.perf-metric {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    color: var(--text-primary);
    text-decoration: none;
}
.perf-metric:hover { text-decoration: none; color: var(--text-primary); opacity: 0.8; }
.perf-metric i { font-size: 10px; }
.perf-metric.cpu i { color: #ff6b6b; }
.perf-metric.mem i { color: #9c27b0; }
.perf-metric.dl  i { color: #2196f3; }
.perf-metric.ul  i { color: #4caf50; }
.perf-val-low  { color: #4caf50; }
.perf-val-med  { color: #ff9800; }
.perf-val-high { color: #f44336; }
.perf-metric.task-copy i { color: #ff6b6b; }
.perf-metric.task-dl  i { color: #2196f3; }
.perf-metric.task-ul  i { color: #4caf50; }
.perf-metric.task-qps i { color: #7e57c2; }
[data-theme="dark"] .perf-metric.task-qps i { color: #b39ddb; }

.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar, var(--bg-primary));
    border-right: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
    transition: transform var(--transition), width var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
}
.app-sidebar:not(.open) {
    width: 0;
    overflow: hidden;
    border-right: none;
}

/* Tree section */
.tree-section {
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tree-section.expanded {
    flex: 1;
}

/* Vertical splitter (tree ↔ nav) */
.tree-splitter {
    height: 8px;
    cursor: row-resize;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, transparent, var(--border) 40%, var(--border) 60%, transparent);
}
.tree-splitter:hover {
    background: var(--primary-light);
}
.splitter-handle {
    width: 24px;
    height: 3px;
    background: var(--text-muted);
    border-radius: 2px;
}

/* Nav items container */
.nav-items-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.nav-items-container.collapsed {
    display: none;
}

/* Horizontal splitter (sidebar ↔ content) */
.sidebar-splitter {
    width: 4px;
    cursor: col-resize;
    flex-shrink: 0;
    background: var(--border);
}
.sidebar-splitter:hover {
    background: var(--primary);
}

/* Drag state */
body.sidebar-dragging {
    user-select: none;
    -webkit-user-select: none;
}
body.sidebar-dragging * {
    pointer-events: none;
}
body.sidebar-dragging .sidebar-splitter,
body.sidebar-dragging .tree-splitter {
    pointer-events: all;
}
body.sidebar-dragging .app-sidebar {
    transition: none;
}

/* Nav toggle button */
.nav-items-toggle-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-muted);
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}
.nav-items-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-nav {
    padding: 8px 0;
}

.nav-section {
    margin-bottom: 4px;
}

.nav-section-title {
    padding: 8px 16px 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-icon { width: 18px; text-align: center; }

/* ---------- Folder Tree (Sidebar) ---------- */
.folder-tree {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.tree-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.tree-header:hover { color: var(--text-secondary); }
.tree-header-icon { font-size: 12px; }
.tree-header-title { flex: 1; }
.tree-header-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 3px;
}
.tree-header-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.tree-header-chevron { font-size: 10px; }

.tree-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    padding-bottom: 4px;
}
.tree-content > div {
    width: fit-content;
    min-width: 100%;
}
.tree-loading, .tree-empty {
    padding: 8px 16px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}
.tree-node-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    border-left: 3px solid transparent;
    transition: background var(--transition);
    white-space: nowrap;
}
.tree-node-row:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.tree-node-row.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}
.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 10px;
    color: var(--text-muted);
    border-radius: 3px;
}
.tree-toggle:hover { color: var(--text-primary); background: var(--bg-tertiary); }
img.tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
}
i.tree-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--folder-icon);
}
.tree-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}
.tree-lock-icon {
    position: absolute;
    bottom: -3px;
    right: -4px;
    font-size: 8px;
}
.tree-name {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .folder-tree { display: none; }
    .sidebar-splitter, .tree-splitter, .nav-items-toggle-btn { display: none; }
}

/* ---------- Content ---------- */
.app-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-secondary);
}

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

/* The media server page's screen-reader-only labels are absolute: positioned here, they scroll with the
   content instead of lengthening the document. */
.media-server-page {
    position: relative;
}

/* its tabs: one strip that stays on top while a tab's panel scrolls, and scrolls sideways on a phone */
.ms-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.ms-tabs::-webkit-scrollbar { display: none; }
.ms-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.ms-tab:hover { color: var(--text-primary); }
.ms-tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.ms-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.ms-panel { max-width: 1400px; }
/* two columns where there's room; a section holding a table spans both, and the next fills the hole it leaves */
.ms-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; grid-auto-flow: dense; }
.ms-grid > .setting-group { margin-bottom: 0; min-width: 0; }
@media (min-width: 1200px) {
    .ms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ms-grid > .setting-group:has(.data-table) { grid-column: 1 / -1; }
}
.ms-panel > .ms-grid + .setting-group, .ms-panel > .setting-group + .ms-grid { margin-top: 16px; }
/* a part of a section: a quiet frame and its name, not the browser's raised box */
.media-server-page fieldset {
    min-width: 0;
    margin: 12px 0;
    padding: 10px 14px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
}
.media-server-page legend {
    padding: 0 6px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
/* the overview's tiles, each opening its tab */
.ms-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.ms-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}
.ms-tile:hover { border-color: var(--primary); }
.ms-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ms-tile-head { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.ms-tile-head i { color: var(--primary); }
.ms-tile-value { font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.ms-tile-note { font-size: 12px; color: var(--text-secondary); }
/* the viewer profiles: an initial on its colour or a picture, the name and what the profile sees */
.profile-list { list-style: none; margin: 8px 0 0; padding: 0; }
.profile-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.profile-row:last-child { border-bottom: none; }
.profile-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 160px; }
.profile-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.profile-text .setting-help { margin: 0; }
.profile-avatar[class*="profile-color-"], img.profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    object-fit: cover;
}
.profile-avatar.profile-avatar-large { width: 64px; height: 64px; font-size: 26px; }
.profile-color-0 { background: #1565c0; }
.profile-color-1 { background: #2e7d32; }
.profile-color-2 { background: #c62828; }
.profile-color-3 { background: #6a1b9a; }
.profile-color-4 { background: #ad5700; }
.profile-color-5 { background: #00695c; }
.profile-color-6 { background: #ad1457; }
.profile-color-7 { background: #4e342e; }
.profile-colors { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.profile-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid transparent;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
}
.profile-swatch[aria-checked="true"] { border-color: var(--text-primary); }
.profile-swatch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* a phone: each table row a card, every value under its column's name */
@media (max-width: 720px) {
    .media-server-page .data-table,
    .media-server-page .data-table tbody,
    .media-server-page .data-table tr,
    .media-server-page .data-table td { display: block; width: 100%; }
    .media-server-page .data-table thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
    }
    .media-server-page .data-table tr {
        margin-bottom: 10px;
        padding: 10px 12px;
        border: 1px solid var(--border-light);
        border-radius: var(--border-radius);
        background: var(--bg-secondary);
    }
    .media-server-page .data-table td { padding: 4px 0; border: none; text-align: left; }
    .media-server-page .data-table td:first-child { font-size: 15px; font-weight: 600; padding-bottom: 6px; }
    .media-server-page .data-table td[data-label] {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 8px;
        align-items: baseline;
    }
    .media-server-page .data-table td[data-label] > * { grid-column: 2; }
    .media-server-page .data-table td[data-label]::before {
        content: attr(data-label);
        font-size: 12px;
        color: var(--text-secondary);
    }
    .media-server-page .data-table td.ms-cell-actions { padding-top: 8px; }
    .media-server-page .data-table .ml-actions { width: 100%; }
    .media-server-page .data-table select.form-input { width: 100%; max-width: 100%; }
    .ms-tab { padding: 0 12px; }
    .ms-tabs { margin-left: -4px; margin-right: -4px; }
}

/* the Media server page's library editor */
.ml-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
/* the row's icon buttons on one line; the cell stays a table cell (flex on a <td> broke the row's border) */
.ml-actions {
    width: 1%;
}
.ml-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}
.ml-folder {
    font-size: 0.85em;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}
.ml-roots {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}
.ml-roots .ml-folder {
    flex: 1;
    min-width: 0;
}
.ml-warn {
    color: var(--danger);
}
/* a library made private with no PIN yet: the PIN's fields, set off from the switches around them */
.ml-newpin {
    margin: 4px 0 12px;
    padding: 4px 0 0 12px;
    border-inline-start: 3px solid var(--danger);
}
/* the Media server page's Emby API for other apps: keys and addresses in a fixed-width face, the request log folded */
.ms-api-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow-wrap: anywhere;
}
input.ms-api-key {
    flex: 1;
    min-width: 0;
}
.ms-api-addresses {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ms-api-addresses li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.ms-api-log summary {
    cursor: pointer;
    padding: 6px 0;
}
.ms-api-log summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ml-form fieldset {
    border: none;
    padding: 0;
    margin: 0 0 16px;
}
.ml-checks {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}
.ml-checks li {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}
.ml-checks input[type="checkbox"] {
    flex: 0 0 auto;
    margin: 0;
}
.form-group .ml-checks label {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 10px 0;
    overflow-wrap: anywhere;
    cursor: pointer;
}

/* ---------- the web media client (pages/media_client/): the apps' media theme (MediaTheme.swift) ---------- */
.content-body:has(.media-client) { padding-top: 0; padding-left: 0; padding-right: 0; padding-bottom: 0; }
.app-content:has(.media-client) { background: var(--mc-bg1, var(--bg-secondary)); }
/* .mc-tokens: the theme alone, for the client's dialogs opened on another page (待确认's Identify) */
.media-client, .mc-tokens {
    --mc-brand: #1A6B9E;
    --mc-brand-fill: #1A6B9E;
    --mc-brand-hi: #16638F;
    --mc-bg1: #F4F6FA;
    --mc-bg2: #FFFFFF;
    --mc-bg3: #EDF1F7;
    --mc-bg4: #E1E8F1;
    --mc-line: rgba(0, 0, 0, 0.10);
    --mc-line-strong: rgba(0, 0, 0, 0.18);
    --mc-wash: rgba(0, 0, 0, 0.07);
    --mc-wash-strong: rgba(0, 0, 0, 0.14);
    --mc-plate: rgba(0, 0, 0, 0.06);
    --mc-glass: rgba(244, 246, 250, 0.86);
    --mc-text-hi: #0B1220;
    --mc-text: #1B2534;
    --mc-text-mid: #55627A;
    --mc-text-low: #58647A;
    --mc-success: #047857;
    --mc-danger: #C81E1E;
    --mc-scrim: 244, 246, 250;
    --mc-side: 24px;
    --mc-r1: 4px;
    --mc-r2: 8px;
    --mc-r3: 12px;
    --mc-r4: 16px;
    color: var(--mc-text);
    font-size: 14px;
}
.media-client {
    position: relative;
    /* the page takes what is left, so the mini player below it stands at the bottom however short the page */
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-height));
    background: var(--mc-bg1);
}
[data-theme="dark"] .media-client, [data-theme="dark"] .mc-tokens {
    --mc-brand: #2184BF;
    --mc-brand-fill: #1C6FA0;
    --mc-brand-hi: #4BA8DB;
    --mc-bg1: #0D1117;
    --mc-bg2: #131923;
    --mc-bg3: #1B2230;
    --mc-bg4: #232B3A;
    --mc-line: rgba(255, 255, 255, 0.08);
    --mc-line-strong: rgba(255, 255, 255, 0.16);
    --mc-wash: rgba(255, 255, 255, 0.12);
    --mc-wash-strong: rgba(255, 255, 255, 0.18);
    --mc-plate: rgba(0, 0, 0, 0.5);
    --mc-glass: rgba(13, 17, 23, 0.82);
    --mc-text-hi: #FFFFFF;
    --mc-text: #E6ECF3;
    --mc-text-mid: #A8B3C4;
    --mc-text-low: #8592A6;
    --mc-success: #10B981;
    --mc-danger: #EF4444;
    --mc-scrim: 13, 17, 23;
}
.media-client.mc-phone { --mc-side: 16px; }
.media-client :focus-visible, .mc-tokens :focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 2px; }
.media-client a, .mc-tokens a { color: inherit; text-decoration: none; }
.media-client button, .mc-tokens button { font: inherit; color: inherit; }
.mc-body { position: relative; flex: 1 0 auto; min-width: 0; }
.mc-pad { padding-left: var(--mc-side); padding-right: var(--mc-side); }
.mc-page { display: flex; flex-direction: column; gap: 22px; padding: 12px 0 32px; }
.mc-red { color: var(--mc-danger); }
.mc-green { color: var(--mc-success); }
.mc-accent { color: var(--mc-brand-hi); font-weight: 600; }
.mc-accent:hover { text-decoration: underline; }
.mc-mid { color: var(--mc-text-mid); margin: 0; }
.mc-hint { color: var(--mc-text-low); font-size: 12px; margin: 0; }
.mc-error { color: var(--mc-danger); font-size: 13px; padding: 0 var(--mc-side); margin: 0; }
.mc-empty { color: var(--mc-text-mid); font-size: 14px; padding: 24px var(--mc-side); margin: 0; text-align: center; }
.mc-spacer { flex: 1; }
.mc-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--mc-text-low); margin: 0 0 8px; }

/* the bar above every page */
.mc-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 6px var(--mc-side);
    border-bottom: 1px solid var(--mc-line);
}
/* the glass sits behind the bar, not on it: a blur on the bar itself would hold its menu's scrim to the bar's 48px */
.mc-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--mc-glass);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.mc-header-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--mc-text-hi);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mc-toolbar { display: flex; align-items: center; gap: 2px; }
.mc-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--mc-text-mid);
    cursor: pointer;
    font-size: 15px;
}
.mc-icon-btn:hover { background: var(--mc-wash); color: var(--mc-text-hi); }
.mc-icon-btn[aria-current="page"] { color: var(--mc-brand-hi); background: var(--mc-wash); }
.mc-on-dark { color: #fff; }

/* menus */
.mc-menu-wrap { position: relative; display: inline-flex; }
.mc-menu-scrim { position: fixed; inset: 0; z-index: 60; }
.mc-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 61;
    min-width: 220px;
    max-height: 420px;
    overflow-y: auto;
    padding: 6px;
    background: var(--mc-bg2);
    border: 1px solid var(--mc-line-strong);
    border-radius: var(--mc-r3);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
}
.mc-menu-right { left: auto; right: 0; }
.mc-menu-at { position: fixed; top: 0; left: 0; }
.mc-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--mc-r2);
    background: none;
    color: var(--mc-text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.mc-menu-item i { width: 16px; text-align: center; color: var(--mc-text-mid); }
.mc-menu-item:hover, .mc-menu-item:focus-visible { background: var(--mc-wash); }
.mc-menu-tick { visibility: hidden; color: var(--mc-brand-hi) !important; }
.mc-menu-item[aria-checked="true"] .mc-menu-tick { visibility: visible; }
.mc-menu-item[aria-checked="true"] { color: var(--mc-brand-hi); font-weight: 600; }
.mc-menu-label { padding: 6px 10px; font-size: 12px; color: var(--mc-text-low); }
.mc-menu-sep { height: 1px; margin: 4px 6px; background: var(--mc-line); }
/* a phone: bigger rows to tap. Where a menu opens, and how tall it may be, menus.rs works out */
.mc-phone .mc-menu-item { min-height: 44px; padding: 10px 12px; font-size: 15px; white-space: normal; }

/* states */
.mc-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 520px;
    margin: 0 auto;
    padding: 64px var(--mc-side);
    text-align: center;
    color: var(--mc-text-mid);
}
.mc-state p { margin: 0; }
.mc-state-icon { font-size: 44px; color: var(--mc-brand-hi); }
.mc-state-hint { font-size: 12px; color: var(--mc-text-low); word-break: break-word; }
.mc-spinner { display: flex; justify-content: center; padding: 16px; color: var(--mc-brand-hi); font-size: 18px; }
.mc-spinner-big { padding: 72px 16px; font-size: 30px; }
.mc-loading { display: flex; align-items: center; gap: 8px; color: var(--mc-text-mid); margin: 0; }
.mc-loading .mc-spinner { padding: 0; }

/* buttons */
.mc-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-plate);
    color: var(--mc-text-hi) !important;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.mc-pill:hover { background: var(--mc-wash-strong); }
.mc-pill:disabled { opacity: 0.45; cursor: default; }
.mc-pill.mc-primary { background: var(--mc-brand-fill); border-color: var(--mc-brand-hi); color: #fff !important; }
.mc-pill.mc-primary:hover { filter: brightness(1.08); }
.mc-pill.mc-large { min-height: 46px; padding: 12px 20px; font-size: 16px; }
.mc-pill[aria-pressed="true"] { border-color: var(--mc-line-strong); }
.mc-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--mc-line);
    background: var(--mc-wash);
    color: var(--mc-text-mid);
    font-size: 12px;
    cursor: pointer;
}
.mc-round:hover { color: var(--mc-text-hi); background: var(--mc-wash-strong); }
.mc-round:disabled { opacity: 0.35; cursor: default; }
.mc-round-lg { width: 40px; height: 40px; font-size: 14px; background: var(--mc-bg2); }
.mc-round-heart { width: 40px; height: 40px; font-size: 16px; background: var(--mc-bg2); }
.mc-link { border: none; background: none; padding: 0; color: var(--mc-brand-hi); font-size: 12px; font-weight: 600; cursor: pointer; }
.mc-link:hover { text-decoration: underline; }

/* dialogs */
.mc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
    animation: fade-in 0.15s ease;
}
.mc-sheet {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    max-height: min(680px, calc(100vh - 32px));
    max-height: min(680px, calc(100dvh - 32px));
    background: var(--mc-bg2);
    color: var(--mc-text);
    border: 1px solid var(--mc-line-strong);
    border-radius: var(--mc-r4);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    outline: none;
}
.mc-sheet-wide { max-width: 560px; }
/* a phone: dialogs rise from the bottom edge, as the apps' sheets, and take the height the browser leaves showing */
.mc-phone .mc-overlay { align-items: flex-end; padding: 8px 8px calc(8px + var(--safe-area-bottom)); }
.mc-phone .mc-sheet { max-height: calc(100vh - 24px - var(--safe-area-bottom)); max-height: calc(100dvh - 24px - var(--safe-area-bottom)); }
.mc-phone .mc-sheet-head { padding: 12px 14px; }
.mc-phone .mc-sheet-body { padding: 14px; }
.mc-phone .mc-sheet-foot { padding: 10px 14px; }
/* buttons share the row's width rather than huddle at its end */
.mc-phone .mc-sheet-foot > * { flex: 1 1 auto; }
.mc-sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--mc-line); }
.mc-sheet-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 700; color: var(--mc-text-hi); }
.mc-sheet-body { padding: 18px; overflow-y: auto; flex: 1; min-height: 0; }
/* many buttons wrap to a second line rather than run off the side */
.mc-sheet-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--mc-line); }
.mc-sheet-foot:empty { display: none; }
.mc-form { display: flex; flex-direction: column; gap: 14px; }
.mc-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--mc-text-mid); }
.mc-checkline, .mc-toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.mc-toggle { justify-content: space-between; padding: 8px 0; }
.mc-toggle input, .mc-checkline input { width: 18px; height: 18px; accent-color: var(--mc-brand); }
.mc-choices { display: flex; flex-direction: column; margin: -8px -18px; }
.mc-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    border: none;
    border-bottom: 0.5px solid var(--mc-line);
    background: none;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}
.mc-choice:hover { background: var(--mc-wash); }
/* inside the row: the dialog clips what goes past its sides */
.mc-choice:focus-visible { background: var(--mc-wash); outline-offset: -2px; }
.mc-choice[aria-selected="true"] { color: var(--mc-brand-hi); font-weight: 600; }
.mc-choice-mark { display: inline-flex; gap: 8px; color: var(--mc-brand-hi); }

/* text that opens */
.mc-expand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.mc-overview { margin: 0; font-size: 14px; line-height: 1.55; color: var(--mc-text-mid); white-space: pre-line; }
.mc-clamped { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.mc-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: none;
    border-radius: 999px;
    background: color-mix(in srgb, var(--mc-brand-hi) 14%, transparent);
    color: var(--mc-brand-hi);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* cards */
.mc-card { display: flex; flex-direction: column; gap: 4px; min-width: 0; color: var(--mc-text-hi); }
.mc-art {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    border-radius: var(--mc-r3);
    border: 1px solid var(--mc-line);
    background: var(--mc-bg3);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.mc-card:hover .mc-art, .mc-card:focus-visible .mc-art { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22); }
.mc-card:focus-visible { outline: none; }
.mc-card:focus-visible .mc-art { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-art-poster { aspect-ratio: 2 / 3; }
.mc-art-wide { aspect-ratio: 16 / 9; }
.mc-art-square { aspect-ratio: 1; }
.mc-art-book { aspect-ratio: 2 / 3; border-radius: var(--mc-r2); }
.mc-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mc-img.mc-contain { object-fit: contain; background: rgba(0, 0, 0, 0.6); }
.mc-glyph { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 30%; color: rgba(255, 255, 255, 0.5); }
.mc-art-poster .mc-glyph, .mc-art-square .mc-glyph, .mc-art-wide .mc-glyph { font-size: 32px; }
.mc-card-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-card-name.mc-strong { font-weight: 600; }
.mc-card-sub { font-size: 11px; color: var(--mc-text-low); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }
/* the play button over a card's picture (cards.rs PlayOver), beside the card's link: shown while the pointer is over
   the card or a key moved into it; not on screens that can't hover, nor while titles are being picked */
.mc-card-box { position: relative; min-width: 0; }
.mc-card-box:hover .mc-art { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22); }
.mc-play-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: transform 0.18s ease;
}
.mc-play-poster { aspect-ratio: 2 / 3; }
.mc-play-wide { aspect-ratio: 16 / 9; }
.mc-play-square { aspect-ratio: 1; }
.mc-card-box:hover .mc-play-layer { transform: translateY(-2px); }
.mc-play {
    pointer-events: auto;
    width: clamp(44px, 32%, 64px);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.mc-play i { margin-left: 3px; }
.mc-play:hover { background: var(--mc-brand); }
.mc-card-box:hover .mc-play, .mc-card-box:focus-within .mc-play { opacity: 1; transform: scale(1); }
.mc-play:focus-visible { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-cell:has(.mc-pick) .mc-play-layer { display: none; }
@media (hover: none) { .mc-play-layer { display: none; } }
.mc-check {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--mc-success);
    color: #fff;
    font-size: 11px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.mc-check-sm { width: 16px; height: 16px; font-size: 8px; top: 3px; right: 3px; }
.mc-count {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #047857;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}
.mc-status {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}
.mc-status-on { background: #1C6FA0; }
.mc-status.mc-lifted { bottom: 14px; }
/* not identified yet (white on it: 5.6:1) */
.mc-status-pending { background: #8A5A00; }
.mc-pending-note { margin: 6px 0 0; font-size: 13px; color: var(--mc-text-mid); }
.mc-pending-spin { margin-right: 6px; }
/* the library's scan on the server, under the bar */
.mc-scan { margin: 0 0 8px; padding: 0 var(--mc-side); font-size: 13px; color: var(--mc-text-mid); }
.mc-progress { position: absolute; left: 8px; right: 8px; bottom: 6px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.mc-progress > span { display: block; height: 100%; background: #4BA8DB; }
.mc-badges { position: absolute; top: 6px; left: 6px; display: flex; flex-wrap: wrap; gap: 3px; max-width: calc(100% - 40px); }
.mc-badge {
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.92);
    color: #0B1220;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: 0.02em;
}
.mc-badge-guess { background: rgba(0, 0, 0, 0.6); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9); }
.mc-book-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8%;
    text-align: center;
    color: #fff;
}
.mc-book-glyph { font-size: 22px; opacity: 0.6; }
.mc-book-title { font-weight: 700; font-size: 12px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.mc-book-author { font-size: 10px; opacity: 0.85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* people */
.mc-person { display: flex; flex-direction: column; align-items: center; gap: 4px; width: calc(var(--d) + 16px); text-align: center; }
.mc-person-photo {
    position: relative;
    width: var(--d);
    height: var(--d);
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--mc-line);
    flex-shrink: 0;
}
.mc-person-photo .mc-glyph { font-size: 24px; }
.mc-person:focus-visible { outline: none; }
.mc-person:focus-visible .mc-person-photo { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-person-name { font-size: 11px; font-weight: 600; color: var(--mc-text-hi); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-person-role { font-size: 10px; color: var(--mc-text-low); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 18px 14px; justify-items: center; }

/* library tiles */
.mc-tile { display: block; width: calc(196px * var(--mc-scale, 1)); }
.mc-tile-art { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--mc-r3); overflow: hidden; border: 1px solid var(--mc-line); transition: transform 0.18s ease; }
.mc-tile:hover .mc-tile-art { transform: translateY(-2px); }
.mc-tile:focus-visible { outline: none; }
.mc-tile:focus-visible .mc-tile-art { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-tile-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%); font-size: 30px; color: rgba(255, 255, 255, 0.85); }
.mc-tile-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.6)); }
.mc-tile-name { position: absolute; left: 10px; right: 10px; bottom: 8px; color: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* how far a library got while it isn't finished: a pie of the share identified; turning while the server is at it,
   a clock while it waits its turn, a spinner while it is walked */
.mc-tile-badge { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, 0.72); display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.mc-tile-pie { width: 20px; height: 20px; border-radius: 50%; background: conic-gradient(#fff calc(var(--mc-p, 0) * 1%), rgba(255, 255, 255, 0.28) 0); }
.mc-tile-badge-active::after, .mc-tile-badge-walking::after { content: ""; position: absolute; inset: 1px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--mc-brand-hi); border-right-color: var(--mc-brand-hi); animation: mc-tile-turn 1.1s linear infinite; }
.mc-tile-badge-walking .mc-tile-pie { background: rgba(255, 255, 255, 0.28); }
.mc-tile-badge-waiting .mc-tile-pie { opacity: 0.55; }
.mc-tile-clock { position: absolute; font-size: 13px; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, 0.9); }
@keyframes mc-tile-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .mc-tile-badge-active::after, .mc-tile-badge-walking::after { animation: none; }
}

/* rows */
.mc-rail { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mc-rail-head { display: flex; align-items: center; gap: 12px; padding: 0 var(--mc-side); }
.mc-rail-title { flex: 1; margin: 0; font-size: 16px; font-weight: 700; color: var(--mc-text-hi); }
.mc-rail-title a { display: inline-flex; align-items: center; gap: 8px; }
.mc-rail-title a i { font-size: 12px; color: var(--mc-text-mid); }
.mc-rail-title a:hover { color: var(--mc-brand-hi); }
.mc-rail-arrows { display: flex; gap: 6px; }
.mc-phone .mc-rail-arrows { display: none; }
.mc-rail-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 4px var(--mc-side) 8px;
    scroll-padding: 0 var(--mc-side);
    /* no bar: still scrolled by wheel/trackpad, touch, the row's arrows and keyboard focus */
    scrollbar-width: none;
}
.mc-rail-track::-webkit-scrollbar { display: none; }
/* dragged with a mouse (RailTrack): no snapping or text selection until let go */
.mc-rail-dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; -webkit-user-select: none; }
.mc-rail-dragging * { cursor: grabbing; }
.mc-rail-track > * { flex-shrink: 0; scroll-snap-align: start; }
.mc-cast-cell { width: 88px; display: flex; justify-content: center; }

/* home: the featured titles */
.mc-featured { --peek: clamp(24px, 5%, 72px); --gap: 16px; display: flex; flex-direction: column; gap: 12px; }
.mc-phone .mc-featured { --peek: 14px; --gap: 8px; }
.mc-feat-track { position: relative; height: clamp(240px, 26vw, 340px); overflow: hidden; touch-action: pan-y; overscroll-behavior-x: contain; }
/* dragged: the cards follow the pointer at once, and settle with the usual motion when let go */
.mc-feat-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.mc-feat-dragging .mc-slide { transition: transform 0.55s ease, opacity 0.4s ease; }
.mc-feat-dragging .mc-slide-far { opacity: 1; }
/* a phone: as tall as the width allows; from 600px (a tablet held upright) the slide is laid out as on a wide window */
.mc-phone .mc-feat-track { height: clamp(200px, 56vw, 420px); }
/* a window with little height (a phone on its side): the carousel leaves room for the rows under it */
@media (max-height: 500px) { .mc-feat-track { height: clamp(180px, 52vh, 240px); } }
.mc-slide {
    position: absolute;
    top: 0;
    bottom: 0;
    width: calc(100% - 2 * (var(--peek) + var(--gap)));
    left: calc(var(--peek) + var(--gap) + var(--off) * (100% - 2 * var(--peek) - var(--gap)) + var(--drag, 0px));
    transition: left 0.55s cubic-bezier(0.2, 0.9, 0.3, 1), transform 0.55s ease, opacity 0.4s ease;
    border-radius: var(--mc-r4);
    overflow: hidden;
}
.mc-slide-side { transform: scale(0.94); cursor: pointer; }
.mc-slide-side::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.mc-slide-far { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .mc-slide { transition: none; } }
.mc-slide-link { position: absolute; inset: 0; display: block; color: #fff; }
.mc-slide-link:focus-visible { outline: 3px solid var(--mc-brand-hi); outline-offset: -3px; border-radius: var(--mc-r4); }
.mc-slide-art { position: absolute; inset: 0; }
.mc-blur { filter: blur(36px) brightness(0.7); transform: scale(1.2); }
.mc-slide-poster { position: absolute; right: 6%; top: 9%; height: 82%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--mc-r2); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); }
@media (max-width: 599px) { .mc-phone .mc-slide-poster { display: none; } }
.mc-slide-scrim {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to right, rgba(0, 0, 0, 0.72), transparent 70%),
        linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent 65%);
}
@media (max-width: 599px) { .mc-phone .mc-slide-scrim { background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent 75%); } }
.mc-slide-text {
    position: absolute;
    left: 28px;
    bottom: 26px;
    max-width: min(56%, 640px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
@media (max-width: 599px) { .mc-phone .mc-slide-text { left: 16px; right: 16px; bottom: 16px; max-width: none; } }
.mc-slide-why { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #4BA8DB; }
.mc-slide-name { font-size: 34px; font-weight: 800; line-height: 1.1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 599px) { .mc-phone .mc-slide-name { font-size: 26px; } }
.mc-slide-logo { max-height: 76px; max-width: 100%; object-fit: contain; object-position: left; align-self: flex-start; }
@media (max-width: 599px) { .mc-phone .mc-slide-logo { max-height: 52px; } }
.mc-slide-ep { font-size: 15px; font-weight: 600; }
.mc-slide-facts { font-size: 13px; color: rgba(255, 255, 255, 0.85); }
.mc-slide-overview { font-size: 14px; color: rgba(255, 255, 255, 0.85); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 599px) { .mc-phone .mc-slide-overview { display: none; } }
.mc-slide-progress { position: relative; width: 180px; height: 4px; }
.mc-slide-progress .mc-progress { left: 0; right: 0; bottom: 0; height: 4px; }
.mc-feat-controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.mc-dots { display: flex; align-items: center; gap: 6px; }
.mc-dot { width: 7px; height: 7px; padding: 0; border: none; border-radius: 999px; background: color-mix(in srgb, var(--mc-text-low) 55%, transparent); cursor: pointer; transition: width 0.25s ease; }
.mc-dot-on { width: 20px; background: var(--mc-brand-hi); }

/* a library's grid */
.mc-grid-page { gap: 10px; }
.mc-gridbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 0 var(--mc-side); }
.mc-phone .mc-gridbar { gap: 8px; }
.mc-count-text { font-size: 12px; font-weight: 600; color: var(--mc-text-mid); }
.mc-tool {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-bg2);
    color: var(--mc-text) !important;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.mc-tool i { font-size: 13px; }
.mc-tool:hover { background: var(--mc-bg4); }
.mc-tool:disabled { opacity: 0.45; cursor: default; }
.mc-tool-on { background: color-mix(in srgb, var(--mc-brand) 16%, transparent); border: 1.5px solid var(--mc-brand); color: var(--mc-brand-hi) !important; }
.mc-tool-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--mc-brand-fill);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
}
.mc-phone .mc-tool { padding: 10px 11px; }
.mc-phone .mc-tool i { font-size: 16px; }
.mc-phone .mc-tool-text { display: none; }
.mc-segment { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--mc-r2); border: 1px solid var(--mc-line); background: var(--mc-bg2); }
.mc-seg { width: 30px; height: 30px; border: none; border-radius: 6px; background: none; color: var(--mc-text-mid); font-size: 12px; cursor: pointer; }
.mc-seg:hover { color: var(--mc-text-hi); }
.mc-seg[aria-checked="true"] { background: var(--mc-brand-fill); color: #fff; }
.mc-segment-text { display: flex; margin-bottom: 8px; }
.mc-segment-text .mc-seg { flex: 1; width: auto; padding: 6px 10px; font-size: 13px; }
.mc-chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 var(--mc-side) 2px; scrollbar-width: none; }
.mc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-bg2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.mc-chip i { font-size: 12px; }
.mc-chip:hover { background: var(--mc-bg4); }
.mc-chip[aria-pressed="true"] { background: var(--mc-brand-fill); border-color: var(--mc-brand-hi); color: #fff; }
.mc-chip-n { font-weight: 400; color: var(--mc-text-mid); font-variant-numeric: tabular-nums; }
.mc-chip[aria-pressed="true"] .mc-chip-n { color: rgba(255, 255, 255, 0.85); }
.mc-pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 0; }
.mc-pager-label {
    min-width: 96px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-bg2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.mc-sentinel { height: 1px; }
.mc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 136px), 100%), 1fr));
    gap: 18px 14px;
    padding: 0 var(--mc-side);
}
.mc-grid.mc-pad { padding: 0 var(--mc-side); }
.mc-pad .mc-grid { padding: 0; }
.mc-cell { position: relative; min-width: 0; }
.mc-cell-on .mc-art, .mc-cell-on .mc-row-pic { outline: 3px solid var(--mc-brand-hi); outline-offset: 4px; }
.mc-pick {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 8px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
.mc-pick[aria-pressed="true"] i { color: var(--mc-brand-hi); background: #fff; border-radius: 50%; }
.mc-selbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 var(--mc-side); }
.mc-banners { display: flex; flex-direction: column; gap: 12px; padding: 0 var(--mc-side); }
.mc-banner { display: block; }
.mc-banner .mc-art { height: var(--h, 150px); }
.mc-banner:hover .mc-art { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22); }
.mc-banner:focus-visible { outline: none; }
.mc-banner:focus-visible .mc-art { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-banner-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 30%, rgba(0, 0, 0, 0.7)); }
.mc-banner-text { position: absolute; left: 12px; bottom: 10px; right: 12px; display: flex; flex-direction: column; color: #fff; }
.mc-banner-name { font-size: 14px; font-weight: 700; }
.mc-banner-sub { font-size: 11px; color: rgba(255, 255, 255, 0.8); }
.mc-list { display: flex; flex-direction: column; padding: 0 var(--mc-side); }
.mc-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--mc-line); }
.mc-row:hover { background: var(--mc-wash); }
.mc-row-pic { width: calc(60px * var(--s, 1)); flex-shrink: 0; border-radius: var(--mc-r2); }
.mc-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mc-row-name { font-size: 14px; font-weight: 600; color: var(--mc-text-hi); }
.mc-row-meta { font-size: 11px; color: var(--mc-text-mid); }
.mc-row-chev { font-size: 12px; color: var(--mc-text-low); }

/* filters */
.mc-filters { display: flex; flex-direction: column; gap: 22px; }
.mc-fgroup { display: flex; flex-direction: column; gap: 8px; }
.mc-fgroup h3 { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--mc-text-mid); }
.mc-fgroup-head { display: flex; align-items: center; gap: 8px; }
.mc-fgroup-head h3 { flex: 1; }
.mc-fgroup-n { font-size: 12px; color: var(--mc-brand-hi); font-weight: 700; }
.mc-fsearch { border-radius: 999px; }
.mc-fchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mc-fchip { padding: 7px 12px; border-radius: 999px; border: none; background: var(--mc-bg3); color: var(--mc-text-mid); font-size: 12px; cursor: pointer; }
.mc-fchip:hover { color: var(--mc-text-hi); }
.mc-fchip[aria-pressed="true"] { background: var(--mc-brand-fill); color: #fff; font-weight: 600; }

/* a title's page */
.mc-detail { position: relative; display: flex; flex-direction: column; gap: 22px; padding-bottom: 32px; }
/* a dialog (Identify, Edit Metadata) stays over the whole window, not in the page's flow */
.mc-detail > :not(.mc-backdrop, .mc-overlay, .mc-art-choosers) { position: relative; z-index: 1; }
/* the part with a menu open lies over the parts after it (a long audio or subtitle list over the cast) */
.mc-detail > :has(.mc-menu) { z-index: 2; }
.mc-backdrop { position: absolute; top: -49px; left: 0; right: 0; height: min(86vh, 900px); overflow: hidden; z-index: 0; }
.mc-backdrop-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1.6s ease; }
.mc-backdrop-img.mc-shown { opacity: 1; }
.mc-backdrop-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(var(--mc-scrim), 0.82), rgba(var(--mc-scrim), 0.88) 45%, rgba(var(--mc-scrim), 0.96) 80%, rgb(var(--mc-scrim)));
}
.mc-hero { display: flex; gap: 28px; align-items: flex-start; padding: 28px var(--mc-side) 0; }
.mc-hero-poster { position: relative; flex-shrink: 0; width: 220px; aspect-ratio: 2 / 3; border-radius: var(--mc-r3); overflow: hidden; border: 1px solid var(--mc-line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); }
.mc-hero-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.mc-hero-title { margin: 0; font-size: 30px; font-weight: 800; line-height: 1.15; color: var(--mc-text-hi); }
.mc-logo { display: block; max-height: 88px; max-width: min(100%, 480px); object-fit: contain; object-position: left; }
.mc-crumb { display: flex; flex-wrap: wrap; gap: 2px; font-size: 12px; font-weight: 600; color: var(--mc-brand-hi); }
.mc-crumb a { text-decoration: underline; }
.mc-facts { margin: 0; font-size: 12px; color: var(--mc-text-mid); }
.mc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.mc-resume { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; color: var(--mc-text-mid); }
.mc-next-label { color: var(--mc-brand-hi); font-weight: 600; }
.mc-resume-bar { position: relative; flex: 1; max-width: 460px; min-width: 120px; height: 4px; }
.mc-resume-bar .mc-progress { left: 0; right: 0; bottom: 0; height: 4px; background: var(--mc-wash-strong); }
.mc-tracks { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-track-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-bg3);
    font-size: 13px;
    color: var(--mc-text);
    cursor: pointer;
}
span.mc-track-chip { cursor: default; }
.mc-track-key { color: var(--mc-text-low); }
.mc-track-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.mc-track-chip i { font-size: 10px; color: var(--mc-text-mid); }
.mc-section { display: flex; flex-direction: column; gap: 10px; }
.mc-part { width: 200px; }
.mc-play-mark { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 34px; color: rgba(255, 255, 255, 0.9); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.mc-episode { position: relative; display: flex; flex-direction: column; gap: 4px; width: 220px; }
.mc-episode-art { display: block; }
.mc-episode-art .mc-art { border-radius: var(--mc-r2); }
.mc-episode-art .mc-img { filter: brightness(0.8); }
.mc-episode:hover .mc-episode-art .mc-img { filter: none; }
.mc-episode-art:focus-visible { outline: none; }
.mc-episode-art:focus-visible .mc-art { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-here .mc-episode-art .mc-art { box-shadow: 0 0 0 2px var(--mc-brand-hi); }
.mc-here .mc-episode-title { color: var(--mc-brand-hi); }
.mc-episode-play {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
.mc-episode-play > i { pointer-events: auto; }
.mc-episode:hover .mc-episode-play, .mc-episode-play:focus-visible, .mc-here .mc-episode-play, .mc-phone .mc-episode-play { opacity: 1; }
.mc-episode-title { font-size: 13px; font-weight: 600; color: var(--mc-text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-episode-meta { font-size: 11px; color: var(--mc-text-mid); }
.mc-episode-overview { font-size: 11px; color: var(--mc-text-low); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mc-chips-section { gap: 14px; }
.mc-chiprow-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.mc-vchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-bg2);
    font-size: 13px;
    font-weight: 600;
    color: var(--mc-text-hi);
}
.mc-vchip:hover { background: var(--mc-bg4); }
/* a fact shown as a chip that leads nowhere (an album's release date, its country) */
.mc-vchip-plain:hover { background: var(--mc-bg2); }
.mc-credit { margin: 0; font-size: 12px; color: var(--mc-text-low); }
.mc-vchip i { font-size: 11px; color: var(--mc-text-mid); }
/* Favorites' hearted genres, studios and tags: a list that wraps, so every chip (and its focus ring) shows */
.mc-chiprow-wrap { flex-wrap: wrap; overflow: visible; list-style: none; margin: 0; padding: 0 0 2px; }
.mc-path { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--mc-brand-hi); word-break: break-all; user-select: text; }
.mc-file-chip { margin: 0; align-self: flex-start; padding: 3px 10px; border-radius: 999px; background: var(--mc-bg3); font-size: 12px; color: var(--mc-text-mid); }
.mc-streams { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; align-items: stretch; }
.mc-detect { align-self: flex-start; }
.mc-stream { flex-shrink: 0; width: 300px; padding: 14px; border-radius: var(--mc-r3); background: var(--mc-bg2); border: 1px solid var(--mc-line); }
.mc-stream h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--mc-text-hi); }
.mc-stream h3 i { color: var(--mc-brand-hi); }
.mc-stream dl, .mc-kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 10px; margin: 0; font-size: 12px; }
.mc-stream dt, .mc-kv dt { color: var(--mc-text-low); }
.mc-stream dd, .mc-kv dd { margin: 0; color: var(--mc-text); word-break: break-word; user-select: text; }
.mc-kv { grid-template-columns: 140px 1fr; gap: 0; }
.mc-kv dt, .mc-kv dd { padding: 6px 0; border-bottom: 1px solid var(--mc-line); white-space: pre-line; }
.mc-portrait .mc-backdrop { position: relative; top: auto; height: auto; aspect-ratio: 16 / 9; margin-top: -1px; }
.mc-portrait .mc-backdrop-scrim { background: linear-gradient(to bottom, transparent 55%, rgb(var(--mc-scrim))); }
.mc-portrait-top { display: flex; flex-direction: column; gap: 8px; padding: 0 var(--mc-side); margin-top: -40px; }
.mc-portrait .mc-hero-title { font-size: 26px; }
.mc-portrait .mc-logo { max-height: 56px; }
.mc-portrait .mc-tracks, .mc-portrait > .mc-actions, .mc-portrait > .mc-resume { padding: 0 var(--mc-side); }
.mc-portrait .mc-tracks { flex-direction: column; align-items: flex-start; }

/* music and books */
.mc-music-head { display: flex; gap: 28px; align-items: flex-start; padding: 16px var(--mc-side) 0; }
.mc-music-head.mc-stacked { flex-direction: column; align-items: center; gap: 16px; }
.mc-stacked .mc-music-col { align-self: stretch; }
.mc-album-cover { width: 240px; flex-shrink: 0; }
.mc-stacked .mc-album-cover { width: min(280px, 80vw); }
.mc-album-cover .mc-glyph { font-size: 64px; }
.mc-book-cover { width: 160px; flex-shrink: 0; border-radius: var(--mc-r3); }
.mc-stacked .mc-book-cover { width: 200px; }
.mc-music-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.mc-phone .mc-hero-title { font-size: 22px; }
.mc-artist-links { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 15px; }
.mc-series-link { font-size: 14px; }
.mc-disc { margin: 14px 0 6px; font-size: 14px; font-weight: 700; color: var(--mc-text-mid); }
.mc-tracks-list { list-style: none; margin: 0; padding: 0; }
.mc-track { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--mc-line); }
.mc-track-play { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px 8px; border: none; background: none; text-align: left; cursor: pointer; }
.mc-track:hover { background: var(--mc-wash); }
.mc-track-n { width: 30px; flex-shrink: 0; text-align: right; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--mc-text-low); }
.mc-track-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mc-track-name { font-size: 14px; font-weight: 500; color: var(--mc-text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-track-by { font-size: 12px; color: var(--mc-text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-track-len { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--mc-text-mid); }
.mc-artist-head, .mc-person-head { display: flex; gap: 24px; align-items: center; padding: 16px var(--mc-side) 0; }
.mc-person-head { align-items: flex-start; }
.mc-person-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-person-forget { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--mc-text-mid); }
.mc-person-forget input { margin-top: 2px; }
.mc-id-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-avatar { position: relative; width: 140px; height: 140px; flex-shrink: 0; border-radius: 50%; overflow: hidden; border: 1px solid var(--mc-line); }
.mc-avatar-sm { width: 96px; height: 96px; }
.mc-person-photo-lg { width: 160px; flex-shrink: 0; border-radius: var(--mc-r2); }
.mc-phone .mc-person-photo-lg { width: 110px; }
.mc-kicker { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--mc-brand-hi); }
.mc-group-head { display: flex; flex-direction: column; gap: 6px; padding: 16px var(--mc-side) 0; }
.mc-inline-field select { min-width: 140px; }
.mc-person-top { position: relative; padding-bottom: 8px; }
.mc-person-top > :not(.mc-backdrop, .mc-overlay) { position: relative; z-index: 1; }
.mc-person-top > :has(.mc-menu) { z-index: 2; }
.mc-person-top > .mc-backdrop { top: -61px; bottom: -32px; height: auto; }
/* the backdrop fades out below the top, over what follows: that is drawn above it (the filmography bar's top was hidden); a
   dialog (order, filters, picture size) stays fixed over the whole window */
.mc-person-top ~ :not(.mc-overlay) { position: relative; z-index: 1; }
.mc-phone .mc-person-top > .mc-backdrop { position: absolute; aspect-ratio: auto; margin-top: 0; }
.mc-phone .mc-person-top > .mc-backdrop .mc-backdrop-scrim { background: linear-gradient(to bottom, rgba(var(--mc-scrim), 0.78), rgba(var(--mc-scrim), 0.9) 60%, rgb(var(--mc-scrim))); }

/* Identify and Edit Metadata */
/* Identify, as the apps' sheet: its head, then cards (location, now, search, the list) */
.mc-sheet-icon {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; height: 40px; border-radius: 50%;
    background: color-mix(in srgb, var(--mc-brand-hi) 14%, transparent); color: var(--mc-brand-hi); font-size: 18px;
}
.mc-sheet-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mc-sheet-sub { margin: 0; font-size: 12px; color: var(--mc-text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-sheet:has(.mc-id) { max-width: 640px; }
.mc-id { display: flex; flex-direction: column; gap: 14px; }
.mc-id-card {
    display: flex; flex-direction: column; gap: 8px; padding: 14px 16px;
    border-radius: var(--mc-r3); background: var(--mc-wash); border: 1px solid var(--mc-line);
}
.mc-id-head { margin: 0; font-size: 14px; font-weight: 700; color: var(--mc-text-hi); }
.mc-id-label { margin: 0; font-size: 11px; font-weight: 700; color: var(--mc-text-mid); }
.mc-id-line { margin: 0; font-size: 14px; color: var(--mc-text); line-height: 1.5; }
.mc-id-path, .mc-id-file { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: 13px; word-break: break-all; }
.mc-id-path { color: var(--mc-text-hi); }
.mc-id-file { padding-left: 22px; color: var(--mc-text-mid); }
.mc-id-path i, .mc-id-file i { width: 14px; flex-shrink: 0; text-align: center; font-size: 12px; }
.mc-link-btn {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 4px 0;
    border: none; background: none; color: var(--mc-brand-hi); font: inherit; font-size: 13px; cursor: pointer;
}
.mc-link-btn:hover { text-decoration: underline; }
.mc-link-btn:focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 2px; border-radius: 4px; }
.mc-id-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mc-id-search .mc-id-query { flex: 1 1 180px; min-width: 0; }
.mc-id-search .mc-id-year { width: 76px; flex: none; }
.mc-id-kind { flex: none; }
.mc-seg.mc-seg-text { width: auto; padding: 0 14px; font-size: 13px; }
.mc-seg[aria-pressed="true"] { background: var(--mc-brand-fill); color: #fff; }
.mc-seg:focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 1px; }
.mc-id-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mc-id-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.mc-id-row + .mc-id-row { border-top: 0.5px solid var(--mc-line); }
.mc-id-choose {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 4px; margin: 0;
    border: none; border-radius: var(--mc-r2); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.mc-id-choose:hover { background: var(--mc-wash); }
.mc-id-choose:focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 1px; }
.mc-id-choose:disabled { cursor: progress; opacity: 0.7; }
.mc-id-tick { color: var(--mc-brand-hi); }
.mc-id-poster {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; aspect-ratio: 2 / 3; border-radius: var(--mc-r1, 4px); overflow: hidden;
    background: var(--mc-wash); color: var(--mc-text-low);
}
.mc-id-poster img { width: 100%; height: 100%; object-fit: cover; }
.mc-id-poster.mc-id-cover { aspect-ratio: 1; }
.mc-id-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mc-id-name { font-size: 14px; font-weight: 600; color: var(--mc-text-hi); overflow: hidden; text-overflow: ellipsis; }
.mc-sheet-foot .mc-id-current { align-self: center; }
/* Ask AI's answer */
.mc-id-line.mc-strong { font-weight: 600; color: var(--mc-text-hi); }
.mc-id-sent summary { cursor: pointer; font-size: 12px; color: var(--mc-text-mid); }
.mc-id-sent summary:focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 2px; border-radius: 4px; }
.mc-id-sent pre { margin: 6px 0 0; padding: 8px 10px; border-radius: var(--mc-r2); background: var(--mc-bg2); font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--mc-text-mid); }
/* More info on a candidate */
.mc-id-more { display: flex; flex-direction: column; gap: 14px; }
.mc-id-more-head { display: flex; gap: 16px; align-items: flex-start; }
.mc-id-more-poster {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 110px; aspect-ratio: 2 / 3; border-radius: var(--mc-r2); overflow: hidden;
    background: var(--mc-wash); color: var(--mc-text-low); font-size: 28px;
}
.mc-id-more-poster img { width: 100%; height: 100%; object-fit: cover; }
.mc-id-tagline { margin: 4px 0 0; font-style: italic; color: var(--mc-text-mid); font-size: 13px; }
.mc-id-more-part { display: flex; flex-direction: column; gap: 4px; }
.mc-id-cast { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 16px; font-size: 13px; }
.mc-id-cast li { display: flex; flex-direction: column; }
.mc-id-links { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; font-size: 13px; }
.mc-edit-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.mc-edit-row > .mc-field { flex: 1 1 120px; min-width: 0; }
.mc-edit-overview { resize: vertical; min-height: 96px; font: inherit; }
.mc-edit-cast { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mc-edit-remove { align-self: flex-end; margin-bottom: 2px; }
.mc-edit-add { align-self: flex-start; }
/* Edit Metadata's pictures (pictures.rs): each one's picture, its name and state, its menu; an actor's photo */
.mc-art-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mc-art-row { display: flex; align-items: center; gap: 12px; }
.mc-art-thumb {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--mc-r2);
    background: var(--mc-wash);
    color: var(--mc-text-low);
}
.mc-art-thumb img { width: 100%; height: 100%; object-fit: contain; }
/* scoped to .mc-art-thumb: the grid's cards use .mc-art-poster / .mc-art-wide too */
.mc-art-thumb.mc-art-poster { width: 80px; height: 120px; }
.mc-art-thumb.mc-art-poster img { object-fit: cover; }
.mc-art-thumb.mc-art-wide { width: 128px; height: 72px; }
.mc-art-thumb.mc-art-wide img { object-fit: cover; }
.mc-art-thumb.mc-art-logo { width: 130px; height: 72px; }
.mc-art-thumb.mc-art-banner { width: 220px; height: 40px; }
.mc-art-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mc-art-name { font-weight: 600; color: var(--mc-text-hi); }
.mc-pill.mc-icon-only { padding: 0; width: 38px; }
.mc-edit-actor { align-items: center; }
.mc-edit-actor .mc-pill { align-self: flex-end; }
.mc-actor-photo {
    flex: none;
    align-self: flex-end;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mc-wash);
    color: var(--mc-text-low);
}
.mc-actor-photo img { width: 100%; height: 100%; object-fit: cover; }
.mc-art-choices {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.mc-art-choices-wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.mc-art-choice {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 1px solid var(--mc-line);
    border-radius: var(--mc-r2);
    overflow: hidden;
    background: var(--mc-wash);
    cursor: pointer;
    aspect-ratio: 2 / 3;
}
.mc-art-choices-wide .mc-art-choice { aspect-ratio: 16 / 9; }
.mc-art-choices-logo .mc-art-choice { background: #4A5568; }
.mc-art-choice img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-art-choices-logo .mc-art-choice img { object-fit: contain; padding: 8px; box-sizing: border-box; }
.mc-art-choice:hover { border-color: var(--mc-brand-hi); }
.mc-art-choice:focus-visible { outline: 3px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-art-lang {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}
/* the cloud drive's chooser opens over the sheet */
.mc-art-cloud .modal-overlay { z-index: 1010; }
/* a phone: smaller pictures, and the menu's button is its icon (its label names what it chooses) */
.mc-phone .mc-art-thumb.mc-art-poster { width: 60px; height: 90px; }
.mc-phone .mc-art-thumb.mc-art-wide, .mc-phone .mc-art-thumb.mc-art-logo { width: 96px; height: 54px; }
.mc-phone .mc-art-thumb.mc-art-banner { width: 110px; height: 20px; }
.mc-phone .mc-art-row .mc-pill { padding: 0; width: 44px; min-height: 44px; }
.mc-phone .mc-art-choose-text { display: none; }
.mc-phone .mc-art-choices { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.mc-phone .mc-art-choices-wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mc-warn { color: var(--mc-danger); }
.mc-saved { margin: 0; padding: 0 var(--mc-side); font-size: 13px; color: var(--mc-text-mid); }

/* search */
.mc-searchbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 var(--mc-side);
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--mc-line);
    background: var(--mc-bg2);
    color: var(--mc-text-low);
}
.mc-searchbox:focus-within { border-color: var(--mc-brand-hi); }
.mc-search-input { flex: 1; min-width: 0; height: 42px; border: none; background: none; color: var(--mc-text-hi); font-size: 15px; outline: none; }
.mc-search-page .mc-section .mc-rail-title { margin-bottom: 4px; font-size: 14px; }
.mc-search-scope { margin: 10px var(--mc-side) 0; max-width: 420px; }
.mc-search-scope .mc-seg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the video player: the picture over the whole window, the apps' controls over it (controls.rs) */
.media-client.mc-playing { background: #000; }
.mc-player { position: fixed; inset: 0; z-index: 1500; background: #000; color: #fff; }
.mc-cant { position: absolute; left: 50%; top: 50%; z-index: 6; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px)); padding: 16px; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(20, 28, 38, 0.92); display: flex; flex-direction: column; gap: 10px; }
.mc-cant p { margin: 0; }
.mc-player .mc-pill { color: #fff !important; border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.1); }
.mc-player .mc-hint { color: rgba(255, 255, 255, 0.75); }
.pl-error { position: absolute; left: 0; right: 0; top: 64px; z-index: 6; text-align: center; color: #ff8a80; }
.pl-root {
    --pl-accent: #2184bf; --pl-accent-hi: #4ba8db; --pl-glass: rgba(255, 255, 255, 0.1); --pl-glass-hi: rgba(255, 255, 255, 0.18);
    --pl-border: rgba(255, 255, 255, 0.12); --pl-panel: rgba(20, 28, 38, 0.62);
    position: absolute; inset: 0; overflow: hidden; background: #000; color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.pl-root.pl-hidden { cursor: none; }
.pl-stage { position: absolute; inset: 0; }
.pl-stage .mc-video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.mc-dec { position: absolute; inset: 0; background: #000; overflow: hidden; }
.mc-dec-pic { position: absolute; inset: 0; }
.pl-tap { position: absolute; inset: 0; z-index: 3; }
.pl-wait { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; font-size: 34px; color: rgba(255, 255, 255, 0.85); pointer-events: none; }
.pl-chrome { position: absolute; inset: 0; z-index: 5; pointer-events: none; transition: opacity 0.2s ease-in-out; }
.pl-chrome > * { pointer-events: auto; }
.pl-chrome > .pl-shade-top, .pl-chrome > .pl-shade-bottom { pointer-events: none; }
.pl-hidden .pl-chrome { opacity: 0; }
.pl-hidden .pl-chrome * { pointer-events: none !important; }
.pl-shade-top { position: absolute; left: 0; right: 0; top: 0; height: 140px; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0)); }
.pl-shade-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 200px; background: linear-gradient(to top, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0)); }
.pl-portrait .pl-shade-bottom { height: 320px; }
/* buttons: glass circles, glass squares in the row */
.pl-circle, .pl-sq { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; border: 0.5px solid var(--pl-border); background: var(--pl-glass); color: #fff; cursor: pointer; transition: transform 0.1s, background 0.15s, opacity 0.1s; }
.pl-circle { width: 44px; height: 44px; border-radius: 50%; font-size: 18px; }
.pl-sq { width: 42px; height: 42px; border-radius: 10px; font-size: 18px; }
.pl-circle:hover, .pl-sq:hover { background: var(--pl-glass-hi); }
.pl-circle:active, .pl-sq:active { transform: scale(0.9); opacity: 0.8; }
.pl-circle:focus-visible, .pl-sq:focus-visible, .pl-row:focus-visible, .pl-panel-close:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
/* a row's edges are the panel's: its ring goes inside */
.pl-row:focus-visible { outline-offset: -2px; }
/* the line icons, in proportion to their button */
.pl-ico { display: block; flex-shrink: 0; width: 1.35em; height: 1.35em; }
.pl-circle:disabled, .pl-sq:disabled { opacity: 0.3; cursor: default; transform: none; }
.pl-root .pl-sq.pl-on, .pl-root .pl-circle.pl-on { background: rgba(33, 132, 191, 0.85); border-color: transparent; }
/* an outlined ⓘ (Video Info), beside the filled one (Media Information) as the apps' info.circle and info.circle.fill */
.pl-ring { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 19px; height: 19px; border: 2px solid currentColor; border-radius: 50%; font-size: 9px; }
.pl-row-icon.pl-ring { width: 22px; height: 22px; margin: 0 3px; font-size: 10px; }
.pl-small { width: 36px; height: 36px; font-size: 15px; }
.pl-top .pl-small { width: 40px; height: 40px; font-size: 16px; }
.pl-tiny { width: 24px; height: 24px; font-size: 11px; }
.pl-plain { background: transparent; border-color: transparent; }
.pl-sq-small { width: 32px; height: 32px; font-size: 14px; border-radius: 8px; }
.pl-count { position: absolute; top: -4px; right: -4px; min-width: 14px; padding: 1px 4px; border-radius: 999px; background: var(--pl-accent); color: #fff; font-size: 9px; font-weight: 700; line-height: 12px; }
.pl-root .pl-play { background: rgba(255, 255, 255, 0.94); color: #0c1218; border-color: transparent; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
.pl-root .pl-play:hover { background: #fff; }
/* the top bar */
.pl-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: 14px 22px 12px; padding-top: max(14px, env(safe-area-inset-top)); padding-left: max(22px, env(safe-area-inset-left)); padding-right: max(22px, env(safe-area-inset-right)); }
.pl-titles { flex: 1; min-width: 0; }
.pl-title { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.pl-full .pl-title { font-size: 16px; }
.pl-sub { margin: 2px 0 0; font-size: 12px; color: rgba(255, 255, 255, 0.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-badges { display: flex; gap: 6px; flex-shrink: 0; }
.pl-badge { padding: 3px 6px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(0, 0, 0, 0.3); font-size: 10px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.pl-full .pl-badge { font-size: 11px; padding: 4px 7px; }
/* a Dolby Atmos song the browser decodes: the apps' Atmos colours (white on them is 7:1 or more) */
.pl-badge.pl-badge-atmos { border-color: transparent; background: linear-gradient(90deg, #0046AD, #7B2CBF); color: #fff; }
.pl-grow { flex: 1; }
.pl-top-portrait { padding: 8px 18px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.pl-top-portrait .pl-badges { flex-shrink: 1; min-width: 0; overflow: hidden; }
/* the title's clear logo, under the top bar while the controls show */
.pl-logo { position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + 62px); left: max(24px, env(safe-area-inset-left)); max-width: 220px; max-height: 72px; object-fit: contain; object-position: left top; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
.pl-chrome > .pl-logo { pointer-events: none; }
.pl-compact .pl-logo { left: 12px; max-width: 180px; max-height: 60px; }
.pl-portrait .pl-logo { top: calc(max(8px, env(safe-area-inset-top)) + 60px); left: 18px; max-width: 160px; max-height: 52px; }
/* the transport: in the row, on its own line on a phone held upright */
.pl-transport { display: flex; align-items: center; flex-shrink: 0; gap: 12px; }
.pl-transport .pl-circle { width: 44px; height: 44px; font-size: 17px; }
.pl-root .pl-transport .pl-circle.pl-play { width: 60px; height: 60px; font-size: 24px; }
.pl-portrait .pl-transport { justify-content: center; }
.pl-portrait .pl-transport .pl-circle.pl-step { width: 48px; height: 48px; }
.pl-root.pl-portrait .pl-transport .pl-circle.pl-play { width: 64px; height: 64px; font-size: 26px; }
.pl-time { flex-shrink: 0; margin-left: 4px; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.pl-time-total { color: rgba(255, 255, 255, 0.7); }
.pl-tool-name { display: none; }
/* the bottom: the times, the seek bar, the row */
.pl-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 22px; padding-bottom: max(14px, env(safe-area-inset-bottom)); padding-left: max(22px, env(safe-area-inset-left)); padding-right: max(22px, env(safe-area-inset-right)); }
.pl-compact .pl-bottom, .pl-compact .pl-top { padding-left: 12px; padding-right: 12px; }
.pl-full .pl-bottom { padding-bottom: 16px; }
.pl-times { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; color: rgba(255, 255, 255, 0.9); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.pl-full .pl-times { font-size: 12px; }
.pl-remain { opacity: 0.7; }
/* the seek bar's end: a button that looks like the label, turning the length to what's left and back */
:where(.pl-end) { margin: 0; padding: 0; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-shadow: inherit; text-transform: inherit; text-indent: 0; }
.pl-end { position: relative; cursor: pointer; text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.pl-time > .pl-end { text-align: start; white-space: pre; }
@media (hover: hover) { .pl-end:hover { color: #fff; } }
.pl-end:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
.pl-time > .pl-end:focus-visible { outline-offset: 0; }
/* a finger's room on a touch screen, the look unchanged */
.touch-device .pl-end::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: 44px; transform: translate(-50%, -50%); }
/* … under the seek bar (a phone upright): it reaches down, never over the bar */
.touch-device .ap-phone .pl-end::after, .touch-device .pl-bottom-portrait .pl-end::after { top: 0; transform: translateX(-50%); }
.pl-tools { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.pl-compact .pl-tools { gap: 4px; }
.pl-divider { width: 1px; height: 28px; margin: 0 4px; background: rgba(255, 255, 255, 0.12); flex-shrink: 0; }
.pl-bottom-portrait { display: flex; flex-direction: column; gap: 10px; padding: 12px 18px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.pl-title-big { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pl-bottom-portrait .pl-sub { font-size: 13px; color: rgba(255, 255, 255, 0.75); margin: 0; }
.pl-bottom-portrait .pl-times { margin-top: -10px; color: rgba(255, 255, 255, 0.75); }
/* a phone held upright: the tools, named, across the width */
.pl-tools-named { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 0 -8px; }
.pl-tools-named .pl-sq { flex-direction: column; gap: 3px; width: auto; height: 60px; border: 0; background: none; font-size: 20px; }
.pl-root .pl-tools-named .pl-sq.pl-on { background: none; color: var(--pl-accent-hi); }
.pl-tools-named .pl-tool-name { display: block; max-width: 100%; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-tools-named .pl-count { top: 2px; right: 50%; margin-right: -24px; }
.pl-tools-named .pl-count-speed { display: none; }
/* a phone on its side: the same tools at the row's end, the seek bar between the times */
.pl-tools-row { display: flex; gap: 4px; margin: 0; }
.pl-tools-row .pl-sq { width: 64px; height: 56px; }
.pl-seek-row { display: flex; align-items: center; gap: 12px; }
.pl-seek-row .pl-seek { flex: 1; min-width: 0; }
.pl-seek-row .pl-time { margin: 0; font-size: 12px; }
/* the seek bar: a 4px rail in a 28px row that takes the pointer */
.pl-seek { position: relative; height: 28px; cursor: pointer; touch-action: none; outline: none; }
.pl-seek:focus-visible .pl-rail { outline: 2px solid var(--pl-accent-hi); outline-offset: 6px; border-radius: 4px; }
.pl-full .pl-seek { height: 30px; }
.pl-rail { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: rgba(255, 255, 255, 0.22); }
.pl-buffered, .pl-played { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; }
.pl-buffered { background: rgba(255, 255, 255, 0.35); }
.pl-played { background: var(--pl-accent); transition: top 0.15s ease-out, bottom 0.15s ease-out; }
.pl-dragging .pl-played { top: -1px; bottom: -1px; }
.pl-tick { position: absolute; top: -2px; width: 2px; height: 8px; margin-left: -1px; background: rgba(255, 255, 255, 0.55); }
/* a show's intro end and ending start (SKIP_INTRO.md): brand colour, taller than a chapter tick */
.pl-skip-mark { top: -4px; width: 3px; height: 12px; margin-left: -1.5px; border-radius: 1px; background: var(--pl-accent-hi); }
.pl-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(33, 132, 191, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35); transition: width 0.15s, height 0.15s, margin 0.15s; }
.pl-dragging .pl-dot { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
.pl-pop { position: absolute; bottom: 28px; transform: translateX(-50%); padding: 3px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.pl-cancel .pl-pop { opacity: 0.4; }
/* the volume */
.pl-vol-wrap { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; gap: 8px; }
.pl-vol-inline { -webkit-appearance: none; appearance: none; width: 96px; height: 4px; margin: 0 4px 0 0; border-radius: 2px; background: linear-gradient(to right, #fff var(--pl-vol, 100%), rgba(255, 255, 255, 0.25) var(--pl-vol, 100%)); cursor: pointer; }
.pl-vol-inline::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.pl-vol-inline::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.pl-vol-inline:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 6px; }
.pl-vol-pop { position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: 64px; padding: 10px 0; border-radius: 12px; border: 1px solid var(--pl-border); background: rgba(15, 20, 28, 0.98); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.pl-vol-pct { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pl-vol-slider { writing-mode: vertical-lr; direction: rtl; width: 28px; height: 120px; margin: 0; accent-color: var(--pl-accent-hi); cursor: pointer; }
/* notes: the speed, the transport's step, a key, what couldn't be played as asked */
.pl-step-osd { position: absolute; top: 96px; left: 50%; z-index: 7; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 360px; padding: 16px 22px; border-radius: 16px; border: 0.5px solid var(--pl-border); background: rgba(20, 28, 38, 0.85); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); pointer-events: none; }
.pl-phone .pl-step-osd { top: 70px; }
.pl-portrait .pl-step-osd { top: 80px; }
.pl-step-main { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; max-width: 316px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-step-second { font-size: 14px; font-weight: 500; color: var(--pl-accent-hi); }
.pl-osd { position: absolute; left: 50%; top: 50%; z-index: 7; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 20px; border-radius: 12px; background: rgba(0, 0, 0, 0.55); pointer-events: none; font-size: 14px; }
.pl-osd > i { font-size: 32px; }
.pl-osd-bar { width: 140px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.pl-osd-bar > span { display: block; height: 100%; background: #fff; }
.pl-notice-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pl-notice-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.pl-notice-act { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; border: 0.5px solid var(--pl-border); background: rgba(255, 255, 255, 0.12); color: #fff; font: inherit; font-size: 12.5px; text-decoration: none; cursor: pointer; }
.pl-notice-act:hover { background: rgba(255, 255, 255, 0.2); }
.pl-notice-act:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
.pl-notice { position: absolute; top: 70px; left: 50%; z-index: 7; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100% - 32px)); padding: 8px 8px 8px 14px; border-radius: 12px; border: 0.5px solid var(--pl-border); background: rgba(20, 28, 38, 0.9); font-size: 13px; line-height: 1.4; }
/* panels: beside the picture on a wide window, from the bottom on a phone */
.pl-dim { position: absolute; inset: 0; z-index: 8; background: rgba(0, 0, 0, 0.15); }
.pl-panel { position: absolute; z-index: 9; display: flex; flex-direction: column; border: 1px solid var(--pl-border); background: var(--pl-panel); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4); color: #fff; }
.pl-docked { top: 16px; right: 16px; bottom: 16px; width: 420px; border-radius: 18px; }
.pl-sheet { left: 0; right: 0; bottom: 0; height: 72%; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
/* a phone on its side: the full height of the right edge, over the bars */
.pl-phone .pl-docked { top: 0; right: 0; bottom: 0; width: min(420px, 100%); border-radius: 18px 0 0 18px; padding-right: env(safe-area-inset-right); }
.pl-has-panel .pl-top, .pl-has-panel .pl-bottom, .pl-has-panel .pl-shade-top, .pl-has-panel .pl-shade-bottom { right: 436px; }
/* a panel over the bars: they'd show through it */
.pl-panel-over .pl-chrome { visibility: hidden; }
.pl-panel-split { flex: 1; min-height: 0; display: flex; }
.pl-tabs { flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; width: 76px; padding: 8px 6px; background: rgba(255, 255, 255, 0.04); overflow-y: auto; }
.pl-tabs-list { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.pl-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 52px; padding: 4px 0; border: none; border-radius: 10px; background: none; color: rgba(255, 255, 255, 0.78); font: inherit; font-size: 12px; cursor: pointer; }
.pl-tab .pl-ico { width: 22px; height: 22px; }
.pl-tab:hover { background: rgba(255, 255, 255, 0.08); }
.pl-tab.pl-on { background: rgba(33, 132, 191, 0.45); color: #fff; font-weight: 600; }
.pl-tab:focus-visible, .pl-seg-b:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
.pl-panel-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pl-panel-title { margin: 0; padding: 14px 16px 2px; font-size: 18px; font-weight: 600; }
.pl-seg { flex-shrink: 0; display: flex; gap: 2px; margin: 10px 12px 4px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); }
.pl-seg-b { flex: 1; min-width: 0; min-height: 34px; padding: 4px 6px; border: none; border-radius: 8px; background: none; color: #fff; font: inherit; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.pl-seg-b.pl-on { background: #fff; color: #0c1218; font-weight: 600; }
.pl-note { margin: 0; padding: 16px; font-size: 14px; line-height: 1.5; color: rgba(255, 255, 255, 0.75); }
.pl-handle { width: 40px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: rgba(255, 255, 255, 0.4); flex-shrink: 0; }
.pl-panel-close { display: flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 40px; border: none; border-radius: 10px; background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.85); font-size: 16px; cursor: pointer; }
.pl-panel-close:hover { color: #fff; }
.pl-panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 8px; }
.pl-panel-body:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: -2px; }
.pl-section { margin: 0; padding: 16px 20px 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: rgba(255, 255, 255, 0.6); }
.pl-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 20px; border: none; background: none; color: #fff; text-align: left; font: inherit; cursor: pointer; }
.pl-row:hover { background: rgba(255, 255, 255, 0.08); }
.pl-row[aria-checked="true"] { background: rgba(255, 255, 255, 0.15); }
.pl-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pl-row-title { font-size: 16px; overflow-wrap: anywhere; }
.pl-row[aria-checked="true"] .pl-row-title { font-weight: 600; color: var(--pl-accent-hi); }
.pl-row-detail { font-size: 13px; color: rgba(255, 255, 255, 0.6); }
.pl-row-tick { font-size: 16px; color: var(--pl-accent-hi); visibility: hidden; }
.pl-row[aria-checked="true"] .pl-row-tick { visibility: visible; }
.pl-row-icon { display: flex; justify-content: center; width: 28px; font-size: 18px; color: rgba(255, 255, 255, 0.85); }
.pl-row-go { font-size: 12px; color: rgba(255, 255, 255, 0.5); }
.pl-info { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; padding: 14px 20px; font-size: 13px; }
.pl-info dt { color: rgba(255, 255, 255, 0.6); }
.pl-info dd { margin: 0; overflow-wrap: anywhere; }
/* Intro and Ending */
.pl-skip-season { margin: 0; padding: 14px 20px 4px; font-size: 13px; color: rgba(255, 255, 255, 0.7); overflow-wrap: anywhere; }
.pl-switch { position: relative; flex-shrink: 0; width: 44px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.36); transition: background 0.15s; }
.pl-switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.pl-skip-switch[aria-checked="true"] { background: none; }
.pl-skip-switch[aria-checked="true"] .pl-row-title { font-weight: inherit; color: inherit; }
.pl-skip-switch[aria-checked="true"] .pl-switch { background: var(--pl-accent); }
.pl-skip-switch[aria-checked="true"] .pl-switch span { transform: translateX(18px); }
.pl-skip-hint { margin: 0; padding: 0 20px 12px; font-size: 12px; line-height: 1.45; color: rgba(255, 255, 255, 0.65); }
.pl-skip-field { padding: 12px 20px; border-top: 1px solid var(--pl-border); }
.pl-skip-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pl-skip-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--pl-accent-hi); }
.pl-skip-value.pl-skip-unset { font-weight: 400; color: rgba(255, 255, 255, 0.65); }
.pl-skip-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pl-skip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 0.5px solid var(--pl-border); background: var(--pl-glass); color: #fff; font: inherit; font-size: 14px; cursor: pointer; }
.pl-skip-btn:hover:not(:disabled) { background: var(--pl-glass-hi); }
.pl-skip-btn:disabled { opacity: 0.45; cursor: default; }
.pl-skip-btn:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .pl-switch, .pl-switch span { transition: none; } }
.pl-about { display: flex; flex-direction: column; gap: 14px; padding: 12px 20px 4px; }
.pl-about-facts { margin: 0; font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.pl-about-text { margin: 0; font-size: 14px; line-height: 1.5; color: rgba(255, 255, 255, 0.85); white-space: pre-line; -webkit-user-select: text; user-select: text; }
.pl-genres { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pl-genres li { padding: 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); font-size: 11px; font-weight: 500; }
.pl-cast { display: flex; gap: 14px; margin: 0; padding: 0 20px 12px; list-style: none; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.pl-cast:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: -2px; border-radius: 8px; }
.pl-person { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 92px; text-align: center; }
.pl-person-photo { position: relative; display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 50%; overflow: hidden; border: 0.5px solid rgba(255, 255, 255, 0.18); color: rgba(255, 255, 255, 0.5); font-size: 24px; }
.pl-person-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pl-person-name, .pl-person-role { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-person-name { font-size: 11px; font-weight: 600; }
.pl-person-role { margin-top: -4px; font-size: 10px; color: rgba(255, 255, 255, 0.6); }
.pl-keys kbd { display: inline-block; min-width: 18px; padding: 2px 6px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.08); font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: #fff; }
@media (prefers-reduced-motion: reduce) {
    .pl-chrome, .pl-circle, .pl-sq, .pl-played, .pl-dot { transition: none; }
}

/* music: the bar at the bottom and the queue */
.mc-mini {
    position: sticky;
    bottom: 12px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 var(--mc-side) 12px;
    padding: 8px 10px;
    border-radius: var(--mc-r4);
    background: var(--mc-glass);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border: 1px solid var(--mc-line-strong);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}
.mc-phone .mc-mini { bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 16px); }
.mc-mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--mc-wash); }
.mc-mini-progress > span { display: block; height: 100%; background: var(--mc-brand-hi); }
.mc-mini-song { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.mc-mini-cover { position: relative; width: 42px; height: 42px; flex-shrink: 0; border-radius: var(--mc-r2); overflow: hidden; }
.mc-mini-cover .mc-glyph { font-size: 16px; }
.mc-mini-text { min-width: 0; display: flex; flex-direction: column; }
.mc-mini-name { font-size: 14px; font-weight: 600; color: var(--mc-text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-mini-artist { font-size: 12px; color: var(--mc-text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-mini-failed { color: var(--mc-danger); }
.mc-mini-buttons { display: flex; align-items: center; gap: 2px; }
.mc-mini-play { color: var(--mc-text-hi); font-size: 18px; }
.mc-queue { list-style: none; margin: 8px -8px 0; padding: 0; }
.mc-qrow { display: flex; align-items: center; gap: 4px; border-radius: var(--mc-r2); }
.mc-qrow:hover { background: var(--mc-wash); }
.mc-qplay { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px; border: none; background: none; text-align: left; cursor: pointer; }
.mc-qn { width: 26px; flex-shrink: 0; text-align: right; font-size: 12px; color: var(--mc-text-low); font-variant-numeric: tabular-nums; }
.mc-here .mc-qn { color: var(--mc-brand-hi); }
.mc-qtext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mc-qname { font-size: 14px; color: var(--mc-text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-here .mc-qname { color: var(--mc-brand-hi); font-weight: 600; }
.mc-qsub { font-size: 12px; color: var(--mc-text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-qlen { font-size: 12px; color: var(--mc-text-mid); font-variant-numeric: tabular-nums; }
/* the bar's song opens the full player */
.mc-mini-song { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--mc-r2); }
.mc-mini-song:focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 2px; }

/* music: the full player (now_playing.rs), always dark, its light from the cover, as the apps' audio stage. The cover
   and the words stand out of the pointer's way: taps on them reach the surface behind (double tap, hold). */
.ap-root { position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; background: #0b0f14; --pl-panel: rgba(16, 22, 30, 0.6); --ap-tint: rgb(75 168 219); --ap-tint-rgb: 75 168 219; -webkit-touch-callout: none; touch-action: manipulation; }
/* see-through, with no blur, as the owner settled for the audio panels */
.ap-root .pl-panel { -webkit-backdrop-filter: none; backdrop-filter: none; }
.ap-light { position: absolute; inset: 0; overflow: hidden; background: #0b0f14; pointer-events: none; }
.ap-light-img { position: absolute; left: -18%; top: -18%; width: 136%; height: 136%; object-fit: cover; opacity: 0; filter: blur(56px) saturate(1.5); transition: opacity 0.7s ease-out; }
.ap-light-img.ap-light-on { opacity: var(--ap-room, 0.62); }
.ap-light::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(8, 11, 15, 0.34), rgba(8, 11, 15, 0.58) 60%, rgba(8, 11, 15, 0.8)); }
.ap-surface { position: absolute; inset: 0; z-index: 1; }
.ap-top, .ap-main, .ap-bottom { position: relative; z-index: 2; }
.ap-top { flex: none; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.ap-top > * { pointer-events: auto; }
.ap-top > .pl-grow { pointer-events: none; }
.ap-main, .ap-sleeve, .ap-cover-box, .ap-cover, .ap-info { pointer-events: none; }
.ap-info a, .ap-info button, .ap-pane { pointer-events: auto; }
.ap-bottom { flex: none; }
/* the cover: the largest square its box holds; paused it settles back */
.ap-cover-box { position: relative; min-width: 0; min-height: 0; container-type: size; }
.ap-cover { position: absolute; left: 0; top: 0; display: flex; align-items: center; justify-content: center; width: min(78vw, 40vh); height: min(78vw, 40vh); width: 100cqmin; height: 100cqmin; overflow: hidden; border-radius: 14px; background: linear-gradient(135deg, #2a3644, #151c25); box-shadow: 0 24px 72px -18px rgb(var(--ap-tint-rgb) / 0.5), 0 4px 16px rgba(0, 0, 0, 0.4); transform: scale(0.94); transition: transform 0.42s ease-out, box-shadow 0.42s ease-out; }
.ap-playing .ap-cover { transform: none; }
.ap-cover-glyph { font-size: 22cqmin; color: rgba(255, 255, 255, 0.34); }
.ap-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.ap-no-cover .ap-cover-img { display: none; }
/* the words */
.ap-info { display: flex; flex-direction: column; min-width: 0; }
.ap-song { margin: 0; font-size: var(--ap-title, 22px); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ap-artist { margin: 2px 0 0; font-size: var(--ap-artist, 17px); line-height: 1.3; color: rgba(255, 255, 255, 0.86); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-root .ap-album { width: fit-content; max-width: 100%; margin-top: 2px; font-size: var(--ap-album, 14px); line-height: 1.35; color: rgba(255, 255, 255, 0.76); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; }
.ap-root .ap-album:hover { color: #fff; text-decoration: underline; }
.ap-album:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
.ap-place { margin: 2px 0 0; font-size: var(--ap-small, 12px); line-height: 1.4; color: rgba(255, 255, 255, 0.72); }
/* the signal line: one line, cut at its end; the path amber when something changes the sound */
.ap-root .ap-signal { display: inline-flex; align-items: center; gap: 6px; width: fit-content; max-width: 100%; min-height: 26px; margin-top: 10px; padding: 2px 10px 2px 3px; border: 0; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.78); font: inherit; font-size: var(--ap-signal, 12px); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: left; cursor: pointer; }
.ap-root .ap-signal:hover { background: rgba(255, 255, 255, 0.14); }
.ap-signal:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
.ap-sig-chip { flex: none; padding: 2px 8px; border-radius: 999px; }
/* its first chip: DSD and Atmos in the apps' colours (white on each is 4.9:1 or more), lossless in a calm blue */
.pl-badge.pl-badge-dsd { border-color: transparent; background: #B35400; color: #fff; }
.pl-badge.pl-badge-hires { border-color: transparent; background: #1c4966; color: #fff; }
.pl-badge.pl-badge-lossless { border-color: transparent; background: #1c4966; color: #fff; }
.pl-badge.pl-badge-channels { border-color: transparent; background: #6D28D9; color: #fff; }
.ap-signal .pl-badge:not(.pl-badge-dsd):not(.pl-badge-atmos):not(.pl-badge-lossless):not(.pl-badge-hires) { border-color: transparent; background: rgba(255, 255, 255, 0.16); }
.ap-sig-part { flex: none; }
.ap-sig-arrow { flex: none; color: rgba(255, 255, 255, 0.62); }
.ap-sig-out { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ap-warn { color: #ffcc66; font-weight: 600; }
/* a note above the seek bar: the browser wants a tap */
.ap-root .ap-tap { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin-bottom: 8px; border: 0; border-radius: 12px; background: #fff; color: #0c1218; font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.ap-tap:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
/* the seek bar takes the cover's colour; selected controls stay brand blue */
.ap-root .pl-played { background: var(--ap-tint); }
.ap-root .pl-dot { box-shadow: 0 0 0 4px rgb(var(--ap-tint-rgb) / 0.4), 0 1px 3px rgba(0, 0, 0, 0.5); }
.ap-seek-row { display: flex; align-items: center; gap: 12px; }
.ap-seek-row .pl-seek { flex: 1; min-width: 0; }
.ap-seek-row .pl-time { margin: 0; }
.ap-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; }
.ap-left { flex: 0 1 auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.ap-volume { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ap-tools { flex: none; display: flex; align-items: center; gap: 8px; }
.ap-root .pl-transport { gap: var(--ap-gap, 12px); }
.ap-root .pl-transport .pl-circle.pl-file { width: var(--ap-file, 48px); height: var(--ap-file, 48px); font-size: 17px; }
.ap-root .pl-transport .pl-circle.pl-step { width: var(--ap-step, 44px); height: var(--ap-step, 44px); font-size: 17px; }
.ap-root .pl-transport .pl-circle.pl-play { width: var(--ap-play, 60px); height: var(--ap-play, 60px); font-size: 24px; }
/* opened, and waiting for more of it: a ring on Play */
.ap-root .pl-play.ap-busy::after, .mc-mini-play.mc-busy::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--pl-accent-hi, #4ba8db); border-right-color: var(--pl-accent-hi, #4ba8db); animation: ap-spin 0.9s linear infinite; pointer-events: none; }
@keyframes ap-spin { to { transform: rotate(360deg); } }
.mc-mini-play { position: relative; }
.mc-mini-play.mc-busy::after { inset: 0; border-width: 2px; border-top-color: var(--mc-brand-hi); border-right-color: var(--mc-brand-hi); }
.ap-root .pl-wait { z-index: 6; }
.ap-root .pl-step-osd { top: 72px; }
.ap-root .pl-osd { z-index: 7; }
.ap-has-panel .pl-step-osd, .ap-has-panel .pl-osd, .ap-has-panel .ap-error { left: calc((100% - 436px) / 2); }
.ap-has-panel .pl-wait { left: 0; right: 436px; }
/* the pane: lyrics or the queue */
.ap-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ap-pane-tabs { flex: none; display: flex; gap: 4px; margin-bottom: 8px; }
.ap-root .ap-pane-tab { min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: none; color: rgba(255, 255, 255, 0.78); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.ap-root .ap-pane-tab:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.ap-root .ap-pane-tab.pl-on { background: rgba(255, 255, 255, 0.16); color: #fff; }
.ap-pane-tab:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
/* the queue: in the pane, the panel and the sheet over an album's page */
.ap-queue { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.ap-pane .ap-queue { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.24) transparent; }
.ap-qhead { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; font-size: 14px; }
.ap-qsummary { flex: 1; min-width: 0; color: var(--mc-text-mid); }
/* what the queue says of itself: a cue sheet's tracks left out, and why */
.ap-qnote { display: flex; gap: 8px; align-items: baseline; margin: 0 8px 8px; padding: 8px 12px; border-radius: 10px; background: var(--mc-wash); color: var(--mc-text-hi); font-size: 13px; line-height: 1.45; }
.ap-qnote i { flex: none; }
.ap-root .ap-qnote { background: rgba(255, 255, 255, 0.1); color: #fff; }
.mc-qrow-wrap { list-style: none; }
.ap-qmore { flex: none; }
.ap-qmenu { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 8px 12px 44px; }
.ap-ask { margin: 0 8px 8px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 128, 120, 0.12); font-size: 14px; }
.ap-ask p { margin: 0 0 10px; line-height: 1.4; }
.ap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-chips-pad { padding: 0 20px; }
.ap-chip { min-height: 36px; min-width: 56px; padding: 4px 12px; border: 0; border-radius: 10px; background: var(--mc-wash); color: var(--mc-text-hi); font: inherit; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer; }
.ap-chip:hover { filter: brightness(1.15); }
.ap-chip:focus-visible { outline: 2px solid var(--mc-brand-hi); outline-offset: 2px; }
.ap-danger { background: #ffb4ab; color: #2a0a06; }
.ap-root .mc-queue { margin: 0; }
.ap-root .ap-chip { background: rgba(255, 255, 255, 0.12); color: #fff; }
.ap-root .ap-chip.pl-on { background: var(--pl-accent); color: #fff; }
.ap-root .ap-chip.ap-danger { background: #ffb4ab; color: #2a0a06; }
.ap-root .ap-chip:focus-visible { outline-color: var(--pl-accent-hi); }
.ap-root .ap-qsummary { color: rgba(255, 255, 255, 0.78); }
.ap-root .mc-qrow:hover { background: rgba(255, 255, 255, 0.08); }
.ap-root .mc-qplay { color: #fff; font: inherit; }
.ap-root .mc-qn { color: rgba(255, 255, 255, 0.62); }
.ap-root .mc-qname { color: #fff; }
.ap-root .mc-qsub, .ap-root .mc-qlen { color: rgba(255, 255, 255, 0.7); }
.ap-root .mc-here { background: rgb(var(--ap-tint-rgb) / 0.16); }
.ap-root .mc-here .mc-qn { color: var(--ap-tint); }
.ap-root .mc-here .mc-qname { color: #fff; font-weight: 600; }
.ap-root .mc-qn .pl-ico { width: 18px; height: 18px; margin-left: auto; }
.mc-qn .pl-ico { width: 18px; height: 18px; margin-left: auto; }
.ap-root .ap-qmore { color: rgba(255, 255, 255, 0.82); }
.mc-qplay:focus-visible, .ap-qmore:focus-visible { outline: 2px solid var(--pl-accent-hi, var(--mc-brand-hi)); outline-offset: -2px; border-radius: 8px; }
.ap-note { margin: 4px 20px 8px; font-size: 13px; line-height: 1.45; color: rgba(255, 255, 255, 0.78); }
.ap-note:empty { display: none; }
.ap-note-tight { margin-top: 0; }
.ap-seg { margin: 0 20px; }
.ap-row-static { cursor: default; }
.ap-row-static:hover { background: none; }
.ap-vol-row { display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.ap-vol-row .pl-vol-inline { flex: 1; min-width: 0; margin: 0; }
.ap-vol-pct { flex: none; width: 44px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.78); }
.ap-plain-list { margin: 0; padding: 0 20px 8px; list-style: none; font-size: 14px; line-height: 1.7; }
.ap-about-name { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
/* the chain: source, path, output, joined in the cover's colour */
.ap-chain { display: grid; margin: 0; padding: 0 20px; list-style: none; }
.ap-chain li { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 8px 0 8px 18px; font-size: 14px; }
.ap-chain li::before { content: ""; position: absolute; left: 3px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--ap-tint); }
.ap-chain li:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 25px; bottom: -14px; width: 2px; background: rgb(var(--ap-tint-rgb) / 0.4); }
.ap-chain-k { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.ap-chain-v { overflow-wrap: anywhere; }
/* what went wrong */
.ap-error { position: absolute; left: 50%; top: 50%; z-index: 8; transform: translate(-50%, -50%); width: min(92%, 440px); box-sizing: border-box; padding: 24px; border-radius: 18px; border: 1px solid var(--pl-border); background: rgba(20, 28, 38, 0.98); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.ap-error h3 { margin: 0 0 8px; font-size: 19px; font-weight: 650; line-height: 1.3; }
.ap-error p { margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: rgba(255, 255, 255, 0.86); }
.ap-root .ap-error .ap-error-meta { font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, 0.72); overflow-wrap: anywhere; }
.ap-error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ap-root .ap-action { flex: 1 1 auto; min-height: 44px; padding: 8px 16px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); color: #fff; font: inherit; font-size: 15px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.ap-root .ap-action:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.ap-root .ap-action:disabled { opacity: 0.45; cursor: default; }
.ap-root .ap-action-primary { background: #fff; color: #0c1218; box-shadow: none; }
.ap-root .ap-action-primary:hover:not(:disabled) { background: #dff0fb; }
.ap-action:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }

/* wide: the cover and the pane side by side, one row along the bottom */
.ap-wide { --ap-title: 26px; --ap-artist: 18px; --ap-album: 15px; --ap-small: 13px; --ap-signal: 13px; }
.ap-wide .ap-top { padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
.ap-wide .ap-main { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr); gap: 48px; padding: 12px max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left)); }
.ap-wide .ap-sleeve { display: flex; flex-direction: column; min-height: 0; }
.ap-wide .ap-cover-box { flex: 1 1 0; min-height: 120px; }
.ap-wide .ap-info { flex: none; margin-top: 16px; }
.ap-wide .ap-bottom { padding: 0 max(24px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
.ap-wide .pl-panel { top: 16px; right: 16px; bottom: 16px; }
.ap-has-panel .ap-pane { visibility: hidden; }
.ap-has-panel .ap-bottom { margin-right: 436px; }
.ap-has-panel .ap-top .pl-circle:not(:first-child) { visibility: hidden; }

/* a column: a phone upright, and a narrow window. Two rows at the bottom, the only place that's allowed */
.ap-phone .ap-top { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
.ap-phone .ap-main { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding: 8px max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
.ap-phone .ap-sleeve { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.ap-phone .ap-cover-box { flex: 1 1 0; min-height: 96px; }
.ap-phone .ap-cover { right: 0; margin-inline: auto; }
.ap-phone .ap-info { flex: none; margin-top: 14px; }
.ap-phone .ap-bottom { padding: 2px max(24px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
.ap-phone .ap-seek-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.ap-phone .ap-seek-row .pl-seek { grid-column: 1 / 3; grid-row: 1; }
.ap-phone .ap-elapsed { grid-column: 1; grid-row: 2; margin-top: -2px; }
.ap-phone .ap-left-time { grid-column: 2; grid-row: 2; margin-top: -2px; justify-self: end; }
.ap-phone .ap-controls { display: block; margin-top: 4px; }
.ap-phone .ap-left { justify-content: center; margin-bottom: 6px; }
.ap-phone .pl-transport { justify-content: center; }
.ap-phone .ap-seek-row .pl-time { font-size: 13px; }
/* the lyrics in the cover's place: a small cover and the song over them */
.ap-phone.ap-lyrics-on .ap-sleeve { flex: none; flex-direction: row; align-items: center; gap: 12px; }
.ap-phone.ap-lyrics-on .ap-cover-box { flex: none; width: 56px; height: 56px; min-height: 0; }
.ap-phone.ap-lyrics-on .ap-cover { right: auto; margin-inline: 0; border-radius: 8px; box-shadow: none; transform: none; }
.ap-phone.ap-lyrics-on .ap-info { flex: 1 1 0; margin: 0; }
.ap-phone.ap-lyrics-on .ap-album, .ap-phone.ap-lyrics-on .ap-place, .ap-phone.ap-lyrics-on .ap-signal { display: none; }
.ap-phone.ap-lyrics-on .ap-song { font-size: calc(var(--ap-title, 22px) * 0.78); -webkit-line-clamp: 1; }
.ap-phone.ap-lyrics-on .ap-artist { font-size: calc(var(--ap-artist, 17px) * 0.82); }
.ap-phone .ap-pane { flex: 1 1 0; min-height: 0; margin-top: 8px; }
.ap-phone .pl-panel.pl-sheet, .ap-side .pl-panel.pl-sheet { height: 66%; border-radius: 24px 24px 0 0; }
.ap-panel-over .ap-bottom { visibility: hidden; }
/* no blur on the panel, so what's written under a sheet would run into what's written on it; the dim keeps its text at
   4.5:1 over the brightest cover */
.ap-phone.ap-panel-over .ap-info, .ap-phone.ap-panel-over .ap-pane { visibility: hidden; }
.ap-root .pl-dim { background: rgba(0, 0, 0, 0.45); }
.ap-phone .pl-keys { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.ap-root.pl-phone .pl-seg-b { padding: 4px 2px; font-size: 12px; }
/* a phone's transport, and a tighter one with the 10 s buttons */
.ap-phone.pl-phone { --ap-play: 68px; --ap-step: 48px; --ap-file: 52px; --ap-gap: 24px; }
.ap-phone.pl-phone.ap-long { --ap-play: 64px; --ap-step: 44px; --ap-file: 44px; --ap-gap: 10px; }
.ap-phone .pl-tools-named.ap-named { margin: 0 -8px; }
.ap-named .pl-sq { height: 56px; }
.ap-root .ap-named .pl-sq:focus-visible { outline-offset: -2px; border-radius: 12px; }
/* a mobile browser's own edge swipe stays the browser's: nothing here reacts to it */
.touch-device .ap-root { overscroll-behavior: none; }

/* a phone on its side: the cover at the left at full height, everything else beside it in one row */
.ap-side { --ap-title: 18px; --ap-artist: 14px; --ap-album: 12px; --ap-small: 12px; --ap-signal: 12px; --ap-play: 56px; --ap-step: 44px; --ap-file: 44px; --ap-gap: 8px; display: grid; grid-template-columns: minmax(180px, 38%) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.ap-side .ap-light, .ap-side .ap-surface { grid-column: 1 / -1; grid-row: 1 / -1; }
.ap-side .ap-main, .ap-side .ap-sleeve { display: contents; }
.ap-side .ap-top { grid-column: 2; grid-row: 1; padding: 10px max(16px, env(safe-area-inset-right)) 0 0; }
.ap-side .ap-cover-box { position: relative; z-index: 2; grid-column: 1; grid-row: 1 / -1; align-self: stretch; margin: 12px 20px 12px max(16px, env(safe-area-inset-left)); }
.ap-side .ap-cover { inset: 0; margin: auto; }
.ap-side .ap-info { position: relative; z-index: 2; grid-column: 2; grid-row: 2; align-self: center; padding-right: max(16px, env(safe-area-inset-right)); min-height: 0; overflow: hidden; }
.ap-side .ap-place { display: none; }
.ap-side .ap-pane { position: relative; z-index: 2; grid-column: 2; grid-row: 3; padding-right: max(16px, env(safe-area-inset-right)); min-height: 0; }
.ap-side .ap-bottom { grid-column: 2; grid-row: 3; padding: 0 max(16px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) 0; }
.ap-side .ap-controls { gap: 8px; }
.ap-side .pl-tools-named.ap-named { display: flex; flex: none; gap: 0; margin: 0; }
.ap-side .ap-named .pl-sq { width: 54px; height: 50px; }
.ap-side .ap-seek-row .pl-time { font-size: 12px; }
.ap-side.ap-lyrics-on { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.ap-side.ap-lyrics-on .ap-pane { grid-row: 3; }
.ap-side.ap-lyrics-on .ap-bottom { grid-row: 4; }
.ap-side.ap-lyrics-on .ap-info { grid-row: 2; }
.ap-side.ap-lyrics-on .ap-album, .ap-side.ap-lyrics-on .ap-signal, .ap-side.ap-lyrics-on .ap-artist { display: none; }
.ap-side.ap-lyrics-on .ap-song { font-size: 15px; -webkit-line-clamp: 1; }
.ap-side .pl-panel.pl-docked { top: 8px; right: max(16px, env(safe-area-inset-right)); bottom: 8px; width: min(420px, 62%); padding-right: 0; border-radius: 18px; }
.ap-side.ap-panel-over .ap-info, .ap-side.ap-panel-over .ap-top { visibility: hidden; }
.ap-root.ap-side .ly-now { min-height: 40px; margin-top: 6px; }
.ap-side .ly-now-words { font-size: 15px; }
/* a short window that is no phone: the words in less room */
@media (max-height: 620px) {
    .ap-wide .ap-info { margin-top: 8px; }
    .ap-wide .ap-signal { margin-top: 6px; }
    .ap-wide { --ap-title: 20px; --ap-artist: 15px; --ap-album: 13px; --ap-small: 12px; }
    .ap-phone .ap-place { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ap-cover, .ap-light-img { transition: none; }
    .ap-root .pl-play.ap-busy::after, .mc-mini-play.mc-busy::after { animation-duration: 3s; }
}

/* lyrics (lyrics/view.rs): start-aligned bold lines, the lit one white, the others dimmed; the lit line follows the
   music about 30% down */
.ly-view { flex: 1; min-height: 0; width: 100%; display: flex; }
.ly-scroll { flex: 1; min-height: 0; position: relative; container-type: size; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; outline: none;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 86%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 86%, transparent); }
.ly-scroll::-webkit-scrollbar { display: none; }
.ly-scroll:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: -2px; border-radius: 8px; }
.ly-lines { margin: 0; padding: 30vh 0 55vh; padding: 30cqh 0 62cqh; list-style: none; }
.ly-li { margin: 0; font-size: 30px; }
.ap-root .ly-line { display: block; width: 100%; margin: 0 0 0.3em; padding: 0.25em 0.3em; border: 0; border-radius: 10px; background: none; color: rgba(255, 255, 255, 0.5); font: inherit; font-weight: 700; line-height: 1.3; text-align: start; overflow-wrap: anywhere; cursor: pointer; transition: color 0.3s ease; }
.ap-root .ly-line:hover { background: rgba(255, 255, 255, 0.07); }
.ly-line:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 0; }
.ap-root .ly-browsing .ly-line { color: rgba(255, 255, 255, 0.7); }
.ap-root .ly-line.ly-on { color: #fff; }
.ly-words { display: block; }
.ly-tr { display: block; margin-top: 0.15em; font-size: 0.65em; font-weight: 400; white-space: pre-line; color: rgba(255, 255, 255, 0.55); }
.ly-on .ly-tr { color: rgba(255, 255, 255, 0.85); }
.ly-pause { min-height: 0.2em; }
.ly-dots { display: inline-flex; gap: 0.3em; padding: 0.35em 0.3em 0.6em; transform-origin: left center; animation: ly-breathe 2.4s ease-in-out infinite; }
.ly-dots > span { width: 0.38em; height: 0.38em; border-radius: 50%; background: var(--ap-tint, #fff); }
@keyframes ly-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
.ap-root:not(.ap-wide) .ly-li { font-size: 24px; }
.ap-side .ly-li { font-size: 18px; }
/* plain lyrics: shown as they are, under a caption */
.ly-plain .ly-scroll { padding: 8px 0 40px; -webkit-mask-image: linear-gradient(to bottom, #000 88%, transparent); mask-image: linear-gradient(to bottom, #000 88%, transparent); }
.ly-caption { margin: 0 0 18px; font-size: 13px; color: rgba(255, 255, 255, 0.75); }
.ly-pline { margin: 0 0 0.35em; font-size: 22px; font-weight: 700; line-height: 1.35; color: rgba(255, 255, 255, 0.85); -webkit-user-select: text; user-select: text; }
.ly-break { height: 0.8em; margin: 0; }
/* the lit line alone under the cover: it keeps its room (two lines and a translation) */
.ap-root .ly-now { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; width: 100%; min-height: 62px; margin: 10px 0 0; padding: 0; border: 0; border-radius: 10px; background: none; color: #fff; font: inherit; text-align: left; cursor: pointer; }
.ly-now:hover { background: rgba(255, 255, 255, 0.06); }
.ly-now:focus-visible { outline: 2px solid var(--pl-accent-hi); outline-offset: 2px; }
.ly-now-text { display: flex; flex-direction: column; gap: 2px; max-width: 100%; animation: ly-fade 0.25s ease-out; }
.ly-now-words { font-size: 18px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ap-wide .ly-now-words { font-size: 19px; }
.ly-now-tr { font-size: 14px; color: rgba(255, 255, 255, 0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes ly-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .ly-line { transition: none; }
    .ly-now-text, .ly-dots { animation: none; }
}

/* a touch screen keeps :hover on what was last tapped: no card stays lifted after coming back to its page */
@media (hover: none) {
    .mc-card:hover:not(:focus-visible) .mc-art, .mc-tile:hover:not(:focus-visible) .mc-tile-art { transform: none; box-shadow: none; }
    .mc-card-box:hover .mc-art:not(:focus-visible) { transform: none; box-shadow: none; }
    .mc-banner:hover:not(:focus-visible) .mc-art { box-shadow: none; }
}

/* a phone: what is tapped is at least 36px (the carousel's arrows, Show more, the segments) */
.mc-phone .mc-feat-controls .mc-round { width: 36px; height: 36px; font-size: 13px; }
.mc-phone .mc-dot { position: relative; }
.mc-phone .mc-dot::after { content: ""; position: absolute; inset: -12px -3px; }
.mc-phone .mc-more-btn { min-height: 36px; padding: 6px 14px; }
.mc-phone .mc-seg { height: 36px; min-width: 36px; }
/* an album's Play and Shuffle share the first row, its smaller buttons the next, as Apple Music's */
.mc-stacked .mc-actions { justify-content: center; }
.mc-stacked .mc-actions > .mc-half { flex: 1 1 40%; }
/* the bar at the bottom: the song's name gets the room */
.mc-phone .mc-mini { gap: 8px; }
/* a long press on the bar isn't the browser's menu */
.touch-device .mc-mini { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ---------- the file browser's player (pages/media_client/file_player.rs): the media client's players over the file
   browser. The host takes no room of its own; the video player and the full music player are fixed over the window
   as on the media pages, and the music's bar is fixed at the bottom of the window, over the file browser's page
   (--fp-left and --fp-width: where that page lies), above a phone's tab bar ---------- */
.fp-host { flex: 0 0 auto; height: 0; }
.fp-host .mc-mini {
    position: fixed;
    left: calc(var(--fp-left, 0px) + 12px);
    width: calc(var(--fp-width, 100vw) - 24px);
    bottom: 12px;
    margin: 0;
    z-index: 90;
    box-sizing: border-box;
}
.fp-host.mc-phone .mc-mini {
    left: calc(var(--fp-left, 0px) + 8px);
    width: calc(var(--fp-width, 100vw) - 16px);
    bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 16px);
}
/* the page's lists, their foot and the properties end above the bar while it shows; a phone's lists already scroll
   under its floating tab bar, and scroll further for the bar above it */
.files-page.fp-has-bar .files-content-area { margin-bottom: 80px; }
@media (max-width: 768px) {
    .files-page.fp-has-bar .files-content-area { margin-bottom: 0; }
    .files-page.fp-has-bar .file-list-scroll-area,
    .files-page.fp-has-bar .file-props-scroll { padding-bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 100px); }
}

/* App Pro's ten-second demo in the file browser's player (pro_demo.rs): the banner while it runs, the dialog after.
   Always dark, over a picture or the file browser alike. */
.pd-banner {
    position: fixed;
    top: 16px;
    left: 0;
    right: 0;
    z-index: 1400;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: fit-content;
    max-width: calc(100% - 24px);
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
}
/* over the video player's picture, under its top bar and its notes; it goes to full screen with the player */
.pd-banner.pd-inside { position: absolute; top: 128px; z-index: 7; }
.pd-icon { flex-shrink: 0; font-size: 14px; }
.pd-crown { color: #f59e0b; }
.pd-text { min-width: 0; font-variant-numeric: tabular-nums; }
.pd-banner button, .pd-wall button {
    flex-shrink: 0;
    border: 0;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.pd-banner button:focus-visible, .pd-wall button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pd-banner .pd-upgrade, .pd-wall .pd-upgrade { background: #f59e0b; color: #0f172a; }
.pd-wall {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
}
.pd-wall-box { max-width: 440px; padding: 32px 16px; text-align: center; }
.pd-wall-icon { display: block; margin-bottom: 16px; font-size: 48px; }
.pd-wall-box h2 { margin: 0 0 12px; font-size: 22px; font-weight: 600; color: #fff; }
.pd-wall-box p { margin: 0 0 24px; font-size: 15px; line-height: 1.5; color: #cbd5e1; }
.pd-wall-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.pd-wall .pd-wall-actions button { min-height: 44px; padding: 12px 28px; border-radius: 8px; font-size: 15px; }
.pd-wall .pd-wall-actions button i { margin-right: 8px; }
.pd-wall .pd-close { background: #fff; color: #0f172a; }
/* a disc image's or a cue sheet's tables being read, before either player opens (file_player.rs ReadingNote): over
   the file browser, above the music's bar and a phone's tab bar */
.fp-busy {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 96px;
    z-index: 1400;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: fit-content;
    max-width: calc(100% - 24px);
    padding: 10px 12px 10px 16px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
}
.fp-host.mc-phone .fp-busy { bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 96px); }
/* over the media tokens' `button { color: inherit }` */
.fp-busy .fp-busy-cancel {
    flex-shrink: 0;
    min-height: 32px;
    border: 0;
    border-radius: 6px;
    padding: 6px 14px;
    background: #fff;
    color: #0f172a;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.fp-busy .fp-busy-cancel:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (max-width: 768px) {
    .mc-hero { flex-direction: column; }
    .mc-hero-poster { width: 160px; }
    .mc-header-title { font-size: 16px; }
    .mc-slide-text { left: 16px; bottom: 16px; }
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}
/* Back arrow for sub-pages — hidden on desktop, shown on mobile/touch.
   Placed inside <h1> so it stays on the same line as the title. */
.mobile-back-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0 8px 0 0;
    font-size: 0.8em;
    vertical-align: middle;
    -webkit-tap-highlight-color: transparent;
}
.touch-device .mobile-back-btn { display: inline; }

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

.version-badge {
    font-size: 13px;
    padding: 2px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn:hover { background: var(--bg-secondary); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); border-color: color-mix(in srgb, var(--danger) 85%, #000); }

.btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.btn-sm { padding: 6px 12px; font-size: 14px; min-height: 32px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(220, 53, 69, 0.08);
    border-radius: var(--border-radius);
}

.input-group {
    display: flex;
    align-items: stretch;
    position: relative;
}
.input-group .form-input {
    padding-left: 36px;
}
.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 1;
}
.input-addon {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
}

.form-check { display: flex; align-items: center; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ---------- Password Input ---------- */
.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.password-input-wrap .form-input {
    padding-right: 36px;
    width: 100%;
}
.password-toggle-btn {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    font-size: 13px;
    line-height: 1;
}
.password-toggle-btn:hover { color: var(--text-primary); }
.form-text-muted, .form-help {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.encrypt-password-warning {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    border-radius: var(--border-radius);
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}
.encrypt-password-warning > i {
    color: #e6a700;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}
.encrypt-password-warning strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 13px;
}
.encrypt-password-warning p { margin: 0; }

/* ---------- Alerts ---------- */
.alert {
    padding: 10px 14px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error, .alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: var(--danger);
}
.alert-success {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: var(--success);
}
.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: var(--warning);
}
.alert-info {
    background: rgba(23, 162, 184, 0.1);
    border: 1px solid rgba(23, 162, 184, 0.3);
    color: var(--info);
}

/* ---------- Cards ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.storage-card, .mount-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    transition: var(--transition);
}
.storage-card:hover, .mount-card:hover {
    box-shadow: var(--shadow-hover);
}

.storage-header, .mount-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.storage-icon, .mount-icon {
    font-size: 24px;
    color: var(--primary);
}

.storage-info, .mount-info { flex: 1; }
.storage-name, .mount-path {
    font-weight: 600;
    font-size: 14px;
}
.storage-user, .mount-source {
    font-size: 12px;
    color: var(--text-secondary);
}

.storage-actions {
    display: flex;
    gap: 8px;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}
.badge-success {
    background: rgba(25, 135, 84, 0.15);
    color: var(--success);
}
.badge-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.badge-tag {
    text-transform: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 500;
    gap: 4px;
}
.badge-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 2px;
    font-size: 10px;
    line-height: 1;
}
.badge-remove:hover { color: var(--danger); }
.string-list-editor { display: flex; flex-direction: column; gap: 8px; }
.string-list-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.string-list-input { max-width: 300px; }

/* ---------- Dashboard ---------- */
.dashboard-page {
    max-width: 1800px;
    margin: 0 auto;
}
.dashboard-header {
    text-align: center;
    margin-bottom: 2rem;
}
.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.dashboard-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Dashboard header */
.dashboard-header {
    margin-bottom: 24px;
}
.dashboard-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}
.dashboard-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
}

/* Function cards grid */
.function-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
@media (min-width: 1100px) {
    .function-cards {
        grid-template-columns: repeat(7, 1fr);
    }
    /* eight with the Media card: two rows of four until eight fit in one */
    .function-cards:has(> :nth-child(8)) {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (min-width: 1440px) {
    .function-cards:has(> :nth-child(8)) {
        grid-template-columns: repeat(8, 1fr);
    }
}
.function-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.25rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}
.function-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-primary);
}
.function-card .fc-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    margin-bottom: 10px;
}
.function-card .fc-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}
.function-card .fc-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
    min-height: 32px;
}
.function-card .fc-stat {
    font-size: 1.5rem;
    font-weight: 700;
}
.function-card .fc-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 2px;
}
.function-card.disabled {
    opacity: 0.5;
    cursor: default;
}
.function-card.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Icon color variants */
.fc-icon.files     { background: linear-gradient(135deg, #667eea, #764ba2); }
.fc-icon.mounts    { background: linear-gradient(135deg, #f093fb, #f5576c); }
.fc-icon.media     { background: linear-gradient(135deg, #ff5f6d, #845ec2); }
.fc-icon.clouds    { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.fc-icon.backups   { background: linear-gradient(135deg, #fa709a, #fee140); }
.fc-icon.webdav    { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.fc-icon.tokens    { background: linear-gradient(135deg, #f7971e, #ffd200); }
.fc-icon.membership { background: linear-gradient(135deg, #fbc2eb, #a18cd1); }

/* Recent Files section */
.recent-files-section {
    margin-top: 1.5rem;
}
.recent-files-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.recent-files-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    padding: 2px 6px;
}
.recent-files-title:hover { background: var(--bg-secondary); }
.recent-files-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.recent-files-title i { color: var(--text-secondary); font-size: 0.9rem; }
.recent-files-title .section-toggle { font-size: 0.7rem; width: 0.8rem; text-align: center; }
.recent-files-show-all {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    transition: background 0.15s;
}
.recent-files-show-all:hover { background: var(--bg-secondary); }
.recent-files-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
    gap: 0.5rem;
}
.recent-files-empty i { font-size: 1.5rem; opacity: 0.5; }
.recent-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.5rem;
}
.recent-file-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
    color: var(--text-primary);
    font: inherit;
}
.recent-file-card:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.recent-file-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--accent);
    font-size: 0.9rem;
}
.recent-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.recent-file-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recent-file-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Recent Files Modal */
.recent-files-modal { max-width: 640px; }
.recent-files-modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}
.recent-files-modal-body {
    max-height: 60vh;
    overflow-y: auto;
}
.recent-files-list {
    display: flex;
    flex-direction: column;
}
.recent-file-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.recent-file-row:last-child { border-bottom: none; }
.recent-file-row-main {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    color: var(--text-primary);
    font: inherit;
    min-width: 0;
    transition: background 0.15s;
}
.recent-file-row-main:hover { background: var(--bg-secondary); }
.recent-file-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all 0.15s;
    font-size: 0.8rem;
}
.recent-file-remove:hover { background: var(--bg-secondary); color: var(--danger); }

/* Full-page recent files list */
.recent-files-list-page {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
}

/* Stats grid (bottom panels) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}
.stat-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}
.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-primary);
}
.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.stat-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.stat-icon.info     { background: rgba(13, 202, 240, 0.1); color: var(--info); }
.stat-icon.success  { background: rgba(25, 135, 84, 0.1);  color: var(--success); }
.stat-icon.primary  { background: rgba(13, 110, 253, 0.1); color: var(--primary); }

/* Tasks grid inside stat card */
.tasks-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
.task-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
}
.task-item .task-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}
.task-icon.copy     { background: rgba(255, 193, 7, 0.15);  color: #ffc107; }
.task-icon.download { background: rgba(33, 150, 243, 0.15); color: #2196f3; }
.task-icon.upload   { background: rgba(76, 175, 80, 0.15);  color: #4caf50; }
.task-item .task-count {
    font-size: 1.1rem;
    font-weight: 700;
}
.task-item .task-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

/* Online devices stat */
.stat-value-large {
    font-size: 2rem;
    font-weight: 700;
}
.stat-subtitle {
    font-size: 0.85rem;
    color: var(--success);
}
.stat-subtitle i { margin-right: 4px; }

/* Performance mini stats */
.perf-stats-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.perf-stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}
.perf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.perf-dot.cpu      { background: #ff6b6b; }
.perf-dot.memory   { background: #9c27b0; }
.perf-dot.dl       { background: #2196f3; }
.perf-dot.ul       { background: #4caf50; }
.perf-label {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.perf-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ---------- File Browser ---------- */
.content-body:has(.files-page) { padding: 0; }
.app-content:has(.files-page) { background: var(--bg-file-container, var(--bg-secondary)); }
.files-page { display: flex; flex-direction: column; height: calc(100vh - var(--header-height)); background: var(--bg-file-container, var(--bg-secondary)); padding: 0 12px; }

/* Breadcrumb bar (Row 1) */
.files-breadcrumb-bar {
    display: flex;
    align-items: center;
    padding: 6px 0;
    gap: 8px;
}
.files-breadcrumb-bar .breadcrumb { flex: 1; min-width: 0; }
.breadcrumb-edit-btn { flex-shrink: 0; color: var(--text-muted); opacity: 0.6; }
.breadcrumb-edit-btn:hover { opacity: 1; }
.breadcrumb-path-input {
    flex: 1;
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid var(--primary);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
}

/* Topbar wrapper (invisible on desktop, merges breadcrumb + toolbar on mobile) */
.files-topbar { display: contents; }

/* Action toolbar — shown above breadcrumb on all screen sizes */
.files-toolbar {
    display: flex;
    align-items: center;
    padding: 4px 0;
    gap: 4px;
    order: -1;
}
.toolbar-actions-left { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.toolbar-actions-right { display: flex; gap: 4px; align-items: center; margin-left: auto; }

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: grab;
}
.breadcrumb:active { cursor: grabbing; }
.breadcrumb::-webkit-scrollbar { display: none; }

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 14px;
    min-height: 32px;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: var(--transition);
}
.breadcrumb-item:hover { background: var(--bg-secondary); }
.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
    cursor: default;
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
}

/* File list */
.file-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}
.file-list-scroll-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Pull-to-refresh & swipe-back: hidden by default, shown on touch devices */
.ptr-indicator { display: none; }
.touch-device .ptr-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
    height: 0;
    color: var(--text-secondary);
    font-size: 14px;
    flex-shrink: 0;
    transition: none;
}
.touch-device .ptr-indicator i { font-size: 16px; }
.touch-device .ptr-indicator.refreshing { transition: height 0.2s ease; }

.swipe-back-indicator { display: none; }
.touch-device .swipe-back-indicator {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 56px;
    background: var(--primary);
    border-radius: 0 14px 14px 0;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    z-index: 100;
    pointer-events: none;
}

/* Page picker bottom sheet: hidden by default, shown on touch devices */
.page-picker-backdrop { display: none; }
.page-picker-sheet { display: none; }
.touch-device .page-picker-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 600;
}
.touch-device .page-picker-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 60vh;
    background: var(--bg-primary);
    border-radius: 12px 12px 0 0;
    z-index: 601;
    animation: slide-up 0.25s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.touch-device .page-picker-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto 0;
}
.touch-device .page-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.touch-device .page-picker-cancel {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 60px;
    text-align: left;
}
.touch-device .page-picker-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.touch-device .page-picker-list {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}
.touch-device .page-picker-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-light, var(--border));
    cursor: pointer;
    font-size: 16px;
    color: var(--text-primary);
    text-align: left;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}
.touch-device .page-picker-item:active {
    background: var(--bg-secondary);
}
.touch-device .page-picker-page {
    flex: 1;
}
.touch-device .page-picker-range {
    color: var(--text-secondary);
    font-size: 14px;
}
.touch-device .page-picker-check {
    color: var(--primary);
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.file-list {
    width: 100%;
    display: block;
}

/* thead hidden — unified header above scroll area replaces it */
.file-list thead {
    display: none;
}
.file-list tbody {
    display: block;
}

.file-list th {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.file-list th.sortable { cursor: pointer; }
.file-list th.sortable:hover { color: var(--text-primary); }

.col-icon { width: 36px; }
.col-size { width: 100px; }
.col-modified { width: 160px; }

.file-row {
    display: flex;
    align-items: center;
    padding: 0 12px;
    cursor: pointer;
    transition: var(--transition);
}
@media (hover: hover) { .file-row:hover { background: var(--bg-secondary); } }
.file-row.selected { background: var(--primary-light); }
.file-row.focused { background: var(--primary-light); box-shadow: inset 3px 0 0 var(--primary); }

.file-row td {
    padding: 6px 8px;
    font-size: 15px;
}
.file-row {
    border-bottom: 1px solid var(--border-light);
}

.file-icon {
    text-align: center;
    color: var(--text-muted);
    position: relative;
    font-size: 36px;
    width: 44px;
    flex-shrink: 0;
}
/* macOS-style folder icon — replaces plain FontAwesome folder everywhere */
.folder-icon,
.wf-card-icon > .fa-folder,
i.tree-icon.fa-folder,
i.tree-icon.fa-folder-open {
    color: transparent !important;  /* hide FA glyph */
    width: 1em;
    height: 1em;
    display: inline-block;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 56'%3E%3Cdefs%3E%3ClinearGradient id='fb' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%234AC3F8'/%3E%3Cstop offset='1' stop-color='%231A8DF5'/%3E%3C/linearGradient%3E%3ClinearGradient id='ft' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%2362D4FF'/%3E%3Cstop offset='1' stop-color='%2347BBFA'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='0' y='10' width='64' height='44' rx='6' fill='url(%23fb)'/%3E%3Crect x='0' y='14' width='64' height='40' rx='5' fill='url(%23fb)'/%3E%3Cpath d='M0 10 Q0 4 6 4 L22 4 Q26 4 28 8 L30 12 H58 Q64 12 64 18 V14 Q64 8 58 8 H30 L28 4 Q26 0 22 0 H6 Q0 0 0 6 Z' fill='url(%23ft)'/%3E%3Crect x='2' y='15' width='60' height='1' rx='0.5' fill='rgba(255,255,255,0.15)'/%3E%3C/svg%3E") no-repeat center / contain;
}
i.tree-icon.fa-folder-open {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 56'%3E%3Cdefs%3E%3ClinearGradient id='fb' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%234AC3F8'/%3E%3Cstop offset='1' stop-color='%231A8DF5'/%3E%3C/linearGradient%3E%3ClinearGradient id='ft' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%2362D4FF'/%3E%3Cstop offset='1' stop-color='%2347BBFA'/%3E%3C/linearGradient%3E%3ClinearGradient id='fl' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%2362D4FF'/%3E%3Cstop offset='1' stop-color='%231A8DF5'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 10 Q0 4 6 4 L22 4 Q26 4 28 8 L30 12 H58 Q64 12 64 18 V16 H0 Z' fill='url(%23ft)'/%3E%3Cpath d='M4 18 H60 Q64 18 63 22 L56 50 Q55 54 51 54 H6 Q2 54 1 50 L-4 22 Q-5 18 0 18 Z' fill='url(%23fl)'/%3E%3Crect x='5' y='19' width='54' height='1' rx='0.5' fill='rgba(255,255,255,0.15)'/%3E%3C/svg%3E");
}

/* CloudDrive2's sync folder (/<cloud>/CloudDrive2 Sync): the logo with a round sync badge in
   place of the folder glyph. 1em square like the glyph, so each slot's font-size sizes it. */
.sync-folder-icon {
    --sync-ring: var(--bg-primary);
    position: relative;
    display: inline-block;
    width: 1em;
    height: 1em;
    line-height: 1;
    vertical-align: -0.125em;   /* sits where the Font Awesome glyph box does */
    flex-shrink: 0;
}
span.sync-folder-icon > img.sync-folder-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.sync-folder-badge {
    position: absolute;
    right: -0.08em;
    bottom: -0.08em;
    width: max(7px, 0.46em);
    height: max(7px, 0.46em);
    border-radius: 50%;
    /* the brand's darker blue in both themes, as on every platform: white arrows on it are 5.5:1 */
    background: #1c6fa0;
    box-shadow: 0 0 0 max(1px, 0.05em) var(--sync-ring);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sync-folder-badge > i {
    font-size: max(5px, 0.26em);
    color: #fff;
}
.file-row .sync-folder-icon { --sync-ring: var(--bg-file-container, var(--bg-secondary)); }
.file-grid-item .sync-folder-icon,
.wf-item .sync-folder-icon { --sync-ring: var(--bg-card); }
.tree-icon-wrap > .sync-folder-icon { font-size: 13px; --sync-ring: var(--bg-sidebar, var(--bg-primary)); }
.folder-entry-icon-wrap > .sync-folder-icon { font-size: 14px; margin: 0 2px; }

/* File type icon colors — iOS-style palette */
.fa-file-video { color: #AF52DE; }         /* purple — video */
.fa-file-audio { color: #FF2D55; }         /* pink — audio */
.fa-file-image { color: #34C759; }         /* green — image */
.fa-file-pdf { color: #FF3B30; }           /* red — PDF */
.fa-file-word { color: #2B579A; }          /* Word blue */
.fa-file-excel { color: #217346; }         /* Excel green */
.fa-file-powerpoint { color: #D24726; }    /* PowerPoint orange */
.fa-file-archive { color: #8E8E93; }       /* gray — archives */
.fa-compact-disc { color: #8E8E93; }       /* gray — ISO */
.fa-closed-captioning { color: #8E8E93; }  /* gray — subtitles */

.file-name { font-weight: 400; position: relative; flex: 1; min-width: 0; }
.file-name-text { display: inline; padding-right: 24px; word-break: break-word; }
@media (hover: hover) {
    .file-name-text,
    .file-grid-name,
    .wf-card-name,
    .wf-overlay-name { cursor: pointer; }
    .file-name-text:hover,
    .file-grid-name:hover,
    .wf-card-name:hover,
    .wf-overlay-name:hover {
        color: var(--primary);
        text-decoration: underline;
    }
}
.file-name-text:focus-visible,
.file-grid-name:focus-visible,
.wf-card-name:focus-visible,
.wf-overlay-name:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 2px;
}
.mobile-file-subtitle { display: none; }
.file-name-ellipsis {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}
.file-name-ellipsis:hover { color: var(--text-primary); }
.directory .file-name { font-weight: 500; }

.file-size, .file-modified {
    color: var(--text-secondary);
    font-size: 12px;
}
.file-checkbox { flex-shrink: 0; padding: 6px 4px; }
.file-size { width: 100px; flex-shrink: 0; }
.file-type { width: 80px; flex-shrink: 0; }
.file-modified { width: 160px; flex-shrink: 0; }
.file-created { width: 160px; flex-shrink: 0; }
.file-accessed { width: 160px; flex-shrink: 0; }

/* View mode buttons (in toolbar) */
.view-mode-buttons { display: flex; gap: 2px; align-items: center; }
.view-mode-buttons .btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Unified header — shown in all view modes (grid, list, waterfall) */
.unified-header {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
    min-height: 38px;
    flex-shrink: 0;
}
.uh-col {
    cursor: pointer;
    padding: 8px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}
.uh-col:hover { color: var(--text-primary); }
.uh-checkbox { width: 36px; text-align: center; cursor: default; flex-shrink: 0; padding: 6px 4px; }
.uh-icon-spacer { width: 44px; flex-shrink: 0; cursor: default; padding: 6px 8px; }
.uh-name {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
}
.uh-sort-label { white-space: nowrap; cursor: pointer; }
.uh-size { width: 100px; }
.uh-type { width: 80px; }
.uh-modified { width: 160px; }
.uh-created { width: 160px; }
.uh-accessed { width: 160px; }

/* Inline filter in unified header Name column */
.uh-filter {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 320px;
    min-width: 80px;
}
.uh-filter-icon {
    position: absolute;
    left: 6px;
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
}
.uh-filter-input {
    width: 100%;
    padding: 4px 22px 4px 22px;
    font-size: 12px;
    font-weight: 400;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}
.uh-filter-input:focus { border-color: var(--primary); }
.uh-filter-input::placeholder { color: var(--text-muted); }
.uh-filter-input.has-sticky { padding-right: 40px; }
.uh-filter-sticky {
    position: absolute;
    right: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 4px;
    font-size: 10px;
    opacity: 0.5;
    transition: var(--transition);
}
.uh-filter-sticky:hover { opacity: 0.8; }
.uh-filter-sticky.active {
    color: var(--primary);
    opacity: 1;
    transform: rotate(45deg);
}
.uh-filter-clear {
    position: absolute;
    right: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 4px;
    font-size: 10px;
}
.uh-filter-clear:hover { color: var(--text-primary); }

/* Mobile sort button (hidden on desktop) */
.uh-sort-btn-wrapper { display: none; position: relative; }
.uh-sort-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    transition: var(--transition);
}
.uh-sort-btn:hover, .uh-sort-btn:focus-visible { color: var(--text-primary); border-color: var(--primary); }
.uh-sort-btn-label { font-size: 12px; white-space: nowrap; }
.uh-sort-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 2001;
    min-width: 160px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    margin-top: 4px;
    /* A popup's length is the data's; never let it clip its own tail. */
    max-height: min(70vh, 520px);
    overflow-y: auto;
}
.uh-sort-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.uh-sort-option:hover { background: var(--bg-hover); }
.uh-sort-option.active { color: var(--primary); font-weight: 600; }
.uh-sort-option i { width: 16px; text-align: center; }

/* "+ Add" dropdown */
.add-dropdown {
    position: relative;
    display: inline-flex;
}
.add-dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
}
/* Play folder dropdown */
.play-folder-dropdown {
    position: relative;
    display: inline-flex;
}

/* Waterfall button wrapper + size popup */
.waterfall-btn-wrapper {
    position: relative;
    display: inline-flex;
}
.waterfall-size-popup {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1000;
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}
.wf-size-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}
.wf-size-btn:hover { border-color: var(--primary); color: var(--primary); }
.wf-size-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* File grid view */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    /* Override masonry inline height when switching from waterfall view */
    height: auto !important;
}
.file-grid-item {
    position: relative !important;
    width: auto !important;
    left: auto !important;
    top: auto !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
    border: 2px solid transparent;
}
@media (hover: hover) { .file-grid-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); } }
.file-grid-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.file-grid-item.focused {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.file-grid-icon {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
}
/* folder-icon styling handled in combined rule above */
.file-grid-thumb {
    width: 100%;
    height: 100px;
    margin-bottom: 8px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}
.file-grid-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 4px;
}
.file-grid-name {
    font-size: 12px;
    text-align: center;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}
.file-grid-size {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.file-grid-date {
    font-size: 11px;
    color: var(--text-muted);
}

/* Waterfall/Gallery view — JS masonry (absolute positioning) */
.file-waterfall {
    position: relative;
}

/* Each item: absolutely positioned by JS masonry algorithm.
   Items without left/top are not yet positioned — keep them hidden to avoid stacking at (0,0). */
.wf-item {
    position: absolute;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s;
    background: var(--bg-card);
    border: 2px solid transparent;
}
.wf-item:not([style*="left"]) {
    visibility: hidden;
}
@media (hover: hover) {
    .wf-item:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
}
.wf-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.wf-item.focused {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Image/video tile — natural aspect ratio */
.wf-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: var(--bg-tertiary);
    line-height: 0; /* remove baseline gap below img */
}
.wf-img {
    width: 100%;
    height: auto; /* natural aspect ratio */
    display: block;
    object-fit: cover;
    transition: transform 0.2s;
}
@media (hover: hover) {
    .wf-item:hover .wf-img {
        transform: scale(1.03);
    }
}
/* Fallback min-height while image loads */
.wf-img[src] {
    min-height: 80px;
}
/* Hide image while loading (on page change) — revealed by onload handler */
.wf-img.wf-img-loading {
    visibility: hidden;
    min-height: 120px;
}

/* Video play button overlay */
.wf-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 2;
    transition: transform 0.2s;
}
.wf-play-overlay.wf-play-btn {
    pointer-events: auto;
    cursor: pointer;
}
@media (hover: hover) {
    .wf-item:hover .wf-play-overlay {
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Dark gradient overlay at bottom of image */
.wf-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
    padding: 20px 10px 8px;
    z-index: 1;
}
.wf-overlay-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.wf-overlay-size {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
    line-height: 1.3;
}

/* Folder / non-preview file cards */
.wf-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 16px;
    min-height: 140px;
    text-align: center;
    gap: 6px;
}
.wf-folder .wf-card-icon {
    color: var(--folder-icon);
}
.wf-card-icon {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.wf-card-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}
.wf-card-name {
    font-size: 13px;
    font-weight: 500;
    word-break: break-word;
    line-height: 1.3;
}
.wf-card-size {
    font-size: 11px;
    color: var(--text-muted);
}
.wf-card-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Overlay meta (size + date) in image/video tiles */
.wf-overlay-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
    line-height: 1.3;
}
.wf-overlay-date {
    opacity: 0.7;
}

/* Empty state in waterfall */
.wf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
    width: 100%;
}
.wf-empty .empty-icon {
    font-size: 48px;
    opacity: 0.4;
}

/* Video thumbnail generation container */
.wf-video-thumb-container {
    width: 100%;
    min-height: 120px;
    background: var(--bg-tertiary);
}
.wf-video-thumb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 30px;
    color: var(--text-muted);
}
.wf-thumb-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: wf-spin 0.8s linear infinite;
}
@keyframes wf-spin {
    to { transform: rotate(360deg); }
}
/* Once thumbnail is generated, the container just holds the img */
.wf-video-thumb-container .wf-img {
    width: 100%;
    height: auto;
    display: block;
}

/* Footer with pagination and status */
.file-list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pagination-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 2px;
}
.pagination-separator { color: var(--border); margin: 0 4px; }
.pagination-info {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0 4px;
    white-space: nowrap;
}
.btn-xs {
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.btn-xs:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn-xs.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-xs:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.file-list-status {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Page-size select dropdown */
.page-size-select {
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.5;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
}

/* Page navigation cards (prev/next) in grid + waterfall */
.file-grid-item.page-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--primary);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    min-height: 100px;
    gap: 8px;
    transition: background var(--transition);
}
.file-grid-item.page-nav:hover {
    background: var(--primary-light);
}
.file-grid-item.page-nav i {
    font-size: 2em;
}
.file-grid-item.page-nav span {
    font-size: 12px;
    font-weight: 500;
}
.wf-card.wf-page-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--primary);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    padding: 24px 12px;
    gap: 8px;
}
.wf-item.page-nav:hover .wf-page-nav {
    background: var(--primary-light);
}
.wf-page-nav i {
    font-size: 2em;
}
.wf-page-nav span {
    font-size: 12px;
    font-weight: 500;
}

/* List view prev/next page rows */
.file-list .page-nav-row {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 2px dashed var(--primary);
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}
.file-list .page-nav-row:hover {
    background: var(--primary-light);
}
.file-list .page-nav-row .file-icon i,
.file-list .page-nav-row .page-nav-name {
    color: var(--primary);
}
.file-list .page-nav-row .file-icon i {
    font-size: 1.1em;
}
.file-list .page-nav-row .page-nav-name {
    font-weight: 500;
}

/* ── Media Viewer (iOS-style lightbox) ──────────────────── */
.viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    outline: none;
}
.viewer-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

/* Toolbar — gradient overlay, 56px */
.viewer-toolbar {
    position: relative;
    z-index: 2;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 4px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
    flex-shrink: 0;
}
.viewer-toolbar-right {
    display: flex;
    gap: 0;
    align-items: center;
    flex-shrink: 0;
}
.viewer-counter {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    padding: 0 8px;
    white-space: nowrap;
    flex-shrink: 0;
}
/* Filename in center */
.viewer-title {
    flex: 1;
    text-align: center;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
}
/* Separator between button groups */
.viewer-btn-separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
    flex-shrink: 0;
}
.viewer-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0.8;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    border-radius: 4px;
    transition: opacity 0.2s, background 0.2s;
    flex-shrink: 0;
}
.viewer-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}
.viewer-btn.active {
    opacity: 1;
    color: var(--primary);
}
/* Transform buttons: inline on desktop, dropdown on mobile */
.viewer-transform-inline { display: flex; align-items: center; }
.viewer-transform-dropdown { display: none; position: relative; }
.viewer-transform-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}
.viewer-transform-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.viewer-transform-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}
.viewer-transform-item:hover,
.viewer-transform-item:active {
    background: rgba(255, 255, 255, 0.12);
}
.viewer-transform-item i {
    width: 18px;
    text-align: center;
    opacity: 0.8;
}
.viewer-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: viewer-spin 0.6s linear infinite;
    margin: 0 10px;
}
@keyframes viewer-spin {
    to { transform: rotate(360deg); }
}

/* Content area */
.viewer-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

/* Navigation arrows */
.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 44px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}
.viewer-content:hover .viewer-nav,
.viewer-nav:focus { opacity: 1; }
.viewer-nav:hover { background: rgba(255, 255, 255, 0.2); }
.viewer-nav-left { left: 16px; }
.viewer-nav-right { right: 16px; }

/* Slide container — 3 holders side-by-side, translated to show current (center) */
.viewer-slide-container {
    position: absolute;
    inset: 0;
    display: flex;
    width: 300%;
    z-index: 1;
    transform: translateX(-33.3333%);
    transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}
.viewer-slide-container.no-transition {
    transition: none;
}
.viewer-slide {
    width: 33.3333%;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Media container — centered zoom via translate+scale */
.viewer-media {
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
    will-change: transform;
}
.viewer-media.no-transition {
    transition: none;
}
/* Slide-in animation for navigation */
@keyframes slide-from-right {
    from { transform: translateX(60px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slide-from-left {
    from { transform: translateX(-60px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}
.viewer-media.slide-from-right { animation: slide-from-right 0.25s ease-out; }
.viewer-media.slide-from-left  { animation: slide-from-left  0.25s ease-out; }

/* Image — smooth rotate/flip transition */
.viewer-media img {
    max-width: 100%;
    max-height: calc(100vh - 136px); /* toolbar 56px + strip 80px */
    max-height: calc(100dvh - 136px); /* Safari: dynamic viewport height */
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.25s ease;
}
.viewer-media video {
    max-width: 100%;
    max-height: calc(100vh - 136px);
    max-height: calc(100dvh - 136px);
    object-fit: contain;
    outline: none;
}
.viewer-media .viewer-audio-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px;
}
.viewer-media .viewer-audio-container audio {
    width: 400px;
    max-width: 90vw;
}
.viewer-media .viewer-audio-container .viewer-audio-notice {
    max-width: min(480px, 90vw);
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    line-height: 1.6;
    text-align: center;
}
.viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.5);
}

/* Thumbnail strip */
.viewer-thumbnail-strip {
    position: relative;
    z-index: 2;
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
    flex-shrink: 0;
    touch-action: pan-x; /* allow native horizontal swipe on mobile */
    cursor: grab;
}
.viewer-thumbnail-strip:active {
    cursor: grabbing;
}
.viewer-thumbnail-strip::-webkit-scrollbar { display: none; }
.viewer-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.65;
    transition: opacity 0.2s, transform 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 20px;
}
.viewer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none; /* clicks pass through to .viewer-thumb */
    user-select: none;
    -webkit-user-drag: none;
}
.viewer-thumb.active {
    border-color: #fff;
    opacity: 1;
    transform: scale(1.1);
}
.viewer-thumb:not(.active):hover {
    opacity: 1;
}

/* Properties panel (slide-in from right) */
.viewer-props-panel {
    position: absolute;
    right: 0;
    top: 56px;
    bottom: 80px;
    width: 300px;
    z-index: 10;
    background: rgba(18, 18, 18, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}
.viewer-props-panel.open {
    transform: translateX(0);
}
.viewer-props-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 8px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}
.viewer-props-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.props-file-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 12px;
    gap: 8px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.props-file-name {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    text-align: center;
    word-break: break-all;
    line-height: 1.4;
}
.props-section {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.props-section:last-child { border-bottom: none; }
.props-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    padding: 4px 16px 6px;
}
.props-row {
    display: flex;
    padding: 3px 16px;
    gap: 12px;
    font-size: 13px;
    line-height: 1.5;
}
.props-row-label {
    color: rgba(255, 255, 255, 0.45);
    flex-shrink: 0;
    min-width: 70px;
}
.props-row-value {
    color: #fff;
    word-break: break-word;
    flex: 1;
}
.viewer-props-loading {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 13px;
}

/* ── Fullscreen / Immersive ──────────────────────────────── */
.viewer-overlay.immersive .viewer-toolbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    transition: opacity 0.3s;
}
.viewer-overlay.immersive .viewer-thumbnail-strip {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 10;
    transition: opacity 0.3s;
}
.viewer-overlay.immersive .viewer-nav {
    z-index: 10;
    transition: opacity 0.3s;
}
.viewer-overlay.immersive.controls-hidden .viewer-toolbar,
.viewer-overlay.immersive.controls-hidden .viewer-nav,
.viewer-overlay.immersive.controls-hidden .viewer-thumbnail-strip {
    opacity: 0;
    pointer-events: none;
}
.viewer-overlay.immersive .viewer-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.viewer-overlay.immersive .viewer-media img {
    max-height: 100vh;
    max-height: 100dvh;
}
.viewer-overlay.immersive video {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
/* Hide thumbnail strip in fullscreen when video is playing — native controls overlap */
.viewer-overlay.immersive.video-playing .viewer-thumbnail-strip {
    display: none;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .viewer-props-panel {
        width: 100%;
        bottom: 68px;
    }
    .viewer-nav {
        width: 36px;
        height: 60px;
        font-size: 18px;
        opacity: 0.6;
    }
    .viewer-nav-left { left: 4px; }
    .viewer-nav-right { right: 4px; }
    .viewer-thumbnail-strip {
        height: 68px;
    }
    .viewer-thumb {
        width: 50px;
        height: 50px;
    }
}

/* Loading bar */
.loading-bar {
    height: 3px;
    background: var(--bg-tertiary);
    overflow: hidden;
}
.loading-bar-inner {
    height: 100%;
    width: 40%;
    background: var(--primary);
    animation: loading-slide 1.2s ease-in-out infinite;
}
@keyframes loading-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Empty state */
.empty-state, .empty-content {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.file-list .empty-state { display: flex; }
.empty-state td { flex: 1; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }

.placeholder-content {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}
.placeholder-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }

/* Loading spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 48px;
    color: var(--text-muted);
}

/* Inline dialog (create folder, etc.) */
.inline-dialog {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
}
.inline-dialog .form-input {
    width: auto;
    flex: 1;
    max-width: 300px;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    gap: 0;
}

.tab-btn {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ---------- Login Page ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
}

.login-title {
    font-size: 24px;
    font-weight: 600;
}

.login-form {
    margin-top: 16px;
}

.login-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.login-proxy-section {
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 12px;
    transition: color 0.15s;
}

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

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 99999;
    max-width: 380px;
}

.toast {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    animation: toast-in 0.3s ease;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.toast-body {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }

.toast-message { flex: 1; }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
}

.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.toast-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.toast-action-btn:hover {
    background: var(--bg-tertiary, var(--bg-hover));
}
.toast-action-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
.toast-action-btn.danger {
    color: var(--danger);
    border-color: var(--danger);
}
.toast-action-btn.danger:hover {
    background: rgba(220, 53, 69, 0.1);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in 0.15s ease;
    overflow-y: auto;
    padding: 16px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 540px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.modal-sm { max-width: 400px; }

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Delete confirmation file list */
.delete-file-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 4px 0;
}
.delete-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    font-size: 13px;
}
.delete-file-item:hover { background: var(--bg-secondary); }
.delete-file-icon { width: 16px; text-align: center; color: var(--text-muted); flex-shrink: 0; }
.delete-file-icon.folder { color: #f0c040; }
.delete-file-name {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.delete-file-badge {
    font-size: 10px; padding: 1px 6px;
    border-radius: 8px; background: var(--bg-tertiary); color: var(--text-secondary);
    flex-shrink: 0;
}
.delete-file-size {
    font-size: 12px; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0;
}
.delete-file-more {
    padding: 6px 10px; font-size: 12px; color: var(--text-muted); font-style: italic;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-dialog {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 540px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog.modal-lg { max-width: 900px; }

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

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---------- Server Health ---------- */
.health-indicator {
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.health-indicator.connected { color: var(--success); }
.health-indicator.disconnected { color: var(--danger); }
.health-indicator.unhealthy {
    color: var(--warning);
    font-size: 13px;
    cursor: help;
}
.health-status-text {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Mobile-only server health banner (hidden on desktop) */
.mobile-health-banner {
    display: none;
}
@media (max-width: 768px) {
    .mobile-health-banner {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px;
        background: var(--danger);
        color: #fff;
        font-size: 13px;
        font-weight: 500;
        flex-shrink: 0;
    }
    .mobile-health-banner.reconnecting {
        background: var(--warning, #f0ad4e);
        color: #333;
    }
    .mobile-health-banner i {
        font-size: 14px;
        flex-shrink: 0;
    }
}

/* The plan couldn't be checked online: the notice above every page, and in a dialog */
.plan-check-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 2px solid var(--warning);
    font-size: 13px;
    flex-shrink: 0;
}
.plan-check-notice > i {
    color: var(--text-primary);
    font-size: 16px;
    flex-shrink: 0;
}
.plan-check-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.plan-check-notice .btn {
    flex-shrink: 0;
}

/* ---------- Global Error Modal ---------- */
.error-modal .modal-header {
    border-bottom-color: var(--warning);
}
.error-modal-icon {
    text-align: center;
    padding: 16px 0 12px;
}
.error-modal-message {
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    padding: 0 8px 8px;
}
.error-suggestions {
    text-align: left;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}
.error-suggestions h5 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text-secondary);
}
.error-suggestions ul {
    margin: 0;
    padding-left: 20px;
}
.error-suggestions li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---------- Cloud Storage Cards ---------- */
.cloud-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: var(--transition);
}
.cloud-card:hover { box-shadow: var(--shadow-hover); }
.cloud-card.locked { border-color: var(--warning); opacity: 0.8; }

.cloud-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
}

.cloud-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
}

.cloud-info { flex: 1; min-width: 0; }
.cloud-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cloud-user {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-memberships { padding: 12px 16px 0; }
.cloud-space { padding: 12px 16px 0; margin-bottom: 0; }
.cloud-space:empty { padding: 0; }
.cloud-space.loading-text {
    font-size: 12px;
    color: var(--text-muted);
}

.space-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.space-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(to right, #22c55e, #84cc16 35%, #eab308 55%, #f97316 75%, #ef4444 100%);
    background-size: var(--gradient-scale, 100%) 100%;
    transition: width 0.3s ease;
}

.space-text {
    font-size: 11px;
    color: var(--text-secondary);
}

.cloud-card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    margin-top: 12px;
}

/* ---------- Provider Grid (Add Cloud Modal) ---------- */
.provider-section {
    margin-bottom: 20px;
}
.provider-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}
.provider-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.provider-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 12px;
    color: var(--text-primary);
    text-align: center;
}
.provider-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.provider-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
}
.provider-icon-placeholder {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
}

/* Provider item — disabled/locked state */
.provider-item.disabled { opacity: 0.5; cursor: not-allowed; position: relative; }
.provider-item.disabled:hover { border-color: var(--border); background: var(--bg-primary); transform: none; box-shadow: none; }
.provider-item .lock-icon { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Upgrade banner in add-cloud modal */
.upgrade-banner { background: var(--primary-light); border: 1px solid var(--primary); border-radius: var(--border-radius); padding: 14px 16px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.upgrade-banner-content { display: flex; align-items: flex-start; gap: 10px; flex: 1; min-width: 0; }
.upgrade-banner-content > i { font-size: 20px; color: var(--warning); flex-shrink: 0; margin-top: 2px; }
.upgrade-banner-text { font-size: 13px; color: var(--text-primary); }
.upgrade-banner-text strong { display: block; margin-bottom: 2px; }
.upgrade-details { font-size: 12px; color: var(--text-secondary); margin: 0; }
.locked-badge { font-size: 11px; color: var(--text-muted); font-weight: 400; margin-left: 8px; }
.locked-badge i { margin-right: 3px; }

/* ---------- Config Sections (Cloud Config Modal) ---------- */
.config-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}
.config-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.config-section-title i {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ---------- Proxy Group ---------- */
.proxy-group {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}
.proxy-group-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}

/* ---------- Form Row (side-by-side fields) ---------- */
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.form-row > .form-group {
    margin-bottom: 12px;
}

/* ---------- OAuth / Auth Method Selector ---------- */
.auth-method-selector {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
}
.oauth-auth-section {
    text-align: center;
    padding: 20px 0;
}
.btn-block {
    display: block;
    width: 100%;
}
.btn-group {
    display: inline-flex;
    gap: 0;
}
.btn-group .btn {
    border-radius: 0;
}
.btn-group .btn:first-child {
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}
.btn-group .btn:last-child {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
}
.btn-link:hover {
    text-decoration: underline;
}

/* ---------- Tasks Page ---------- */
.content-body:has(.tasks-page) { padding: 0; }
.tasks-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    padding: 16px 24px 0;
    gap: 12px;
}

/* Summary Cards */
.task-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.25rem;
    flex-shrink: 0;
}

.summary-card {
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}
.summary-card.copy::before { background: linear-gradient(90deg, #ff6b6b, #ee5a52); }
.summary-card.download::before { background: linear-gradient(90deg, #2196f3, #03a9f4); }
.summary-card.upload::before { background: linear-gradient(90deg, #4caf50, #8bc34a); }
.summary-card.qps::before { background: linear-gradient(90deg, #7e57c2, #9575cd); }
.summary-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.summary-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--bg-secondary); }
.summary-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.summary-card-header {
    display: flex;
    align-items: center;
}
.summary-card-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.summary-card-icon-inline { font-size: 13px; }
.summary-card.copy .summary-card-icon-inline { color: #ff6b6b; }
.summary-card.download .summary-card-icon-inline { color: #2196f3; }
.summary-card.upload .summary-card-icon-inline { color: #4caf50; }
.summary-card.qps .summary-card-icon-inline { color: #7e57c2; }

.summary-count {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}
.summary-card.copy .summary-count { color: #ff6b6b; }
.summary-card.download .summary-count { color: #2196f3; }
.summary-card.upload .summary-count { color: #4caf50; }
.summary-card.qps .summary-count { color: #7e57c2; }

.summary-status-row { display: flex; align-items: center; gap: 6px; }
.summary-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}
.summary-subtitle.active { font-weight: 500; }
.summary-subtitle.active.copy { color: #ff6b6b; }
.summary-subtitle.active.download { color: #2196f3; }
.summary-subtitle.active.upload { color: #4caf50; }
.summary-subtitle.active.qps { color: #7e57c2; }
/* #7e57c2 is too dark on the dark background; this lighter purple keeps 4.5:1 */
[data-theme="dark"] .summary-card.qps .summary-card-icon-inline,
[data-theme="dark"] .summary-card.qps .summary-count,
[data-theme="dark"] .summary-subtitle.active.qps { color: #b39ddb; }

/* QPS tab: one row per cloud account sending requests */
.qps-list { list-style: none; margin: 0; padding: 0; }
.qps-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qps-account { min-width: 0; flex: 1; }
.qps-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qps-detail { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qps-rate { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; min-width: 120px; }
.qps-value { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.qps-limit { font-size: 11px; color: var(--text-secondary); }
.qps-bar .progress-fill { background: #7e57c2; }

.summary-progress-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 10px; color: var(--text-secondary); }
.progress-bar-inline { width: 100%; height: 3px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.progress-bar-inline .progress-fill { height: 100%; background: #4caf50; border-radius: 2px; transition: width 0.3s ease; }

/* Task Section (tab content) */
.task-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

/* Copy Tasks Toolbar */
.modern-copy-toolbar, .modern-upload-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.select-all-container { display: flex; align-items: center; gap: 4px; }
.select-all-container input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.selection-info { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.bulk-actions, .global-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.action-btn:hover { background: var(--bg-tertiary); }
.action-btn.remove { color: #dc3545; }
.action-btn.remove:hover { background: rgba(220,53,69,0.08); }
.action-btn.pause { color: #fd7e14; }
.action-btn.restart { color: var(--primary); }

/* Copy Tasks List */
.copy-tasks-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
}

.copy-task-compact {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid var(--border);
}
.copy-task-compact:hover { box-shadow: var(--shadow-sm); }
.copy-task-compact.selected { background: rgba(var(--primary-rgb, 59, 130, 246), 0.06); border-color: var(--primary); }
.copy-task-compact.status-running { border-left-color: var(--primary); }
.copy-task-compact.status-completed { border-left-color: #28a745; }
.copy-task-compact.status-failed { border-left-color: #dc3545; }
.copy-task-compact.status-paused { border-left-color: #fd7e14; }

.task-main-info { margin-bottom: 8px; }
.task-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.title-left { display: flex; align-items: center; }
.title-left input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.title-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.operation-badge, .status-badge, .paused-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.operation-badge { background: rgba(var(--primary-rgb, 59, 130, 246), 0.1); color: var(--primary); }
.status-badge { background: var(--bg-tertiary); color: var(--text-secondary); }
.status-badge.status-running { background: rgba(59,130,246,0.1); color: var(--primary); }
.status-badge.status-completed { background: rgba(40,167,69,0.1); color: #28a745; }
.status-badge.status-failed { background: rgba(220,53,69,0.1); color: #dc3545; }
.status-badge.status-paused { background: rgba(253,126,20,0.1); color: #fd7e14; }
.paused-badge { background: rgba(253,126,20,0.1); color: #fd7e14; }

.progress-compact { margin-top: 4px; }
.progress-bar-compact { height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.progress-fill-compact { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s ease; }
.progress-text-compact { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.task-details-compact { font-size: 12px; }
.detail-row-compact { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.detail-label-compact { color: var(--text-muted); font-weight: 500; min-width: 75px; flex-shrink: 0; }
.detail-value-compact { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.detail-item-compact { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); }
.detail-item-compact i { font-size: 11px; color: var(--text-muted); }
.detail-item-compact.error { color: #dc3545; }
.detail-item-compact.error i { color: #dc3545; }
.progress-stats { margin-top: 2px; }

/* Error List */
.error-list-compact { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.error-list-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #dc3545;
    cursor: pointer;
    user-select: none;
}
.error-list-header i.fa-exclamation-triangle { font-size: 12px; }
.expand-errors-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    font-size: 11px;
}
.error-list-container {
    max-height: 120px;
    overflow-y: auto;
    margin-top: 4px;
}
.error-item {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    font-size: 11px;
    border-bottom: 1px solid var(--bg-tertiary);
}
.error-item:last-child { border-bottom: none; }
.error-time { color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.error-message { color: #dc3545; word-break: break-all; }

/* Download Table */
.download-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.download-table thead th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.download-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--bg-tertiary);
    vertical-align: middle;
}
.download-table tbody tr:hover { background: var(--bg-secondary); }
.download-table .file-cell { max-width: 0; width: 100%; }
.download-table .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.download-table .file-error { font-size: 11px; color: #dc3545; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.download-table .file-error .error-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.download-table .file-processes { display: flex; flex-direction: column; gap: 0px; margin-top: 2px; }
.download-table .process-item { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-secondary); padding: 0 0; }
.download-table .process-item i { color: var(--primary); font-size: 10px; flex-shrink: 0; }
.download-table .process-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1; min-width: 0; }
.download-table .size-cell, .download-table .buffer-cell, .download-table .speed-cell, .download-table .threads-cell { white-space: nowrap; text-align: right; }
.download-table-wrapper { flex: 1; overflow-y: auto; }

/* Upload Tasks */
.upload-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.upload-filters .search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 150px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 4px 8px;
}
.upload-filters .search-box i { color: var(--text-muted); font-size: 12px; }
.upload-filters .search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 12px;
    color: var(--text-primary);
    width: 100%;
}
.upload-filters .filter-select {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}
.clear-search {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 2px;
    font-size: 12px;
}

/* Upload filter toggle — hidden on desktop, shown on mobile */
.upload-filters-toggle { display: none; }

/* Upload list header + rows */
.upload-list-header {
    display: grid;
    grid-template-columns: 32px 1fr 200px 100px 110px;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}
.upload-tasks-list {
    flex: 1;
    overflow-y: auto;
}
.upload-task-row {
    display: grid;
    grid-template-columns: 32px 1fr 200px 100px 110px;
    gap: 8px;
    padding: 8px 12px;
    align-items: center;
    border-bottom: 1px solid var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
}
.upload-task-row:hover { background: var(--bg-secondary); }
.upload-task-row.selected { background: rgba(var(--primary-rgb, 59, 130, 246), 0.06); }
.upload-task-row .col-select { display: flex; align-items: center; justify-content: center; }
.upload-task-row .col-select input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.upload-task-row .col-file { min-width: 0; }
.upload-task-row .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.upload-task-row .file-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-muted); }

.size-with-progress {
    position: relative;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 12px;
    white-space: nowrap;
    background: linear-gradient(to right, rgba(40,167,69,0.12) var(--progress, 0%), transparent var(--progress, 0%));
}
.size-text { display: flex; gap: 2px; align-items: baseline; white-space: nowrap; }
.size-transferred { font-weight: 500; }
.size-separator { color: var(--text-muted); margin: 0 1px; }
.size-total { color: var(--text-secondary); }

.operator-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.status-indicator.status-uploading { background: rgba(59,130,246,0.1); color: var(--primary); }
.status-indicator.status-completed { background: rgba(40,167,69,0.1); color: #28a745; }
.status-indicator.status-paused { background: rgba(253,126,20,0.1); color: #fd7e14; }
.status-indicator.status-failed { background: rgba(220,53,69,0.1); color: #dc3545; }
.status-indicator.status-cancelled { background: rgba(108,117,125,0.1); color: #6c757d; }
.status-indicator.status-pending { background: var(--bg-tertiary); color: var(--text-secondary); }

.error-row {
    grid-column: 1 / -1;
    padding: 4px 12px 8px 44px;
    font-size: 11px;
    color: #dc3545;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Pagination */
.modern-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 5;
    margin-top: auto;
}
.pagination-info { font-size: 12px; color: var(--text-secondary); }
.pagination-controls { display: flex; align-items: center; gap: 2px; }
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 28px;
    padding: 0 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.page-btn:hover { background: var(--bg-tertiary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.items-per-page select {
    padding: 3px 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Refresh control */
.refresh-control-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.refresh-control-btn:hover { background: var(--bg-tertiary); }
.refresh-control-btn.paused { color: #28a745; border-color: #28a745; }

/* Task toolbar old compat (merge tab) */
.task-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.speed-indicator { font-size: 13px; color: var(--primary); font-weight: 500; }
.task-count { font-size: 12px; color: var(--text-secondary); }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    transition: var(--transition);
}
.task-card:hover { box-shadow: var(--shadow-sm); }
.task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.task-paths { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.task-source, .task-dest { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.task-arrow { color: var(--text-muted); font-size: 10px; flex-shrink: 0; }
.progress-bar { height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s ease; }
.task-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); }
.task-error { margin-top: 8px; font-size: 12px; color: var(--danger); padding: 4px 8px; background: rgba(220, 53, 69, 0.08); border-radius: var(--border-radius); }
.task-card-actions { display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.task-card-actions .btn { font-size: 11px; padding: 3px 8px; }

@media (max-width: 768px) {
    /* ── Tasks page: compact header ── */
    .tasks-page { padding: 8px 12px 0; }
    /* Keep title + controls on one row; drop subtitle */
    .tasks-page .page-header { flex-direction: row; align-items: center; flex-wrap: wrap; margin-bottom: 8px; gap: 6px; }
    .tasks-page .page-title { font-size: 15px; }
    .tasks-page .page-description { display: none; }
    /* Hide "Update Interval" text, keep the select */
    .tasks-page .header-actions label > span { display: none; }

    /* ── 3 summary cards side-by-side ── */
    .task-summary { grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .summary-card { height: auto; min-height: 56px; padding: 5px 7px; }
    /* Prevent title from wrapping; clip overflow */
    .summary-card-title { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .summary-card-icon-inline { font-size: 10px; }
    .summary-count { font-size: 1rem; }
    /* Hide byte totals in upload progress on narrow cards */
    .summary-progress-inline > span { display: none; }
    /* ── Upload filter toggle (mobile) ── */
    .upload-filters-toggle {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        margin-bottom: 8px;
        cursor: pointer;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--border-radius);
        font-size: 13px;
        color: var(--text-secondary);
    }
    .upload-filters-toggle .filter-badge {
        background: var(--primary);
        color: #fff;
        font-size: 10px;
        padding: 1px 6px;
        border-radius: 8px;
        margin-left: auto;
    }
    .upload-filters.filters-collapsed { display: none; }

    /* ── Upload column header hidden on mobile ── */
    .upload-list-header { display: none; }

    /* ── Upload task cards (matching download card style) ── */
    .upload-tasks-list { display: flex; flex-direction: column; gap: 6px; }
    .upload-task-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 8px;
        background: var(--bg-primary);
        border: 1px solid var(--border);
        border-radius: var(--border-radius);
        padding: 8px 10px;
        border-left: 3px solid var(--border);
    }
    .upload-task-row.status-uploading { border-left-color: var(--primary); }
    .upload-task-row.status-completed { border-left-color: #28a745; }
    .upload-task-row.status-paused { border-left-color: #fd7e14; }
    .upload-task-row.status-failed { border-left-color: #dc3545; }

    .upload-task-row .col-select { flex: 0 0 auto; }
    .upload-task-row .col-file {
        flex: 1 1 100%; max-width: 100%; order: 1;
    }
    .upload-task-row .file-name {
        white-space: normal; word-break: break-all; font-size: 13px;
    }
    .upload-task-row .file-path {
        white-space: normal; word-break: break-all;
    }
    .upload-task-row .col-size { display: flex !important; flex: 0 0 auto; order: 3; }
    .upload-task-row .col-operator { display: flex !important; flex: 0 0 auto; order: 4; }
    .upload-task-row .col-status { display: flex !important; flex: 0 0 auto; order: 5; }

    /* Compact upload toolbar on mobile */
    .modern-upload-toolbar { padding: 6px 10px; }
    .modern-upload-toolbar .action-btn span { display: none; }

    /* ── Download table → card layout ── */
    .download-table { display: block; }
    .download-table thead { display: none; }
    .download-table tbody { display: flex; flex-direction: column; gap: 6px; }
    .download-table tbody tr {
        display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
        background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--border-radius);
        padding: 8px 10px; border-left: 3px solid var(--border);
    }
    .download-table tbody tr.status-running { border-left-color: var(--primary); }
    .download-table tbody td { padding: 0; border: none; vertical-align: baseline; }
    .download-table .file-cell {
        flex: 1 1 100%; max-width: 100%; width: auto; order: 1;
    }
    .download-table .file-name {
        white-space: normal; word-break: break-all; font-size: 13px;
    }
    .download-table .file-processes { margin-top: 4px; }
    .download-table .process-item span {
        white-space: normal; word-break: break-all;
    }
    .download-table .size-cell { order: 2; font-size: 12px; color: var(--text-secondary); }
    .download-table .buffer-cell { order: 3; font-size: 12px; color: var(--text-secondary); }
    .download-table .speed-cell { order: 4; font-size: 12px; }
    .download-table .threads-cell { order: 5; font-size: 12px; color: var(--text-secondary); }
    .download-table .size-cell::before { content: "Size: "; color: var(--text-muted); font-size: 11px; }
    .download-table .buffer-cell::before { content: "Buf: "; color: var(--text-muted); font-size: 11px; }
    .download-table .speed-cell::before { content: "Speed: "; color: var(--text-muted); font-size: 11px; }
    .download-table .threads-cell::before { content: "T: "; color: var(--text-muted); font-size: 11px; }

    /* ── Copy task cards: improve mobile layout ── */
    .copy-task-compact { padding: 8px 10px; }
    .detail-value-compact { white-space: normal; word-break: break-all; }
    .detail-label-compact { min-width: 60px; }

    /* ── Merge task cards ── */
    .task-card { padding: 8px 10px; }
}

/* ---------- Mount Cards ---------- */
.mount-card {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mount-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #7c3aed, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.mount-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.mount-path-pill {
    font-size: 12px;
    font-family: monospace;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    word-break: break-all;
    display: inline-block;
}

.mount-badges {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    flex-shrink: 0;
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
}

.mount-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
}

.mount-action-buttons {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover:not(:disabled) {
    background: var(--bg-tertiary);
}
.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.btn-icon.btn-success {
    color: var(--success);
    border-color: var(--success);
    background: var(--bg-secondary);
}
.btn-icon.btn-warning {
    color: #e67e22;
    border-color: #e67e22;
    background: var(--bg-secondary);
}
.btn-icon.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--bg-secondary);
}

.mount-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.mount-tag {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.mount-tag.tag-warning { color: var(--warning); }
.mount-tag.tag-success { color: var(--success); }

.mount-error {
    font-size: 12px;
    color: var(--danger);
    padding: 6px 10px;
    background: rgba(220, 53, 69, 0.08);
    border-radius: var(--border-radius);
    margin-top: 6px;
}

.mount-preview {
    font-size: 12px;
    color: var(--info);
    padding: 6px 10px;
    background: rgba(13, 202, 240, 0.08);
    border-radius: var(--border-radius);
    margin-top: 6px;
}

.mount-form .form-group { margin-bottom: 14px; }

.input-with-button {
    display: flex;
    gap: 6px;
    align-items: center;
}
.input-with-button .form-input { flex: 1; }

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.advanced-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}

.confirm-warning {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    background: rgba(255, 193, 7, 0.08);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 193, 7, 0.2);
}

.mount-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

/* ---------- Settings Page ---------- */
.settings-section { padding: 4px 0; }

/* Two-column responsive grid for settings cards */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 4px 0;
}
.settings-grid .setting-group {
    margin-bottom: 0; /* gap replaces margin-bottom */
}
.setting-group-wide {
    grid-column: 1 / -1; /* span all columns */
}
@media (max-width: 760px) {
    .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .setting-group {
        padding: 12px;
        border-radius: var(--border-radius);
    }
    .setting-row {
        gap: 4px 8px;
    }
    .setting-row > label:not(.toggle-switch) {
        min-width: 80px;
    }
    .setting-row > select.form-input,
    .setting-row > input[type="number"].form-input {
        min-width: 80px;
        max-width: 120px !important;
    }
    .setting-row .input-with-button {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100% !important;
        box-sizing: border-box;
    }
}

.setting-group {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.setting-group h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.setting-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}
.setting-row:last-child { border-bottom: none; }

/* Left side wrapper (label + help text together) — shrinks to let control stay on line */
.setting-row > div {
    flex: 1;
    min-width: 0;
}

/* Bare label (old flat pattern) — also takes available space */
.setting-row > label:not(.toggle-switch) {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
    min-width: 120px;
}

/* Label inside a wrapper div */
.setting-row > div > label:not(.toggle-switch) {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-row .toggle-switch {
    min-width: unset;
    flex-shrink: 0;
}

/* Right-side select/number controls — fixed width, never wrap */
.setting-row > select.form-input,
.setting-row > input[type="number"].form-input {
    flex: 0 0 auto;
    width: auto;
    min-width: 100px;
    max-width: 200px;
    text-align: right;
}

/* Right-side text inputs — flexible, fill available space */
.setting-row > input[type="text"].form-input,
.setting-row > input[type="url"].form-input,
.setting-row > input[type="password"].form-input {
    flex: 1;
    min-width: 120px;
    max-width: 400px;
}

/* Compound control containers (input + unit toggle, input + link) */
.setting-row > div[style*="display:flex"] {
    flex: 0 1 auto;
    min-width: 0;
}

/* Help text as flat sibling (old pattern) — full width on its own row */
.setting-row > p.setting-help {
    flex: 0 0 100%;
    margin: 0;
}

/* Port URL hint (inside left-side wrapper div) */
.port-url-hint {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.port-url-hint code {
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.port-url-hint .btn-link {
    padding: 2px 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.port-url-hint .btn-link:hover { color: var(--accent); }

.setting-row .form-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.setting-help {
    width: 100%;
    margin: 2px 0 0;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-muted);
    opacity: 0.65;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

/* Settings: log level grid */
.log-levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.log-level-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 12px;
}
.log-level-card label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}
.log-level-card .form-input {
    width: 100%;
    max-width: none;
    text-align: left;
}

/* Settings: disk cache note banner */
.disk-cache-note {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    align-items: flex-start;
}
.disk-cache-note-icon { color: var(--primary); font-size: 1.1rem; margin-top: 2px; flex-shrink: 0; }
.disk-cache-note p { margin: 0 0 8px; font-size: 0.9rem; }

/* Settings: disk cache folders list */
.disk-cache-folders-list { margin-bottom: 16px; }
.dc-folder-row {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    margin-bottom: 6px;
    background: var(--bg-secondary);
}
.dc-folder-path { font-weight: 500; margin-bottom: 4px; }
.dc-folder-path a { color: var(--primary); text-decoration: none; }
.dc-folder-path a:hover { text-decoration: underline; }
.dc-folder-rules { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.8rem; color: var(--text-secondary); align-items: center; }
.dc-rule { white-space: nowrap; }
.dc-folder-cfg-btn { margin-left: auto; padding: 2px 8px; font-size: 0.8rem; opacity: 0.7; }
.dc-folder-cfg-btn:hover { opacity: 1; }

/* Properties panel: disk cache status */
.disk-cache-status { margin-top: 6px; }

/* Settings: disk cache stats panel */
.disk-cache-stats-panel {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
}
.disk-cache-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    cursor: pointer;
    user-select: none;
}
.disk-cache-stats-toggle {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 0;
}
.disk-cache-stats-actions { display: flex; gap: 8px; }
.disk-cache-stats-body { padding: 16px; }

/* Settings: disk cache usage bar */
.disk-cache-usage-section { margin-bottom: 16px; }
.disk-cache-usage-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 6px; }
.disk-cache-usage-bar { display: flex; flex-direction: column; gap: 4px; }
.usage-bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}
.usage-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Settings: disk cache stats 4-card grid */
.disk-cache-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.disk-cache-stat {
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 12px 16px;
}
.disk-cache-stat .stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.disk-cache-stat .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}
@media (max-width: 768px) {
    .disk-cache-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .disk-cache-stats-grid { grid-template-columns: 1fr; }
    .disk-cache-stats-header { flex-direction: column; gap: 8px; align-items: flex-start; }
}

/* Settings: btn-group-toggle (KB/MB/GB unit selector) */
.btn-group-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
}
.btn-group-toggle .btn-xs {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    margin: 0;
}
.btn-group-toggle .btn-xs:last-child { border-right: none; }
.btn-group-toggle .btn-xs.active {
    background: var(--primary);
    color: #fff;
}

/* Settings: priority order pills */
.priority-order-list { margin-bottom: 4px; }
.priority-pill {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
}
.priority-label {
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 500;
}
.priority-arrow {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: var(--transition);
}
.priority-arrow:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ---------- Info Card (About, Profile, WebDAV) ---------- */
.info-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.info-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.info-card.alert-info {
    border-color: var(--info);
    background: rgba(13, 202, 240, 0.05);
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}
.info-row:last-child { border-bottom: none; }

.info-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.info-value {
    font-size: 13px;
    color: var(--text-primary);
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Profile Page ---------- */
.profile-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.profile-content > .profile-header-card {
    grid-column: 1 / -1;
}

.profile-section-full {
    grid-column: 1 / -1;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    margin-bottom: 16px;
}

.profile-avatar { color: var(--primary); }

.profile-info h2 { font-size: 20px; font-weight: 600; }
.profile-email { font-size: 13px; color: var(--text-secondary); }

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* Keep form action buttons always visible at the bottom of scrollable modals */
.modal-body .form-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    padding: 12px 0 0;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    z-index: 1;
}
/* held at the dialog's edge, not the body's padding above it, with the dialog's own colour, so nothing scrolled
   shows below or behind the buttons */
.modal-body .form-actions {
    bottom: -20px;
    margin-bottom: -20px;
    padding-bottom: 20px;
}
[data-theme="dark"] .modal-body .form-actions { background: var(--bg-secondary); }

/* ---------- Token Card ---------- */
.token-value {
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.token-value code {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    word-break: break-all;
}

/* ---------- Badge Variants ---------- */
.badge-primary {
    background: rgba(13, 110, 253, 0.15);
    color: var(--primary);
}

.badge-danger {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger);
}

.badge-warning {
    background: rgba(255, 193, 7, 0.2);
    color: #b38600;
}
[data-theme="dark"] .badge-warning { color: var(--warning); }

.badge-info {
    background: rgba(13, 202, 240, 0.15);
    color: var(--info);
}

.badge-group {
    display: flex;
    gap: 4px;
}

/* ---------- Button Variants ---------- */
.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-success:hover { background: color-mix(in srgb, var(--success) 85%, #000); border-color: color-mix(in srgb, var(--success) 85%, #000); }

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #000;
}
.btn-warning:hover { background: color-mix(in srgb, var(--warning) 85%, #000); border-color: color-mix(in srgb, var(--warning) 85%, #000); }

/* ---------- WebDAV Page ---------- */
.webdav-status-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
}
.webdav-status-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.webdav-status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot-active {
    background: var(--success, #22c55e);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}
.status-dot-inactive {
    background: var(--text-muted);
}
.status-text { font-size: 0.9rem; }
.status-active { color: var(--success, #22c55e); }
.status-inactive { color: var(--text-muted); }

.webdav-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.webdav-url-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.webdav-url-value {
    font-family: monospace;
    font-size: 0.85rem;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-primary);
    user-select: all;
}
.webdav-address-block {
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.webdav-url-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.webdav-url-list .webdav-url-label { min-width: 11em; }

/* Config Grid */
.webdav-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.webdav-config-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}
.webdav-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}
.webdav-config-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.webdav-config-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}
.webdav-config-icon {
    color: var(--primary);
    font-size: 1.1rem;
}
.webdav-config-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.webdav-config-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.webdav-config-note i { margin-top: 2px; }
.webdav-config-warning {
    color: var(--warning, #f59e0b);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    transition: 0.25s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
    border-color: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}
/* The real checkbox is 0x0 and invisible, so its own outline can't show;
   draw the keyboard focus ring on the slider instead. */
.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Users Section */
.webdav-users-section {
    margin-top: 8px;
}
.webdav-users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.webdav-users-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}
.webdav-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.webdav-user-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--transition), transform var(--transition);
}
.webdav-user-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.webdav-user-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 10px;
}
.webdav-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}
.webdav-user-info {
    flex: 1;
    min-width: 0;
}
.webdav-user-info h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.webdav-user-status {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}
.webdav-user-body {
    padding: 0 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.webdav-user-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.webdav-user-path {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.webdav-user-path-label { white-space: nowrap; }
.webdav-user-path code {
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}
.webdav-user-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* ---------- WebDAV Mobile ---------- */
@media (max-width: 768px) {
    .webdav-status-card { padding: 12px 14px; gap: 12px; }
    .webdav-url-row { flex-wrap: wrap; }
    .webdav-url-value { word-break: break-all; min-width: 0; }
    .webdav-config-grid { grid-template-columns: 1fr; }
    .webdav-users-grid { grid-template-columns: 1fr; }
    .webdav-user-path code { max-width: none; }
    .webdav-user-actions { flex-wrap: wrap; }
}
@media (max-width: 480px) {
    .webdav-status-card { padding: 10px 12px; gap: 10px; }
    .webdav-status-left { gap: 10px; }
    .webdav-config-header { padding: 10px 12px; }
    .webdav-config-body { padding: 12px; }
    .webdav-user-header { padding: 10px 12px 8px; }
    .webdav-user-body { padding: 0 12px 10px; }
    .webdav-user-actions { padding: 8px 12px; }
    .webdav-users-header { flex-wrap: wrap; gap: 8px; }
}

/* ---------- About Page ---------- */
.about-header {
    background: linear-gradient(135deg, var(--primary), #6c757d);
    color: #fff;
    padding: 2rem;
    border-radius: 0 0 1rem 1rem;
    margin: -20px -20px 1.5rem -20px;
}
.about-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.about-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.about-title-row h1 {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
}
.about-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
}
.about-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.about-actions .btn {
    color: #fff;
}
.about-subtitle {
    font-size: 1rem;
    opacity: 0.85;
    margin-top: 0.5rem;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.about-section {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}
.about-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.about-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.about-section-title i {
    color: var(--primary);
    font-size: 1.1rem;
}
.about-section-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}
.about-section-body {
    padding: 1.25rem;
}
.about-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}
.about-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.about-info-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.about-info-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Version pill badges */
.version-pill {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
}
.version-pill.current {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.version-pill.new {
    background: var(--success);
    color: #fff;
    animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Update section */
.update-available, .update-current {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.update-status-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.update-status-icon.success {
    background: rgba(25, 135, 84, 0.1);
    color: var(--success);
}
.update-status-icon.current {
    background: rgba(13, 110, 253, 0.1);
    color: var(--primary);
}
.update-details p {
    margin: 0 0 4px;
    font-size: 0.95rem;
}
.update-description {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    font-size: 0.85rem;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    margin: 8px 0;
}
.update-status {
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.update-progress-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}
.update-progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.update-progress-bar-container {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}
.update-progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width 0.3s ease;
}
.update-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.update-installing-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
}
.update-installing-spinner i {
    font-size: 2rem;
    color: var(--primary);
}
.update-progress-message {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* External links */
.external-links {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.external-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: var(--primary);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: all 0.15s;
}
.external-link:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
    text-decoration: none;
}
.external-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}
.link-info {
    display: flex;
    flex-direction: column;
}
.link-title {
    font-weight: 600;
    font-size: 0.9rem;
}
.link-url {
    font-size: 0.8rem;
    opacity: 0.7;
    font-family: monospace;
}

@media (max-width: 768px) {
    .about-header {
        padding: 1.25rem;
    }
    .about-header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    .about-title-row h1 {
        font-size: 1.5rem;
    }
    .about-actions {
        width: 100%;
    }
    .about-actions .btn {
        flex: 1;
    }
    .about-info-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Header Actions ---------- */
.header-actions {
    display: flex;
    gap: 8px;
}

/* ---------- Devices Page ---------- */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}
.device-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    max-width: 400px;
    position: relative;
}
.device-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(135deg, #1e40af, #0ea5e9);
}
.device-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.device-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
.device-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: linear-gradient(135deg, #1e40af, #0ea5e9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.device-name-group {
    min-width: 0;
}
.device-name {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.device-type {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.device-details {
    padding: 0.75rem 1rem;
}
.detail-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}
.detail-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.detail-value {
    font-size: 0.75rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ip-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    padding: 1px 3px;
    line-height: 1;
}
.ip-toggle:hover {
    color: var(--primary);
}
.device-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}
.device-actions .btn {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---------- Utilities ---------- */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar:not(.open) {
        transform: translateX(-100%);
    }

    .content-body {
        padding: 12px 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .function-cards {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 1rem;
    }

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

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

    .col-modified { display: none; }
}

@media (max-width: 480px) {
    .content-body { padding: 8px 12px; }
    .col-size { display: none; }
}

/* ---------- Performance Page ---------- */
.perf-connection-status {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.perf-stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.perf-stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.perf-stat-card:hover { box-shadow: var(--shadow-sm); }

.perf-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.perf-stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.perf-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.perf-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.perf-stat-icon.cpu { background: rgba(220, 53, 69, 0.12); color: var(--danger); }
.perf-stat-icon.memory { background: rgba(111, 66, 193, 0.12); color: #6f42c1; }
.perf-stat-icon.download { background: rgba(13, 110, 253, 0.12); color: var(--primary); }
.perf-stat-icon.upload { background: rgba(25, 135, 84, 0.12); color: var(--success); }

.progress-fill.cpu { background: var(--danger); }
.progress-fill.memory { background: #6f42c1; }
.progress-fill.download { background: var(--primary); }
.progress-fill.upload { background: var(--success); }

.perf-sparkline {
    font-family: monospace;
    font-size: 14px;
    letter-spacing: 1px;
    margin-top: 10px;
    color: var(--accent-color, var(--primary));
    overflow: hidden;
    white-space: nowrap;
}

.perf-minmax {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.perf-chart-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.perf-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.perf-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.perf-data-points {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.perf-card-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.perf-chart-body { padding: 12px 16px; }

/* Performance sections (System Details, Open File Handles) */
.perf-section {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
}

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

.perf-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.perf-section-title i { color: var(--primary); font-size: 16px; }
.perf-section-title h2 { margin: 0; font-size: 15px; font-weight: 600; }

.perf-section-body { padding: 20px; }

/* System Details grid */
.system-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.sys-detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.sys-detail-item.clickable {
    cursor: pointer;
}

.sys-detail-item.clickable:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.sys-detail-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(13, 110, 253, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.sys-detail-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.sys-detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.sys-detail-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.sys-detail-arrow {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

@media (max-width: 1200px) {
    .perf-stat-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .perf-stat-cards { grid-template-columns: 1fr; }
    .system-details-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .system-details-grid { grid-template-columns: 1fr; }
}

/* ---------- Membership Page ---------- */
.membership-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.plan-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}

.plan-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.plan-icon {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 12px;
}

.plan-price {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 12px;
}

.plan-duration {
    font-size: 15px;
    font-weight: 400;
    color: var(--text-secondary);
}

.membership-error {
    padding: 40px 20px;
    text-align: center;
    color: var(--danger);
}

.membership-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    flex-wrap: wrap;
}

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

.membership-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.membership-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.membership-header-info h2 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.membership-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.membership-balance {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.membership-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    white-space: nowrap;
}

.plan-badge-primary {
    background: linear-gradient(135deg, #ffd700, #ffb300);
    color: #5a4000;
}

.plan-badge-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.plan-badge-premium {
    background: linear-gradient(135deg, #ffd700, #ffb300);
    color: #5a4000;
}

.plan-badge-pro {
    background: linear-gradient(135deg, #4dabf7, #228be6);
    color: #fff;
}

.plan-badge-free {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.membership-badges .plan-badge-pro {
    background: #1766a6;
}

.plan-badge-ribbon {
    position: absolute;
    top: -1px;
    right: -1px;
    background: linear-gradient(135deg, #ffd700, #ff9800);
    color: #5a4000;
    padding: 4px 12px;
    border-radius: 0 var(--border-radius-lg) 0 var(--border-radius-lg);
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-card { position: relative; }

/* Scope chip on plan cards that grant the App-Pro entitlement (App Pro: "For the
   App and this console"; Ultimate Bundle: "Core + App"). Placed right under the
   plan name so users see at a glance what the SKU covers. */
.plan-scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 8px;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.plan-scope-chip i { font-size: 0.9em; }

/* CloudDrive2 App ecosystem clarifier — sits above the plans grid whenever the
   catalog includes an App-Pro plan. Sized like an alert-info sibling so it
   feels informational, not promotional. */
.app-ecosystem-notice {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: var(--border-radius);
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-secondary, transparent));
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
}
.app-ecosystem-notice-icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--primary) 18%, transparent);
    color: var(--primary);
    font-size: 1.05em;
}
.app-ecosystem-notice-body { flex: 1 1 auto; min-width: 0; }
.app-ecosystem-notice-title {
    margin: 0 0 4px;
    font-size: 0.95em;
    color: var(--text-primary, var(--text));
}
.app-ecosystem-notice-text {
    margin: 0 0 10px;
    font-size: 0.85em;
    color: var(--text-secondary, var(--text-muted));
    line-height: 1.5;
}
.app-ecosystem-notice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
@media (max-width: 520px) {
    .app-ecosystem-notice { flex-direction: column; }
    .app-ecosystem-notice-icon { align-self: flex-start; }
}

.plan-featured {
    border-color: #ffd700;
    box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.3);
}

.plan-original-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.65em;
    font-weight: 400;
    margin-right: 6px;
}

.plan-current-price {
    font-weight: 700;
}

.plan-features-list {
    text-align: left;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plan-feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    padding: 2px 0;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    padding: 4px 0;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.95em;
}

.feature-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
}
.feature-icon.feature-enabled { background: rgba(25, 135, 84, 0.12); color: var(--success); }
.feature-icon.feature-disabled { background: var(--bg-tertiary); color: var(--text-muted); }

.feature-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.feature-name {
    color: var(--text-primary);
    font-weight: 500;
}

.feature-desc {
    font-size: 0.85em;
    color: var(--text-muted);
}

.feature-value {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}
.feature-value-unlimited {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}
.feature-value-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
.feature-value-badge.enabled {
    background: rgba(25, 135, 84, 0.12);
    color: var(--success);
    border: 1px solid rgba(25, 135, 84, 0.2);
}
.feature-value-badge.disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}
/* The cross alone is loud. A feature the account does NOT have is what a reader
   scans this list for, and in the muted grey the mark read as a dim tick at the
   same weight as its own DISABLED label — which stays muted. */
/* the Media Server without App Pro: "Needs App Pro" (amber that passes AA on the card in both themes) */
:root { --needs-pro: #92400e; }
[data-theme="dark"] { --needs-pro: #fdba74; }
.feature-value-badge.needs-pro {
    color: var(--needs-pro);
    background: rgba(245, 158, 11, 0.14);
    font-weight: 600;
}

.feature-value-badge.disabled i {
    color: var(--danger);
}
.feature-value-badge.filesize {
    background: rgba(13, 110, 253, 0.1);
    color: var(--primary);
    border: 1px solid rgba(13, 110, 253, 0.2);
}

.panel-header-row {
    margin-bottom: 4px;
}

.activation-alert {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 0.9em;
    display: flex;
    align-items: center;
}
.activation-alert.error {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
    border: 1px solid rgba(220, 53, 69, 0.2);
}
.activation-alert.success {
    background: rgba(25, 135, 84, 0.1);
    color: var(--success);
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.promotion-banners-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.promotion-banner {
    border-radius: 10px;
    padding: 16px;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.promotion-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}
.banner-logo { flex-shrink: 0; }
.banner-text { flex: 1; }
.banner-text h4 { margin: 0 0 4px 0; font-size: 1.05em; font-weight: 600; }
.banner-text p { margin: 0; font-size: 0.85em; opacity: 0.9; }
.banner-action { opacity: 0.8; font-size: 1.1em; }

/* ---------- Promotions Page ---------- */
.promo-loading { text-align: center; padding: 48px 0; }
.promo-loading p { margin-top: 12px; }

.promo-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    gap: 0;
}
.promo-tab-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: var(--transition);
}
.promo-tab-btn:hover { color: var(--text-primary); }
.promo-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.promo-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}
.promo-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}
.promo-title { margin: 0; font-size: 1.3em; font-weight: 600; }
.promo-subtitle { margin: 6px 0 0; color: var(--text-secondary); font-size: 0.95em; }

.promo-card-body { padding: 24px; }

.promo-qr-section {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    padding: 20px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
}
.promo-qr-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 200px;
}
.promo-qr-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
    border: 2px dashed var(--border);
    border-radius: var(--border-radius);
}
.promo-qr-img {
    max-width: 250px;
    max-height: 250px;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.promo-qr-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.promo-qr-instructions {
    font-size: 0.95em;
    color: var(--text-secondary);
    margin: 0 0 8px;
}
.promo-qr-link {
    font-size: 0.85em;
    word-break: break-all;
    color: var(--primary);
}

.promo-rules-section,
.promo-notices-section {
    margin-bottom: 20px;
}
.promo-section-title {
    font-size: 1.05em;
    font-weight: 600;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.promo-rules-list,
.promo-notices-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.promo-rule-item,
.promo-notice-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-left: 3px solid var(--primary);
    background: var(--bg-secondary);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    font-size: 0.93em;
    line-height: 1.5;
}
.promo-rule-icon { color: var(--primary); margin-top: 2px; flex-shrink: 0; }
.promo-notice-item { border-left-color: var(--warning); }
.promo-notice-icon { color: var(--warning); margin-top: 2px; flex-shrink: 0; }

.promo-agreement-section {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    text-align: center;
}
.promo-agreement-text {
    margin: 0 0 16px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

@media (max-width: 768px) {
    .promo-qr-section {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .promo-qr-container { justify-content: center; }
    .promo-qr-info { align-items: center; }
}

.activation-confirm {
    margin-top: 10px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
}

.form-label {
    display: block;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ---------- Profile Page ---------- */
.profile-header-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
}

.profile-avatar-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.profile-header-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-header-info h2 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}

.detail-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.security-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.security-card {
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.security-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.security-card-header:hover {
    background: var(--bg-tertiary);
}

.security-card-disabled .security-card-header {
    cursor: not-allowed;
    opacity: 0.6;
}

.security-card-disabled .security-card-header:hover {
    background: var(--bg-secondary);
}

.security-card-disabled-note {
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 0.85em;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

/* Destructive security card (delete account) — flagged in red so it reads as
   distinct from the routine cards next to it. The focus ring is inherited from
   the shared :focus-visible rules; only the colour changes here. */
.security-card-danger-title {
    color: var(--danger, #dc3545);
}

.security-card-disabled .security-card-danger-title {
    color: var(--text-muted);
}

/* "What will be deleted" list inside the delete-account modal */
.delete-account-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.delete-account-list li {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    line-height: 1.45;
}

.delete-account-list li + li {
    border-top: 1px solid var(--border-light);
}

.delete-account-list li i {
    flex: 0 0 auto;
    margin-top: 3px;
    color: var(--text-muted);
}

.security-form {
    padding: 16px;
    border-top: 1px solid var(--border-light);
}

.inline-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.inline-error {
    margin: 8px 0;
    padding: 10px 12px;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 6px;
    color: var(--danger, #dc3545);
    font-size: 0.9em;
}

.recovery-codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    margin: 12px 0;
}

.recovery-code-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 0.85em;
}

.recovery-code-num {
    color: var(--text-muted);
    font-size: 0.75em;
    min-width: 18px;
}

@media (max-width: 768px) {
    .membership-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .membership-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .plans-grid {
        grid-template-columns: 1fr;
    }
    .features-grid {
        grid-template-columns: 1fr;
    }
    .details-grid {
        grid-template-columns: 1fr;
    }
    .profile-content {
        grid-template-columns: 1fr;
    }
    .profile-header-card {
        flex-direction: column;
        text-align: center;
    }
    .security-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Data Table ---------- */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* ---------- Webhook Content ---------- */
.webhook-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

/* ---------- Nav Badge ---------- */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--danger);
    border-radius: 10px;
    margin-left: auto;
}

/* Task count badges in sidebar */
.task-counts-badges {
    display: flex;
    gap: 3px;
    margin-left: auto;
}
.task-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
}
.task-badge:hover { opacity: 0.85; text-decoration: none; color: #fff; }
.task-badge.copy { background: #ff6b6b; }
.task-badge.download { background: #2196f3; }
.task-badge.upload { background: #4caf50; }
.task-badge.qps { background: #7e57c2; }

/* Update indicator dot (green, matching Blazor) */
.update-indicator {
    color: #22c55e;
    font-size: 12px;
    margin-left: auto;
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
/* Update dot overlay on avatar/icon buttons — positioned top-right */
.update-dot-badge {
    position: relative;
    display: inline-flex;
}
.update-dot-badge::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    pointer-events: none;
    z-index: 1;
    animation: pulse-dot 2s ease-in-out infinite;
}
/* Update dot on bottom tab bar Settings item */
.tab-update-dot {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    pointer-events: none;
    z-index: 1;
    animation: pulse-dot 2s ease-in-out infinite;
}

/* ---------- Search Bar ---------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.search-bar .form-input {
    flex: 1;
    max-width: 400px;
}

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

/* Active toolbar button */
.toolbar-actions-left .btn.active,
.toolbar-actions-right .btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ---------- Folder Selector Modal ---------- */
.modal-folder-selector {
    max-width: 500px;
    height: 70vh;
    display: flex;
    flex-direction: column;
}

.modal-folder-selector .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Breadcrumb */
.folder-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 2px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    min-height: 34px;
}
.folder-breadcrumb::-webkit-scrollbar { display: none; }
.folder-breadcrumb .breadcrumb-item {
    cursor: pointer;
    color: var(--primary);
    padding: 2px 4px;
    border-radius: 3px;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.breadcrumb-item:hover:not(.breadcrumb-current) {
    background: var(--bg-secondary);
}
.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
    cursor: default;
}
.breadcrumb-sep {
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 12px;
    margin: 0 1px;
    user-select: none;
}

/* Folder list (flat browser) */
.folder-list {
    padding: 4px 0;
    min-height: 200px;
}

.folder-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition);
}
.folder-list-item:hover {
    background: var(--bg-secondary);
}
.folder-list-item.folder-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}


.folder-list-item .folder-icon {
    color: var(--folder-icon);
    font-size: 14px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

/* A file offered by the picker's file-pick mode (e.g. a Google client .json) */
.folder-list-item .folder-file-icon {
    color: var(--text-secondary);
    font-size: 14px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.folder-entry-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Read-only marker on a non-selectable destination folder */
.folder-entry-readonly-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 193, 7, 0.2);
    color: #8a6500;
}
[data-theme="dark"] .folder-entry-readonly-badge {
    color: var(--warning);
}

/* Up-folder (..) item */
.up-folder {
    color: var(--text-secondary);
    font-weight: 500;
}
.up-folder:hover {
    color: var(--text-primary);
}
.folder-icon-up {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

/* Inline new folder row */
.new-folder-item {
    cursor: default;
    gap: 6px;
}
.new-folder-item:hover {
    background: transparent;
}
.folder-icon-create {
    color: var(--success, #28a745);
    font-size: 14px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}
.new-folder-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}
.new-folder-input:focus {
    border-color: var(--primary);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
    transition: var(--transition);
}
.btn-icon-confirm {
    background: var(--success, #28a745);
    color: #fff;
}
.btn-icon-confirm:hover:not(:disabled) {
    opacity: 0.85;
}
.btn-icon-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-icon-cancel {
    background: none;
    color: var(--text-muted);
}
.btn-icon-cancel:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Empty state */
.folder-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Filter bar */
.folder-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
}

.folder-filter-icon {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

.folder-filter-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}
.folder-filter-input:focus {
    border-color: var(--primary);
}
.folder-filter-input::placeholder {
    color: var(--text-muted);
}

.folder-filter-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: var(--transition);
}
.folder-filter-clear:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Inline create button (in filter bar) */
.btn-create-inline {
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    background: var(--success, #28a745);
    color: #fff;
    border: none;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-create-inline:hover:not(:disabled) {
    opacity: 0.85;
}
.btn-create-inline:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Selected path display */
.selected-path-display {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-select-warning {
    width: 100%;
    font-size: 0.8rem;
    color: var(--warning, #e6a700);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

/* Footer left actions (create folder button) */
.modal-footer-left {
    flex-shrink: 0;
}

/* Save / restore row */
.folder-save-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.folder-save-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.folder-save-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.btn-go-saved {
    white-space: nowrap;
    font-size: 12px;
    color: var(--primary);
    background: none;
    border: 1px solid var(--primary);
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-go-saved:hover {
    background: var(--primary-light);
}

/* ---------- Path Autocomplete Dropdown ---------- */
.path-autocomplete-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}
.path-autocomplete-wrapper .breadcrumb-path-input {
    width: 100%;
    box-sizing: border-box;
}
.path-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1002;
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow-lg);
}
.path-ac-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.1s;
}
.path-ac-option:hover {
    background: var(--bg-secondary);
}
.path-ac-active {
    background: var(--primary-light);
    color: var(--primary);
}
.path-ac-icon {
    font-size: 14px;
    color: var(--folder-icon);
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}
.path-ac-cloud-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    object-fit: contain;
}
.path-ac-lock {
    font-size: 10px;
    color: var(--warning, #f0ad4e);
    flex-shrink: 0;
}
.path-ac-unlock {
    font-size: 10px;
    color: var(--success, #28a745);
    flex-shrink: 0;
}
.path-ac-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Folder Picker: Breadcrumb Bar with Edit ---------- */
.folder-breadcrumb-bar {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}
.folder-breadcrumb-bar .folder-breadcrumb {
    flex: 1;
    min-width: 0;
}
.folder-breadcrumb-bar .path-autocomplete-wrapper {
    flex: 1;
    min-width: 0;
}
.folder-breadcrumb-bar .breadcrumb-edit-btn {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0.6;
}
.folder-breadcrumb-bar .breadcrumb-edit-btn:hover {
    opacity: 1;
}

/* ---------- Folder Picker: Cloud Icons & Encryption Badges ---------- */
.folder-entry-icon-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.folder-cloud-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
}
.folder-enc-badge {
    font-size: 9px;
    color: var(--warning, #f0ad4e);
}
.folder-enc-badge.folder-enc-unlocked {
    color: var(--success, #28a745);
}

/* ---------- Folder Picker: Unlock Dialog ---------- */
.folder-unlock-overlay {
    position: absolute;
    inset: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-lg);
}
.folder-unlock-dialog {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
    width: 90%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
}
.folder-unlock-dialog h4 {
    margin: 0 0 8px;
    font-size: 15px;
}
.folder-unlock-path {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.folder-unlock-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.modal-actions {
    display: flex;
    gap: 8px;
}

/* ---------- Add Cloud Form ---------- */
.add-cloud-form {
    max-width: 100%;
}

.add-cloud-form .form-group {
    margin-bottom: 14px;
}

.add-cloud-form .form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.add-cloud-form select.form-input {
    cursor: pointer;
}

/* ---------- Config Display ---------- */
.config-display {
    font-size: 13px;
}

.config-pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 12px;
    font-size: 11px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    overflow-x: auto;
    max-height: 300px;
    margin-top: 8px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------- Context Menu ---------- */
.context-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
}

.context-menu {
    position: fixed;
    min-width: 180px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 2001;
    animation: fade-in 0.1s ease;
    /* A popup's length is the data's; never let it clip its own tail. */
    max-height: min(70vh, 520px);
    overflow-y: auto;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}
.context-menu-item:hover {
    background: var(--bg-secondary);
}
.context-menu-item.danger {
    color: var(--danger);
}
.context-menu-item.danger:hover {
    background: rgba(220, 53, 69, 0.08);
}
.context-menu-item i, .context-menu-item .icon-xunlei {
    width: 16px;
    text-align: center;
    font-size: 12px;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}
.context-menu-submenu {
    position: relative;
}
.context-menu-submenu > .context-menu-item::after {
    content: '\f054';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 9px;
    margin-left: auto;
    opacity: 0.5;
}
.context-submenu-popup {
    display: none;
    position: absolute;
    top: -4px;
    left: 100%;
    min-width: 160px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 2002;
    /* A popup's length is the data's; never let it clip its own tail. */
    max-height: min(70vh, 520px);
    overflow-y: auto;
}
/* Submenu shown only via .open class (set by JS on click and mouseenter).
   No pure CSS :hover — JS handles positioning with position:fixed. */
/* When opened via click/tap (.open), show the submenu popup.
   JS (toggle_submenu) sets position:fixed + coordinates via inline styles. */
.context-menu-submenu.open > .context-submenu-popup {
    display: block;
}
/* Transparent bridge strip on the right of an open submenu row.
   This fills any pixel gap between the menu's right edge and the popup's
   left edge so the mouse never crosses dead space that would fire mouseleave. */
.context-menu-submenu.open::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 8px;
    height: 100%;
    z-index: 2002;
}

/* ---------- Recovery Codes ---------- */
.recovery-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.recovery-code {
    display: block;
    padding: 6px 10px;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    text-align: center;
}

/* ---------- File Properties Panel ---------- */
.file-props-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.file-props-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    flex-shrink: 0;
}

.file-props-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
}

/* Preview / Icon section */
.file-props-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 0 12px;
    min-height: 60px;
}
.file-props-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 0 12px 12px;
}
.file-props-thumb {
    max-width: 100%;
    max-height: 180px;
    border-radius: 4px;
    object-fit: contain;
}
.file-props-thumb-wrap,
.file-props-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.file-props-icon-wrap .wf-card-icon {
    font-size: 64px;
}
.file-props-icon-wrap .wf-card-icon img {
    width: 64px;
    height: 64px;
}
.file-props-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    pointer-events: none;
}
.file-props-encrypt-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--bg-primary);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Properties table */
.properties-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.properties-table td {
    padding: 4px 0;
    vertical-align: top;
    line-height: 1.4;
}
.prop-name {
    width: 32%;
    text-align: right;
    padding-right: 8px !important;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}
.prop-value {
    word-break: break-word;
    font-size: 12px;
    position: relative;
}
.prop-path {
    font-family: monospace;
    font-size: 11px;
    word-break: break-all;
}
.prop-hash {
    font-family: monospace;
    font-size: 10px;
    word-break: break-all;
    color: var(--text-secondary);
}
.prop-row.clickable { cursor: pointer; }
.prop-row.clickable:hover { background: var(--hover-bg); }
.copy-icon {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    margin-left: 4px;
    transition: opacity 0.15s;
}
.prop-row:hover .copy-icon { opacity: 1; }

/* Section dividers */
.section-divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 10px 0 6px;
}
.section-header {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.section-header.clickable { cursor: pointer; border-radius: 4px; padding: 2px 4px; margin-left: -4px; }
.section-header.clickable:hover { background: var(--hover-bg); }
.section-subheader {
    font-weight: 500;
    font-size: 11px;
    margin: 8px 0 4px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Space Usage */
.space-usage-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    gap: 4px;
}
.usage-bar-container {
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 4px;
}
.usage-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s;
}
.usage-low { background: var(--success); }
.usage-medium { background: linear-gradient(90deg, var(--success), #f0ad4e); }
.usage-high { background: linear-gradient(90deg, var(--success), #fd7e14); }
.usage-critical { background: linear-gradient(90deg, var(--success), var(--danger)); }

/* Cache Management */
.cache-input-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
/* Vertically center labels with buttons/inputs in cache rows */
.prop-row.cache-row td { vertical-align: middle; }
.cache-time-input {
    width: 70px;
    padding: 2px 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
}
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 13px;
    line-height: 1;
}
.btn-icon:hover { opacity: 0.7; }

/* Encryption */
.encryption-status {
    margin: 4px 0 8px;
}
.encryption-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}
.bg-warning { background: rgba(240, 173, 78, 0.2); color: #f0ad4e; }
.bg-success { background: rgba(92, 184, 92, 0.2); color: #5cb85c; }
.bg-secondary { background: rgba(128, 128, 128, 0.2); color: var(--text-secondary); }

/* ---------- Permissions Grid (legacy) ---------- */
.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.perm-grid .checkbox-label {
    font-size: 13px;
}

/* ============================================================
   API Tokens Page
   ============================================================ */

/* ---------- Tokens Section Header ---------- */
.tokens-section-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}
.tokens-section-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.tokens-section-header i {
    color: var(--primary);
}

/* ---------- Token Cards Grid ---------- */
.token-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px;
}

.token-card {
    background: var(--bg-card, var(--bg-primary));
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}
.token-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.token-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.token-card-info {
    flex: 1;
    min-width: 0;
}
.token-card-info h4 {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    word-wrap: break-word;
}

.token-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.token-badges .badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.badge-readonly {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}
.badge-readwrite {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.badge-admin {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.token-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
}
.btn-icon:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-icon-danger:hover {
    background: var(--danger, #ef4444);
    color: #fff;
    border-color: var(--danger, #ef4444);
}

.token-card-details {
    padding: 16px;
}
.token-detail-row {
    margin-bottom: 12px;
}
.token-detail-row:last-child {
    margin-bottom: 0;
}
.token-detail-label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.token-detail-value {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.token-value-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
}
.token-text {
    flex: 1;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Input with button ---------- */
.input-with-button {
    position: relative;
    display: flex;
    width: 100%;
}
.input-with-button .form-input {
    flex: 1;
    padding-right: 40px;
}
.btn-inside {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
    font-size: 13px;
}
.btn-inside:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ---------- Expires controls ---------- */
.expires-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.expires-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---------- Token display box ---------- */
.token-display-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

/* ---------- Permissions Editor (modern) ---------- */
.permissions-editor-modern {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Permission Group */
.perm-group {
    background: var(--bg-card, var(--bg-primary));
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.perm-group:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.perm-group .perm-group-content {
    display: block;
}
.perm-group.collapsed .perm-group-content {
    display: none;
}

.perm-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.perm-group-header:hover {
    background: var(--bg-hover, var(--bg-secondary));
}

.perm-group-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.perm-group-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}
.perm-group-icon {
    color: var(--primary);
    font-size: 1rem;
}

.perm-group-info {
    flex: 1;
}
.perm-group-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.perm-group-subtitle {
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: block;
    margin-top: 2px;
}

.perm-group-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Tri-state toggle (group level) */
.tri-state-toggle {
    position: relative;
    width: 44px;
    height: 22px;
    cursor: pointer;
}
.toggle-track {
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    border-radius: 11px;
    position: relative;
    transition: all 0.2s;
    border: 1px solid var(--border);
}
.tri-state-toggle.all .toggle-track {
    background: #10b981;
    border-color: #10b981;
}
.tri-state-toggle.some .toggle-track {
    background: #f59e0b;
    border-color: #f59e0b;
}
.toggle-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tri-state-toggle.all .toggle-thumb,
.tri-state-toggle.some .toggle-thumb {
    transform: translateX(22px);
}

.expand-icon {
    color: var(--text-secondary);
    transition: transform 0.2s;
    font-size: 0.875rem;
}
.expand-icon.expanded {
    transform: rotate(180deg);
}

/* Permission Sections */
.perm-sections-container {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.perm-section {
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border);
    overflow: visible;
    transition: border-color 0.2s;
}
.perm-section:hover {
    border-color: var(--text-secondary);
}

.perm-section .perm-section-content {
    display: block;
}
.perm-section.collapsed .perm-section-content {
    display: none;
}

.perm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.perm-section-header:hover {
    filter: brightness(0.95);
}

.perm-section-header-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.perm-section-icon {
    color: var(--primary);
    font-size: 0.8rem;
}
.perm-section-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}
.perm-section-badge {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 500;
    margin-left: auto;
    border: 1px solid var(--border);
}

.perm-section-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tri-state mini (section level) */
.tri-state-mini {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.tri-state-mini.all {
    background: #10b981;
    color: #fff;
    border-color: #10b981;
}
.tri-state-mini.some {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
}

.perm-section-expand {
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: transform 0.2s;
}
.perm-section-expand.expanded {
    transform: rotate(180deg);
}

/* Permission Items Grid */
.perm-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4px;
    padding: 8px 12px;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.8rem;
    color: var(--text-primary);
}
.perm-item:hover {
    background: var(--bg-secondary);
}
.perm-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.perm-item-label {
    color: var(--text-primary);
    font-size: 0.8rem;
}

@media (max-width: 600px) {
    .token-cards-grid {
        grid-template-columns: 1fr;
    }
    .token-card-header {
        flex-direction: column;
        gap: 8px;
    }
    .token-card-actions {
        justify-content: flex-start;
    }
    .perm-items-grid {
        grid-template-columns: 1fr;
    }
    .expires-inline {
        flex-direction: column;
        align-items: stretch;
    }
    .expires-inline input,
    .expires-inline select {
        width: 100% !important;
    }
}

/* ============================================================
   Backups Page
   ============================================================ */

/* ---------- Batch Action Bar ---------- */
.backup-batch-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    flex-wrap: wrap;
}
.backup-batch-bar .batch-count {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-right: 4px;
}
.backup-select-cb {
    flex-shrink: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* ---------- Backup List ---------- */
.backup-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
@media (max-width: 1024px) {
    .backup-list { grid-template-columns: 1fr; }
}

/* ---------- Backup Card ---------- */
.backup-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    border-left: 3px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
    overflow: hidden;
}
.backup-card:hover {
    box-shadow: var(--shadow-sm);
}
.backup-card.running   { border-left-color: var(--primary); }
.backup-card.completed { border-left-color: var(--success); }
.backup-card.failed    { border-left-color: var(--danger); }
.backup-card.disabled  { border-left-color: var(--text-muted); opacity: 0.7; }

/* ---------- Backup Header ---------- */
.backup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.backup-source {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.backup-source > i {
    font-size: 1.1em;
    flex-shrink: 0;
}
.backup-source > i.fa-spinner { color: var(--primary); }
.backup-source > i.fa-check-circle { color: var(--success); }
.backup-source > i.fa-exclamation-circle { color: var(--danger); }
.backup-source > i.fa-pause-circle { color: var(--text-muted); }
.backup-source-path {
    font-weight: 600;
    font-size: 0.95em;
    word-break: break-all;
}

/* ---------- Destinations Section ---------- */
.backup-destinations {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}
.backup-dest-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.backup-dest-title {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
}
.backup-dest-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.9em;
}
.backup-dest-item .dest-icon {
    color: var(--text-muted);
    font-size: 0.8em;
    flex-shrink: 0;
}
.backup-dest-item .dest-path {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.backup-dest-item .dest-toggle {
    flex-shrink: 0;
    cursor: pointer;
}

/* ---------- Inline Add Destination ---------- */
.inline-add-dest {
    border-top: 1px solid var(--border-light);
    padding-top: 10px;
    margin-top: 8px;
}
.inline-add-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.inline-add-row .form-input {
    flex: 1;
}
.inline-add-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* ---------- Error Message ---------- */
.backup-error-msg {
    background: rgba(220, 53, 69, 0.08);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Info Grid ---------- */
.backup-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--border-light);
}
.backup-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.backup-info-item .info-label {
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}
.backup-info-item span:last-child {
    font-size: 0.85em;
    font-weight: 500;
}

/* ---------- Last Backup Time ---------- */
.backup-last-time {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.backup-last-time i {
    color: var(--text-muted);
}

/* ---------- Actions ---------- */
.backup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

/* ---------- Status Panel ---------- */
.backup-status-panel {
    margin-top: 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 12px;
    background: var(--bg-secondary);
}
.status-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.status-panel-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9em;
}
.status-panel-body { font-size: 0.9em; }
.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.status-errors { margin-top: 8px; }
.status-errors-title {
    font-weight: 600;
    font-size: 0.85em;
    margin-bottom: 6px;
    color: var(--danger);
}
.status-error-item {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.85em;
    border-bottom: 1px solid var(--border-light);
}
.status-error-item:last-child { border-bottom: none; }
.error-time {
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.error-msg { color: var(--danger); }

/* ---------- Backup Mobile ---------- */
@media (max-width: 768px) {
    .backup-card { padding: 12px; }
    .backup-header { flex-wrap: wrap; gap: 8px; }
    .backup-info-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
    .backup-destinations { padding: 8px; }
    .backup-actions { gap: 4px; }
    .backup-actions .btn { font-size: 0.82em; padding: 4px 8px; }
}
@media (max-width: 480px) {
    .backup-card { padding: 10px; }
    .backup-header { gap: 6px; }
    .backup-info-grid { grid-template-columns: repeat(2, 1fr); }
    .backup-actions .btn span { display: none; }
    .backup-dest-item { font-size: 0.82em; }
}

/* ---------- Wizard Progress ---------- */
.wizard-progress {
    display: flex;
    padding: 12px 20px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.wizard-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s;
}
.wizard-step.active {
    background: var(--primary);
    color: #fff;
}
.wizard-step.completed {
    background: var(--primary-light);
    color: var(--primary);
}
.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid currentColor;
    font-size: 0.8em;
    font-weight: 700;
}
.wizard-step.active .wizard-step-num {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}
.wizard-step.completed .wizard-step-num {
    border-color: var(--primary);
}
.wizard-step-label {
    display: none;
}
@media (min-width: 600px) {
    .wizard-step-label { display: inline; }
}

/* ---------- Settings Tabs ---------- */
.settings-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: var(--bg-secondary);
    padding: 0 16px;
}
.settings-tab {
    padding: 10px 16px;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.settings-tab:hover {
    color: var(--primary);
}
.settings-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Ensure filter rules form is tall enough to show the Add Rule dropdown without clipping */
.filter-rules-form {
    min-height: 240px;
}

/* ---------- Wizard Destinations ---------- */
.wizard-dests {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}
.wizard-dest-item {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 8px;
}

/* ---------- Schedules Section ---------- */
.schedules-section {
    margin-top: 8px;
}
.schedule-item {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}
.schedule-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.schedule-time {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}
.time-input {
    width: 56px !important;
    text-align: center;
    min-width: 0 !important;
}
.schedule-days {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.days-checkboxes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.day-check {
    font-size: 0.85em !important;
}

/* ---------- Filter Rule Item ---------- */
.filter-rule-item {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
}
.filter-rule-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.filter-rule-type {
    font-weight: 600;
    font-size: 0.9em;
}
.filter-rule-options {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-wrap: wrap;
}
.filter-rule-content {
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}
.radio-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85em;
    cursor: pointer;
}
.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85em;
    cursor: pointer;
}

/* ---------- Min Size Input ---------- */
.minsize-input {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.minsize-input .form-input:first-child {
    max-width: 120px;
}
.minsize-input select {
    max-width: 100px;
}

/* ---------- Dropdown Menu ---------- */
.dropdown-menu {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: var(--shadow);
    padding: 4px 0;
    min-width: 180px;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.9em;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    text-align: left;
}
.dropdown-item:hover {
    background: var(--bg-secondary);
}

/* ---------- Alert Warning ---------- */
.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid var(--warning);
    color: #856404;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
}
[data-theme="dark"] .alert-warning {
    color: #ffc107;
    background: rgba(255, 193, 7, 0.08);
}

/* ---------- Outline Button ---------- */
.btn-outline {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ---------- Checkbox / Radio Label ---------- */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ---------- Modal Large ---------- */
.modal-lg {
    max-width: 720px;
    width: 95vw;
}
.modal-lg > .modal-body {
    min-height: 0;
}

/* ---------- Balance Log Source ---------- */
.balance-source-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}
.balance-source-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.balance-operation-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    background: var(--bg-secondary);
    padding: 1px 6px;
    border-radius: 4px;
    align-self: flex-start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ---------- Referral Modal ---------- */
.referral-modal {
    max-width: 540px;
    width: 92vw;
}
.referral-modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}
.referral-hero {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 59, 130, 246), 0.08), rgba(34, 197, 94, 0.05));
    border-radius: 16px;
    margin-bottom: 20px;
}
.referral-hero-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--success, #22c55e));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    margin: 0 auto 12px;
    box-shadow: 0 8px 24px rgba(var(--primary-rgb, 59, 130, 246), 0.3);
}
.referral-hero-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text-primary);
}
.referral-earning-highlight {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(var(--primary-rgb, 59, 130, 246), 0.1);
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--primary);
    margin-top: 10px;
}
.referral-code-section {
    padding: 20px;
    border: 2px solid var(--border-light);
    border-radius: 16px;
    margin-bottom: 20px;
}
.referral-code-label {
    display: block;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.referral-code-display {
    display: flex;
    gap: 10px;
    align-items: center;
}
.referral-code-input {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 1px;
    text-align: center;
}
.referral-benefits {
    padding: 20px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), rgba(var(--primary-rgb, 59, 130, 246), 0.05));
    border-radius: 16px;
}
.referral-benefits-title {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 16px;
    color: var(--text-primary);
}
.referral-benefit-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.referral-benefit-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card, var(--bg-secondary));
    border: 1px solid var(--border-light);
    border-radius: 12px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.referral-benefit-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.referral-benefit-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}
.referral-benefit-icon.benefit-1 { background: linear-gradient(135deg, var(--primary), var(--success, #22c55e)); }
.referral-benefit-icon.benefit-2 { background: linear-gradient(135deg, var(--success, #22c55e), var(--warning)); }
.referral-benefit-icon.benefit-3 { background: linear-gradient(135deg, var(--warning), var(--info, #06b6d4)); }
.referral-benefit-icon.benefit-4 { background: linear-gradient(135deg, var(--info, #06b6d4), var(--primary)); }
.referral-benefit-content h5 {
    margin: 0 0 4px;
    font-size: 0.9rem;
    font-weight: 600;
}
.referral-benefit-content p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

@media (max-width: 640px) {
    .referral-benefit-list {
        grid-template-columns: 1fr;
    }
}

/* ---------- Upload Progress Bar ---------- */
.upload-progress-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--border-radius);
    font-size: 0.85em;
    color: var(--primary);
    margin: 0 16px 8px;
}

/* ---------- Drag-Drop Overlay ---------- */
.files-page.drag-over {
    position: relative;
}
.drag-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 110, 253, 0.08);
    border: 3px dashed var(--primary);
    border-radius: var(--border-radius-lg);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drag-drop-content {
    text-align: center;
    color: var(--primary);
}
.drag-drop-content i {
    font-size: 3em;
    margin-bottom: 12px;
    display: block;
}
.drag-drop-content p {
    font-size: 1.1em;
    font-weight: 500;
}

/* ---------- Files Load Error ---------- */
.files-load-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    flex: 1;
    min-height: 200px;
}
.files-load-error-icon {
    font-size: 48px;
    color: var(--danger);
    margin-bottom: 16px;
}
.files-load-error-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.files-load-error-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 600px;
    width: 100%;
    line-height: 1.5;
    word-break: break-word;
    max-height: 40vh;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
}

/* ---------- Conflict Resolution ---------- */
.conflict-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95em;
}
.radio-label input[type="radio"] {
    margin: 0;
}

.conflict-files-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    margin: 12px 0 16px;
}
.conflict-files-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.conflict-files-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.conflict-files-list li {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 0;
    font-size: 0.85rem;
    font-family: var(--font-mono, monospace);
    color: var(--text-primary);
    word-break: break-all;
}
.conflict-files-list li i {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}
.conflict-files-more {
    font-family: inherit !important;
    color: var(--text-muted) !important;
    font-style: italic;
}
.conflict-action-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.conflict-action-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.conflict-action-card:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}
.conflict-action-card.selected {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, var(--bg-secondary));
}
.conflict-action-icon {
    font-size: 1.3rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--bg-tertiary);
}
.conflict-action-text {
    flex: 1;
    min-width: 0;
}
.conflict-action-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.conflict-action-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* (file-props-path/hash moved to properties-table styles above) */
.text-muted {
    color: var(--text-muted);
}

/* ---------- Bottom Tab Bar ---------- */
.bottom-tab-bar {
    display: none;
    position: fixed;
    bottom: calc(8px + var(--safe-area-bottom));
    left: 12px;
    right: 12px;
    height: var(--tab-bar-height);
    border-radius: 22px;
    /* iOS 26 Liquid Glass (adapted from kevinbism/liquid-glass-effect) */
    background: rgba(255, 255, 255, 0.12);
    -webkit-backdrop-filter: blur(2px) saturate(180%);
    backdrop-filter: blur(2px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 8px 32px rgba(31, 38, 135, 0.12),
        inset 0 4px 20px rgba(255, 255, 255, 0.2);
    z-index: 100;
    justify-content: space-around;
    align-items: stretch;
}
/* Liquid glass refraction layer — specular rim highlights + depth */
.bottom-tab-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
    box-shadow:
        inset -10px -8px 0px -11px rgba(255, 255, 255, 0.8),
        inset 0px -9px 0px -8px rgba(255, 255, 255, 0.8);
    opacity: 0.5;
    z-index: -1;
    filter: blur(1px) drop-shadow(10px 4px 6px rgba(0, 0, 0, 0.15)) brightness(115%);
    pointer-events: none;
}
[data-theme="dark"] .bottom-tab-bar {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.25),
        inset 0 4px 20px rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .bottom-tab-bar::after {
    background: rgba(255, 255, 255, 0.05);
    box-shadow:
        inset -10px -8px 0px -11px rgba(255, 255, 255, 0.5),
        inset 0px -9px 0px -8px rgba(255, 255, 255, 0.5);
    opacity: 0.4;
    filter: blur(1px) drop-shadow(10px 4px 6px rgba(0, 0, 0, 0.3)) brightness(110%);
}
.tab-bar-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    min-width: 44px;
    min-height: 44px;
    color: rgba(0, 0, 0, 0.5);
    text-decoration: none;
    font-size: 10px;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
}
[data-theme="dark"] .tab-bar-item {
    color: rgba(255, 255, 255, 0.7);
}
.tab-bar-item:hover { text-decoration: none; }
.tab-bar-item.active {
    color: var(--primary);
}
.tab-bar-item.active::before {
    content: '';
    position: absolute;
    inset: 4px 8px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.10);
    border: 0.5px solid rgba(0, 0, 0, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
    z-index: -1;
}
[data-theme="dark"] .tab-bar-item.active::before {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.tab-bar-icon {
    font-size: 18px;
    line-height: 1;
}
.tab-bar-label {
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
}

/* ---------- Mobile-only elements (hidden on desktop) ---------- */
.mobile-overflow-btn { display: none; }
.mobile-parent-btn { display: none; }
.mobile-folder-name { display: none; }
.mobile-select-btn { display: none; }
.mobile-pagination-bar { display: none; }
.mobile-filter-bar { display: none; }

/* ---------- Mobile Overflow Menu ---------- */

.mobile-overflow-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 500;
}
.mobile-overflow-menu {
    position: fixed;
    top: calc(var(--header-height) + 36px);
    right: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 501;
    max-height: 60vh;
    min-width: 200px;
    overflow-y: auto;
    padding: 8px 0;
    animation: fade-in 0.15s ease;
}
.mobile-overflow-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
    min-height: 44px;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}
.mobile-overflow-item:hover,
.mobile-overflow-item:active {
    background: var(--bg-secondary);
}
.mobile-overflow-item i, .mobile-overflow-item .icon-xunlei {
    width: 20px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}
.mobile-overflow-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.mobile-overflow-section-header {
    padding: 8px 20px 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.mobile-overflow-item .menu-check {
    width: 20px;
    text-align: center;
    color: var(--accent, var(--primary));
    flex-shrink: 0;
}
.mobile-overflow-item .menu-check.hidden { visibility: hidden; }
.mobile-overflow-gallery-sizes {
    display: flex;
    gap: 4px;
    padding: 4px 20px 8px 52px;
}

/* ---------- Touch Selection Action Bar ---------- */
/* Rendering is controlled by Rust (has_touch + select_mode), so always display when present */
.mobile-selection-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    z-index: 150;
    justify-content: space-around;
}

.selection-bar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    min-height: 52px;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.selection-bar-btn i, .selection-bar-btn .icon-xunlei { font-size: 22px; }
.selection-bar-btn.danger { color: var(--danger); }
.selection-bar-btn:active { opacity: 0.7; }

/* ---------- Settings page avatar dropdown (mobile-only) ---------- */
.settings-avatar-wrapper { display: none; }

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

    /* Sidebar: slide-in overlay drawer */
    .app-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px !important;
        transform: translateX(-100%);
        transition: transform 0.28s ease !important;
        z-index: 200;
        box-shadow: var(--shadow-lg);
    }
    .app-sidebar:not(.open) {
        width: 280px !important; /* override width:0 — use transform instead */
        overflow: hidden;
    }
    .app-sidebar.open {
        transform: translateX(0);
    }
    /* Backdrop shown when sidebar is open */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        top: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 199;
        -webkit-tap-highlight-color: transparent;
    }
    /* Show tab bar */
    .bottom-tab-bar { display: flex; }

    /* Tab bar floats over content — no bottom padding on container */
    .app-container {
        padding-bottom: 0;
    }

    .layout-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 200;
        background: var(--bg-primary);
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
    }
    .layout-sidebar.open {
        left: 0;
    }

    .layout-content {
        margin-left: 0 !important;
    }

    /* Hide app header on mobile — all functionality available via bottom tab bar + Settings page */
    .app-header { display: none !important; }

    /* Toolbar: show mobile-only elements, hide desktop-only */
    .mobile-overflow-btn { display: inline-flex; }
    .toolbar-overflow-hide { display: none !important; }
    .toolbar-actions-right { display: none !important; }
    .toolbar-refresh-btn { display: none !important; }
    .mobile-parent-btn { display: inline-flex !important; order: 0; flex-shrink: 0; }
    .mobile-folder-name {
        display: block !important;
        order: 1;
        font-size: 15px;
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
        flex: 1;
        line-height: 44px;
    }
    .mobile-overflow-btn { order: 10; margin-left: auto; flex-shrink: 0; }
    .add-dropdown { order: 11; flex-shrink: 0; }
    .add-dropdown .dropdown-menu { left: auto; right: 0; }
    .toolbar-actions-left > .btn-primary { order: 11; flex-shrink: 0; }
    .mobile-select-btn {
        display: inline-flex !important;
        order: 12;
        flex-shrink: 0;
        font-size: 15px;
        padding: 8px 12px;
        min-height: 44px;
        background: none !important;
        border: none !important;
        color: var(--primary) !important;
        align-items: center;
    }
    .add-btn-label { display: none; }
    .add-btn-caret { display: none; }
    .files-toolbar .btn { min-width: 44px; min-height: 44px; }

    /* Toolbar button styling — iPhone-style individual circles */
    .mobile-parent-btn {
        border-radius: 50% !important;
        border: none !important;
        background: var(--bg-secondary) !important;
        color: var(--text-primary) !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
    .mobile-overflow-btn {
        border: none !important;
        background: var(--bg-secondary) !important;
        color: var(--text-primary) !important;
        border-radius: 50% !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
    .add-dropdown .btn,
    .toolbar-actions-left > .btn-primary {
        border: none !important;
        background: transparent !important;
        color: var(--text-primary) !important;
        border-radius: 50% !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        font-size: 18px !important;
    }

    /* Viewer: collapse transform buttons into dropdown */
    .viewer-transform-inline { display: none; }
    .viewer-transform-dropdown { display: block; }

    /* Two-row layout: Row 1 = toolbar, Row 2 = filter, Row 3 = breadcrumb */
    .files-topbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0;
        padding: 4px 0;
        flex-shrink: 0;
    }

    /* Row 1: toolbar buttons — reorder above breadcrumb */
    .files-topbar .files-toolbar {
        order: -1;
        width: 100%;
        padding: 0;
        flex-shrink: 0;
        gap: 2px;
    }

    /* Row 2: mobile filter (rendered via Rust in files-topbar) */
    .mobile-filter-bar {
        display: block;
        order: 0;
        width: 100%;
        padding: 4px 8px;
        flex-shrink: 0;
    }
    .mobile-filter-wrap {
        position: relative;
        display: flex;
        align-items: center;
    }
    .mobile-filter-icon {
        position: absolute;
        left: 12px;
        color: var(--text-secondary);
        font-size: 14px;
        pointer-events: none;
    }
    .mobile-filter-input {
        width: 100%;
        padding: 8px 36px 8px 36px;
        border-radius: 10px;
        background: var(--bg-secondary);
        border: none;
        font-size: 16px;
        min-height: 36px;
        box-sizing: border-box;
        color: var(--text-primary);
        outline: none;
    }
    .mobile-filter-input::placeholder { color: var(--text-muted); }
    .mobile-filter-input:focus { background: var(--bg-tertiary, var(--bg-secondary)); }
    .mobile-filter-sticky {
        position: absolute;
        right: 32px;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 8px;
        font-size: 14px;
        opacity: 0.5;
        transition: color 0.2s, opacity 0.2s, transform 0.2s;
    }
    .mobile-filter-sticky.active {
        color: var(--primary);
        opacity: 1;
        transform: rotate(45deg);
    }
    .mobile-filter-clear {
        position: absolute;
        right: 4px;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 8px;
        font-size: 12px;
    }

    /* Row 3: breadcrumb — full width, touch-friendly */
    .files-topbar .files-breadcrumb-bar {
        order: 1;
        width: 100%;
        min-width: 0;
        padding: 0 4px;
    }
    .breadcrumb-item {
        min-height: 36px;
        padding: 4px 10px;
        display: inline-flex;
        align-items: center;
    }

    .files-topbar .breadcrumb-edit-btn { display: none; }

    /* Hide the filter inside file-list-container on mobile (replaced by mobile-filter-bar) */
    .unified-header { display: none; }

    .toolbar-actions-left {
        display: flex;
        align-items: center;
        flex: 1;
        gap: 2px;
        flex-wrap: nowrap;
        min-width: 0;
    }

    /* Unified header hidden on mobile — replaced by mobile-filter-bar above */

    .file-list .col-modified {
        display: none;
    }

    .file-list .col-size {
        width: 70px;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
    }

    /* Remove card borders on mobile — match iOS app flat card style */
    .file-grid-item,
    .wf-item {
        border: none;
    }
    .file-grid-item.selected,
    .file-grid-item.focused,
    .wf-item.selected,
    .wf-item.focused {
        outline: 2px solid var(--primary);
        outline-offset: -2px;
    }

    /* Waterfall: do not override --waterfall-item-width here;
       the inline style from the size selector takes priority. */

    /* Footer hidden on mobile — pagination moved to mobile-pagination-bar */
    .file-list-footer { display: none !important; }

    /* Mobile compact pagination bar */
    .mobile-pagination-bar {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 16px;
        padding: 2px 12px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }
    .mobile-page-btn {
        min-width: 36px;
        min-height: 32px;
        background: none;
        border: none;
        color: var(--primary);
        font-size: 16px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-page-btn:disabled { color: var(--text-secondary); opacity: 0.4; cursor: default; }
    .mobile-page-info {
        font-size: 13px;
        color: var(--text-primary);
        background: none;
        border: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    /* Page picker child styles moved to .touch-device scope (outside media query) */

    /* iPhone-style file rows: compact two-line layout */
    .file-row td { padding: 0 4px; font-size: 14px; }
    .file-list th { padding: 10px 12px; }
    .file-row .file-modified,
    .file-row .file-type,
    .file-row .file-created,
    .file-row .file-accessed { display: none; }
    /* Hide size column on mobile — info shown in subtitle */
    .file-row .file-size { display: none; }

    /* Two-line file name layout — centering handled by .file-row .file-name rule below */
    .mobile-file-subtitle {
        display: block;
        font-size: 12px;
        color: var(--text-secondary);
        font-weight: 400;
        line-height: 1.3;
    }
    .file-name-text {
        font-weight: 500;
        font-size: 15px;
        line-height: 1.3;
        padding-right: 0 !important;
    }

    /* List icons on mobile — match iPhone app size */
    .file-row td.file-icon { font-size: 44px; width: 52px; }

    /* Ellipsis button always visible on touch devices */
    .file-name-ellipsis { display: block; opacity: 1; }

    /* Row separators — indented past icon like iPhone */
    .file-row { border-bottom: none !important; }
    .file-row .file-name { border-bottom: 1px solid var(--border-light); align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 1px; }

    /* Suppress native long-press actions on file items */
    .file-row, .file-grid-item, .wf-item {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Larger touch targets for ellipsis buttons (grid/waterfall views) */
    .item-ellipsis {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }


    /* Context menu as popup dropdown (same as desktop) */
    .context-menu {
        max-height: 60vh;
        overflow-y: auto;
    }
    .context-menu-item { padding: 12px 16px; min-height: 44px; font-size: 15px; }

    /* Modal — keep centered popup on mobile */
    .modal-content, .modal-dialog {
        width: 92%;
        max-height: calc(100vh - 32px);
    }
    .modal-folder-selector {
        height: 65vh;
    }

    /* Properties panel as bottom sheet */
    .panel-splitter { display: none; }
    .file-props-panel {
        position: fixed !important;
        bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 16px);
        left: 0;
        right: 0;
        width: 100% !important;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        z-index: 200;
    }

    /* On small screens, position selection bar above floating tab bar */
    .mobile-selection-bar {
        bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 24px);
    }

    /* Breadcrumb: scrollable */
    .breadcrumb {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        font-size: 0.85em;
    }
    .breadcrumb::-webkit-scrollbar { display: none; }

    /* viewer mobile overrides handled in main viewer block above */

    .search-bar {
        flex-direction: column;
    }
    .search-bar .form-input { max-width: none; font-size: 16px; }

    .inline-dialog {
        flex-direction: column;
        align-items: stretch;
    }

    /* Prevent iOS input zoom */
    input, textarea, select { font-size: 16px !important; }

    /* Responsive cards & layout */
    .card-grid { grid-template-columns: 1fr; gap: 8px; }

    .content-body {
        padding: 8px 12px 12px;
    }

    /* Dashboard: compact horizontal cards like native app */
    .dashboard-header { margin-bottom: 12px; text-align: left; }
    .dashboard-title { font-size: 18px; }
    .dashboard-subtitle { font-size: 12px; }

    .function-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; padding: 0; }
    .function-card {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: 10px;
        gap: 10px;
        min-width: 0;
    }
    .function-card .fc-title { font-size: 13px; margin-bottom: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .function-card .fc-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        border-radius: 10px;
        font-size: 16px;
        margin-bottom: 0;
    }
    .function-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .function-card .fc-desc { display: none; }
    .function-card .fc-stat { font-size: 14px; font-weight: 600; color: var(--primary); white-space: nowrap; }
    .function-card .fc-label { display: none; }

    .recent-files-section { margin-top: 12px; }
    .recent-files-grid { grid-template-columns: 1fr; gap: 4px; }
    .recent-file-card { padding: 8px 10px; }
    .recent-file-icon { width: 28px; height: 28px; font-size: 0.8rem; }
    .recent-files-modal { max-width: 100%; margin: 8px; }

    .stats-grid { gap: 8px; margin-top: 0; }
    .stat-card { padding: 12px; }
    .stat-header { margin-bottom: 8px; }

    .page-title { font-size: 18px; }

    /* Files page full height — tab bar floats over content.
       Use flex:1 + min-height:0 instead of 100dvh so the files page fills
       exactly the remaining space inside app-content, even when
       MobileHealthBanner is visible. This prevents iOS Safari from scrolling
       the toolbar/breadcrumb out of view when scroll-into-view focuses a file. */
    .app-content:has(.files-page) {
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    .app-content:has(.files-page) > .content-body {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .files-page {
        flex: 1;
        min-height: 0;
        padding: 0 8px;
        overflow: hidden;
    }

    /* Remove file browser content area border on mobile */
    .file-list-container {
        border: none;
        border-radius: 0;
    }

    /* Bottom padding in scroll areas so last items can scroll above floating tab bar */
    .file-list-scroll-area,
    .file-grid {
        padding-bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 24px);
    }

    /* All pages: bottom padding so last items scroll above floating tab bar.
       Uses !important to override earlier .content-body padding shorthand in this media query.
       The files page is unaffected — it sets its own height and scroll areas. */
    .content-body:not(:has(.files-page)) {
        padding-bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 24px) !important;
    }

    /* Login page: allow scrolling when 2FA or keyboard pushes content */
    .login-page {
        align-items: flex-start;
        padding: 24px 16px;
        min-height: 100dvh;
        overflow-y: auto;
    }
    .login-card {
        max-width: none;
        padding: 24px 20px;
        margin: auto;
    }

    /* Prevent outer page scroll — only inner content scrolls */
    html, body { overflow: hidden; height: 100dvh; height: 100vh; }

    /* Issue 2: Always show ellipsis on mobile (hover:hover rule hides it) */
    .item-ellipsis { opacity: 1 !important; }
    .file-name-ellipsis { opacity: 1 !important; }

    /* Issue 4: Compact page nav items in list view */
    .file-list .page-nav-row { padding: 4px 12px; white-space: nowrap; }
    .file-list .page-nav-row .page-nav-name { font-size: 13px; }

    /* Issue 5: Clouds page — prevent horizontal overflow */
    .cloud-card { overflow: hidden; word-break: break-word; }
    .cloud-card-header { flex-wrap: wrap; }
    .cloud-space { overflow: hidden; }
    .space-text { font-size: 12px; word-break: break-all; }
    .cloud-card-actions { flex-wrap: wrap; gap: 6px; }
    .cloud-card-actions .btn { font-size: 12px; padding: 4px 8px; }

    /* Issue 7: Settings pages — prevent horizontal overflow */
    .setting-group { overflow: hidden; word-break: break-word; }
    .setting-row input[type="text"],
    .setting-row input[type="number"],
    .setting-row input[type="url"],
    .setting-row select,
    .setting-row .form-input { max-width: 100%; box-sizing: border-box; }
    .port-row { flex-wrap: wrap; gap: 4px; }
    .port-row .port-link { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .cert-section { overflow: hidden; }
    .cert-section .form-input { font-size: 12px; }

    /* Issue 8: Log file buttons on same line */
    .data-table td:last-child { white-space: nowrap; }
    .data-table td:last-child .btn { display: inline-flex; margin: 2px; }

    /* Issue 9: Performance page — mobile responsive */
    .perf-stat-cards { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; margin-bottom: 8px; }
    .perf-stat-card { padding: 12px; }
    .perf-stat-header { margin-bottom: 8px; }
    .perf-stat-value { font-size: 1.3em; }
    .perf-stat-label { font-size: 11px; }
    .perf-stat-icon { width: 32px; height: 32px; font-size: 14px; }
    .perf-section { margin-bottom: 8px; }
    .perf-section-body { padding: 8px; }
    .perf-section-header {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 12px;
    }
    .perf-chart-legend { gap: 4px; flex-wrap: wrap; }
    .perf-legend-item { font-size: 11px; }
    .perf-data-points { font-size: 11px; }
    .perf-chart-body { padding: 4px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .perf-chart-body svg { width: 100%; height: auto; min-width: 400px; }
    .perf-card-sub { font-size: 0.75em; }
    .system-details-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
    .sys-detail-item { padding: 10px !important; }
    .sys-detail-icon { width: 32px; height: 32px; font-size: 14px; }
    .sys-detail-label { font-size: 11px; }
    .sys-detail-value { font-size: 14px; }
    .perf-connection-status { font-size: 11px; }
    .perf-connection-status .btn-label,
    .header-actions .btn .btn-label { display: none; }

    /* Issue 10: Hide empty folder-tree area in sidebar on mobile */
    .tree-section { display: none !important; }
    .tree-splitter { display: none !important; }

    /* PTR and swipe-back indicator display is now handled by .touch-device rules */

    /* Settings page: keep header as row so avatar stays right-aligned */
    .page-header:has(.settings-avatar-wrapper) {
        flex-direction: row;
        align-items: center;
    }

    /* Settings page: avatar dropdown in header row */
    .settings-avatar-wrapper {
        display: block;
        position: relative;
        margin-left: auto;
    }
    .settings-avatar-btn {
        background: none;
        border: none;
        font-size: 24px;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 4px;
        line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }
    .settings-avatar-menu {
        position: absolute;
        top: 100%;
        right: 0;
        min-width: 200px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: var(--shadow-lg);
        z-index: 1001;
        padding: 4px 0;
    }
}

@keyframes slide-up {
    from { transform: translateY(100%); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 1024px) {
    .toolbar-actions-left .toolbar-overflow-hide,
    .toolbar-actions-right .toolbar-overflow-hide {
        display: none;
    }
}

@media (max-width: 480px) {
    .files-toolbar {
        padding: 6px 8px;
    }

    .toolbar-actions-left .btn,
    .toolbar-actions-right .btn {
        padding: 5px 8px;
        font-size: 12px;
    }

    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
        gap: 4px !important;
    }

    .file-grid-name {
        font-size: 0.75em;
    }

    .view-mode-buttons {
        gap: 2px;
    }

}

/* ---------- Select All Checkbox ---------- */
.col-checkbox { width: 36px; text-align: center; }
.file-checkbox { text-align: center; width: 36px; }
.file-checkbox input[type="checkbox"] { cursor: pointer; }

/* ---------- Column Visibility Menu ---------- */
.column-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 6px 0;
    min-width: 160px;
    z-index: 500;
}
.column-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
}
.column-menu-item:hover {
    background: var(--bg-secondary);
}
.column-menu-item input[type="checkbox"] {
    margin: 0;
}

/* ---------- Additional Column Styles ---------- */
.col-type { width: 80px; }
.col-created { width: 160px; }
.col-accessed { width: 160px; }
.file-type, .file-created, .file-accessed {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Xunlei SVG icon — inline mask so it inherits currentColor */
.icon-xunlei {
    display: inline-block;
    width: 1em;
    height: 1em;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 643 611'%3E%3Cpath d='M603.268 0C604.738 0 606.381.738 604.931 4.601c0 0-51.016 71.39-79.52 129.542-.01.027-1.192 3.084 2.567 1.723 0 0 7.221-2.071 14.537-3.456 0 0 5.271-1.008 1.706 4.319-.133.173-48.061 62.506-86.385 132.402.86-.093 1.724-.184 2.596-.274.095.014 106.339 15.564 180.409 63.04 0 0 4.272 4.319-2.567 5.182-.205.027-156.594 20.224-258.844 55.717 12.629 26.535 26.027 55.692 40.226 87.769 18.867 36.672 40.287 81.635 57.022 125.953 0 0 1.025 7.768-5.987 1.726-.033-.042-71.023-88.534-171.859-148.54-19.129-11.375-163.819-56.58-165.877-186.528-.4-25.488 13.256-69.088 1.711-90.679-.029-.093-6.91-22.078-40.189-50.087-.137-.092-32.314-21.639-84.642-45.768 0 0-5.559-2.733-9.405-4.316-.014-.029-1.952-4.211 2.563-3.455.126.037 81.569 23.972 111.154 34.541 0 0 6.329 2.071 12.827-.863.116-.048 45.08-18.522 84.646 14.682l.028.035c4.452 2.322 20.559 12.862 50.15 54.328.414-.345.869-.641 1.286-.977.982-.817 2.018-1.601 3.094-2.356 1.34-1.003 2.663-2.016 4.046-2.959 13.62-11.791 135.437-114.048 331.286-175.02 0 0 .846-.282 1.758-.282Z'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 643 611'%3E%3Cpath d='M603.268 0C604.738 0 606.381.738 604.931 4.601c0 0-51.016 71.39-79.52 129.542-.01.027-1.192 3.084 2.567 1.723 0 0 7.221-2.071 14.537-3.456 0 0 5.271-1.008 1.706 4.319-.133.173-48.061 62.506-86.385 132.402.86-.093 1.724-.184 2.596-.274.095.014 106.339 15.564 180.409 63.04 0 0 4.272 4.319-2.567 5.182-.205.027-156.594 20.224-258.844 55.717 12.629 26.535 26.027 55.692 40.226 87.769 18.867 36.672 40.287 81.635 57.022 125.953 0 0 1.025 7.768-5.987 1.726-.033-.042-71.023-88.534-171.859-148.54-19.129-11.375-163.819-56.58-165.877-186.528-.4-25.488 13.256-69.088 1.711-90.679-.029-.093-6.91-22.078-40.189-50.087-.137-.092-32.314-21.639-84.642-45.768 0 0-5.559-2.733-9.405-4.316-.014-.029-1.952-4.211 2.563-3.455.126.037 81.569 23.972 111.154 34.541 0 0 6.329 2.071 12.827-.863.116-.048 45.08-18.522 84.646 14.682l.028.035c4.452 2.322 20.559 12.862 50.15 54.328.414-.345.869-.641 1.286-.977.982-.817 2.018-1.601 3.094-2.356 1.34-1.003 2.663-2.016 4.046-2.959 13.62-11.791 135.437-114.048 331.286-175.02 0 0 .846-.282 1.758-.282Z'/%3E%3C/svg%3E") no-repeat center / contain;
    vertical-align: -0.125em;
}

/* ---------- Cloud Provider Icons ---------- */
.cloud-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}
.cloud-icon-sm {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
}

/* ---------- Page Jump Input ---------- */
.page-jump-input {
    width: 48px;
    padding: 2px 4px;
    font-size: 11px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
}
.page-jump-input:focus {
    border-color: var(--primary);
}
/* Hide number input spinners */
.page-jump-input::-webkit-outer-spin-button,
.page-jump-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.page-jump-input[type=number] {
    -moz-appearance: textfield;
}

/* ---------- Upload Dropdown ---------- */
.upload-dropdown {
    display: inline-flex;
    gap: 0;
}
.upload-dropdown .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}
.upload-folder-btn {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
}

/* ---------- Play Folder Dropdown ---------- */
.play-folder-dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    min-width: 160px;
    z-index: 500;
    padding: 4px 0;
    /* A popup's length is the data's; never let it clip its own tail. */
    max-height: min(70vh, 520px);
    overflow-y: auto;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.dropdown-item:hover {
    background: var(--bg-secondary);
    text-decoration: none;
}
.dropdown-item i { width: 16px; text-align: center; color: var(--text-secondary); }

/* ---------- Search Enhancements ---------- */
.search-fuzzy {
    white-space: nowrap;
    font-size: 12px;
}
.search-path {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ---------- Panel Splitter ---------- */
.panel-splitter {
    width: 4px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}
.panel-splitter:hover {
    background: var(--primary);
}

/* ---------- Files Content Area ---------- */
.files-content-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ---------- Dual Panel Mode ---------- */
.file-panel-dual {
    border-radius: 4px;
    overflow: hidden;
}
.file-panel-dual .panel-breadcrumb-bar {
    opacity: 0.6;
    transition: opacity 0.15s;
}
.file-panel.active .panel-breadcrumb-bar {
    opacity: 1;
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-secondary));
}
.dual-panel-splitter {
    width: 4px;
    cursor: col-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}
.dual-panel-splitter:hover {
    background: var(--primary);
}
.panel-breadcrumb-bar {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    gap: 4px;
    min-height: 32px;
}
.panel-breadcrumb-bar .breadcrumb {
    flex: 1;
    min-width: 0;
}
.panel-load-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: color-mix(in srgb, var(--danger) 10%, var(--bg-secondary));
    color: var(--danger);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.panel-load-error span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dual-panel-toggle.active {
    color: var(--primary);
    background: var(--primary-light);
}
@media (max-width: 768px) {
    .dual-panel-toggle { display: none !important; }
}

/* ---------- Drag Target Highlight ---------- */
.file-grid-item.drag-target,
.wf-item.drag-target {
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
    background: var(--primary-light);
}
.file-row.drag-target {
    background: var(--primary-light);
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
}
.tree-node-row.drag-target {
    background: var(--primary-light);
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
}

/* ---------- Ellipsis Menu Button ---------- */
.item-ellipsis {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    border: none;
    padding: 0;
}
.item-ellipsis:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ---------- Checkbox Overlay (Select Mode) ---------- */
.item-checkbox {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 2;
}
.item-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Hide ellipsis by default and reveal on hover — only for hover-capable devices.
   On touch-only devices (iOS/Android), ellipsis stays visible and no :hover trap occurs. */
@media (hover: hover) {
    .item-ellipsis {
        opacity: 0;
        transition: opacity 0.15s;
    }
    .file-grid-item:hover .item-ellipsis,
    .wf-item:hover .item-ellipsis { opacity: 1; }
    .file-name-ellipsis {
        opacity: 0;
        transition: opacity 0.15s;
    }
    .file-row:hover .file-name-ellipsis { opacity: 1; }
}

/* ---------- Encryption Overlay ---------- */
.encryption-overlay {
    position: absolute;
    top: 0.35rem;
    left: 0.35rem;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 10;
    pointer-events: none;
}
/* List view: small badge overlaid on bottom-right of icon */
.file-icon .encryption-overlay {
    position: absolute;
    bottom: -2px;
    right: -2px;
    top: auto;
    left: auto;
    width: 14px;
    height: 14px;
    font-size: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   Offline Download Manager
   ═══════════════════════════════════════════════════════════════ */

.offline-manager-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
}

.offline-manager-modal {
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    width: min(900px, 96vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

/* ── Header ─────────────────────────────────────────────────── */
.offline-manager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
    flex-shrink: 0;
}

.offline-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    color: var(--text-primary, #e2e8f0);
}

.offline-header-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.offline-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.offline-header-btn {
    padding: 5px 8px !important;
    background: transparent !important;
    border: 1px solid var(--border-color, rgba(255,255,255,0.15)) !important;
    color: var(--text-secondary, rgba(255,255,255,0.7)) !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s, color 0.15s;
}
.offline-header-btn:hover {
    background: rgba(255,255,255,0.08) !important;
    color: var(--text-primary, #e2e8f0) !important;
}
.offline-btn-danger:hover {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239,68,68,0.4) !important;
    color: #ef4444 !important;
}

/* ── Quota widget ────────────────────────────────────────────── */
.offline-quota {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary, rgba(255,255,255,0.6));
}

.offline-quota-bar {
    width: 80px;
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.offline-quota-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* ── Clear dropdown ──────────────────────────────────────────── */
.offline-clear-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-primary, #16161e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: 8px;
    padding: 4px 0;
    min-width: 150px;
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.offline-clear-item {
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary, rgba(255,255,255,0.75));
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.offline-clear-item:hover {
    background: rgba(255,255,255,0.07);
    color: var(--text-primary, #e2e8f0);
}

/* ── Body / empty ────────────────────────────────────────────── */
.offline-manager-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.offline-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-secondary, rgba(255,255,255,0.4));
    font-size: 0.9rem;
}

/* ── Table ───────────────────────────────────────────────────── */
.offline-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--text-primary, #e2e8f0);
}

.offline-table thead tr {
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.offline-table th {
    padding: 8px 10px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary, rgba(255,255,255,0.5));
    white-space: nowrap;
}

.offline-row {
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.05));
    transition: background 0.12s;
}
.offline-row:hover { background: rgba(255,255,255,0.04); }
.offline-row:last-child { border-bottom: none; }

.offline-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.offline-col-check  { width: 36px; text-align: center; }
.offline-col-name   { min-width: 160px; max-width: 260px; }
.offline-col-size   { width: 90px; white-space: nowrap; }
.offline-col-status { width: 130px; }
.offline-col-progress { width: 140px; }
.offline-col-added  { width: 130px; white-space: nowrap; font-size: 0.78rem; color: var(--text-secondary, rgba(255,255,255,0.5)); }
.offline-col-actions { width: 96px; white-space: nowrap; }

.offline-file-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Status badges ───────────────────────────────────────────── */
.offline-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
}
.offline-status-queued     { background: rgba(148,163,184,0.15); color: #94a3b8; }
.offline-status-downloading{ background: rgba(59,130,246,0.15);  color: #60a5fa; }
.offline-status-completed  { background: rgba(34,197,94,0.15);   color: #4ade80; }
.offline-status-error      { background: rgba(239,68,68,0.15);   color: #f87171; }

/* ── Progress bar ────────────────────────────────────────────── */
.offline-progress-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.offline-progress-bar {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.offline-progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.offline-progress-pct {
    font-size: 0.72rem;
    color: var(--text-secondary, rgba(255,255,255,0.5));
    white-space: nowrap;
    min-width: 32px;
}

/* ── Row action buttons ──────────────────────────────────────── */
.offline-action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 5px;
    color: var(--text-secondary, rgba(255,255,255,0.5));
    font-size: 0.8rem;
    transition: background 0.12s, color 0.12s;
}
.offline-action-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary, #e2e8f0);
}
.offline-action-btn.offline-btn-danger:hover {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
}

/* ── Pagination ──────────────────────────────────────────────── */
.offline-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
    flex-shrink: 0;
}

.offline-page-info {
    font-size: 0.82rem;
    white-space: nowrap;
    color: var(--text-secondary, rgba(255,255,255,0.5));
}

/* ── Confirm dialog ──────────────────────────────────────────── */
.offline-confirm-backdrop {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.offline-confirm-dialog {
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: 10px;
    padding: 24px;
    width: min(380px, 90%);
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.offline-confirm-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    margin-bottom: 8px;
}

.offline-confirm-msg {
    font-size: 0.88rem;
    color: var(--text-secondary, rgba(255,255,255,0.65));
    margin-bottom: 16px;
    line-height: 1.5;
}

.offline-confirm-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary, rgba(255,255,255,0.7));
    margin-bottom: 16px;
    cursor: pointer;
    user-select: none;
}

.offline-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Mobile: stack columns, hide some */
@media (max-width: 600px) {
    .offline-col-added,
    .offline-col-progress { display: none; }
    .offline-manager-modal { max-height: 90vh; }
}

/* ── Add Offline Dialog — option checkboxes ──────────────────── */
.offline-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}
.offline-option-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    cursor: pointer;
    padding: 4px 2px;
    border-radius: 4px;
}
.offline-option-row:hover { background: rgba(255,255,255,0.04); }
.offline-option-row input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.offline-option-label {
    font-size: 0.88rem;
    color: var(--text-primary, #e2e8f0);
}
.offline-option-help {
    font-size: 0.78rem;
    color: var(--text-secondary, rgba(255,255,255,0.45));
    flex-basis: 100%;
    padding-left: 20px;
    line-height: 1.3;
}

/* ── Add Offline Dialog — error / success banners ────────────── */
.offline-dialog-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 4px;
}
.offline-dialog-error {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.offline-dialog-success {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

/* ── Add Offline Dialog — quota row ──────────────────────────── */
.offline-quota-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 2px;
}
.offline-quota-label {
    font-size: 0.82rem;
    color: var(--text-secondary, rgba(255,255,255,0.5));
    flex-shrink: 0;
}
.offline-quota-nums {
    font-size: 0.80rem;
    color: var(--text-secondary, rgba(255,255,255,0.5));
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Add Offline Dialog — file upload row ────────────────────── */
.offline-file-upload-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.offline-upload-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
}
.offline-upload-btn:hover { opacity: 0.85; }

/* ── Order Summary & Payment ──────────────────────────── */
.order-summary-divider { border-top: 1px solid var(--border-color, var(--border)); margin: 8px 0; }
.info-row.total-row .info-label { font-weight: 600; }
.info-row.total-row .info-value { font-weight: 700; font-size: 1.1em; color: var(--primary); }
.payment-methods { text-align: center; padding: 16px 0; }
.payment-methods h4 { margin-bottom: 16px; }
.btn-alipay { background: #1677ff; color: #fff; border: none; padding: 10px 24px; font-size: 1em; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.btn-alipay:hover { background: #0958d9; }
.btn-alipay i { font-size: 1.2em; }
.payment-note { font-size: 0.85em; margin-top: 8px; color: var(--text-muted); }

/* ── Sign-out modal (two-button layout) ──────────────── */
.sign-out-intro { margin: 0 0 14px; }
.sign-out-actions { display: flex; flex-direction: column; gap: 4px; }
.sign-out-action {
    appearance: none;
    width: 100%;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font: inherit;
    text-align: left;
    transition: filter var(--transition), background var(--transition), border-color var(--transition);
}
.sign-out-action:disabled { cursor: not-allowed; opacity: 0.6; }
.sign-out-action:not(:disabled):hover { filter: brightness(0.95); }
.sign-out-action__label { font-weight: 600; }
.sign-out-action i { font-size: 1.05em; flex-shrink: 0; }
.sign-out-action--primary { background: var(--primary); color: var(--primary-contrast, #fff); }
.sign-out-action--danger  { background: var(--danger,  #dc3545); color: #fff; margin-top: 12px; }
.sign-out-help { margin: 4px 4px 4px 4px; font-size: 0.85em; line-height: 1.4; }

/* ── Third-party Login ──────────────────────────────── */
.login-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--text-secondary); font-size: 13px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.third-party-login { display: flex; justify-content: center; gap: 12px; }
.cloud-icon-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.cloud-icon-btn:hover { border-color: var(--primary); background: var(--bg-tertiary); }
.cloud-icon-btn img { width: 28px; height: 28px; }

/* ============================================================
   Accessibility
   ============================================================ */

/* Global focus-visible indicators */
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex="0"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.header-btn:focus-visible, .viewer-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Fix outline:none inputs — provide focus replacement */
.breadcrumb-path-input:focus { box-shadow: 0 0 0 2px var(--primary); }
.upload-filters .search-box:focus-within { box-shadow: 0 0 0 2px var(--primary); }

/* ─── Live Log Viewer ─── */
.log-status-bar {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.log-level-select {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
}
.log-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Lucida Console', monospace;
    font-size: 12px;
    max-height: 600px;
    overflow-y: auto;
}
.log-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}
.log-entry {
    border-bottom: 1px solid var(--border);
    padding: 2px 8px;
}
.log-entry:hover {
    background: var(--bg-hover);
}
.log-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.log-time {
    color: var(--text-muted);
    min-width: 72px;
    flex-shrink: 0;
    font-size: 11px;
}
.log-level-badge {
    display: inline-block;
    min-width: 28px;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    border-radius: 3px;
    padding: 0 3px;
    flex-shrink: 0;
    line-height: 16px;
}
.log-level-badge.log-trace {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.12);
}
.log-level-badge.log-debug {
    color: #06b6d4;
    background: rgba(6, 182, 212, 0.12);
}
.log-level-badge.log-info {
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
}
.log-level-badge.log-warn {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
}
.log-level-badge.log-error {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}
.log-target {
    color: #60a5fa;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 11px;
}
.log-message {
    flex: 1;
    word-break: break-all;
    white-space: pre-wrap;
}
.log-fields {
    padding: 0 8px 2px 108px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.log-field {
    background: var(--bg-tertiary, rgba(128,128,128,0.1));
    padding: 0 4px;
    border-radius: 2px;
}
/* Desktop: show log-line, hide mobile */
.log-desktop { display: flex; }
.log-mobile { display: none; }
.log-mobile-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}
.log-mobile-message {
    padding-left: 4px;
    word-break: break-all;
    white-space: pre-wrap;
}
@media (max-width: 768px) {
    .log-desktop { display: none !important; }
    .log-mobile { display: block; }
    .log-content { font-size: 11px; }
    .log-time { font-size: 10px; min-width: auto; }
    .log-target { max-width: none; font-size: 10px; }
    .log-entry { padding: 3px 6px; }
}

/* PWA standalone mode — safe area insets for iOS status bar */
@media (display-mode: standalone) {
    .app-container {
        padding-top: env(safe-area-inset-top, 0px);
    }
    .viewer-toolbar {
        padding-top: env(safe-area-inset-top, 0px);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Media Scrape (Emby/Jellyfin/Plex/Kodi NFO + sidecar artwork) ──────── */
.media-scrape-section {
    margin: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle, var(--surface));
}
.media-scrape-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}
.media-scrape-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.media-scrape-header > .media-scrape-title { flex: 1; }
.media-scrape-header > i.fas:first-child { color: var(--accent); }
.media-scrape-toggle { font-size: 0.9em; color: var(--text-secondary); }

.media-scrape-body {
    padding: 0 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.media-scrape-header-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.media-scrape-poster {
    flex: 0 0 auto;
    width: 120px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface-muted, rgba(0,0,0,0.08));
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
@media (max-width: 480px) {
    .media-scrape-header-row { flex-direction: column; align-items: stretch; }
    .media-scrape-poster { width: 100%; max-width: 280px; }
}
.media-scrape-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.media-scrape-movie-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
}
.media-scrape-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85em;
    color: var(--text-secondary);
}
.media-scrape-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.media-scrape-rating { color: var(--warning); }
.media-scrape-mpaa {
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    color: var(--text-secondary);
}
.media-scrape-tagline {
    margin: 4px 0 0;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.92em;
}
.media-scrape-episode {
    display: flex;
    gap: 8px;
    font-size: 0.85em;
    color: var(--text-secondary);
}
.media-scrape-show-title { font-weight: 600; }

.media-scrape-plot {
    font-size: 0.95em;
    line-height: 1.5;
    color: var(--text);
}
.media-scrape-plot > p {
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.media-scrape-plot.expanded > p {
    -webkit-line-clamp: unset;
    overflow: visible;
}
.media-scrape-show-more-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.85em;
    padding: 4px 0;
    cursor: pointer;
}
.media-scrape-show-more-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.media-scrape-list-label {
    display: block;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 600;
}
.media-scrape-inline-list .media-scrape-inline-value {
    font-size: 0.9em;
    color: var(--text);
}
.media-scrape-chip-row .media-scrape-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.media-scrape-chip {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface-muted, rgba(0,0,0,0.08));
    color: var(--text);
    font-size: 0.82em;
}
.media-scrape-cast-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.media-scrape-cast-card {
    flex: 0 0 80px;
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    border-radius: 6px;
    background: transparent;
    text-align: center;
}
.media-scrape-cast-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.media-scrape-cast-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light, var(--accent)) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9em;
}
.media-scrape-cast-name {
    font-size: 0.78em;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.media-scrape-cast-role {
    font-size: 0.72em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.media-scrape-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.media-scrape-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: var(--accent-fg, white);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
}
.media-scrape-play-btn:hover { filter: brightness(1.08); }
.media-scrape-play-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.media-scrape-trailer-btn,
.media-scrape-extra-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-muted, rgba(0,0,0,0.06));
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9em;
}
.media-scrape-trailer-btn:hover,
.media-scrape-extra-row:hover {
    background: var(--surface-hover, rgba(0,0,0,0.1));
}
.media-scrape-trailer-btn:focus-visible,
.media-scrape-extra-row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.media-scrape-extras { display: flex; flex-direction: column; gap: 6px; }
.media-scrape-extras .media-scrape-extra-row { width: 100%; }

/* ── Multi-gRPC-server feature ─────────────────────────────────── */

/* Ambient current-server badge in the header. Clicks navigate to the
   Servers page; in embedded mode the badge isn't rendered at all. */
.header-current-server {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    margin-right: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12px;
    line-height: 1;
    max-width: 200px;
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.header-current-server:hover {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.header-current-server i { color: var(--accent); font-size: 11px; }
.header-current-server__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
@media (max-width: 768px) {
    .header-current-server__name { display: none; }
    .header-current-server { padding: 4px 8px; }
}

/* Page intro paragraph shared with other CRUD pages. */
.page-description {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0 0 16px;
    max-width: 720px;
}

/* Server cards on the management page. */
.server-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}
.server-card--current {
    border-color: color-mix(in srgb, var(--success) 55%, var(--border));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 25%, transparent) inset;
}
.server-card__header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.server-card__icon {
    font-size: 22px;
    color: var(--accent);
    margin-top: 2px;
    flex-shrink: 0;
}
.server-card__title-wrap {
    flex: 1;
    min-width: 0;
}
.server-card__name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.server-card__url {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.server-card__rename-input {
    font-size: 15px;
    padding: 4px 8px;
    width: 100%;
}
.server-card__badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.server-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.server-card__actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Add-server modal form spacing matches other modals. */
.add-server-form .form-group { margin-bottom: 12px; }
.add-server-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.add-server-form .form-help {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0 0 12px;
}
.add-server-form .form-error {
    color: var(--danger);
    font-size: 13px;
    margin: 4px 0 12px;
}

/* ---------- Sync with cloud (profile page) ---------- */
.cloud-sync-desc {
    margin: 0 0 12px;
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.5;
}
.cloud-sync-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.cloud-sync-actions {
    margin-left: auto;
}
.cloud-sync-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.9em;
}
.cloud-sync-list-wrap {
    max-height: 40vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
}
.cloud-sync-list {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
}
.cloud-sync-list th,
.cloud-sync-list td {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
    word-break: break-all;
}
.cloud-sync-list th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
}
.cloud-sync-list td .badge + .badge {
    margin-left: 6px;
}
.cloud-sync-strategy {
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 10px 14px 12px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cloud-sync-strategy legend {
    padding: 0 6px;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
}
.cloud-sync-strategy .radio-label {
    align-items: flex-start;
}
.cloud-sync-strategy .radio-label input[type="radio"] {
    margin-top: 4px;
}
@media (max-width: 600px) {
    .cloud-sync-actions {
        margin-left: 0;
        width: 100%;
    }
}

/* Visually hidden, read by screen readers. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Link to a guide on the website (components/help_link.rs). */
.help-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.help-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Archive folder badge next to the name (format, or a warning). */
.archive-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary, rgba(127, 127, 127, 0.16));
    border: 1px solid var(--border);
    vertical-align: middle;
}
.archive-badge-warn {
    border-color: var(--warning);
}
/* Grid and gallery: the badge sits on its own line under the name. */
.archive-badges {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 2px;
}
.archive-badges .archive-badge {
    margin-left: 0;
}

/* ── Book reader (components/book_reader.rs, public/reader/book-reader.js) ── */
/* Each reading theme sets the chrome's colours; text, muted text and links all
   reach 4.5:1 on its background and on its bars. */
.book-reader-overlay {
    --br-bg: #FFFFFF;
    --br-bar: rgba(247, 247, 248, 0.97);
    --br-panel: #FFFFFF;
    --br-fg: #1C1C1E;
    --br-muted: #55585E;
    --br-accent: #0B57D0;
    --br-border: rgba(0, 0, 0, 0.14);
    --br-hover: rgba(0, 0, 0, 0.06);
    --br-scrim: rgba(0, 0, 0, 0.4);
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--br-bg);
    color: var(--br-fg);
    color-scheme: light;
    overscroll-behavior: contain;
    outline: none;
}
.book-reader-overlay[hidden] {
    display: none;
}
.book-reader-overlay:focus-visible {
    outline: 2px solid var(--br-accent);
    outline-offset: -3px;
}
.book-reader-overlay.book-theme-sepia {
    --br-bg: #F4ECD8;
    --br-bar: rgba(235, 224, 198, 0.97);
    --br-panel: #F7F0DF;
    --br-fg: #4A3B2C;
    --br-muted: #5E4B37;
    --br-accent: #7A3E00;
    --br-border: rgba(74, 59, 44, 0.2);
    --br-hover: rgba(74, 59, 44, 0.08);
}
.book-reader-overlay.book-theme-dark,
[data-theme="dark"] .book-reader-overlay.book-theme-auto {
    --br-bg: #1E1E20;
    --br-bar: rgba(42, 42, 45, 0.97);
    --br-panel: #2A2A2D;
    --br-fg: #D8D8DC;
    --br-muted: #A9A9B0;
    --br-accent: #8AB4F8;
    --br-border: rgba(255, 255, 255, 0.14);
    --br-hover: rgba(255, 255, 255, 0.08);
    --br-scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
}
.book-reader-overlay.book-theme-black {
    --br-bg: #000000;
    --br-bar: rgba(22, 22, 24, 0.97);
    --br-panel: #161618;
    --br-fg: #C8C8C8;
    --br-muted: #A0A0A8;
    --br-accent: #8AB4F8;
    --br-border: rgba(255, 255, 255, 0.14);
    --br-hover: rgba(255, 255, 255, 0.08);
    --br-scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}
.book-reader-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* Bars float over the book; a tap in the middle hides and shows them. */
.book-reader-bar {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    background: var(--br-bar);
    color: var(--br-fg);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.book-reader-top {
    top: 0;
    align-items: center;
    gap: 4px;
    height: calc(48px + var(--safe-area-top, 0px));
    padding: var(--safe-area-top, 0px) 8px 0;
    border-bottom: 1px solid var(--br-border);
}
.book-reader-bottom {
    bottom: 0;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px calc(6px + var(--safe-area-bottom, 0px));
    border-top: 1px solid var(--br-border);
}
.book-reader-overlay.bars-hidden .book-reader-top {
    opacity: 0;
    transform: translateY(-100%);
    pointer-events: none;
}
.book-reader-overlay.bars-hidden .book-reader-bottom {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}
/* A keyboard user tabbing into a hidden bar always sees it. */
.book-reader-overlay.bars-hidden .book-reader-bar:focus-within {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}
.book-reader-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0 8px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.book-reader-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--br-fg);
    font-size: 16px;
    cursor: pointer;
}
.book-reader-btn:hover:not(:disabled) {
    background: var(--br-hover);
}
.book-reader-btn.active {
    color: var(--br-accent);
}
.book-reader-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.book-reader-overlay button:focus-visible,
.book-reader-overlay input:focus-visible,
.book-reader-overlay [tabindex="-1"]:focus-visible {
    outline: 2px solid var(--br-accent);
    outline-offset: 2px;
}
.book-reader-progress {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-height: 18px;
    padding: 0 8px;
    font-size: 13px;
    color: var(--br-muted);
}
.book-reader-chapter {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.book-reader-page,
.book-reader-percent {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.book-reader-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.book-reader-slider {
    flex: 1;
    min-width: 0;
    height: 28px;
    margin: 0;
    accent-color: var(--br-accent);
    cursor: pointer;
}

/* Panels: Contents on the start side, Settings on the end side; sheets on phones.
   Layers: book, loading/error (1), panel scrim (3), bars (4), panels and notes (5),
   link question (6–7). */
.book-reader-scrim {
    position: absolute;
    inset: 0;
    z-index: 3;
}
.book-reader-scrim-dim {
    z-index: 6;
    background: var(--br-scrim);
}
.book-reader-panel {
    position: absolute;
    z-index: 5;
    top: calc(56px + var(--safe-area-top, 0px));
    right: 8px;
    width: min(380px, calc(100% - 16px));
    max-height: calc(100% - 72px - var(--safe-area-top, 0px));
    display: flex;
    flex-direction: column;
    background: var(--br-panel);
    color: var(--br-fg);
    border: 1px solid var(--br-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}
#book-reader-contents {
    right: auto;
    left: 8px;
}
.book-reader-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 6px 6px 16px;
    border-bottom: 1px solid var(--br-border);
}
.book-reader-panel-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--br-fg);
}
.book-reader-panel-body {
    overflow-y: auto;
    padding: 6px 0 10px;
}
.book-reader-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.book-reader-toc-item {
    display: block;
    width: 100%;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-inline-end: 16px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--br-fg);
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    text-align: start;
    cursor: pointer;
}
.book-reader-toc-item:hover {
    background: var(--br-hover);
}
.book-reader-toc-item[aria-current="true"] {
    color: var(--br-accent);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--br-accent);
}
.book-reader-overlay .book-reader-toc-item:focus-visible {
    outline-offset: -2px;
}
.book-reader-toc-heading {
    display: block;
    padding-top: 8px;
    padding-bottom: 4px;
    font-size: 13px;
    color: var(--br-muted);
}
.book-reader-field {
    min-width: 0;
    margin: 0;
    padding: 8px 16px;
    border: none;
}
.book-reader-field > label,
.book-reader-field > legend {
    display: block;
    float: left;
    width: 100%;
    margin: 0 0 8px;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--br-muted);
}
.book-reader-field > legend + * {
    clear: both;
}
.book-reader-font-row {
    clear: both;
    display: flex;
    align-items: center;
    gap: 12px;
}
.book-reader-font-row input {
    flex: 1;
    min-width: 0;
    accent-color: var(--br-accent);
}
.book-reader-font-row output {
    min-width: 3.5em;
    text-align: end;
    font-variant-numeric: tabular-nums;
}
.book-reader-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.book-reader-choice {
    position: relative;
    cursor: pointer;
}
/* The radio stays in the page for the keyboard and screen readers. */
.book-reader-choice input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
}
.book-reader-choice-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--br-border);
    border-radius: 999px;
    font-size: 14px;
    color: var(--br-fg);
}
.book-reader-choice:hover .book-reader-choice-box {
    background: var(--br-hover);
}
.book-reader-choice input:checked + .book-reader-choice-box {
    border-color: var(--br-accent);
    box-shadow: inset 0 0 0 1px var(--br-accent);
    color: var(--br-accent);
    font-weight: 600;
}
.book-reader-choice input:focus-visible + .book-reader-choice-box {
    outline: 2px solid var(--br-accent);
    outline-offset: 2px;
}
.book-reader-swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(127, 127, 127, 0.7);
}
.book-reader-swatch.swatch-auto { background: linear-gradient(135deg, #FFFFFF 50%, #1E1E20 50%); }
.book-reader-swatch.swatch-white { background: #FFFFFF; }
.book-reader-swatch.swatch-sepia { background: #F4ECD8; }
.book-reader-swatch.swatch-dark { background: #1E1E20; }
.book-reader-swatch.swatch-black { background: #000000; }

/* Footnote popup, link question, network notice */
.book-reader-footnote {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: calc(96px + var(--safe-area-bottom, 0px));
    transform: translateX(-50%);
    width: min(560px, calc(100% - 24px));
    max-height: 55%;
    display: flex;
    flex-direction: column;
    background: var(--br-panel);
    color: var(--br-fg);
    border: 1px solid var(--br-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}
.book-reader-footnote-text {
    overflow-y: auto;
    padding: 12px 16px 4px;
    font-size: 15px;
    line-height: 1.55;
}
.book-reader-footnote-text p {
    margin: 0 0 0.75em;
}
.book-reader-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 16px 12px;
}
.book-reader-confirm {
    position: absolute;
    z-index: 7;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100% - 32px));
    padding: 20px 4px 4px;
    background: var(--br-panel);
    color: var(--br-fg);
    border: 1px solid var(--br-border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.book-reader-confirm h3 {
    margin: 0 16px 8px;
    font-size: 16px;
    font-weight: 600;
}
.book-reader-link-url {
    margin: 0 16px 8px;
    font-size: 13px;
    color: var(--br-muted);
    word-break: break-all;
}
.book-reader-banner {
    position: absolute;
    z-index: 5;
    top: calc(56px + var(--safe-area-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 24px);
    padding: 4px 4px 4px 14px;
    background: var(--br-panel);
    color: var(--br-fg);
    border: 1px solid var(--danger);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    font-size: 14px;
}

/* Opening, and what went wrong */
.book-reader-state {
    position: absolute;
    inset: calc(48px + var(--safe-area-top, 0px)) 0 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    background: var(--br-bg);
    color: var(--br-fg);
    text-align: center;
}
.book-reader-state > i {
    font-size: 32px;
    color: var(--br-muted);
}
.book-reader-error p {
    max-width: 460px;
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}
.book-reader-error .book-reader-actions {
    justify-content: center;
    padding: 0;
}

@media (max-width: 600px) {
    .book-reader-panel,
    #book-reader-contents {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 75%;
        border-radius: 12px 12px 0 0;
        padding-bottom: var(--safe-area-bottom, 0px);
    }
}
@media (prefers-reduced-motion: reduce) {
    .book-reader-bar {
        transition: none;
    }
}

/* Percent read next to a book's name in file lists (from this browser's reader). */
.book-progress-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    background: var(--bg-tertiary, rgba(127, 127, 127, 0.16));
    border: 1px solid var(--border);
    vertical-align: middle;
}
.file-grid-item .book-progress-badge {
    margin: 2px 0 0;
}

/* ============================================================
   Media library: titles to confirm (媒体库待确认, pages/library_review.rs)
   ============================================================ */
.lr-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin: -8px 0 20px;
    font-size: 13px;
    color: var(--text-secondary);
}
.lr-count {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.lr-count:empty { display: none; }
.lr-folder { overflow-wrap: anywhere; }
.lr-save { display: inline-flex; align-items: center; gap: 6px; }
.lr-save-ok { color: var(--text-primary); }
.lr-save-ok i { color: var(--success); }
.lr-save-failed {
    flex-basis: 100%;
    align-items: flex-start;
    padding: 8px 12px;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border-left: 4px solid var(--danger);
    border-radius: var(--border-radius);
}
.lr-save-failed i { color: var(--danger); margin-top: 3px; }

.lr-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 48px 16px;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 15px;
}

.lr-empty {
    max-width: 560px;
    margin: 24px auto;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
}
.lr-empty h2 { font-size: 20px; color: var(--text-primary); margin-bottom: 10px; }
.lr-empty p { margin-bottom: 12px; line-height: 1.6; }
.lr-empty .btn { margin-top: 8px; }
.lr-empty-icon { font-size: 40px; margin-bottom: 16px; color: var(--text-muted); }

.lr-error, .lr-notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    line-height: 1.6;
}
.lr-error {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border-left: 4px solid var(--danger);
}
.lr-error > i { color: var(--danger); margin-top: 4px; }
.lr-error .btn { margin-top: 8px; }
.lr-notice {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    font-size: 13px;
}
.lr-notice > i { color: var(--primary); margin-top: 3px; }

.lr-roots { max-width: 640px; }
.lr-roots h2 { font-size: 18px; margin-bottom: 6px; }
.lr-roots > p { color: var(--text-secondary); margin-bottom: 12px; }
.lr-root-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lr-root {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    text-align: left;
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
}
.lr-root:hover { border-color: var(--primary); }
.lr-root-name { font-weight: 600; }
.lr-root-when { color: var(--text-secondary); font-size: 13px; margin-left: auto; }

.lr-group { margin-bottom: 28px; }
.lr-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}
.lr-group-count {
    font-size: 12px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
}
.lr-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.lr-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 0;
    text-align: left;
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.lr-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.lr-card:active { transform: scale(0.98); }
.lr-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.lr-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px 10px;
    min-width: 0;
}
.lr-card-name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.lr-card-folder, .lr-card-device {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lr-poster {
    position: relative;
    aspect-ratio: 2 / 3;
    width: 100%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.lr-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lr-poster-letter {
    font-size: 48px;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
}
.lr-poster-small {
    flex: 0 0 56px;
    width: 56px;
    border-radius: var(--border-radius);
}
.lr-poster-small .lr-poster-letter { font-size: 22px; }

.lr-locked {
    margin-bottom: 28px;
    padding: 14px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--border-radius-lg);
    background: var(--bg-primary);
}
.lr-locked-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.lr-locked-head > i { color: var(--text-secondary); }
.lr-locked-head h2 { font-size: 15px; font-weight: 600; margin-right: auto; }
.lr-unlock-form { margin-top: 12px; }
.lr-unlock-form label, .lr-tmdb-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.lr-unlock-row, .lr-tmdb-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lr-unlock-row .form-input { flex: 0 1 180px; letter-spacing: 0.2em; }
.lr-tmdb-row .form-input { flex: 1 1 220px; min-width: 0; }
.lr-field-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.lr-field-error:empty { display: none; }
.lr-help { font-size: 12px; color: var(--text-secondary); margin-top: 6px; overflow-wrap: anywhere; }
.lr-muted { color: var(--text-secondary); margin-bottom: 12px; }

/* The picker */
.lr-picker { max-width: 640px; }
.lr-picker .modal-title { font-size: 17px; overflow-wrap: anywhere; }
.lr-picker .modal-close {
    min-width: 36px;
    min-height: 36px;
    border-radius: var(--border-radius);
}
.lr-picker .modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.lr-picker-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    overflow-wrap: anywhere;
}
.lr-picker-section { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.lr-cands { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.lr-cand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
}
.lr-cand-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.lr-cand-title { font-weight: 600; overflow-wrap: anywhere; }
.lr-cand-meta { font-size: 12px; color: var(--text-secondary); }
.lr-tmdb-form { margin-bottom: 12px; }
.lr-search-link { display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.lr-picker-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Touch: targets of at least 44 px. */
.touch-device .lr-choose,
.touch-device .lr-picker-footer .btn,
.touch-device .lr-tmdb-row .btn,
.touch-device .lr-unlock-row .btn,
.touch-device .lr-locked-head .btn,
.touch-device .lr-change,
.touch-device .lr-picker .modal-close { min-height: 44px; min-width: 44px; }
.touch-device .lr-card:hover { box-shadow: none; border-color: var(--border); }

@media (max-width: 768px) {
    .lr-meta { margin-top: -12px; }
    .lr-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
    .lr-picker-overlay { padding: 0; align-items: stretch; }
    .lr-picker {
        width: 100%;
        max-width: none;
        max-height: 100dvh;
        border-radius: 0;
    }
    .lr-picker-footer { padding-bottom: calc(12px + var(--safe-area-bottom)); }
    .lr-picker-footer .btn { flex: 1 1 auto; justify-content: center; }
    .lr-root-when { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 360px) {
    .lr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lr-cand { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    .lr-card { transition: none; }
    .lr-card:active { transform: none; }
}

/* the media interface's shell and parental control (components/shell.rs), as the apps draw them */
.app-sidebar.media-sidebar.open { width: 220px; }
.media-sidebar .sidebar-nav { flex: 1; overflow-y: auto; min-height: 0; padding-top: 8px; }
.media-sidebar .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-foot { flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; padding: 6px 10px 12px; }
.app-sidebar:not(.media-sidebar) .shell-foot { padding-right: 40px; }
.app-sidebar:not(.open) .shell-foot { display: none; }
.shell-foot-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 30px; padding: 5px 10px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--text-primary) 18%, transparent); background: transparent; color: var(--text-secondary); font-family: inherit; font-size: 12px; font-weight: 500; line-height: 1.3; text-align: left; cursor: pointer; }
.shell-foot-btn:hover { color: var(--text-primary); background: color-mix(in srgb, var(--text-primary) 6%, transparent); }
.shell-foot-btn:focus-visible, .shell-capsule:focus-visible, .shell-key:focus-visible, .shell-pill:focus-visible, .shell-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.shell-capsule { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: none; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.2; cursor: pointer; }
.dashboard-header { position: relative; }
.dashboard-switch { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.media-tab-bar button.tab-bar-item { border: none; background: none; font: inherit; font-size: 10px; cursor: pointer; }
.media-tab-bar .tab-bar-item[aria-current="page"] { color: var(--primary); }
/* a locked page */
.shell-gate { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 60vh; padding: 32px 20px; text-align: center; color: var(--text-primary); }
.shell-gate-icon { font-size: 52px; color: var(--text-secondary); }
.shell-gate h2 { margin: 0; font-size: 20px; }
.shell-gate p { margin: 0; max-width: 440px; color: var(--text-secondary); line-height: 1.5; }
.shell-pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; cursor: pointer; }
.shell-pill:disabled { opacity: 0.5; cursor: default; }
.shell-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .shell-primary { color: #0b1220; }
/* the code's dialog: four dots over a round-key pad */
.shell-overlay { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.45); }
.shell-code { width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 24px 18px; border-radius: 16px; background: var(--bg-primary); color: var(--text-primary); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); outline: none; }
.shell-code-head { display: flex; align-items: center; gap: 12px; align-self: stretch; }
.shell-code-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); flex-shrink: 0; }
.shell-code-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.shell-code-line { margin: 4px 0 0; color: var(--text-secondary); font-size: 14px; text-align: center; }
.shell-dots { display: flex; gap: 16px; margin: 6px 0 8px; }
.shell-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-secondary); }
.shell-dot-on { background: var(--text-primary); border-color: var(--text-primary); }
.shell-pad { display: grid; grid-template-columns: repeat(3, 56px); gap: 14px 22px; }
.shell-key { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-family: inherit; font-size: 22px; font-weight: 500; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.shell-key:hover:not(:disabled) { background: color-mix(in srgb, var(--text-primary) 10%, var(--bg-secondary)); }
.shell-key:active:not(:disabled) { transform: scale(0.94); }
.shell-key:disabled { opacity: 0.4; cursor: default; }
.shell-key-icon { font-size: 18px; }
.shell-key-ok:not(:disabled) { background: var(--primary); border-color: var(--primary); color: #fff; }
.touch-device .shell-pad { grid-template-columns: repeat(3, 64px); }
.touch-device .shell-key { width: 64px; height: 64px; }
.shell-code-error { margin: 0; min-height: 1.2em; color: var(--danger, #d93025); font-size: 13px; text-align: center; }
.shell-code-error:empty { min-height: 0; }
.shell-link { border: none; background: none; padding: 2px 4px; color: var(--primary); font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.3; cursor: pointer; }
.shell-code-foot { display: flex; justify-content: flex-end; gap: 10px; align-self: stretch; margin-top: 4px; }
.shell-password { width: 100%; }
/* parental control's settings */
.shell-settings { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 4px; border-top: 1px solid var(--border); margin-top: 6px; }
.shell-settings h3 { margin: 0; font-size: 15px; font-weight: 600; }
.shell-settings .mc-pill { align-self: flex-start; }
@media (prefers-reduced-motion: reduce) { .shell-key:active:not(:disabled) { transform: none; } }

/* AI subtitles on the media server (pages/ai_subtitles.rs, media_client/subtitles.rs) */
.summary-card.subtitles::before { background: linear-gradient(90deg, #00897b, #26a69a); }
.summary-card.subtitles .summary-card-icon-inline,
.summary-card.subtitles .summary-count,
.summary-subtitle.active.subtitles { color: #00796b; }
[data-theme="dark"] .summary-card.subtitles .summary-card-icon-inline,
[data-theme="dark"] .summary-card.subtitles .summary-count,
[data-theme="dark"] .summary-subtitle.active.subtitles { color: #4db6ac; }
.ais-intro { margin: 0 0 12px; }
.ais-subhead { margin: 8px 0 4px; font-size: 14px; font-weight: 600; }
.ais-models, .ais-keys { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ais-model { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ais-model-name { font-weight: 500; min-width: 140px; }
.ais-model-state { font-size: 12px; color: var(--text-secondary); }
.ais-model-error { flex-basis: 100%; margin: 0; }
.ais-bar { flex: 1 1 120px; height: 6px; }
.ais-bar .progress-fill { background: #00897b; }
.ais-pct { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 3em; }
.ais-key { display: flex; flex-direction: column; gap: 4px; }
.ais-key .form-label { margin: 0; }
.ais-key-state { font-size: 12px; color: var(--text-secondary); }
.ais-key-state.ais-on { color: var(--success); }
.ais-key-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ais-key-row .form-input { flex: 1 1 200px; min-width: 0; }
.ais-address { flex: 1 1 200px; min-width: 0; font-size: 13px; word-break: break-all; }
.ais-delay { margin-bottom: 8px; }
.ais-section { margin-bottom: 16px; }
.ais-section-head { margin: 4px 0 8px; font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.ais-jobs { list-style: none; margin: 0; padding: 0; }
/* The rows hold screen-reader text (.sr-only, absolute): kept inside them, not pushing the page taller than the window */
.ais-job, .ais-took, .ais-steps { position: relative; }
.ais-move { display: flex; gap: 4px; margin-right: auto; }
.ais-move .btn { min-width: 28px; justify-content: center; }
.ais-job-title { font-size: 14px; font-weight: 600; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ais-job-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.ais-progress { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ais-stats { flex-wrap: wrap; row-gap: 4px; }
.ais-detail { margin-top: 6px; font-size: 12px; color: var(--text-secondary); word-break: break-all; }
.ais-form section[hidden] { display: none; }
.ais-test { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }
.ais-test p { margin: 0; word-break: break-word; }
.ais-test-ok { color: var(--success); }
.ais-test-fail { color: var(--danger); }
.ais-model .ais-model-state { min-width: 0; }

/* an album's MusicBrainz release (media client music.rs Release, TrackList): a label's catalogue numbers in its chip,
   the facts line, the credits and the notes, which wrap and can be selected; a track's work and credits lines wrap */
.mc-vchip-sub { font-weight: 500; color: var(--mc-text-mid); }
.mc-release-text { margin: 0; font-size: 13px; color: var(--mc-text); overflow-wrap: anywhere; user-select: text; }
.mc-release-credits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mc-release-notes { white-space: pre-line; }
.mc-track-more { white-space: normal; }

/* A show exposes every season's cover; selection only changes the episodes below. */
.mc-season-card { width: clamp(124px, 13vw, 180px); padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.mc-season-card[aria-pressed="true"] .mc-art { outline: 2px solid var(--mc-brand-hi); outline-offset: 2px; }
.mc-season-card[aria-pressed="true"] .mc-card-name { color: var(--mc-brand-hi); font-weight: 700; }
.mc-season-card:focus-visible .mc-art { outline: 3px solid var(--mc-brand-hi); outline-offset: 4px; }
.mc-season-count { position: absolute; top: 8px; right: 8px; min-width: 26px; padding: 3px 7px; border-radius: 999px; background: var(--mc-bg1); color: var(--mc-text-hi); text-align: center; font-size: 12px; font-weight: 700; }
.mc-season-summary { margin: 0 var(--mc-side) 4px; max-width: 75ch; }
.mc-season-summary h3 { display: none; }
.mc-season-summary p { white-space: pre-line; overflow-wrap: anywhere; margin: 0 0 8px; }
.mc-season-summary p:empty { display: none; }
