﻿/* =====================================================
   WEAR ME DRIVE — Premium UI — 2026
   Palette: noir sidebar · ivory content · gold accent
   ===================================================== */

/* ── Variables ── */
:root {
    --noir:          #111110;
    --noir-2:        #1d1d1b;
    --ivory:         #f8f7f4;
    --ivory-2:       #f1ede6;
    --ivory-3:       #e6e1d8;
    --white:         #ffffff;
    --gold:          #c9a96e;
    --gold-light:    #dfc38e;
    --ink:           #1a1a18;
    --ink-2:         #4a4a47;
    --ink-3:         #9a9a95;
    --sidebar-text:  #e8e3da;
    --sidebar-muted: #6a6a64;
    --danger:        #c04040;
    --danger-bg:     #fdf2f2;
    --success:       #2d7a50;
    --success-bg:    #f0faf5;
    --sidebar-w:     240px;
    --r-sm:          6px;
    --r:             10px;
    --r-lg:          16px;
    --shadow:        0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.07);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: 'Manrope', system-ui, sans-serif; line-height: 1.5; color: var(--ink); background: var(--ivory); }
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }
svg { display: block; flex-shrink: 0; }

/* =====================================================
   LOGIN
   ===================================================== */
.is-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ivory);
}

.login-wrap {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.login-card {
    background: var(--white);
    border-radius: var(--r-lg);
    padding: 44px 44px 48px;
    box-shadow: var(--shadow);
    border: 1px solid var(--ivory-3);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}

.login-brand span {
    font-size: .8rem;
    font-weight: 700;
    color: var(--ink-2);
    letter-spacing: .05em;
    text-transform: uppercase;
}

.login-card h1 {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -.025em;
    margin-bottom: 6px;
}

.login-hint {
    font-size: .8rem;
    color: var(--ink-3);
    margin-bottom: 28px;
}

/* =====================================================
   BRAND MARK
   ===================================================== */
.brand-mark {
    width: 34px;
    height: 34px;
    background: var(--gold);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--white);
    flex-shrink: 0;
}

/* =====================================================
   FORM ELEMENTS
   ===================================================== */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--ink-2);
    letter-spacing: .06em;
    text-transform: uppercase;
}

.field input,
.field select {
    height: 44px;
    padding: 0 13px;
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-sm);
    background: var(--ivory);
    color: var(--ink);
    font-size: .875rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.field input:focus,
.field select:focus {
    border-color: var(--gold);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(201,169,110,.14);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border-radius: var(--r-sm);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: pointer;
    border: 1px solid var(--ivory-3);
    background: var(--white);
    color: var(--ink-2);
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}

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

.btn-primary {
    background: var(--noir);
    border-color: var(--noir);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--noir-2);
    border-color: var(--noir-2);
}

.btn-full {
    width: 100%;
    height: 46px;
    font-size: .875rem;
    margin-top: 6px;
}

.btn-sm {
    height: 28px;
    padding: 0 11px;
    font-size: .72rem;
}

.btn-danger {
    background: transparent;
    border-color: rgba(192,64,64,.35);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--white);
}

.btn-search {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: var(--noir);
    color: var(--white);
    border-radius: var(--r-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}

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

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    font-size: .84rem;
    line-height: 1.5;
    margin-bottom: 4px;
}

.alert small { display: block; font-size: .72rem; margin-top: 4px; opacity: .75; }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(192,64,64,.15); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(45,122,80,.15); }

/* =====================================================
   APP SHELL
   ===================================================== */
.is-app {
    overflow: hidden;
    height: 100vh;
    background: var(--ivory);
}

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    background: var(--noir);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.07) transparent;
}

.sidebar-inner {
    flex: 1;
    padding: 20px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 0 18px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: 6px;
}

.brand-text strong {
    display: block;
    font-size: .875rem;
    font-weight: 700;
    color: var(--sidebar-text);
    letter-spacing: -.01em;
}

.brand-text span {
    display: block;
    font-size: .65rem;
    color: var(--sidebar-muted);
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-top: 1px;
}

