/**
 * serverless.css - OmniLearn UI Redesign
 * Philosophy: Breathe. One thing at a time. Hide complexity, reveal intent.
 */

/* Design Tokens */
:root {
    --nav-w: 64px;
    --nav-w-open: 220px;
    --sidebar-bg: rgba(10, 11, 18, 0.96);
    --card-bg: rgba(18, 21, 34, 0.85);
    --border: rgba(255, 255, 255, 0.07);
    --border-bright: rgba(255, 255, 255, 0.14);
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.18);
    --accent-glow: rgba(99, 102, 241, 0.35);
    --text: #f1f5f9;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --radius: 16px;
    --radius-sm: 10px;
    --tag-color: #eab308;
    --wiki-color: #6366f1;
    --transition: 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Hide old top header */
.app-header { display: none !important; }

/* ── SIDEBAR NAV ───────────────────────────────────────────────────────── */
.sl-sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--nav-w);
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.2rem 0 1.5rem;
    z-index: 9000;
    transition: width var(--transition);
    overflow: hidden;
}
.sl-sidebar:hover { width: var(--nav-w-open); }

.sl-brand {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1rem; width: 100%; margin-bottom: 2rem;
    cursor: pointer; text-decoration: none;
    overflow: hidden; white-space: nowrap;
}
.sl-brand-icon { font-size: 1.4rem; flex-shrink: 0; width: 40px; text-align: center; }
.sl-brand-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700; font-size: 0.95rem; color: #fff;
    letter-spacing: 0.04em;
    opacity: 0; transition: opacity var(--transition);
}
.sl-sidebar:hover .sl-brand-text { opacity: 1; }

.sl-nav-items {
    display: flex; flex-direction: column; gap: 0.25rem;
    width: 100%; padding: 0 0.6rem; flex: 1;
}

.sl-nav-item {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.75rem 0.85rem; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 0.88rem; font-weight: 600;
    cursor: pointer; border: none; background: transparent;
    width: 100%; text-align: left;
    white-space: nowrap; overflow: hidden;
    transition: color var(--transition), background var(--transition);
}
.sl-nav-item:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.sl-nav-item.active { color: #fff; background: var(--accent-soft); }
.sl-nav-item.active .sl-nav-icon { filter: drop-shadow(0 0 6px var(--accent)); }

.sl-nav-icon { font-size: 1.15rem; flex-shrink: 0; width: 24px; text-align: center; }
.sl-nav-label { opacity: 0; transition: opacity var(--transition); font-size: 0.88rem; }
.sl-sidebar:hover .sl-nav-label { opacity: 1; }

.sl-sidebar-bottom { width: 100%; padding: 0 0.6rem; display: flex; flex-direction: column; gap: 0.25rem; }

.sl-drive-pill {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 0.85rem; border-radius: var(--radius-sm);
    background: transparent; border: none; cursor: pointer;
    width: 100%; overflow: hidden; white-space: nowrap;
    transition: background var(--transition);
}
.sl-drive-pill:hover { background: rgba(255,255,255,0.05); }

.sl-drive-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); flex-shrink: 0; margin: 0 8px;
    transition: background var(--transition), box-shadow var(--transition);
}
.sl-drive-dot.connected { background: #10b981; box-shadow: 0 0 8px rgba(16,185,129,0.7); }

.sl-drive-label {
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
    opacity: 0; transition: opacity var(--transition);
}
.sl-sidebar:hover .sl-drive-label { opacity: 1; }

/* ── MAIN AREA ─────────────────────────────────────────────────────────── */
.sl-main { margin-left: var(--nav-w); flex: 1; min-height: 100vh; transition: margin-left var(--transition); }

/* ── TOPBAR ────────────────────────────────────────────────────────────── */
.sl-topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: 1rem;
    padding: 0.9rem 2rem;
    background: rgba(8,9,16,0.9); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}
.sl-topbar-title { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; }

.sl-search {
    flex: 1; max-width: 460px;
    display: flex; align-items: center; gap: 0.6rem;
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    border-radius: 30px; padding: 0.5rem 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.sl-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sl-search input { background: transparent; border: none; outline: none; color: var(--text); font-size: 0.88rem; width: 100%; }
.sl-search input::placeholder { color: var(--text-muted); }

.sl-topbar-spacer { flex: 1; }
.sl-topbar-actions { display: flex; align-items: center; gap: 0.6rem; }

.sl-icon-btn {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text-dim); font-size: 0.9rem;
    padding: 0.5rem 0.75rem; cursor: pointer;
    transition: background var(--transition), color var(--transition);
    display: flex; align-items: center; gap: 0.4rem;
}
.sl-icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── VIEW SYSTEM ───────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── LIBRARY VIEW ──────────────────────────────────────────────────────── */
#view-library.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.sl-filter-bar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 2rem; flex-wrap: wrap; }

.sl-filter-pill {
    padding: 0.4rem 1rem; border-radius: 30px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-muted); font-size: 0.82rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.sl-filter-pill:hover { border-color: var(--accent); color: var(--text); }
.sl-filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px var(--accent-glow); }

.sl-add-btn {
    margin-left: auto; display: flex; align-items: center; gap: 0.4rem;
    padding: 0.45rem 1.1rem; border-radius: 30px;
    border: 1px solid var(--accent); background: transparent;
    color: var(--accent); font-size: 0.82rem; font-weight: 700; cursor: pointer;
    transition: all var(--transition);
}
.sl-add-btn:hover { background: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-glow); }

