:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #1c2430;
    --muted: #6b7280;
    --line: #e2e5eb;
    --accent: #d7261e;
    --accent-dark: #a50d12;
    --accent-light: #fdeceb;
    --accent-gradient: linear-gradient(135deg, #d7261e 0%, #a50d12 100%);
    --gold: #f2a900;
    --gold-dark: #c98600;
    --success: #1f8a55;
    --success-bg: #e9f8f0;
    --danger: #a50d12;
    --danger-light: #fdeceb;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(20, 30, 45, 0.08);
    --shadow-sm: 0 4px 12px rgba(20, 30, 45, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

body.modal-open {
    overflow: hidden;
}

.shell {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: 26px;
}

h2 {
    margin-bottom: 6px;
    font-size: 17px;
}

p {
    color: var(--muted);
}

a {
    color: var(--accent-dark);
}

/* ---------- Auth pages ---------- */

.auth-panel {
    width: min(400px, 100%);
    margin: 8vh auto 0;
    padding: 32px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    font-size: 22px;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-mark-icon {
    border-radius: 14px;
    background: var(--accent-gradient);
    color: #fff;
}

.auth-back {
    text-align: center;
    margin-top: 16px;
    margin-bottom: 0;
}

.auth-back a {
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

/* ---------- Forms & inputs ---------- */

.form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    color: var(--ink);
    font: inherit;
    background: #fff;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
}

.input-icon input {
    padding-left: 38px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.btn-primary {
    background: var(--accent-gradient);
    border-color: var(--accent-dark);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-danger {
    background: #fff;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.btn-secondary:hover {
    border-color: var(--muted);
    background: var(--bg);
}

.btn-icon {
    padding: 14px;
    background: var(--panel);
    border-color: var(--line);
    color: var(--muted);
}

.btn-icon:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
}

.btn-icon-danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-block {
    width: 100%;
}

/* ---------- Layout ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand .brand-mark {
    margin: 0;
    width: 48px;
    height: 48px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    font-size: 14px;
    font-weight: 600;
}

.breadcrumb a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
}

.breadcrumb a:last-child {
    color: var(--ink);
}

.breadcrumb a:hover {
    color: var(--accent-dark);
}

.breadcrumb-sep {
    font-size: 11px;
    color: var(--line);
}

/* ---------- Folder grid ---------- */

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.folder-card {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.folder-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.folder-open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px;
    color: var(--ink);
    text-decoration: none;
}

.folder-open i {
    font-size: 26px;
    color: var(--gold);
    margin-bottom: 6px;
}

.folder-open span {
    font-weight: 700;
    font-size: 14px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-open small {
    color: var(--muted);
    font-size: 12px;
}

.folder-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px 16px;
    border-top: 1px solid var(--line);
}

.folder-actions form {
    display: contents;
}

.folder-actions .btn {
    flex: 1;
}

.folder-new {
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: var(--panel);
    border: 1px dashed var(--line);
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 14px;
}

.folder-new i {
    font-size: 22px;
}

.folder-new:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
}

/* ---------- Messages ---------- */

.message {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-weight: 700;
    margin-bottom: 16px;
}

.error {
    background: var(--danger-light);
    color: var(--danger);
}

.success {
    background: var(--success-bg);
    color: var(--success);
}

/* ---------- Search ---------- */

.search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    min-width: 220px;
    max-width: 420px;
}

.search-form .input-icon {
    flex: 1;
}

.search-form input {
    background: var(--bg);
    border-color: transparent;
}

.search-form input:focus {
    background: #fff;
}

.search-form .clear-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

/* ---------- Video grid ---------- */

.video-list {
    display: grid;
    gap: 14px;
}

.video-count {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

.video-count i {
    color: var(--gold-dark);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.video-card {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.video-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

video {
    width: 100%;
    height: 180px;
    background: #0c0a09;
    object-fit: contain;
}

.video-body {
    padding: 16px;
    display: grid;
    gap: 4px;
}

.video-body h2 {
    font-size: 16px;
}

.video-body p {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-top: 4px;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card-actions form {
    flex: 1;
}

/* ---------- Tabs ---------- */

.tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 10px 14px;
    margin-bottom: 18px;
}

.tabs {
    display: flex;
    gap: 6px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
}

.tab:hover {
    color: var(--accent-dark);
}

.tab.active {
    color: #fff;
    background: var(--accent-gradient);
    box-shadow: var(--shadow-sm);
}

.empty {
    padding: 48px 24px;
    color: var(--muted);
    text-align: center;
    background: var(--panel);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.empty i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
    color: var(--line);
}

.empty-compact {
    padding: 20px 24px;
    text-align: left;
}

.empty-compact p {
    margin: 0;
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 6px;
    font-weight: 700;
    font-size: 14px;
}

.pagination a {
    color: var(--accent-dark);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pagination-disabled {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    opacity: 0.5;
}

.pagination-info {
    color: var(--muted);
    font-weight: 400;
}

/* ---------- Upload modal ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(28, 25, 23, 0.55);
    backdrop-filter: blur(2px);
    padding: 20px;
    z-index: 100;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    width: min(480px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-sm {
    width: min(360px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 17px;
}

.modal-close {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-body {
    padding: 20px;
}

.upload-target {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--muted);
}

.upload-target i {
    color: var(--gold-dark);
}

.upload-target strong {
    color: var(--ink);
}

.file-drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
    transition: border-color 120ms ease, background 120ms ease;
}

.file-drop-zone i {
    font-size: 24px;
    color: var(--accent);
}

.file-drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

.file-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-progress {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.progress-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.progress-head strong {
    color: var(--ink);
}

.progress-bar {
    width: 100%;
    height: 10px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg);
}

.progress-bar div {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent-gradient);
    transition: width 180ms ease;
}

.upload-progress p {
    margin: 10px 0 0;
    font-size: 14px;
}

.upload-progress.done .progress-bar div {
    background: var(--success);
}

.upload-progress.done p {
    color: var(--success);
}

.upload-progress.failed .progress-bar div {
    background: var(--danger);
}

.upload-progress.failed p,
.upload-progress.failed .progress-head strong {
    color: var(--danger);
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
    .topbar,
    .copy-row,
    .progress-head {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .top-actions {
        justify-content: flex-start;
    }

    .progress-head {
        display: grid;
    }

    .video-grid,
    .folder-grid {
        grid-template-columns: 1fr;
    }

    .search-form {
        flex-wrap: wrap;
    }
}