/* Nav */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    color: var(--sidebar-muted);
    font-size: .82rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-item:hover {
    background: rgba(255,255,255,.06);
    color: var(--sidebar-text);
}

.nav-item.is-active {
    background: rgba(201,169,110,.1);
    color: var(--gold-light);
}

.nav-count {
    font-size: .68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
    background: rgba(255,255,255,.07);
    color: var(--sidebar-muted);
    min-width: 22px;
    text-align: center;
}

.nav-item.is-active .nav-count {
    background: rgba(201,169,110,.18);
    color: var(--gold-light);
}

/* Sidebar sections (folders / categories) */
.sidebar-section {
    padding: 10px 0 4px;
    border-top: 1px solid rgba(255,255,255,.05);
}

.sidebar-heading {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    padding: 0 10px 8px;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 6px;
}

.tag {
    font-size: .68rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    background: rgba(255,255,255,.05);
    color: var(--sidebar-muted);
    border: 1px solid transparent;
    transition: all .15s;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag:hover {
    background: rgba(255,255,255,.1);
    color: var(--sidebar-text);
}

.tag.is-active {
    background: rgba(201,169,110,.12);
    color: var(--gold-light);
    border-color: rgba(201,169,110,.22);
}

/* Sidebar stats card */
.sidebar-stats-card {
    margin: 0 10px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: var(--r);
    overflow: hidden;
    flex-shrink: 0;
}

.ssc-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.ssc-row-2 {
    grid-template-columns: repeat(2, 1fr);
    border-bottom: none;
}

.ssc-stat {
    padding: 10px 10px 9px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 1px solid rgba(255,255,255,.07);
}

.ssc-stat:last-child {
    border-right: none;
}

.ssc-stat strong {
    font-size: .88rem;
    font-weight: 800;
    color: var(--sidebar-text);
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ssc-stat span {
    font-size: .6rem;
    font-weight: 700;
    color: var(--sidebar-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
}

/* Sidebar footer */
.sidebar-foot {
    padding: 14px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(201,169,110,.2);
    color: var(--gold-light);
    font-size: .68rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-meta strong {
    display: block;
    font-size: .775rem;
    font-weight: 700;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 148px;
}

.user-meta span {
    display: block;
    font-size: .66rem;
    color: var(--sidebar-muted);
}

.btn-logout {
    width: 100%;
    padding: 7px 0;
    border-radius: var(--r-sm);
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    color: var(--sidebar-muted);
    font-size: .74rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .02em;
    transition: all .15s;
}

.btn-logout:hover {
    background: rgba(192,64,64,.1);
    border-color: rgba(192,64,64,.2);
    color: #d07070;
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ivory);
}

/* Topbar */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    height: 58px;
    background: var(--white);
    border-bottom: 1px solid var(--ivory-3);
    flex-shrink: 0;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink);
    white-space: nowrap;
    justify-self: start;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 6px;
    width: min(420px, 100%);
    justify-self: center;
}

.search-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-sm);
    background: var(--ivory);
    font-size: .82rem;
    color: var(--ink);
    outline: none;
    transition: border-color .15s, background .15s;
}

.search-input:focus {
    border-color: var(--gold);
    background: var(--white);
}

/* Scrollable body */
.main-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 48px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* =====================================================
   UPLOAD CARD
   ===================================================== */
.upload-card {
    background: var(--white);
    border-radius: var(--r-lg);
    border: 1px solid var(--ivory-3);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.upload-form {
    display: flex;
    flex-direction: column;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    cursor: pointer;
    background: var(--ivory);
    transition: background .15s, box-shadow .15s;
    text-align: center;
    height: 130px;
    overflow: hidden;
    position: relative;
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.dropzone:hover,
.dropzone.is-dragover {
    background: var(--ivory-2);
}

.dropzone.is-dragover {
    box-shadow: inset 0 0 0 2px var(--gold);
    border-color: var(--gold);
}

.dropzone svg { color: var(--ink-3); }

.dropzone-main {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink-2);
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropzone-sub {
    font-size: .7rem;
    color: var(--ink-3);
    letter-spacing: .01em;
}

.upload-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--ivory-3);
    background: var(--white);
    flex-wrap: wrap;
}

