/* ===================================================
   DESIGN TOKENS — warm archive aesthetic
   =================================================== */
:root {
    --bg-base: #14121b;
    --bg-surface: #1d1a25;
    --bg-surface-2: #262230;
    --border: #322c3d;
    --border-soft: #2a2534;
    --accent: #e3a857;
    --accent-soft: rgba(227, 168, 87, 0.14);
    --accent-hover: #edb96f;
    --text-primary: #f3eee6;
    --text-muted: #a79fb3;
    --text-faint: #726b81;
    --danger: #e0637a;
    --danger-soft: rgba(224, 99, 122, 0.14);
    --success: #7fbf9e;
    --radius-card: 14px;
    --radius-input: 8px;
    --radius-pill: 999px;
}

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

body {
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: radial-gradient(ellipse 120% 80% at 50% -10%, #201c2a 0%, var(--bg-base) 55%);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

h1, h2 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    letter-spacing: -0.01em;
}

a { color: inherit; }
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===================================================
   TOPBAR
   =================================================== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: rgba(29, 26, 37, 0.7);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 {
    font-size: 21px;
    letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-right span { color: var(--text-muted); font-size: 14px; margin-right: 4px; }

/* ===================================================
   BUTTONS — pill shape signals "interactive action"
   =================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #1a1610 !important;
    padding: 9px 18px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(0.97); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn-secondary {
    background: transparent;
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger) !important; }
.btn-danger:hover { background: var(--danger); color: #1a1610 !important; }

/* ===================================================
   LAYOUT
   =================================================== */
.layout { display: flex; }
.sidebar {
    width: 250px;
    flex-shrink: 0;
    padding: 22px 18px;
    background: transparent;
    border-right: 1px solid var(--border-soft);
    min-height: calc(100vh - 66px);
}
.content { flex: 1; }

.quota-box { margin-bottom: 20px; font-size: 12.5px; color: var(--text-muted); }
.quota-bar {
    background: var(--bg-surface-2);
    height: 6px;
    border-radius: var(--radius-pill);
    margin-top: 8px;
    overflow: hidden;
}
.quota-fill { background: var(--accent); height: 100%; border-radius: var(--radius-pill); }

.search-form input, .new-album-form input, .sort-form select {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13.5px;
    margin-bottom: 12px;
    font-family: inherit;
}
.search-form input::placeholder { color: var(--text-faint); }
.search-form input:focus, .new-album-form input:focus { border-color: var(--accent); }

.new-album-form { display: flex; gap: 6px; margin: 16px 0; }
.new-album-form input { margin-bottom: 0; }

.album-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-soft);
}
.album-nav a {
    padding: 8px 10px;
    border-radius: var(--radius-input);
    text-decoration: none;
    font-size: 13.5px;
    color: var(--text-muted);
    transition: background 0.12s ease, color 0.12s ease;
}
.album-nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.album-nav a:hover:not(.active) { background: var(--bg-surface); color: var(--text-primary); }
.album-row { display: flex; align-items: center; gap: 4px; }
.album-row a:first-child { flex: 1; }
.mini-x {
    color: var(--text-faint);
    text-decoration: none;
    padding: 0 8px;
    font-size: 13px;
}
.mini-x:hover { color: var(--danger); }

.sort-form {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 14px;
}
.sort-form select { margin: 0; }

/* ===================================================
   GALLERY GRID
   =================================================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    padding: 24px 28px;
}
.bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px 0;
    font-size: 13.5px;
    color: var(--text-muted);
}
.bulk-bar label { display: flex; align-items: center; gap: 8px; }

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-card);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    position: relative;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover {
    border-color: var(--border);
    transform: translateY(-2px);
}
.card .select-box {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.card img, .card video {
    width: 100%;
    height: 210px;
    max-height: none;
    object-fit: cover;
    display: block;
    background: #0b0a0f;
    cursor: pointer;
    transition: transform 0.3s ease;
}
.card:hover img { transform: scale(1.03); }
.card-info { padding: 12px 14px 14px; }
.filename {
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.meta { font-size: 11.5px; color: var(--text-faint); margin: 4px 0 6px; }
.tags { font-size: 11.5px; color: var(--accent); margin-bottom: 8px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty-msg {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    grid-column: 1/-1;
    font-size: 15px;
}
.empty-msg a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }

/* ===================================================
   AUTH PAGES
   =================================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-box {
    background: var(--bg-surface);
    padding: 38px 34px;
    border-radius: 18px;
    width: 340px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
}
.auth-box h2 {
    margin-bottom: 24px;
    text-align: center;
    font-size: 24px;
}
.auth-box form { display: flex; flex-direction: column; gap: 12px; }
.auth-box input, .auth-box select {
    padding: 11px 14px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border);
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}
.auth-box input::placeholder { color: var(--text-faint); }
.auth-box input:focus, .auth-box select:focus { border-color: var(--accent); }
.auth-box button { margin-top: 6px; padding: 11px; border-radius: var(--radius-pill); }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 16px; text-align: center; line-height: 1.5; }

/* ===================================================
   UPLOAD PAGE
   =================================================== */
.upload-page { max-width: 620px; margin: 48px auto; padding: 0 20px; }
.upload-page h2 { margin-bottom: 8px; font-size: 26px; }
.upload-page > .hint { text-align: left; margin-top: 4px; margin-bottom: 4px; }

.upload-options { display: flex; gap: 10px; margin: 20px 0; flex-wrap: wrap; }
.upload-options select, .upload-options input {
    flex: 1;
    padding: 10px 12px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13.5px;
}

.dropzone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-card);
    padding: 56px 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: border-color 0.15s ease, background 0.15s ease;
    font-size: 14.5px;
}
.dropzone.drag-active { border-color: var(--accent); background: var(--accent-soft); color: var(--text-primary); }

.progress-wrap { margin-top: 18px; }
.progress-bar { background: var(--bg-surface-2); height: 8px; border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.2s; }
#progressText { font-size: 12.5px; margin-top: 8px; color: var(--text-muted); }

.success { color: var(--success); margin: 10px 0; font-size: 14px; }
.error { color: var(--danger); margin: 6px 0; font-size: 14px; }

/* ===================================================
   LIGHTBOX
   =================================================== */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 8, 14, 0.95);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.lightbox img { max-width: 88%; max-height: 88%; border-radius: 8px; box-shadow: 0 30px 80px -20px rgba(0,0,0,0.6); }
.lightbox-close, .lightbox-prev, .lightbox-next {
    position: absolute;
    color: var(--text-primary);
    font-size: 30px;
    cursor: pointer;
    user-select: none;
    padding: 10px;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { opacity: 1; color: var(--accent); }
.lightbox-close { top: 18px; right: 26px; font-size: 26px; }
.lightbox-prev { left: 24px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 24px; top: 50%; transform: translateY(-50%); }

/* ===================================================
   ADMIN TABLE
   =================================================== */
table { width: 100%; border-collapse: collapse; }
table th {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
}
table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 14px;
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; min-height: auto; border-right: none; border-bottom: 1px solid var(--border-soft); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
