:root {
    --bg: #000000;
    --bg-card: rgba(255,255,255,0.05);
    --bg-card-hover: rgba(255,255,255,0.08);
    --bg-elevated: rgba(255,255,255,0.1);
    --text: #ffffff;
    --text-secondary: rgba(255,255,255,0.6);
    --text-muted: rgba(255,255,255,0.4);
    --accent: #0A84FF;
    --accent-gradient: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 100%);
    --danger: #FF453A;
    --success: #30D158;
    --purple: #BF5AF2;
    --border: rgba(255,255,255,0.1);
    --glass: rgba(255,255,255,0.05);
    --glass-border: rgba(255,255,255,0.1);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    min-height: 100dvh;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Glass Effect */
.glass {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

/* App Container */
.app {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(to bottom, var(--bg) 60%, transparent);
}

.logo {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent);
}

.header-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.header-btn:hover {
    background: var(--bg-card-hover);
}

/* Admin Section */
.admin-section {
    display: none;
    margin-bottom: 20px;
}

.admin-section.show {
    display: block;
}

.admin-card {
    background: var(--accent-gradient);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.admin-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.admin-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-chevron {
    transition: transform 0.3s;
}

.admin-chevron.open {
    transform: rotate(180deg);
}

.admin-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.admin-body.open {
    max-height: 600px;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    padding: 0 20px 16px;
}

.tab {
    padding: 8px 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 20px;
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab.active {
    background: rgba(255,255,255,0.3);
    color: white;
}

.tab-content {
    display: none;
    padding: 0 20px 20px;
}

.tab-content.active {
    display: block;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.user-row:hover {
    background: rgba(255,255,255,0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-id {
    font-weight: 600;
    font-size: 14px;
}

.user-meta {
    font-size: 12px;
    opacity: 0.7;
}

.whitelist-form {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-family: inherit;
}

.input::placeholder {
    color: rgba(255,255,255,0.5);
}

.input:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
}

.btn-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.3);
}

.whitelist-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.wl-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-xs);
}

.wl-remove {
    width: 28px;
    height: 28px;
    background: rgba(255,59,48,0.3);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.wl-remove:hover {
    background: rgba(255,59,48,0.5);
}

/* User Banner */
.user-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.user-banner.show {
    display: flex;
}

.banner-close {
    background: rgba(255,255,255,0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.blue {
    background: rgba(10, 132, 255, 0.2);
    color: var(--accent);
}

.stat-icon.purple {
    background: rgba(191, 90, 242, 0.2);
    color: var(--purple);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.filters::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.chip:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.chip.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

/* Content */
.content {
    min-height: 200px;
    position: relative;
}

/* Grid View */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.grid-item {
    aspect-ratio: 1;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.grid-item:hover {
    transform: scale(1.02);
}

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

.grid-item .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
}

.grid-item .placeholder svg {
    width: 32px;
    height: 32px;
}

.grid-item .placeholder span {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid-item .badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}

/* List View */
.list {
    display: none;
    flex-direction: column;
    gap: 8px;
}

.list.show {
    display: flex;
}

.list.show + .grid,
.grid:not(.show) {
    display: none;
}

.grid.show {
    display: grid;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.list-item:hover {
    background: var(--bg-card-hover);
}

.list-thumb {
    width: 52px;
    height: 52px;
    background: var(--bg-elevated);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

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

.list-thumb svg {
    color: var(--text-muted);
}

.list-info {
    flex: 1;
    min-width: 0;
}

.list-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.list-meta {
    font-size: 13px;
    color: var(--text-muted);
}

/* Empty State */
.empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty.show {
    display: flex;
}

.empty-icon {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.empty p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Loader */
.loader {
    display: none;
    justify-content: center;
    padding: 40px;
}

.loader.show {
    display: flex;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg-card);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal-wrap {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-wrap.show {
    opacity: 1;
    visibility: visible;
}

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

.modal {
    position: relative;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-wrap.show .modal {
    transform: scale(1) translateY(0);
}

.modal-media {
    aspect-ratio: 4/3;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
}

.modal-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.modal-info {
    padding: 20px;
}

.modal-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    word-break: break-all;
}

.modal-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 0 20px 20px;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn.primary {
    background: var(--accent);
    color: white;
}

.btn.primary:hover {
    filter: brightness(1.1);
}

.btn.danger {
    background: rgba(255,69,58,0.15);
    color: var(--danger);
}

.btn.danger:hover {
    background: rgba(255,69,58,0.25);
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--bg);
    padding: 14px 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Desktop */
@media (min-width: 640px) {
    .app {
        padding: 0 24px;
    }
    
    .grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .grid-item {
        border-radius: var(--radius);
    }
    
    .stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stat-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

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