.upload-dest {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 11px;
    height: 36px;
    background: var(--ivory);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    flex-shrink: 0;
}

.upload-dest svg { color: var(--gold); flex-shrink: 0; }
.upload-dest span { overflow: hidden; text-overflow: ellipsis; }

.upload-cat-input {
    flex: 1;
    min-width: 100px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-sm);
    background: var(--ivory);
    font-size: .82rem;
    color: var(--ink);
    font-family: inherit;
    outline: none;
    transition: border-color .15s, background .15s;
}

.upload-cat-input:focus {
    border-color: var(--gold);
    background: var(--white);
}

/* =====================================================
   STATS ROW
   ===================================================== */
.stats-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat {
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r);
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 88px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink);
    white-space: nowrap;
}

.stat-label {
    font-size: .66rem;
    font-weight: 700;
    color: var(--ink-3);
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* =====================================================
   FILE GRID
   ===================================================== */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.file-card {
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s, transform .2s;
}

.file-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,.1);
    transform: translateY(-2px);
}

.file-thumb {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--ivory-2);
    flex-shrink: 0;
}

.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #f5f1ea 0%, var(--ivory-2) 100%);
}

.file-icon-label {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: .06em;
}

.file-info {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-name {
    font-size: .79rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: .68rem;
    color: var(--ink-3);
    font-weight: 500;
}

.file-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.ftag {
    font-size: .63rem;
    font-weight: 600;
    padding: 2px 7px;
    background: var(--ivory-2);
    border: 1px solid var(--ivory-3);
    border-radius: 20px;
    color: var(--ink-2);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-actions {
    padding: 9px 12px;
    border-top: 1px solid var(--ivory-2);
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.file-actions form { display: contents; }

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.empty-state svg { color: var(--ivory-3); margin-bottom: 6px; }

.empty-state p {
    font-size: .95rem;
    font-weight: 700;
    color: var(--ink-2);
}

.empty-state span {
    font-size: .82rem;
    color: var(--ink-3);
}

/* =====================================================
   SUBFOLDER TAGS
   ===================================================== */
.subfolder-cloud {
    margin-top: 4px;
    padding-left: 10px;
}

.tag-sub {
    font-size: .64rem;
    color: var(--sidebar-muted);
    opacity: .8;
}

.tag-sub.is-active {
    opacity: 1;
}

/* =====================================================
   UPLOAD HINT
   ===================================================== */
.upload-hint {
    font-size: .68rem;
    color: var(--ink-3);
    line-height: 1.4;
}

.upload-hint code {
    background: var(--ivory-3);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: .7rem;
}

.upload-hint em {
    font-style: normal;
    color: var(--ink-2);
    font-weight: 600;
}

/* =====================================================
   BREADCRUMB
   ===================================================== */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 16px;
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r);
    font-size: .78rem;
}

.bc-item {
    color: var(--ink-2);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color .15s;
}

.bc-item:hover {
    color: var(--gold);
}

.bc-home {
    color: var(--ink-3);
}

.bc-home:hover {
    color: var(--gold);
}

.bc-sep {
    color: var(--ink-3);
    font-size: .7rem;
    user-select: none;
}

.bc-current {
    color: var(--ink);
    font-weight: 700;
    cursor: default;
}

/* =====================================================
   SETTINGS PANEL
   ===================================================== */
.settings-card {
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 32px 36px 36px;
    max-width: 580px;
}

.settings-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin-bottom: 28px;
    color: var(--ink);
}

.settings-section {
    padding: 22px 0;
    border-top: 1px solid var(--ivory-3);
}

.settings-section:first-of-type {
    padding-top: 0;
    border-top: none;
}

.settings-section-title {
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--ink);
    margin-bottom: 6px;
}

.settings-desc {
    font-size: .78rem;
    color: var(--ink-3);
    line-height: 1.55;
    margin-bottom: 18px;
}

.settings-desc code {
    background: var(--ivory-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: .74rem;
    color: var(--ink-2);
}

.settings-footer {
    padding-top: 20px;
    border-top: 1px solid var(--ivory-3);
}

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    cursor: pointer;
}