/* Library grid */
.sl-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.sl-media-card {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    cursor: pointer; position: relative;
    backdrop-filter: blur(12px);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.sl-media-card:hover {
    transform: translateY(-5px);
    border-color: var(--border-bright);
    box-shadow: 0 16px 48px rgba(0,0,0,0.55);
}

.sl-card-cover {
    width: 100%; aspect-ratio: 3/2;
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
    display: flex; align-items: center; justify-content: center;
    font-size: 3.2rem; position: relative; overflow: hidden;
}
.sl-card-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.sl-card-type {
    position: absolute; top: 0.65rem; left: 0.65rem;
    font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em;
    padding: 0.18rem 0.55rem; border-radius: 6px;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(8px);
    color: #fff; text-transform: uppercase;
}
.sl-card-type.course   { background: rgba(139,92,246,0.75); }
.sl-card-type.audiobook{ background: rgba(16,185,129,0.75); }
.sl-card-type.book     { background: rgba(59,130,246,0.75); }
.sl-card-type.youtube  { background: rgba(239,68,68,0.75); }

.sl-card-play-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity var(--transition);
}
.sl-media-card:hover .sl-card-play-overlay { opacity: 1; }

.sl-play-circle {
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 0 32px var(--accent-glow);
    transition: transform var(--transition);
}
.sl-media-card:hover .sl-play-circle { transform: scale(1.08); }

.sl-card-body { padding: 1rem 1.1rem 1.2rem; }

.sl-card-title {
    font-size: 0.92rem; font-weight: 700; color: #fff;
    line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 0.4rem;
}

.sl-card-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.sl-card-author { font-size: 0.78rem; color: var(--text-muted); }

.sl-card-badge { font-size: 0.68rem; padding: 1px 6px; border-radius: 4px; font-weight: 700; }
.sl-badge-local { background: rgba(16,185,129,0.15); color: #10b981; }
.sl-badge-drive { background: rgba(59,130,246,0.15); color: #3b82f6; }

.sl-card-episodes { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }

.sl-card-playlist-btn {
    position: absolute; bottom: 0.8rem; right: 0.8rem;
    background: rgba(255,255,255,0.08); border: 1px solid var(--border-bright);
    border-radius: 8px; color: var(--text-dim);
    font-size: 0.75rem; padding: 0.3rem 0.65rem;
    cursor: pointer; opacity: 0;
    transition: opacity var(--transition), background var(--transition);
    backdrop-filter: blur(6px);
}
.sl-media-card:hover .sl-card-playlist-btn { opacity: 1; }
.sl-card-playlist-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── PLAYER VIEW ───────────────────────────────────────────────────────── */
body.player-active {
    overflow: hidden !important;
    height: 100vh !important;
}
body.player-active .sl-main,
body.player-active .main-body {
    height: 100vh !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

#view-player.active {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.sl-player-topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.75rem 1.5rem;
    height: 56px;
    min-height: 56px;
    border-bottom: 1px solid var(--border);
    background: rgba(8,9,16,0.92); backdrop-filter: blur(20px);
    flex-shrink: 0; z-index: 10;
}

.sl-back-btn {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 0.88rem; cursor: pointer;
    display: flex; align-items: center; gap: 0.3rem;
    padding: 0.4rem 0.65rem; border-radius: 8px;
    transition: color var(--transition), background var(--transition); white-space: nowrap;
}
.sl-back-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }

.sl-player-type-badge {
    font-size: 0.62rem; font-weight: 800; letter-spacing: 0.1em;
    padding: 0.2rem 0.65rem; border-radius: 6px; text-transform: uppercase;
    background: var(--accent-soft); color: var(--accent);
}

.sl-player-title-wrap { flex: 1; min-width: 0; }
.sl-player-title { font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-player-subtitle { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sl-note-toggle {
    background: var(--accent-soft); border: 1px solid rgba(99,102,241,0.3);
    border-radius: 10px; color: #a5b4fc;
    font-size: 0.82rem; font-weight: 600; padding: 0.45rem 0.9rem;
    cursor: pointer; display: flex; align-items: center; gap: 0.4rem;
    transition: all var(--transition); white-space: nowrap;
}
.sl-note-toggle:hover { background: var(--accent); color: #fff; box-shadow: 0 4px 12px var(--accent-glow); }
.sl-note-toggle.active { background: var(--accent); color: #fff; }

.sl-tracks-toggle {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text-dim);
    font-size: 0.82rem; font-weight: 600; padding: 0.45rem 0.9rem;
    cursor: pointer; display: flex; align-items: center; gap: 0.4rem;
    transition: all var(--transition); white-space: nowrap;
}
.sl-tracks-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sl-tracks-toggle.active { background: rgba(255,255,255,0.1); color: #fff; }

/* Player body */
.sl-player-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    height: calc(100vh - 56px);
    min-height: 0;
}
.sl-media-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    height: 100%;
    position: relative;
}

/* Media Containers (Video, YouTube, Audiobook, Book) inside sl-media-stage */
.media-layout {
    display: none !important;
    flex: 1;
    flex-direction: row;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    position: relative;
    overflow: hidden;
    gap: 0;
}
.media-layout.active {
    display: flex !important;
}

.sl-tracks-panel {
    display: none !important;
}
.video-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
    min-height: 0;
    min-width: 0;
    background: #000;
}
.video-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    overflow: hidden;
}
.video-wrapper video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Pin custom video controls strictly to bottom of video stage */
.video-wrapper .custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 25;
    background: linear-gradient(to top, rgba(8, 9, 16, 0.95) 0%, rgba(8, 9, 16, 0.7) 70%, transparent 100%);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* YouTube Stage and Iframe */
#youtube-stage {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #000;
    overflow: hidden;
}
#youtube-iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    z-index: 10 !important;
    background: #000 !important;
}

