:root {
    --bg: #060910;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-strong: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.08);
    --text: #e8eefc;
    --muted: #8da2c7;
    --accent: #7ee0ff;
    --accent-2: #ffb86b;
    --danger: #ff6b6b;
    font-family: 'Sora', 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
body {
    margin: 0;
    background: radial-gradient(circle at 20% 0%, rgba(126, 224, 255, 0.18), transparent 32%),
                radial-gradient(circle at 80% 0%, rgba(255, 184, 107, 0.22), transparent 33%),
                var(--bg);
    min-height: 100vh;
}

.backdrop {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(135deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.shell {
    position: relative;
    z-index: 1;
    padding: 20px 22px 160px;
    width: 100%;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(120deg, rgba(126, 224, 255, 0.18), rgba(255, 184, 107, 0.18));
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    backdrop-filter: blur(10px);
    margin: 0 8px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.mark {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(180deg, #101828, #111f3a);
    border: 1px solid var(--border);
    display: grid; place-items: center;
    font-weight: 700; letter-spacing: -0.4px;
}
.hero-actions { display: flex; gap: 10px; }

.search-bar {
    margin-top: 16px;
    margin-inline: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--muted); font-size: 13px; }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row input {
    flex: 1;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
    color: var(--text);
}
.input-row input:focus { outline: 1px solid var(--accent); }
.hints { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-top: 8px; flex-wrap: wrap; }
.current-folder { font-weight: 600; color: var(--text); }
.current-folder-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 6px;
}

.left-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.layout {
    margin-top: 16px;
    margin-inline: 8px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.results {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
}
.section-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: stretch;
}
.section-head .statline { display: flex; gap: 10px; align-items: baseline; }
.scan-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    width: 240px;
    flex-shrink: 0;
    opacity: 1;
    transition: opacity 220ms ease;
}
.scan-progress-track {
    position: relative;
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
}
.scan-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 999px;
    transition: width 160ms ease;
}
.scan-progress-label {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    min-width: 120px;
    text-align: right;
}
.scan-progress.fade-out { opacity: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; color: var(--muted); margin: 0 0 4px; }
.tag-form { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.tag-form input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: var(--text);
    min-width: 180px;
}
.sort-select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: var(--text);
}

.asset-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.asset-grid.detail {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chip {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    color: var(--muted);
    font-size: 12px;
}

.asset-card {
    position: relative;
    background: linear-gradient(160deg, rgba(126, 224, 255, 0.08), rgba(255, 184, 107, 0.08));
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: border 120ms ease, transform 120ms ease;
}
.asset-card.detail {
    display: grid;
    grid-template-columns: 80px 2fr 1fr 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}
.asset-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.asset-card.selected { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(255, 184, 107, 0.4); }

.thumb {
    height: 150px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    display: grid;
    place-items: center;
}
.thumb.detail {
    width: 65px;
    min-width: 65px;
    height: 40px;
    align-self: center;
}
.thumb img, .thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.thumb .icon {
    font-size: 52px;
}

.meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.meta .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}
.muted { color: var(--muted); font-size: 13px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tags .tag { background: rgba(255,255,255,0.1); padding: 5px 9px; border-radius: 10px; font-size: 11px; }
.sentinel { height: 2px; }
.card-body { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body.detail { gap: 4px; }
.meta.detail { justify-content: flex-start; gap: 10px; align-items: center; }
.meta.detail .badge { white-space: nowrap; }
.meta.detail .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.detail-tags { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.actions.detail {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.detail-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.context-menu {
    position: fixed;
    z-index: 120;
    background: #0f1628;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.35);
    min-width: 180px;
}
.context-menu button {
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 6px;
}
.context-menu button:hover {
    background: rgba(255,255,255,0.08);
}

.actions { display: flex; gap: 8px; }
.actions button {
    flex: 1;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    padding: 8px;
    cursor: pointer;
}
.actions button.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #0a1020; border: none; }

.playlist-card {
    position: relative;
    width: 100%;
    backdrop-filter: blur(12px);
    background: rgba(6, 9, 16, 0.98);
    transition: opacity 120ms ease;
    opacity: 1;
    z-index: 50;
}
.left-stack {
    position: sticky;
    top: 12px;
    align-self: start;
}
.queue { margin-top: 10px; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.queue-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    cursor: pointer;
}
.queue-row.active { border-color: var(--accent); }
.queue-row .title {
    margin: 0;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}
.now-playing-title { margin: 0; }
#now-playing {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
}
.now-playing-title {
    margin: 0;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
}
/* Make playlist header text shrinkable for marquee */
.playlist-card .card-head > div:first-child { flex: 1; min-width: 0; }
.marquee {
    display: inline-flex;
    animation: marquee linear infinite;
    animation-duration: var(--marquee-duration, 12s);
}
.marquee-copy {
    padding-right: 48px;
}
@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.queue-row .remove { background: transparent; border: none; color: var(--muted); cursor: pointer; }
.volume { margin-top: 10px; display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.volume input[type="range"] { flex: 1; min-width: 0; width: 100%; max-width: 100%; }

.controls { display: flex; gap: 6px; }
.icon {
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.08);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    min-width: 44px;
    text-align: center;
}
.actions button:disabled, .pill:disabled, .icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.15);
}
.controls-left { display: flex; gap: 6px; flex-shrink: 0; }
.volume-row { align-items: center; justify-content: space-between; gap: 10px; flex-wrap: nowrap; }

.pill {
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    padding: 10px 14px;
    cursor: pointer;
    transition: transform 120ms ease, border 120ms ease;
}
.pill.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); border: none; color: #0a1020; font-weight: 700; }
.pill.ghost { background: rgba(255,255,255,0.08); }
.pill.full { width: 100%; }
.pill:active { transform: translateY(1px); }

