:root {
    color-scheme: dark;
    --bg: #0f0f0f;
    --panel: #181818;
    --panel-2: #222;
    --line: #303030;
    --text: #f7f7f7;
    --muted: #a6a6a6;
    --accent: #ff0033;
    --accent-2: #cc0029;
    --focus: #4fb3ff;
    --ok: #37d67a;
    --danger: #ff6b88;
    --radius: 8px;
    font-family: Inter, Roboto, Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 620px) minmax(90px, 1fr);
    align-items: center;
    gap: 20px;
    height: 64px;
    padding: 0 24px;
    background: rgba(15, 15, 15, .94);
    border-bottom: 1px solid #242424;
    backdrop-filter: blur(14px);
}
.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 900;
    font-size: 1.16rem;
}
.brand-mark {
    position: relative;
    width: 34px;
    height: 24px;
    border-radius: 7px;
    background: var(--accent);
}
.brand-mark::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 6px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 10px solid #fff;
}
.search {
    display: flex;
    align-items: center;
    min-width: 0;
}
.search input, .admin-toolbar input {
    width: 100%;
    min-height: 42px;
    color: var(--text);
    background: #0b0b0b;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 44px 0 16px;
    outline: none;
}
.search input:focus, .admin-toolbar input:focus, .metadata-form input:focus, .metadata-form textarea:focus, .metadata-form select:focus, .auth-panel input:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(79, 179, 255, .18);
}
.round-icon {
    width: 34px;
    height: 34px;
    margin-left: -39px;
    border: 0;
    border-radius: 50%;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}