/* Sidebar Panel inside player (Modules & Notes) */
.sidebar-panel {
    width: 380px;
    min-width: 340px;
    max-width: 440px;
    height: 100%;
    background: rgba(12, 14, 23, 0.98);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}
.sidebar-tab {
    flex: 1;
    padding: 0.85rem 1rem;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
}
.sidebar-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}
.sidebar-tab.active {
    color: #fff;
    border-bottom-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.sidebar-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.episode-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    min-height: 0;
}

/* Folder & Tree Styling */
.sl-folder-details > summary {
    list-style: none;
}
.sl-folder-details > summary::-webkit-details-marker {
    display: none;
}
.sl-folder-details[open] > summary .folder-arrow {
    transform: rotate(0deg);
}
.sl-folder-details:not([open]) > summary .folder-arrow {
    transform: rotate(-90deg);
}
.sl-track-row:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}
.sl-track-row.active {
    background: rgba(99, 102, 241, 0.22) !important;
    border-color: rgba(99, 102, 241, 0.7) !important;
}
.sl-track-row.completed .track-name {
    text-decoration: line-through;
    opacity: 0.6;
}
.sl-track-row.completed.active .track-name {
    text-decoration: none;
    opacity: 1;
}
.sl-tick-btn:hover {
    transform: scale(1.15);
}

/* Fix audiobook container height cutoff and layout */
#audio-container {
    height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
    flex: 1 !important;
    flex-direction: row !important;
    margin-bottom: 0 !important;
    display: none !important;
    overflow: hidden !important;
}
#audio-container.active {
    display: flex !important;
}
#audio-container .sidebar-panel {
    height: 100% !important;
    min-height: 0 !important;
    width: 380px !important;
    min-width: 340px !important;
    max-width: 440px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-left: 1px solid var(--border) !important;
}
#audio-container .audiobook-player-card {
    flex: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    background: #000 !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 2rem !important;
    overflow: hidden !important;
}
#audio-container .audiobook-art-stage {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    max-width: 480px !important;
    margin-bottom: 1.5rem !important;
}
#audio-container .audiobook-cover-wrapper {
    width: 150px !important;
    height: 150px !important;
    min-width: 150px !important;
    margin-bottom: 1rem !important;
    font-size: 4rem !important;
    border-radius: var(--radius) !important;
}
#audio-container .audio-controls-box {
    width: 100% !important;
    max-width: 500px !important;
}

/* Tree and Chapter List scroll containers - never cut off */
.episode-list {
    flex: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}
.sl-modules-tree-container {
    flex: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    padding: 0.6rem !important;
}

/* Floating Draggable Mini-Player Widget */
.mini-floating-player {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 240px;
    min-width: 260px;
    min-height: 170px;
    max-width: 720px;
    max-height: 520px;
    background: rgba(14, 16, 26, 0.96);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(99, 102, 241, 0.2);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}
.mini-floating-player.active {
    display: flex !important;
}
.mini-player-header {
    height: 36px;
    min-height: 36px;
    padding: 0 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    user-select: none;
}
.mini-player-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}
.mini-player-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.mini-player-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 3px 6px;
    border-radius: 6px;
    transition: all 0.15s;
}
.mini-player-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}
.mini-player-body {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-player-controls {
    height: 40px;
    min-height: 40px;
    padding: 0 0.8rem;
    background: rgba(10, 12, 20, 0.95);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mini-player-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Sidebar Quick Note Composer & Cards */
.sidebar-quick-composer {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.sidebar-quick-composer textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #fff;
    font-size: 0.82rem;
    padding: 0.5rem;
    resize: vertical;
    min-height: 55px;
    outline: none;
    font-family: inherit;
}
.sidebar-note-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: border-color 0.18s, background 0.18s;
}
.sidebar-note-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(255, 255, 255, 0.04);
}
.sidebar-note-ts {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.12);
}
.sidebar-note-ts:hover {
    background: var(--accent);
    color: #fff;
}

/* Note drawer (slide up) */
.sl-note-drawer {
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 0; overflow: hidden;
    background: rgba(8,9,16,0.97); backdrop-filter: blur(24px);
    border-top: 0px solid var(--border);
    transition: height var(--transition), border-width var(--transition);
    z-index: 50; display: flex; flex-direction: column;
}
.sl-note-drawer.open { height: 45%; min-height: 200px; border-top-width: 1px; }