.toggle-label {
    font-size: .84rem;
    font-weight: 600;
    color: var(--ink);
}

.toggle-wrap {
    position: relative;
    flex-shrink: 0;
}

.toggle-wrap input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: var(--ivory-3);
    border-radius: 12px;
    transition: background .2s;
    position: relative;
    cursor: pointer;
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
    transition: transform .2s, background .2s;
}

.toggle-wrap input:checked + .toggle-track {
    background: var(--gold);
}

.toggle-wrap input:checked + .toggle-track .toggle-thumb {
    transform: translateX(20px);
}

/* Quality slider */
.quality-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: opacity .2s;
}

.quality-row.is-disabled {
    opacity: .4;
    pointer-events: none;
}

.quality-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quality-labels label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--ink-2);
}

.quality-labels strong {
    font-size: .84rem;
    font-weight: 800;
    color: var(--gold);
    min-width: 42px;
    text-align: right;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: var(--ivory-3);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    border: 2px solid var(--white);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    border: 2px solid var(--white);
}

.quality-hints {
    display: flex;
    justify-content: space-between;
    font-size: .65rem;
    color: var(--ink-3);
}

/* =====================================================
   TOPBAR ACTIONS + NEW FOLDER PANEL
   ===================================================== */
.topbar-actions {
    justify-self: end;
    display: flex;
    align-items: center;
}

.btn-new-folder {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-sm);
    font-size: .74rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}

.btn-new-folder:hover {
    background: var(--ivory-2);
    border-color: var(--gold);
    color: var(--ink);
}

.new-folder-panel {
    background: var(--ivory);
    border-bottom: 1px solid var(--ivory-3);
    padding: 10px 28px;
    flex-shrink: 0;
}

.nfp-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 600px;
}

.nfp-inner svg { color: var(--gold); flex-shrink: 0; }

.nfp-ctx {
    font-size: .78rem;
    color: var(--ink-3);
    white-space: nowrap;
    flex-shrink: 0;
}

.nfp-ctx strong { color: var(--ink-2); }

.nfp-input {
    flex: 1;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--ivory-3);
    border-radius: var(--r-sm);
    background: var(--white);
    font-size: .82rem;
    font-family: inherit;
    color: var(--ink);
    outline: none;
    transition: border-color .15s;
}

.nfp-input:focus { border-color: var(--gold); }

/* =====================================================
   LIGHTBOX
   ===================================================== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox[hidden] { display: none; }

.lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8,8,8,.93);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lb-frame {
    position: relative;
    z-index: 1;
    max-width: min(88vw, 1280px);
    max-height: 82vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-frame img {
    display: block;
    max-width: 100%;
    max-height: 82vh;
    border-radius: var(--r);
    object-fit: contain;
    box-shadow: 0 32px 96px rgba(0,0,0,.7);
    transition: opacity .25s;
}

.lb-footer {
    position: relative;
    z-index: 1;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(20,20,20,.72);
    padding: 7px 18px;
    border-radius: 30px;
    backdrop-filter: blur(6px);
}

.lb-footer #lb-name {
    font-size: .78rem;
    font-weight: 600;
    color: rgba(255,255,255,.82);
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-footer #lb-counter {
    font-size: .7rem;
    color: rgba(255,255,255,.4);
    flex-shrink: 0;
}

.lb-btn {
    position: fixed;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    color: var(--white);
}

.lb-close {
    top: 18px;
    right: 22px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
}

.lb-close:hover { background: rgba(255,255,255,.2); }

.lb-arrow {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 72px;
    border-radius: var(--r);
    background: rgba(255,255,255,.07);
}

.lb-arrow:hover { background: rgba(255,255,255,.16); }

.lb-prev { left: 14px; }
.lb-next { right: 14px; }

.lb-arrow:disabled {
    opacity: .18;
    cursor: default;
    pointer-events: none;
}

.lb-trigger { cursor: zoom-in; }

/* =====================================================
   FOLDER GRID & CARDS
   ===================================================== */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.folder-card {
    position: relative;
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r);
    display: flex;
    align-items: stretch;
    overflow: visible;
    transition: border-color .15s, box-shadow .15s;
}

