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

:root {
    --bg:       #0E0E10;
    --surface:  #18181B;
    --border:   #27272A;
    --accent:   #E02020;
    --text:     #F4F4F5;
    --muted:    #71717A;
    --subtle:   #52525B;
    --font-head: 'IBM Plex Mono', monospace;
    --font-body: 'IBM Plex Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    min-height: 100vh;
}

/* ── TOP BAR ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(14, 14, 16, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: 60px;
    display: flex;
    align-items: center;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 16px;
    flex: 1;
    height: 100%;
}

.topbar-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: default;
    white-space: nowrap;
    min-height: 40px;
}

.topbar-pill svg { width: 13px; height: 13px; }

.topbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* filter trigger */
.filter-trigger { position: relative; }

.filter-trigger .topbar-pill {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s;
}

.filter-trigger .topbar-pill:hover { border-color: var(--accent); color: var(--accent); }

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-body);
}

/* filter panel */
.filter-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    display: none;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.filter-panel.open { display: block; }

.filter-panel h4 {
    font-family: var(--font-head);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--subtle);
    margin-bottom: 8px;
}

.filter-group { margin-bottom: 14px; }
.filter-group:last-child { margin-bottom: 0; }

.filter-options { display: flex; flex-wrap: wrap; gap: 5px; }

.filter-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
    min-height: 40px;
}

.filter-select:focus { border-color: var(--accent); }

.filter-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    min-height: 40px;
}

.filter-chip:hover,
.filter-chip.active {
    border-color: var(--accent);
    background: rgba(224,32,32,.1);
    color: var(--accent);
}

/* search */
.topbar-right {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 100%;
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.search-wrap { position: relative; display: flex; align-items: center; }

.search-wrap svg {
    position: absolute;
    left: 10px;
    color: var(--subtle);
    pointer-events: none;
    width: 14px;
    height: 14px;
}

.search-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    height: 40px;
    padding: 0 12px 0 36px;
    width: 210px;
    transition: border-color .2s, width .3s;
    outline: none;
}

.search-input::placeholder { color: var(--subtle); }
.search-input:focus { border-color: var(--accent); width: 260px; }

/* ── MAIN ── */
.main {
    padding: 20px 20px 60px;
    max-width: 1600px;
    margin: 0 auto;
}

/* stats bar */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.stats-bar .count {
    font-size: 12px;
    color: var(--muted);
}

.stats-bar .count strong {
    color: var(--text);
    font-weight: 500;
}

.active-filters { display: flex; gap: 5px; flex-wrap: wrap; }

.active-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(224,32,32,.1);
    border: 1px solid rgba(224,32,32,.25);
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
    min-height: 36px;
}

.active-tag:hover { background: rgba(224,32,32,.2); }
.active-tag svg { width: 12px; height: 12px; }

/* ── GRID ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

/* ── CARD ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

/* card image — 1.5x bigger via aspect-ratio */
.card-img {
    width: 100%;
    aspect-ratio: 4/3;
    background: #0E0E10;
    position: relative;
    overflow: hidden;
}

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

.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-img-placeholder svg {
    width: 36px;
    height: 36px;
    color: var(--border);
}

/* badge */
.card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.badge-sth { background: #FFD700; color: #6B4F00; }
.badge-th  { background: #3F3F46; color: #A1A1AA; }

/* card body */
.card-body { padding: 10px 12px 12px; }

.card-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text);
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta { display: flex; flex-direction: column; gap: 2px; }

.card-series {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-family: var(--font-head);
}

.card-case {
    font-size: 11px;
    color: var(--subtle);
}

/* ── EMPTY ── */
.empty {
    grid-column: 1 / -1;
    padding: 80px 20px;
    text-align: center;
}

.empty svg { width: 40px; height: 40px; color: var(--border); margin-bottom: 12px; }

.empty p {
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}

.empty small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--subtle);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .topbar-pill:not(.filter-trigger .topbar-pill):not(a.topbar-pill) { display: none; }
    .topbar-divider { display: none; }
}

@media (max-width: 640px) {
    .topbar {
        height: auto;
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }

    .topbar-left {
        padding: 0;
        flex: 1;
    }

    .topbar-right {
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 8px 0 0;
        width: 100%;
    }

    .search-wrap {
        width: 100%;
    }

    .search-input {
        width: 100%;
    }

    .search-input:focus {
        width: 100%;
    }

    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .main { padding: 14px 12px 40px; }
    .filter-panel { min-width: calc(100vw - 32px); }
    .filter-chip { padding: 10px 18px; font-size: 14px; min-height: 44px; }
    .topbar-pill { padding: 8px 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .card, .card-img img, .search-input { transition: none; }
}

a.topbar-pill {
    cursor: pointer;
    text-decoration: none;
    color: var(--muted);
    transition: color .15s;
}

a.topbar-pill:hover {
    color: var(--accent);
}