:root {
    --bg: #0a0b10;
    --surface: #14151c;
    --surface-2: #1c1e28;
    --surface-hover: #23252f;
    --line: #262835;
    --text: #f4f4f8;
    --text-dim: #82849a;
    --accent: #7c5cff;
    --accent-2: #34e8ff;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background: var(--bg);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(124, 92, 255, 0.08), transparent 40%),
        radial-gradient(circle at 85% 10%, rgba(52, 232, 255, 0.06), transparent 35%);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
}

button, input, select { font-family: inherit; color: inherit; border: none; background: none; outline: none; }
button { cursor: pointer; }
.hidden { display: none !important; }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; }

/* ===== NAVBAR ===== */
.navbar {
    background: rgba(20, 21, 28, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.navbar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.brand-mark { color: var(--accent); font-size: 16px; }
.navbar__brand span { color: var(--accent-2); font-weight: 600; }

.navbar__menu {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-btn {
    position: relative;
    padding: 10px 18px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}

.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn.active { color: var(--text); }
.nav-btn.active::after {
    content: '';
    position: absolute;
    left: 14px; right: 14px; bottom: 2px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 2px;
}

/* ===== TELEGRAM AUTH ===== */
.navbar__auth { display: flex; align-items: center; min-height: 36px; }
.tg-auth-slot { display: flex; align-items: center; }
.tg-auth-slot iframe { border-radius: 8px; }

.auth-user {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 6px 14px 6px 6px;
    border-radius: 999px;
}
.auth-user__dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent-2);
    box-shadow: 0 0 8px var(--accent-2);
}
.auth-user__name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
}
.auth-user__logout {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    color: var(--text-dim);
    transition: color 0.15s, background 0.15s;
}
.auth-user__logout:hover { color: #ff5d7a; background: rgba(255, 93, 122, 0.12); }

/* ===== MAIN CONTENT & VIEWS ===== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

.view-header { margin-bottom: 24px; }
.eyebrow {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent-2);
    margin-bottom: 6px;
}
.view-header h2 {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}
.view-header p { color: var(--text-dim); font-size: 14px; max-width: 520px; }

/* ===== CATEGORY RAIL ===== */
.category-rail {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 4px 14px;
    margin-bottom: 4px;
}

.cat-btn {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 84px;
    padding: 12px 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text-dim);
    transition: border-color 0.2s, color 0.2s, transform 0.15s;
}
.cat-btn:hover { color: var(--text); transform: translateY(-2px); }
.cat-btn.active {
    color: var(--text);
    border-color: var(--accent);
    background: linear-gradient(160deg, rgba(124,92,255,0.15), var(--surface));
}
.cat-btn svg { width: 22px; height: 22px; }
.cat-btn span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }

/* ===== FILTERS BAR ===== */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    background: var(--surface);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    flex-wrap: wrap;
}

.search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 10px 16px;
    border-radius: 8px;
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    color: var(--text-dim);
}
.search input { width: 100%; font-size: 14px; font-weight: 600; color: var(--text); }
.search input::placeholder { color: var(--text-dim); }

.select-wrap { position: relative; }
.select-wrap::after {
    content: '';
    position: absolute;
    right: 12px; top: 50%;
    width: 7px; height: 7px;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}
.select-wrap select {
    appearance: none;
    background: var(--bg);
    padding: 10px 34px 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

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

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 14px;
}

/* ===== CARD ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    position: relative;
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.15s, border-color 0.15s;
    cursor: default;
}
.card:hover { transform: translateY(-3px); border-color: var(--rarity-color, var(--accent)); }
.card.is-fav { border-color: #fff; }

.card__shard {
    position: absolute;
    top: 0; left: 0;
    width: 34px; height: 34px;
    background: var(--rarity-color, var(--text-dim));
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.card__fav {
    position: absolute;
    top: 8px; right: 8px;
    z-index: 10;
    background: rgba(10, 11, 16, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    transition: color 0.15s, transform 0.15s;
}
.card__fav:hover { transform: scale(1.08); }
.card__fav.active { color: #ff5d7a; }

.card__img-wrap {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 14px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--rarity-color, var(--surface-2)) 18%, var(--surface)) 0%, var(--surface) 70%);
}
.card__img-wrap img {
    max-width: 100%; max-height: 100%; object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5));
}

.card__footer {
    background: var(--surface-2);
    border-top: 1px solid var(--line);
    padding: 8px 10px;
    text-align: center;
}
.card__name {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== SETTINGS ===== */
.settings-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 4px 20px;
    max-width: 560px;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 0;
}
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row__title { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.settings-row__desc { color: var(--text-dim); font-size: 13px; max-width: 380px; }

.switch { position: relative; flex: 0 0 auto; width: 46px; height: 26px; display: inline-block; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch__track {
    position: absolute; inset: 0;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: background 0.2s, border-color 0.2s;
}
.switch__track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch__track { background: rgba(124, 92, 255, 0.25); border-color: var(--accent); }
.switch input:checked + .switch__track::after { background: var(--accent); transform: translateX(20px); }

/* ===== LOAD MORE ===== */
.load-more-wrap { display: flex; justify-content: center; margin-top: 28px; }
.load-more-btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 32px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    transition: border-color 0.2s, background 0.2s;
}
.load-more-btn:hover { border-color: var(--accent); background: var(--surface-hover); }

/* ===== RESPONSIVE ===== */
@media (max-width: 720px) {
    .navbar__container { padding: 0 14px; gap: 10px; }
    .navbar__brand h1 { font-size: 16px; }
    .nav-btn { padding: 8px 10px; font-size: 12px; }
    .main-content { padding: 20px 14px 60px; }
    .view-header h2 { font-size: 24px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}