:root {
    --bg: #090d16;
    --surface: #111827;
    --surface-hover: #1f2937;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
}

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

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

.container {
    max-width: 1280px;
    margin: 0 auto;
}

header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 900px) {
    header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 8px 20px var(--accent-glow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.brand-logo:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px var(--accent-glow);
}

.brand-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.space-switch {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.25rem;
    gap: 0.25rem;
}

.space-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.45rem 0.9rem;
    border-radius: 9px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.space-btn:hover {
    color: var(--text-main);
}

.space-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.search-input {
    width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.65rem 1rem;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
}

.count-badge {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.view-switch {
    display: flex;
    gap: 0;
}

.view-btn {
    background: #021a30;
    border: 1px solid #1a4a75;
    color: #4a90e2;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.view-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.view-btn:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.view-btn:hover {
    background: #052340;
    color: #6daaf5;
}

.view-btn.active {
    background: #0a335e;
    color: #9cd3ff;
    border-color: #27629e;
}

.upload-panel {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 36%);
    gap: 1rem;
    align-items: stretch;
}

.upload-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.upload-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.input-text, .input-file {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-size: 0.85rem;
    outline: none;
}

.btn-upload {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-upload:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-status {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.gallery-container.mode-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.video-card {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.video-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.video-viewport {
    width: 100%;
    height: 350px;
    background-color: #050505;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}

.video-viewport video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.file-viewport {
    width: 100%;
    height: 190px;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(0, 0, 0, 0.25));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
}

.file-ext-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    letter-spacing: 0.04em;
}

.btn-download {
    margin-top: 0.4rem;
    display: inline-block;
    text-align: center;
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
    border: 1px solid rgba(99, 102, 241, 0.4);
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-download:hover {
    background: var(--accent);
}

.video-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
}

.video-title {
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-tag {
    font-size: 0.75rem;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 700;
}

.gallery-container.mode-list {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-main);
    text-decoration: none;
}

.list-row:hover {
    background: var(--surface-hover);
}

.list-row:last-child {
    border-bottom: none;
}

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

.list-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.list-meta span {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.list-meta .list-ext {
    text-transform: uppercase;
    color: var(--accent);
}

.message-box {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 16px;
    width: 100%;
}

.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 1000px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.modal-content video {
    width: 100%;
    max-height: 85vh;
    display: block;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.storage-tracker {
    min-width: 0;
    margin: 0;
    padding: 0 0 0 1.5rem;
    border-bottom: 0;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 899px) {
    .upload-panel {
        grid-template-columns: 1fr;
    }

    .storage-tracker {
        padding: 1.25rem 0 0;
        border-left: 0;
        border-top: 1px solid var(--border);
    }
}

.storage-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

.admin-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.admin-panel h2 {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.2rem;
}

.admin-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-panel-heading h2 {
    border-bottom: 0;
}

.btn-delete {
    background: #ff4a4a;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-delete:hover {
    background: #d43a3a;
}

.admin-list-row {
    justify-content: space-between;
}

.admin-folder-header {
    margin: 1.5rem 1.5rem 1rem;
    cursor: pointer;
}

.admin-folder-group:first-child .admin-folder-header {
    margin-top: 1.5rem;
}

.admin-folder-group .folder-content {
    overflow: hidden;
}

.admin-folder-group .grid-wrap {
    padding: 0 1.5rem 1.5rem;
}

.folder-heading,
.folder-actions,
.admin-file-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.folder-heading {
    min-width: 0;
    flex: 1;
}

.folder-actions .btn-admin,
.folder-actions .btn-delete,
.admin-file-actions .btn-admin,
.admin-file-actions .btn-delete {
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
}

.admin-video-card .video-viewport {
    height: 260px;
}

.admin-file-size {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.empty-folder {
    margin: 0 1.5rem 1.5rem;
    padding: 1rem;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.btn-admin, .btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.65rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-admin:hover, .btn-back:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--accent);
}

.modal-auth {
    max-width: 420px;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    text-align: center;
}

.modal-auth h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.auth-form .input-text {
    width: 100%;
    padding: 0.75rem 1rem;
}

.auth-form .btn-upload {
    width: 100%;
    padding: 0.75rem 1rem;
}

.auth-error {
    margin-top: 1rem;
    color: #ff4a4a;
    font-size: 0.85rem;
    font-weight: 500;
}

.folder-group {
    margin-bottom: 2rem;
    width: 100%;
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.folder-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.folder-icon {
    color: var(--accent);
}

.folder-name {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.folder-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--surface);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}

.folder-toggle {
    transition: transform 0.3s;
}

.grid-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.gallery-container.mode-list .folder-group { margin-bottom: 1rem; }
.gallery-container.mode-list .folder-content {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.gallery-container.mode-list .folder-content .list-row:last-child { border-bottom: none; }

input.hidden, select.hidden, div.hidden, label.hidden { display: none !important; }