.sl-note-drawer-header {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sl-note-drawer-title { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; flex: 1; }
.sl-drawer-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 0.2rem 0.4rem; border-radius: 6px; transition: color var(--transition); }
.sl-drawer-close:hover { color: #fff; }

.sl-note-drawer-body { flex: 1; display: flex; gap: 1px; overflow: hidden; background: var(--border); }
.sl-note-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: rgba(8,9,16,0.99); }
.sl-note-col-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sl-note-col textarea { flex: 1; background: transparent; border: none; color: var(--text); font-size: 0.88rem; line-height: 1.75; padding: 0.85rem 1.1rem; resize: none; outline: none; font-family: inherit; }
.sl-note-col textarea::placeholder { color: rgba(100,116,139,0.45); }

/* ── NOTES VIEW ────────────────────────────────────────────────────────── */
#view-notes { display: none; }
#view-notes.active { display: flex; height: 100vh; overflow: hidden; }

.notes-layout { display: flex; width: 100%; gap: 0; height: 100%; }

.notes-sidebar {
    width: 280px; min-width: 240px;
    background: var(--sidebar-bg); backdrop-filter: blur(16px);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}
.notes-sidebar-header { padding: 1.2rem 1.2rem 0.8rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notes-sidebar-title { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; display: flex; align-items: center; gap: 0.4rem; }
.notes-sidebar-list { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.note-list-card { padding: 0.75rem 0.85rem; background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer; transition: all var(--transition); }
.note-list-card:hover { background: rgba(255,255,255,0.04); border-color: var(--border); }
.note-list-card.active { background: var(--accent-soft); border-color: rgba(99,102,241,0.35); }
.note-card-title { font-size: 0.88rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-card-preview { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-tags { margin-top: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.note-pill { font-size: 0.66rem; color: var(--tag-color); background: rgba(234,179,8,0.1); padding: 0.1rem 0.4rem; border-radius: 4px; }

.notes-main-workspace { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: rgba(8,9,16,0.98); }
.editor-toolbar { padding: 0.85rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; background: rgba(0,0,0,0.2); flex-shrink: 0; }
.editor-toolbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.timestamp-action-btn { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border: none; border-radius: 8px; padding: 0.45rem 0.9rem; font-size: 0.82rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 0.4rem; box-shadow: 0 4px 12px var(--accent-glow); transition: transform var(--transition), box-shadow var(--transition); }
.timestamp-action-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px var(--accent-glow); }
.editor-status-badge { font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.55rem; border-radius: 20px; background: rgba(255,255,255,0.05); color: var(--text-muted); }
.editor-status-badge.success { color: #10b981; background: rgba(16,185,129,0.1); }
.editor-status-badge.warning { color: #f59e0b; background: rgba(245,158,11,0.1); }
.editor-status-badge.error   { color: #ef4444; background: rgba(239,68,68,0.1); }
.editor-meta-bar { padding: 0.9rem 1.5rem 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; border-bottom: 1px solid rgba(255,255,255,0.04); flex-shrink: 0; }
.note-title-input { background: transparent; border: none; font-size: 1.4rem; font-weight: 800; color: #fff; outline: none; width: 100%; }
.note-tags-input { background: transparent; border: none; font-size: 0.85rem; color: var(--tag-color); outline: none; width: 100%; }
.editor-panes-wrapper { flex: 1; display: flex; overflow: hidden; }
.editor-pane-textarea { flex: 1; background: transparent; border: none; padding: 1.2rem 1.5rem; color: #f1f5f9; font-family: 'SF Mono', 'Fira Code', Menlo, monospace; font-size: 0.93rem; line-height: 1.7; outline: none; resize: none; overflow-y: auto; border-right: 1px solid var(--border); }
.editor-pane-preview { flex: 1; padding: 1.2rem 1.8rem; color: #e2e8f0; overflow-y: auto; font-size: 0.93rem; line-height: 1.75; }
.editor-pane-preview h1 { font-size: 1.6rem; margin: 0.8rem 0 0.4rem; color: #fff; }
.editor-pane-preview h2 { font-size: 1.25rem; margin: 0.6rem 0 0.3rem; color: #f8fafc; }
.editor-pane-preview h3 { font-size: 1.05rem; margin: 0.5rem 0 0.2rem; color: #cbd5e1; }
.editor-pane-preview li { margin: 0.3rem 0; }
.editor-pane-preview blockquote { border-left: 3px solid var(--accent); padding-left: 0.85rem; color: var(--text-muted); margin: 0.6rem 0; }

.timestamp-link { display: inline-flex; align-items: center; gap: 3px; background: var(--accent-soft); color: #818cf8; border: 1px solid rgba(99,102,241,0.3); padding: 0.12rem 0.4rem; border-radius: 6px; text-decoration: none; font-size: 0.82rem; font-weight: 700; font-family: monospace; transition: all var(--transition); }
.timestamp-link:hover { background: var(--accent); color: #fff; box-shadow: 0 0 10px var(--accent-glow); }
.wikilink { color: #38bdf8; background: rgba(56,189,248,0.1); padding: 0.1rem 0.35rem; border-radius: 4px; text-decoration: none; font-weight: 600; transition: background var(--transition); }
.wikilink:hover { background: rgba(56,189,248,0.22); text-decoration: underline; }
.tag-badge { color: var(--tag-color); font-weight: 600; }

/* ── GRAPH VIEW ────────────────────────────────────────────────────────── */
#view-graph { display: none; width: 100%; height: 100vh; position: relative; background: radial-gradient(circle at 50% 50%, rgba(30,35,60,0.5) 0%, rgba(8,9,16,0.98) 100%); overflow: hidden; }
#view-graph.active { display: block; }
#knowledge-graph-canvas { width: 100%; height: 100%; display: block; }
.graph-floating-controls { position: absolute; top: 1.2rem; left: 1.2rem; background: rgba(18,21,34,0.9); backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 1rem; display: flex; align-items: center; gap: 0.8rem; color: #fff; font-size: 0.85rem; box-shadow: 0 8px 30px rgba(0,0,0,0.5); z-index: 10; }
.graph-legend { position: absolute; bottom: 1.2rem; left: 1.2rem; background: rgba(18,21,34,0.9); backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.8rem; display: flex; gap: 0.8rem; font-size: 0.75rem; color: #cbd5e1; z-index: 10; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* ── SCROLLBAR ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── MOBILE ────────────────────────────────────────────────────────────── */
.mobile-nav-bar { display: none !important; }

@media (max-width: 768px) {
    .sl-sidebar { width: 0; border-right: none; }
    .sl-sidebar.mobile-open { width: var(--nav-w-open); border-right: 1px solid var(--border); }
    .sl-main { margin-left: 0; }
    .mobile-nav-bar {
        display: flex !important;
        position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
        background: var(--sidebar-bg); backdrop-filter: blur(20px);
        border-top: 1px solid var(--border); z-index: 9001;
        justify-content: space-around; align-items: center;
    }
    .mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: var(--text-muted); font-size: 0.68rem; font-weight: 600; cursor: pointer; padding: 6px 10px; border-radius: 10px; transition: color var(--transition); }
    .mobile-nav-item.active { color: #fff; }
    .mobile-nav-item .nav-icon { font-size: 1.2rem; }
    #view-library.active { padding: 1rem 1rem 5rem; }
    .sl-library-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
    .sl-tracks-panel.open { position: absolute; top: 0; right: 0; bottom: 0; width: 260px; z-index: 20; }
    .sl-note-drawer.open { height: 55%; }
    .notes-sidebar { display: none; }
    .editor-panes-wrapper { flex-direction: column; }
    .editor-pane-textarea { border-right: none; border-bottom: 1px solid var(--border); min-height: 180px; }
}

/* ── PICTURE-IN-PICTURE (RESET-FREE FLOATING PLAYER) ──────────────────── */
body.player-pip-active #view-player {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 380px !important;
    height: 250px !important;
    min-width: 280px !important;
    min-height: 190px !important;
    max-width: 720px !important;
    max-height: 480px !important;
    resize: both !important;
    overflow: hidden !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(99, 102, 241, 0.45) !important;
    z-index: 99999 !important;
    background: #0e111a !important;
    backdrop-filter: blur(24px) !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.player-pip-active #view-player .sl-player-topbar,
body.player-pip-active #view-player .sidebar-panel,
body.player-pip-active #view-player .sl-note-drawer {
    display: none !important;
}

body.player-pip-active #view-player .sl-player-body {
    flex: 1 !important;
    height: calc(100% - 32px) !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
}

body.player-pip-active #view-player .sl-media-stage {
    flex: 1 !important;
    height: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
    position: relative !important;
}

body.player-pip-active #view-player .video-main,
body.player-pip-active #view-player .video-wrapper,
body.player-pip-active #view-player .audiobook-player-card {
    height: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
}

.player-pip-header {
    display: none;
    height: 32px;
    background: rgba(14, 17, 26, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0 0.8rem;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    cursor: move;
}
body.player-pip-active .player-pip-header {
    display: flex !important;
}

/* ── CARD PROGRESS INDICATORS ────────────────────────────────────────── */
.sl-card-progress-wrap {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sl-card-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}
.sl-card-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #10b981);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.sl-card-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.sl-card-progress-pct {
    font-weight: 700;
    color: #10b981;
}

/* ── HIERARCHICAL FOLDER CARDS & BREADCRUMBS ────────────────────────── */
.sl-folder-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sl-folder-card:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}
.sl-folder-icon {
    font-size: 2.2rem;
    line-height: 1;
}
.sl-folder-info {
    flex: 1;
    overflow: hidden;
}
.sl-folder-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sl-folder-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
.sl-breadcrumb-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}
.sl-breadcrumb-btn:hover {
    text-decoration: underline;
    color: #fff;
}
.sl-breadcrumb-current {
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
}

/* ── TOAST NOTIFICATIONS ─────────────────────────────────────────────── */
.omni-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(18, 21, 34, 0.96);
    border: 1px solid var(--accent);
    color: #fff;
    padding: 0.7rem 1.4rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(99, 102, 241, 0.3);
    z-index: 999999;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.omni-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── 🎧 AUDIOBOOK COMPACT PiP & MINI-PLAYER ────────────────────────────── */
body.player-pip-active #view-player .audiobook-player-card {
    height: 100% !important;
    width: 100% !important;
    padding: 0.4rem 0.8rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    gap: 0.3rem !important;
    overflow: hidden !important;
    background: #0e111a !important;
}
body.player-pip-active #view-player .audiobook-art-stage {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.8rem !important;
    margin-bottom: 0 !important;
    text-align: left !important;
    flex: 1 !important;
    min-height: 0 !important;
}
body.player-pip-active #view-player .audiobook-cover-wrapper {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    font-size: 1.4rem !important;
    margin-bottom: 0 !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
}
body.player-pip-active #view-player .equalizer-visualizer {
    display: none !important;
}
body.player-pip-active #view-player .now-playing-title {
    font-size: 0.82rem !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 260px !important;
}
body.player-pip-active #view-player .now-playing-chapter {
    font-size: 0.72rem !important;
    margin: 0 !important;
    color: var(--text-muted) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 260px !important;
}
body.player-pip-active #view-player .audio-controls-box {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.3rem !important;
}
body.player-pip-active #view-player .audio-scrubber-row {
    margin-bottom: 0.2rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
}
body.player-pip-active #view-player .audio-scrubber-row .time-label {
    font-size: 0.68rem !important;
}
body.player-pip-active #view-player .audio-actions-row {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.4rem !important;
}
body.player-pip-active #view-player .audio-actions-row .ctrl-btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
}
body.player-pip-active #view-player .audio-actions-row .play-pause-btn {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.95rem !important;
}
body.player-pip-active #view-player .speed-control {
    display: none !important;
}

