:root {
    --bg: var(--tg-theme-bg-color, #080b12);
    --text: var(--tg-theme-text-color, #f4f7ff);
    --hint: var(--tg-theme-hint-color, #8b95a8);
    --button: var(--tg-theme-button-color, #5b7cfa);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary: var(--tg-theme-secondary-bg-color, #121826);
    --border: rgba(255, 255, 255, 0.08);
    --accent: #5b7cfa;
    --accent-2: #8b5cf6;
    --success: #22c55e;
    --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 10% 0%, rgba(91, 124, 250, 0.18), transparent 35%),
        radial-gradient(circle at 90% 10%, rgba(139, 92, 246, 0.14), transparent 30%),
        radial-gradient(circle at 50% 100%, rgba(34, 197, 94, 0.08), transparent 35%);
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.hero {
    margin-bottom: 20px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(91, 124, 250, 0.12);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 12px;
    border: 1px solid rgba(91, 124, 250, 0.2);
}

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 700;
    line-height: 1.1;
    background: linear-gradient(135deg, #fff 0%, #b8c7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p,
#subtitle {
    margin: 0;
    color: var(--hint);
    font-size: 14px;
    font-weight: 400;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.stat-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 12px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--hint);
    font-weight: 500;
}

.filters {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(8, 11, 18, 0.82);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

.search-box {
    position: relative;
    margin-bottom: 12px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--hint);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--secondary);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#searchInput::placeholder {
    color: var(--hint);
}

#searchInput:focus {
    border-color: rgba(91, 124, 250, 0.5);
    box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.12);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--hint);
    min-width: 42px;
}

.filter-select,
.filter-date {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--secondary);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.filter-select:focus,
.filter-date:focus {
    border-color: rgba(91, 124, 250, 0.5);
}

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.date-sep {
    color: var(--hint);
    font-size: 13px;
}

.type-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.type-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: var(--secondary);
    color: var(--hint);
    padding: 8px 14px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chip:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.16);
}

.chip.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(91, 124, 250, 0.28);
}

.loader,
.empty {
    text-align: center;
    padding: 56px 16px;
    color: var(--hint);
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    font-size: 14px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.empty h3 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
}

.empty p {
    margin: 0;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

@media (min-width: 640px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 520px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card:hover {
    transform: translateY(-3px);
    border-color: rgba(91, 124, 250, 0.25);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}

.card:active {
    transform: scale(0.98);
}

.thumb {
    position: relative;
    aspect-ratio: 1;
    background: #0d111a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.thumb .icon {
    font-size: 42px;
}

.thumb-overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 28px 10px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

.thumb-time {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.card-body {
    padding: 12px;
}

.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(91, 124, 250, 0.14);
    color: #9eb4ff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.caption {
    font-size: 13px;
    line-height: 1.45;
    font-weight: 400;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 38px;
}

.meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--hint);
    font-weight: 400;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 760px;
    max-height: 92vh;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    padding: 18px;
    overflow: auto;
    animation: slideUp 0.25s ease;
}

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

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

#modalBody img,
#modalBody video,
#modalBody audio {
    width: 100%;
    border-radius: 14px;
    display: block;
}

#modalBody .file-box {
    width: 100%;
    min-height: 240px;
    border-radius: 14px;
    background: #0d111a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    border: 1px dashed var(--border);
}

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(91, 124, 250, 0.25);
}

.modal-meta {
    margin-top: 16px;
    font-size: 13px;
    color: var(--hint);
    line-height: 1.7;
    font-weight: 400;
}

.modal-meta strong {
    color: var(--text);
    font-weight: 600;
}

.modal-meta code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 12px;
    color: #c7d2fe;
}