.folder-card:hover {
    border-color: var(--gold);
    box-shadow: 0 2px 12px rgba(201,169,110,.12);
}

.folder-card.is-drop-over {
    border-color: var(--gold);
    background: rgba(201,169,110,.07);
    box-shadow: 0 0 0 2px rgba(201,169,110,.28);
}

/* ── card body (link) ── */
.folder-card__body {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 12px 12px 14px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.folder-card__ico {
    flex-shrink: 0;
    color: var(--gold);
}

.folder-card__info {
    min-width: 0;
    flex: 1;
}

.folder-card__name {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.folder-card__count {
    display: block;
    font-size: .68rem;
    color: var(--ink-3);
    margin-top: 2px;
}

/* ── 3-dots menu button ── */
.folder-card__btn {
    flex-shrink: 0;
    align-self: center;
    width: 30px;
    height: 30px;
    margin-right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s;
}

.folder-card:hover .folder-card__btn,
.folder-card__btn:focus-visible {
    opacity: 1;
}

.folder-card__btn:hover {
    background: var(--ivory-2);
    color: var(--ink);
}

/* ── Dropdown menu ── */
.folder-card__dropdown {
    position: absolute;
    top: calc(100% + 3px);
    right: 0;
    min-width: 196px;
    background: var(--white);
    border: 1px solid var(--ivory-3);
    border-radius: var(--r);
    box-shadow: 0 8px 28px rgba(0,0,0,.11), 0 2px 6px rgba(0,0,0,.06);
    z-index: 300;
    overflow: hidden;
    padding: 4px 0;
}

.folder-card__dropdown[hidden] { display: none; }

.folder-card__dropdown button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    text-align: left;
    line-height: 1;
    transition: background .1s;
}

.folder-card__dropdown button:hover { background: var(--ivory); }

.folder-card__dropdown button svg { flex-shrink: 0; color: var(--ink-3); }

.folder-card__dropdown button.is-danger { color: #c0392b; }
.folder-card__dropdown button.is-danger svg { color: #c0392b; }
.folder-card__dropdown button.is-danger:hover { background: rgba(192,57,43,.06); }

.dd-sep {
    height: 1px;
    background: var(--ivory-3);
    margin: 3px 0;
}

/* ── Inline rename input ── */
.folder-card__name-input {
    display: block;
    width: 100%;
    font-size: .82rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--ink);
    border: 1.5px solid var(--gold);
    border-radius: 3px;
    padding: 2px 5px;
    outline: none;
    background: var(--white);
    min-width: 0;
    line-height: 1.3;
}

/* ── "Add folder" card ── */
.folder-card--new {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 16px 12px;
    background: transparent;
    border: 1.5px dashed var(--ivory-3);
    color: var(--ink-3);
    cursor: pointer;
    font-family: inherit;
    font-size: .76rem;
    font-weight: 600;
    transition: border-color .15s, color .15s, background .15s;
    min-height: 64px;
    text-align: center;
}

.folder-card--new:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(201,169,110,.04);
}

/* =====================================================
   DRAG & DROP
   ===================================================== */

/* file card — subtle grab cursor */
.file-card[draggable="true"] { cursor: grab; }
.file-card[draggable="true"]:active { cursor: grabbing; }

/* file card being dragged */
.file-card.is-dragging {
    opacity: .3;
    pointer-events: none;
    transform: scale(.96);
}

/* when any file is being dragged — subtly highlight all potential folder targets */
body.is-dragging-file .folder-card:not(.folder-card--new) {
    border-color: rgba(201,169,110,.35);
}

/* sidebar folder tags as drop targets */
body.is-dragging-file .tag[data-drop-folder] {
    cursor: copy;
    transition: background .12s, color .12s;
}

body.is-dragging-file .tag[data-drop-folder]:hover,
body.is-dragging-file .tag[data-drop-folder].is-drop-over {
    background: var(--gold);
    color: var(--white);
    border-color: var(--gold);
}