/* ── 📖 EPUB READER 100% VIEWPORT FIT ─────────────────────────────────── */
#epub-container {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-card) !important;
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border) !important;
    overflow: hidden !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}
.reader-toolbar {
    flex-shrink: 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.6rem 1rem !important;
    background: var(--bg-surface) !important;
    border-bottom: 1px solid var(--border) !important;
    gap: 0.6rem !important;
    flex-wrap: nowrap !important;
}
.epub-viewer-wrapper {
    flex: 1 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    position: relative !important;
    background: #12141c !important;
    overflow: hidden !important;
}
#viewer {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    inset: 0 !important;
}

/* ── 📝 NOTE VIEW MODE vs EDIT MODE ──────────────────────────────────── */
.notes-main-workspace {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    background: var(--bg-card) !important;
}
.notes-main-workspace.view-mode .note-view-pane {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    padding: 1.8rem 2.2rem !important;
    cursor: default !important;
}
.notes-main-workspace.view-mode .note-edit-pane {
    display: none !important;
}
.notes-main-workspace.edit-mode .note-view-pane {
    display: none !important;
}
.notes-main-workspace.edit-mode .note-edit-pane {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
}
.note-rendered-view {
    font-size: 0.98rem !important;
    line-height: 1.75 !important;
    color: #e2e8f0 !important;
}
.note-rendered-view h1, .note-rendered-view h2, .note-rendered-view h3 {
    color: #fff !important;
    margin-top: 1.2rem !important;
    margin-bottom: 0.6rem !important;
    font-weight: 700 !important;
}
.note-rendered-view blockquote {
    border-left: 3px solid var(--accent) !important;
    padding-left: 1rem !important;
    margin: 0.8rem 0 !important;
    color: #94a3b8 !important;
}
.note-rendered-view ul, .note-rendered-view ol {
    padding-left: 1.5rem !important;
    margin: 0.6rem 0 !important;
}
.note-rendered-view li {
    margin-bottom: 0.3rem !important;
}