.admin-link {
    justify-self: end;
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
}
.watch-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 440px);
    gap: 26px;
    width: min(100%, 1880px);
    margin: 0 auto;
    padding: 24px 30px 42px;
}
.player-column { min-width: 0; }
.player-shell {
    overflow: hidden;
    background: #000;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}
.player-shell:fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}
.player-stage {
    position: relative;
    background: #000;
}
.player-stage video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}
.player-shell:fullscreen .player-stage {
    flex: 1 1 auto;
    display: grid;
    align-items: center;
}
.player-shell:fullscreen video {
    height: 100%;
    max-height: calc(100vh - 78px);
    object-fit: contain;
    aspect-ratio: auto;
}
.center-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(20, 20, 20, .78);
    cursor: pointer;
    transition: opacity .16s ease, transform .16s ease, background .16s ease;
}
.center-play:hover { background: rgba(255, 0, 51, .84); }
.player-stage.is-playing .center-play {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(.92);
}
.play-shape {
    width: 0;
    height: 0;
    margin-left: 5px;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-left: 23px solid #fff;
}
.resume-pill {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: none;
    min-height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(15, 15, 15, .76);
    font-weight: 900;
    cursor: pointer;
    backdrop-filter: blur(12px);
}
.resume-pill.visible { display: inline-flex; align-items: center; }
.controls {
    display: grid;
    gap: 6px;
    padding: 8px 14px 12px;
    background: #050505;
}
.timeline {
    position: relative;
    height: 28px;
    cursor: pointer;
    outline: none;
}
.track, .buffered-fill, .played-fill {
    position: absolute;
    left: 0;
    top: 50%;
    height: 7px;
    transform: translateY(-50%);
    border-radius: 999px;
}
.track { right: 0; background: rgba(255,255,255,.16); }
.buffered-fill { width: 0; background: rgba(255,255,255,.46); }
.played-fill { width: 0; background: var(--accent); z-index: 2; }
.scrubber {
    position: absolute;
    left: 0;
    top: 50%;
    z-index: 3;
    width: 15px;
    height: 15px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #fff;
}
.control-row {
    display: flex;
    align-items: center;
    gap: 9px;
}
.icon-control {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: transparent;
    cursor: pointer;
    font-weight: 900;
}
.icon-control:hover, .icon-control:focus-visible { background: rgba(255,255,255,.16); outline: none; }
.time-readout {
    min-width: 116px;
    color: #eee;
    font-size: .88rem;
    font-weight: 800;
}
.volume-wrap { display: flex; align-items: center; gap: 4px; }
.volume-wrap input { width: 88px; accent-color: #fff; }
.control-spacer { flex: 1; }
.video-info {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 0 10px;
}
.video-info h1 {
    margin: 0 0 8px;
    font-size: clamp(1.28rem, 2vw, 1.8rem);
    line-height: 1.16;
    overflow-wrap: anywhere;
}
.meta, .muted { color: var(--muted); font-weight: 700; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.reaction-button, .comment-form button, .modal-actions button, .auth-panel button, .metadata-form button, .admin-primary-link, .section-title button, .logout-button {
    min-height: 40px;
    border: 1px solid #333;
    border-radius: 999px;
    color: #fff;
    background: #242424;
    padding: 0 14px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}
.reaction-button.active, .comment-form button, .auth-panel button, .metadata-form button[type="submit"], .admin-primary-link {
    border-color: var(--accent);
    background: var(--accent);
}
.description-block {
    margin: 2px 0 18px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: #1a1a1a;
    line-height: 1.48;
}
.description-block p { margin: 0; }
.tag-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.tag-row span {
    padding: 5px 9px;
    border-radius: 999px;
    background: #2a2a2a;
    color: #eee;
    font-size: .82rem;
    font-weight: 800;
}
.feed-column { min-width: 0; }
.feed-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    color: var(--muted);
}
.video-feed { display: grid; gap: 12px; }
.video-card {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius);
    text-decoration: none;
    background: transparent;
}
.video-card:hover, .video-card.active { background: #202020; }
.thumb {
    overflow: hidden;
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    border-radius: 7px;
    background: #292929;
}
.thumb img, .admin-video-card img, .admin-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.thumb-fallback, .admin-thumb span {
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
}
.card-copy { min-width: 0; display: grid; align-content: start; gap: 5px; }
.card-copy strong { overflow-wrap: anywhere; line-height: 1.22; }
.card-copy small, .card-copy span { color: var(--muted); font-size: .86rem; line-height: 1.35; }
.card-copy span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.comments {
    display: grid;
    gap: 14px;
    max-width: 860px;
}
.comments h2 { margin: 0; }
.comment-form { display: grid; gap: 10px; }
.comment-form input, .comment-form textarea, .auth-panel input, .metadata-form input, .metadata-form textarea, .metadata-form select {
    width: 100%;
    color: var(--text);
    background: #101010;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    outline: none;
}
.comment-form textarea, .metadata-form textarea { min-height: 88px; resize: vertical; }
.comment-list { display: grid; gap: 10px; }
.comment-item {
    display: grid;
    gap: 4px;
    padding: 12px 0;
    border-bottom: 1px solid #262626;
}
.comment-item p { margin: 0; color: #ddd; }
.comment-item time { color: var(--muted); font-size: .82rem; }
.modal {
    border: 0;
    padding: 0;
    color: var(--text);
    background: transparent;
}
.modal::backdrop { background: rgba(0,0,0,.72); }
.modal-panel {
    width: min(92vw, 420px);
    display: grid;
    gap: 13px;
    padding: 22px;
    border: 1px solid #333;
    border-radius: var(--radius);
    background: #191919;
}
.modal-panel h2, .modal-panel p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: none;
    padding: 10px 14px;
    border-radius: 999px;
    background: #2a2a2a;
    color: #fff;
    font-weight: 800;
    z-index: 40;
}
.toast.visible { display: block; }
.notice {
    grid-column: 1 / -1;
    margin: 0 0 12px;
    padding: 11px 13px;
    border-radius: var(--radius);
    font-weight: 850;
}
.notice.error { color: #ffd4dc; background: rgba(255, 0, 51, .16); }
.notice.ok { color: #d3ffe3; background: rgba(55, 214, 122, .14); }
.empty-state {
    grid-column: 1 / -1;
    display: grid;
    place-items: center;
    min-height: 70vh;
    text-align: center;
    gap: 12px;
}

.admin-auth-body { background: #101010; }
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-panel {
    width: min(100%, 430px);
    display: grid;
    gap: 14px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}
.auth-panel h1 { margin: 8px 0 0; }
.admin-body {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
    background: #111;
}
.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 24px;
    background: #171717;
    border-right: 1px solid #2a2a2a;
}
.admin-nav { display: grid; gap: 7px; }
.admin-nav a, .logout-button {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 11px 13px;
    border-radius: var(--radius);
    color: var(--text);
    background: transparent;
    border: 0;
    text-align: left;
    text-decoration: none;
    font-weight: 850;
}
.admin-nav a:hover, .admin-nav a.active, .logout-button:hover { background: #262626; }
.logout-button { margin-top: auto; cursor: pointer; }
.admin-main {
    min-width: 0;
    padding: 30px;
}
.admin-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.admin-heading p {
    margin: 0 0 5px;
    color: var(--muted);
    font-weight: 900;
}
.admin-heading h1 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.8rem); }
.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat-grid article, .admin-section, .admin-edit-card {
    border: 1px solid #2d2d2d;
    border-radius: var(--radius);
    background: #1a1a1a;
}
.stat-grid article {
    display: grid;
    gap: 7px;
    padding: 16px;
}
.stat-grid span, .admin-video-card span { color: var(--muted); font-weight: 800; font-size: .88rem; }
.stat-grid strong { font-size: 1.28rem; }
.admin-section { padding: 18px; margin-bottom: 18px; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.section-title h2, .admin-section h2 { margin: 0; }
.section-title a { color: #fff; font-weight: 850; }
.admin-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.admin-video-card {
    display: grid;
    gap: 8px;
    min-width: 0;
}
.admin-video-card img {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    background: #292929;
}
.admin-video-card strong { overflow-wrap: anywhere; }
.job-list { display: grid; gap: 10px; }
.job-row {
    display: grid;
    gap: 7px;
    padding: 12px;
    border: 1px solid #303030;
    border-radius: var(--radius);
    background: #121212;
}
.job-row span { color: var(--muted); }
.mini-progress {
    overflow: hidden;
    height: 8px;
    border-radius: 999px;
    background: #333;
}
.mini-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width .18s ease;
}
.upload-surface { display: grid; gap: 14px; }
.dropzone {
    min-height: 210px;
    display: grid;
    place-items: center;
    gap: 7px;
    padding: 24px;
    border: 2px dashed #484848;
    border-radius: var(--radius);
    color: #fff;
    background: #101010;
    cursor: pointer;
}
.dropzone span { font-size: 1.15rem; font-weight: 900; }
.dropzone small { color: var(--muted); font-weight: 750; }
.dropzone.over { border-color: var(--accent); background: rgba(255, 0, 51, .08); }
.upload-progress { display: grid; gap: 8px; }
.admin-toolbar { margin-bottom: 14px; }
.admin-video-list { display: grid; gap: 14px; }
.admin-edit-card {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
}
.admin-thumb {
    display: grid;
    place-items: center;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    align-self: start;
    border-radius: var(--radius);
    background: #282828;
}
.metadata-form { display: grid; gap: 10px; min-width: 0; }
.metadata-form label { display: grid; gap: 5px; color: var(--muted); font-weight: 850; }
.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.form-row.compact { grid-template-columns: minmax(160px, 1fr) auto auto; align-items: end; }
.check {
    grid-auto-flow: column;
    align-items: center;
    justify-content: start;
}
.check input { width: auto; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.metadata-form .danger { border-color: rgba(255,107,136,.5); color: #ffd5dd; }
.metadata-form small { color: var(--muted); overflow-wrap: anywhere; }
.plain-list { line-height: 1.6; }
.admin-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    max-width: min(420px, calc(100vw - 36px));
    padding: 11px 14px;
    border-radius: 999px;
    color: #fff;
    background: #2b2b2b;
    box-shadow: 0 14px 45px rgba(0,0,0,.35);
    font-weight: 850;
}
.admin-toast.error { background: #6f1630; }
.admin-toast.ok { background: #1d6237; }

@media (max-width: 1100px) {
    .watch-shell { grid-template-columns: 1fr; }
    .feed-column { max-width: none; }
    .stat-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}
@media (max-width: 760px) {
    .topbar { grid-template-columns: 1fr auto; height: auto; padding: 12px; }
    .search { grid-column: 1 / -1; order: 3; }
    .watch-shell { padding: 14px 12px 28px; }
    .video-info { display: grid; }
    .action-row { justify-content: start; }
    .video-card { grid-template-columns: 138px minmax(0, 1fr); }
    .volume-wrap input { display: none; }
    .admin-body { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; height: auto; }
    .admin-main { padding: 18px 12px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
    .admin-edit-card { grid-template-columns: 1fr; }
    .form-row, .form-row.compact { grid-template-columns: 1fr; }
}
