/* ── Variables ─────────────────────────── */
:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface2: #1c1c1f;
    --border: #2a2a2e;
    --text: #e8e8ec;
    --text-muted: #8b8b96;
    --accent: #c084fc;
    --accent-hover: #a855f7;
    --cosplay: #f472b6;
    --fanart: #60a5fa;
    --radius: 12px;
}

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

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Header ───────────────────────────── */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
}
.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
}
.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
}
.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Search Bar ───────────────────────── */
.search-bar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem 0;
}
.search-inner {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 1rem;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.search-inner:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.1);
}
.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}
#searchInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.75rem 0.75rem;
    outline: none;
}
#searchInput::placeholder {
    color: var(--text-muted);
}
.search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, color 0.2s;
}
.search-clear.visible {
    opacity: 1;
    pointer-events: auto;
}
.search-clear:hover { color: var(--accent); }

.search-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.5rem 0.25rem 0;
    display: none;
}
.search-hint.visible { display: block; }

/* ── Category Nav ─────────────────────── */
.category-nav {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}
.cat-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
}
.cat-tab:hover { border-color: var(--accent); }
.cat-tab.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}
.cat-icon { font-size: 0.9rem; }
.cat-count {
    background: rgba(255,255,255,0.15);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

/* ── Masonry Grid ─────────────────────── */
.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}
.masonry {
    columns: 4;
    column-gap: 1rem;
}

/* ── Card ─────────────────────────────── */
.card {
    break-inside: avoid;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    animation: fadeUp 0.4s ease both;
    transition: transform 0.2s;
}
.card:hover { transform: translateY(-3px); }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-img-wrap {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}
.card-img {
    width: 100%;
    display: block;
    transition: transform 0.3s;
}
.card-img-wrap:hover .card-img {
    transform: scale(1.03);
}

/* Carousel indicator on card */
.card-carousel-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Character badge on card */
.card-character {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background: rgba(0,0,0,0.75);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}

/* Overlay */
.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 0.75rem 0.75rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.25s;
}
.card-img-wrap:hover .card-overlay { opacity: 1; }

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    background: rgba(0,0,0,0.5);
    transition: background 0.2s;
}
.source-link:hover { background: rgba(192,132,252,0.2); }

.card-caption {
    color: #fff;
    font-size: 0.8rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.card-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.card-badge.cosplay {
    background: rgba(244,114,182,0.2);
    color: var(--cosplay);
    border: 1px solid rgba(244,114,182,0.3);
}
.card-badge.fanart {
    background: rgba(96,165,250,0.2);
    color: var(--fanart);
    border: 1px solid rgba(96,165,250,0.3);
}

/* ── Card Carousel (multi-image) ──────── */
.card-carousel {
    position: relative;
    overflow: hidden;
}
.card-carousel-track {
    display: flex;
    transition: transform 0.3s ease;
}
.card-carousel-track img {
    width: 100%;
    flex-shrink: 0;
}
.card-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}
.card-carousel:hover .card-carousel-nav { opacity: 1; }
.card-carousel-prev { left: 0.4rem; }
.card-carousel-next { right: 0.4rem; }
.card-carousel-dots {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.3rem;
    z-index: 5;
}
.card-carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}
.card-carousel-dot.active { background: #fff; }

/* ── Empty State ──────────────────────── */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent);
}
.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* ── Lightbox ─────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.lightbox.active { display: flex; }

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    z-index: 210;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
}

/* Lightbox Carousel */
.lightbox-carousel {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 100%;
}
.lightbox-carousel img {
    max-width: 85vw;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 8px;
}
.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(192,132,252,0.5); }
.lightbox-prev { left: 0.5rem; }
.lightbox-next { right: 0.5rem; }

.lightbox-dots {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.75rem;
}
.lightbox-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}
.lightbox-dots .dot.active { background: var(--accent); }

.lightbox-info {
    margin-top: 1rem;
    text-align: center;
}
.lightbox-caption {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.lightbox-character {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.lightbox-character:empty { display: none; }
.lightbox-source {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(192,132,252,0.3);
    border-radius: 8px;
    transition: all 0.2s;
}
.lightbox-source:hover {
    background: rgba(192,132,252,0.1);
    border-color: var(--accent);
}

/* ── Footer ───────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ── Responsive ───────────────────────── */
@media (max-width: 1200px) { .masonry { columns: 3; } }
@media (max-width: 768px) {
    .masonry { columns: 2; column-gap: 0.5rem; }
    .card { margin-bottom: 0.5rem; }
    .header { padding: 1rem; }
    .gallery-container { padding: 0 1rem 2rem; }
    .category-nav { padding: 1rem; gap: 0.5rem; }
    .cat-tab { padding: 0.5rem 0.8rem; font-size: 0.8rem; }
    .search-bar { padding: 1rem 1rem 0; }
    .lightbox-carousel img { max-width: 95vw; }
    .lightbox-prev, .lightbox-next { width: 36px; height: 36px; font-size: 1.2rem; }
}
@media (max-width: 480px) {
    .masonry { columns: 2; }
    .subtitle { display: none; }
}

/* ── Lightbox Buttons ─────────────────── */
.lightbox-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.lightbox-original {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    transition: all 0.2s;
}
.lightbox-original:hover {
    background: rgba(255,255,255,0.1);
    border-color: #fff;
}

/* ── Character List ──────────────────── */
.charlist-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid var(--border);
    margin-left: 0.25rem;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    border-radius: 0 11px 11px 0;
}
.charlist-btn:hover { color: var(--accent); background: rgba(192,132,252,0.05); }

.charlist-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 350px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.charlist-dropdown.open { display: block; }

.charlist-header {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.charlist-items { padding: 0.4rem; }

.charlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.charlist-item:hover { background: var(--surface2); }

.charlist-item-name {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.charlist-item-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(192,132,252,0.12);
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    min-width: 1.5rem;
    text-align: center;
}

.charlist-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-bar { position: relative; }