/* ── 🕸️ GRAPH PHYSICS CONTROLS FLOATING PANEL ────────────────────────── */
.graph-floating-controls {
    min-width: 320px !important;
    max-width: 380px !important;
}
.graph-physics-panel input[type="range"] {
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── 🎙️ VOICE DICTATION RECORDING PULSE ──────────────────────────────── */
.mic-btn.recording {
    background: #ef4444 !important;
    color: #fff !important;
    animation: micPulse 1.2s infinite ease-in-out !important;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ── ✨ DISCOVER & DOWNLOADS O'REILLY STYLING ──────────────────────────── */
.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: #cbd5e1;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.topic-chip:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}
.filter-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.filter-pill {
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filter-pill.active, .filter-pill:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
#view-discover.view, #view-downloads.view {
    display: none;
    width: 100%;
    animation: fadeIn 0.25s ease-out;
}
#view-discover.view.active, #view-downloads.view.active {
    display: block;
}
.downloads-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 1.5rem 2rem 4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ☁️ Modern Cloud Vault & Google Drive Modal (Apple / Notion Aesthetic)
   ═══════════════════════════════════════════════════════════════════════════ */
.modern-cloud-modal {
    max-width: 540px !important;
    width: 92% !important;
    background: #0d1017 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 22px !important;
    padding: 1.8rem 2rem !important;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.75), 0 0 40px rgba(99, 102, 241, 0.1) !important;
    backdrop-filter: blur(24px) !important;
    color: #f1f5f9;
    max-height: 88vh;
    overflow-y: auto;
    font-family: inherit;
}

.cloud-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.4rem;
}

.cloud-modal-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.cloud-icon-badge {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cloud-modal-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
    letter-spacing: -0.3px;
}

.cloud-modal-subtitle {
    font-size: 0.78rem;
    color: #94a3b8;
    margin: 0.15rem 0 0 0;
}

/* Hero card for disconnected state */
.cloud-hero-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 1.4rem 1.6rem;
    margin-bottom: 1rem;
    text-align: center;
}

.cloud-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.9rem;
}

.cloud-hero-card h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.4rem;
}