.preview {
    position: fixed;
    inset: 0;
    background: rgba(0, 5, 12, 0.7);
    display: grid;
    place-items: center;
    z-index: 20;
}
.preview.hidden { display: none; }
.preview-card {
    width: min(1100px, 96vw);
    background: #0f1628;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.35);
}
.preview-head { display: flex; justify-content: space-between; align-items: center; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.preview audio { width: 100%; margin-top: 12px; }

code { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

.image-preview {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    background: rgba(0,0,0,0.2);
    height: 70vh;
}
.image-preview.hidden { display: none; }
.image-toolbar { display: flex; gap: 8px; }
.image-viewport {
    position: relative;
    flex: 1;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0b1423;
    cursor: grab;
}
.image-viewport img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    user-select: none;
    pointer-events: none;
}
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 5, 12, 0.8);
    display: grid;
    place-items: center;
    z-index: 80;
}
.auth-overlay.hidden { display: none; }
.auth-card {
    width: min(420px, 90vw);
    background: #0f1628;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.auth-card h2 { margin: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.auth-card input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    color: var(--text);
}
.auth-card button { margin-top: 8px; }
.auth-error { color: var(--danger); font-size: 13px; }

.folders {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    position: relative;
    height: fit-content;
}
.folders-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.folder-panel {
    margin-top: 4px;
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.folder-recursive {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 8px;
    color: var(--muted);
    font-size: 13px;
}
.folder-row {
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    background: rgba(255,255,255,0.02);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.folder-row.active {
    border-color: var(--accent);
    background: rgba(126, 224, 255, 0.15);
}
.folder-row:hover { border-color: var(--border); }
.folder-toggle { font-size: 16px; width: 18px; text-align: center; }
.folder-toggle.dim { color: var(--muted); }
.mobile-only { display: none; }

@media (max-width: 1100px) {
    .section-head { grid-template-columns: 1fr; }
    .layout {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .left-stack { position: static; }
    .folders {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 86vw;
        transform: translateX(-110%);
        transition: transform 180ms ease;
        z-index: 60;
        background: #0a1020;
    }
    .folders.open { transform: translateX(0); }
    .results { order: 0; width: 100%; padding-bottom: 140px; }
    .playlist-card {
        position: fixed;
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
        opacity: 1;
        z-index: 50;
    }
    .mobile-only { display: inline-flex; }
}

@media (max-width: 720px) {
    .hero { flex-direction: column; align-items: flex-start; gap: 10px; }
    .hero-actions { width: 100%; justify-content: flex-end; }
    .input-row { flex-direction: column; }
    .tag-form { width: 100%; }
}