.cloud-hero-card p {
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* Official Google Sign-in button */
.btn-google-signin {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.8rem 1.2rem;
    background: #151824;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-google-signin:hover {
    background: #1e2335;
    border-color: rgba(99, 102, 241, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(99, 102, 241, 0.25);
}

.btn-google-signin:active {
    transform: translateY(0);
}

/* Client ID field */
.cloud-clientid-box {
    margin-top: 1.2rem;
    text-align: left;
}

.cloud-clientid-box label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 0.4rem;
}

.cloud-clientid-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.cloud-clientid-input-wrap input {
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 0.65rem 0.9rem;
    color: #fff;
    font-size: 0.82rem;
    font-family: monospace;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cloud-clientid-input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 90, 240, 0.25);
}

.cloud-clientid-input-wrap input.highlight-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3) !important;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.clientid-hint {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 0.35rem;
    line-height: 1.4;
}

/* GCP Setup Accordion */
.cloud-setup-accordion {
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    text-align: left;
    transition: border-color 0.2s;
}

.cloud-setup-accordion[open] {
    border-color: rgba(99, 102, 241, 0.35);
}

.cloud-setup-accordion summary {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.cloud-setup-accordion summary:hover {
    color: #fff;
}

.cloud-setup-accordion .accordion-content {
    padding: 0 1rem 1rem;
}

.origin-copy-box {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.85rem;
}

.origin-copy-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #a5b4fc;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.origin-copy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.origin-copy-row code {
    font-family: monospace;
    font-size: 0.82rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    word-break: break-all;
}

.btn-mini-copy {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.btn-mini-copy:hover {
    opacity: 0.9;
}

.setup-steps-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.6;
}

.setup-steps-list li {
    margin-bottom: 0.4rem;
}

.setup-steps-list a {
    color: #a5b4fc;
    text-decoration: underline;
}

/* Connected State Card */
.cloud-connected-card {
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, rgba(16, 185, 129, 0.01) 100%);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 18px;
    padding: 1.4rem 1.6rem;
    margin-bottom: 1rem;
}

.cloud-user-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1.2rem;
}

.cloud-avatar-icon {
    width: 48px;
    height: 48px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.cloud-user-details {
    flex: 1;
    overflow: hidden;
}

.cloud-user-email {
    font-size: 0.98rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cloud-status-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: #10b981;
    margin-top: 0.25rem;
}

.pulsing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.cloud-path-banner {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1.2rem;
    font-size: 0.8rem;
}

.cloud-path-icon {
    font-size: 1.1rem;
}

.cloud-path-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cloud-path-info span {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 700;
}

.cloud-path-info code {
    font-family: monospace;
    color: #a5b4fc;
    font-size: 0.82rem;
}

.cloud-actions-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-danger-ghost {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #f87171;
    border-radius: 10px;
    padding: 0.65rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger-ghost:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
    color: #fff;
}

/* Extra accordion at bottom */
.cloud-modal-footer-accordion {
    margin-top: 1.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1rem;
}

.extra-settings-accordion {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    overflow: hidden;
}

.extra-settings-accordion summary {
    padding: 0.65rem 0.9rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    user-select: none;
}

.extra-settings-accordion summary:hover {
    color: #94a3b8;
}

.extra-settings-accordion .accordion-content {
    padding: 0 0.9rem 0.9rem;
}




/* ══════════════════════════════════════════════════════════════
   v5.0 — Collections, SyncProgressPanel, Tag Chips
═══════════════════════════════════════════════════════════════ */
.library-with-sidebar { display: flex; height: 100%; gap: 0; overflow: hidden; }
.collections-sidebar { width: 220px; min-width: 200px; flex-shrink: 0; background: rgba(255,255,255,0.02); border-right: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; padding: 1rem 0; overflow-y: auto; height: 100%; }
.csb-header { display: flex; align-items: center; justify-content: space-between; padding: 0 1rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.06); margin-bottom: 0.4rem; }
.csb-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #64748b; }
.csb-new-btn { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); color: #a5b4fc; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 1rem; line-height: 1; transition: all 0.15s; display: flex; align-items: center; justify-content: center; }
.csb-new-btn:hover { background: rgba(99,102,241,0.35); color: #fff; transform: scale(1.1); }
.csb-list { display: flex; flex-direction: column; gap: 2px; padding: 0 0.5rem; }
.csb-section-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #64748b; padding: 0.8rem 0.5rem 0.3rem; }
.csb-notes-section { padding: 0 0.5rem; margin-top: 0.5rem; border-top: 1px solid rgba(255,255,255,0.06); }
.csb-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 8px; cursor: pointer; transition: background 0.15s; position: relative; }
.csb-item:hover { background: rgba(255,255,255,0.05); }
.csb-item.active { background: rgba(99,102,241,0.15); border-left: 2px solid var(--col-accent, #6366f1); }
.csb-item-emoji { font-size: 0.9rem; flex-shrink: 0; }
.csb-item-name { flex: 1; font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e2e8f0; }
.csb-item-count { font-size: 0.72rem; color: #64748b; background: rgba(255,255,255,0.06); border-radius: 10px; padding: 1px 6px; flex-shrink: 0; }
.csb-item-actions { display: none; gap: 2px; flex-shrink: 0; }
.csb-item:hover .csb-item-actions { display: flex; }
.csb-item-edit, .csb-item-delete { background: none; border: none; cursor: pointer; font-size: 0.7rem; padding: 2px; opacity: 0.5; transition: opacity 0.15s; border-radius: 4px; }
.csb-item-edit:hover, .csb-item-delete:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.sl-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sl-card-tag { font-size: 0.65rem; font-weight: 600; color: #a5b4fc; background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.25); border-radius: 999px; padding: 1px 7px; cursor: pointer; transition: background 0.15s; white-space: nowrap; }
.sl-card-tag:hover { background: rgba(99,102,241,0.3); }
.omni-sync-panel { position: fixed; bottom: 24px; right: 24px; width: 360px; max-width: calc(100vw - 48px); background: rgba(14,16,26,0.95); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; backdrop-filter: blur(20px); box-shadow: 0 20px 60px rgba(0,0,0,0.6); z-index: 9999999; overflow: hidden; opacity: 0; transform: translateY(12px); transition: opacity 0.3s ease, transform 0.3s ease; }
.omni-sync-panel.visible { opacity: 1; transform: translateY(0); }
.osp-header { display: flex; align-items: center; gap: 0.6rem; padding: 0.85rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.07); background: rgba(99,102,241,0.1); }
.osp-title { flex: 1; font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }
.osp-close { background: none; border: none; color: #64748b; cursor: pointer; font-size: 0.9rem; padding: 2px 4px; border-radius: 4px; transition: color 0.15s; }
.osp-close:hover { color: #fff; }
.osp-items { max-height: 280px; overflow-y: auto; padding: 0.4rem 0; }
.osp-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 1rem; font-size: 0.8rem; }
.osp-item--done .osp-bar-fill { background: linear-gradient(90deg, #4ade80, #22c55e); }
.osp-item--uploading .osp-bar-fill { background: linear-gradient(90deg, #6366f1, #8b5cf6); animation: barPulse 1.5s infinite; }
.osp-item--skipped .osp-bar-fill { background: rgba(100,116,139,0.5); }
.osp-item--error .osp-bar-fill { background: rgba(239,68,68,0.6); }
.osp-item-icon { font-size: 0.9rem; flex-shrink: 0; width: 20px; text-align: center; }
.osp-item-label { flex: 1; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.osp-bar-wrap { width: 70px; height: 4px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.osp-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; background: rgba(99,102,241,0.5); }
.osp-pct { font-size: 0.72rem; color: #64748b; width: 50px; text-align: right; flex-shrink: 0; }
.osp-status-icon { font-size: 0.85rem; flex-shrink: 0; }
.osp-footer { padding: 0.6rem 1rem; font-size: 0.78rem; color: #64748b; border-top: 1px solid rgba(255,255,255,0.06); background: rgba(255,255,255,0.02); }
@keyframes barPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.col-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); z-index: 9999999; display: flex; align-items: center; justify-content: center; }
.col-modal { background: #12141e; border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; width: 480px; max-width: 95vw; box-shadow: 0 24px 64px rgba(0,0,0,0.7); overflow: hidden; }
.col-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.07); }
.col-modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; color: #f1f5f9; }
.col-modal-close { background: none; border: none; color: #64748b; font-size: 1.1rem; cursor: pointer; padding: 4px; border-radius: 6px; transition: color 0.15s; }
.col-modal-close:hover { color: #fff; }
.col-modal-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.col-form-row { display: flex; flex-direction: column; gap: 0.4rem; }
.col-form-row label { font-size: 0.78rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.col-form-row input[type="text"] { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; padding: 0.6rem 0.9rem; color: #f1f5f9; font-size: 0.9rem; outline: none; transition: border-color 0.2s; font-family: inherit; width: 100%; box-sizing: border-box; }
.col-form-row input:focus { border-color: rgba(99,102,241,0.6); }
.col-emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.col-emoji-btn { background: rgba(255,255,255,0.05); border: 1px solid transparent; border-radius: 8px; padding: 4px 7px; font-size: 1.1rem; cursor: pointer; transition: all 0.15s; }
.col-emoji-btn:hover { background: rgba(99,102,241,0.2); }
.col-emoji-btn.selected { background: rgba(99,102,241,0.25); border-color: rgba(99,102,241,0.5); }
.col-color-options { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.col-color-btn { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform 0.15s, border-color 0.15s; flex-shrink: 0; }
.col-color-btn:hover { transform: scale(1.15); }
.col-color-btn.selected { border-color: #fff; transform: scale(1.15); }
.col-modal-footer { display: flex; gap: 0.75rem; padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.07); justify-content: flex-end; }
.col-modal-cancel { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #cbd5e1; padding: 0.6rem 1.2rem; border-radius: 10px; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: all 0.15s; font-family: inherit; }
.col-modal-cancel:hover { background: rgba(255,255,255,0.1); }
.col-modal-save { background: linear-gradient(135deg, #6366f1, #8b5cf6); border: none; color: #fff; padding: 0.6rem 1.4rem; border-radius: 10px; cursor: pointer; font-size: 0.88rem; font-weight: 700; transition: all 0.2s; font-family: inherit; box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.col-modal-save:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(99,102,241,0.55); }
.col-pick-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer; font-size: 0.88rem; color: #e2e8f0; }
.col-pick-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: #6366f1; cursor: pointer; flex-shrink: 0; }
.col-pick-emoji { font-size: 1rem; }
@media (max-width: 768px) { .collections-sidebar { display: none; } .library-with-sidebar { flex-direction: column; } }
