/* ==========================================================
   Xognito - Gruvbox theme
   ========================================================== */

:root {
    --bg:          #1b1810;
    --bg-header:   #1d1a11;
    --surface:     #262011;
    --surface-2:   #2f2815;
    --border:      #3c3420;
    --fg:          #ebdbb2;
    --fg-muted:    #a89984;
    --fg-dim:      #7c6f64;
    --orange:      #fe8019;
    --orange-dark: #d65d0e;
    --yellow:      #fabd2f;
    --green:       #b8bb26;
    --aqua:        #8ec07c;
    --red:         #fb4934;
    --on-accent:   #1d2021;
    --avatar-bg:   #fbc8a0;
    --accent-glow: rgba(254, 128, 25, .35);
    --shadow:      0 8px 24px rgba(0, 0, 0, .35);
    --radius:      10px;
    --font:        "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono:   "JetBrains Mono", ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1200px 500px at 50% -200px, rgba(254, 128, 25, .05), transparent 70%),
        var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.accent { color: var(--orange); }
.muted  { color: var(--fg-dim); }
.hl     { color: var(--yellow); }

kbd {
    padding: 0 6px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--yellow);
    font-family: inherit;
    font-size: 12px;
}

::selection { background: var(--orange); color: var(--on-accent); }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 18px 20px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; line-height: 1; }
.logo-img {
    width: auto;
    height: 44px;
    transition: transform .2s;
}
.logo:hover .logo-img { transform: rotate(-6deg); }
.logo-word { display: flex; align-items: baseline; font-family: var(--font-mono); }
.logo-x {
    color: var(--orange);
    font-size: 38px;
    font-weight: 800;
    transition: color .15s;
}
.logo-rest {
    margin-left: 1px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 2px;
}
.logo:hover .logo-x { color: var(--yellow); }

.search {
    flex: 1;
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 38px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: border-color .15s;
}
.search:focus-within { border-color: var(--orange); }
.search-icon {
    width: 18px;
    margin: 0 8px 0 12px;
    fill: none;
    stroke: var(--fg-muted);
    stroke-width: 2.2;
    flex-shrink: 0;
}
.search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--fg);
    font: inherit;
}
.search input::placeholder { color: var(--fg-muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search button {
    height: 100%;
    padding: 0 16px;
    background: transparent;
    border: 0;
    border-left: 1px solid var(--border);
    color: var(--fg-muted);
}
.search button:hover { color: var(--orange); }

.main-nav { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
.main-nav a { color: var(--fg-muted); transition: color .15s, background .15s, border-color .15s; }
.main-nav a:hover { color: var(--fg); }
.main-nav a.active { color: var(--orange); font-weight: 700; }

.main-nav .nav-hot {
    padding: 6px 14px;
    border: 1px solid var(--fg);
    border-radius: 4px;
    color: var(--fg);
    font-weight: 700;
}
.main-nav .nav-hot:hover { background: var(--surface-2); color: var(--fg); }
.main-nav .nav-hot.active { background: var(--fg); color: var(--on-accent); }
.main-nav .nav-hot.active:hover { background: var(--fg); color: var(--on-accent); filter: brightness(1.1); }

.topbar-actions { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }

.btn-upload {
    padding: 7px 16px;
    background: var(--orange);
    color: var(--on-accent);
    border-radius: 4px;
    font-weight: 700;
    transition: background .15s, transform .1s;
}
.btn-upload:hover { background: var(--yellow); }
.btn-upload:active { transform: translateY(1px); }

.avatar-letter {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: hsl(var(--h) 55% 70%);
    color: #1d2021;
    font-weight: 800;
    font-size: 16px;
    line-height: 1;
}

.avatar-btn { padding: 0; background: none; border: 2px solid transparent; border-radius: 50%; display: flex; }
.avatar-btn:hover, .avatar-btn[aria-expanded="true"] { border-color: var(--orange); }

.user-menu-wrap { position: relative; }
.user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    padding: 6px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: var(--shadow);
}
.user-menu-head { padding: 8px 14px; border-bottom: 1px solid var(--border); color: var(--yellow); font-weight: 700; }
.user-menu a,
.user-menu button {
    display: block;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: 0;
    text-align: left;
    color: var(--fg-muted);
}
.user-menu a:hover,
.user-menu button:hover { background: var(--surface-2); color: var(--orange); }
.user-menu form { margin: 0; }

/* ---------- Buttons ---------- */
.btn-primary,
.btn-ghost,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 4px;
    font-weight: 700;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--orange); border: 1px solid var(--orange); color: var(--on-accent); }
.btn-primary:hover { background: var(--yellow); border-color: var(--yellow); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); cursor: pointer; }
.btn-ghost:hover { border-color: var(--orange); color: var(--orange); }
.btn-danger { background: transparent; border: 1px solid var(--border); color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-block { width: 100%; padding: 10px 16px; }

/* ---------- Flash & toast ---------- */
.flash-stack { display: grid; gap: 8px; padding: 14px 20px 0; }
.flash {
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--aqua);
    border-radius: 4px;
    color: var(--aqua);
}
.flash-error { border-left-color: var(--red); color: var(--red); }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    max-width: calc(100% - 40px);
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--red);
    border-radius: 4px;
    color: var(--red);
    box-shadow: var(--shadow);
    animation: fade-in .2s ease both;
}

/* ---------- Category chips ---------- */
.chips {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    padding: 7px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--fg);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: var(--orange); color: var(--orange); }
.chip.active { background: var(--yellow); border-color: var(--yellow); color: var(--on-accent); font-weight: 700; }

/* ---------- Headings ---------- */
.page-heading { margin: 0 0 20px; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
/* Visible to search engines and screen readers only */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Layout ---------- */
.container {
    flex: 1;
    width: 100%;
    padding: 24px 20px 36px;
}

/* ---------- Video grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px 18px;
}

/* Cards: borderless, the thumbnail is the hero */
.card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    animation: fade-in .3s ease both;
}

.card-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface-2);
    box-shadow: 0 0 0 1px rgba(235, 219, 178, .06);
    transition: box-shadow .25s, transform .25s;
}
.card-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent 45%);
    pointer-events: none;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .card-thumb { box-shadow: 0 0 0 2px var(--orange), 0 10px 30px var(--accent-glow); transform: translateY(-3px); }
.card:hover .card-thumb img { transform: scale(1.05); }

/* Placeholder until real thumbnails exist */
.thumb-placeholder {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 30%, hsl(var(--h) 45% 26% / .9), transparent 60%),
        linear-gradient(135deg, hsl(var(--h) 35% 18%), hsl(calc(var(--h) + 40) 45% 9%));
}

/* Round play icon on hover */
.play-hover {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    opacity: 0;
    transition: opacity .2s;
}
.play-hover svg {
    width: 54px;
    height: 54px;
    padding: 14px 12px 14px 16px;
    background: rgba(29, 32, 33, .65);
    border: 2px solid var(--fg);
    border-radius: 50%;
    fill: var(--fg);
    backdrop-filter: blur(4px);
}
.card:hover .play-hover { opacity: 1; }

.badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    padding: 2px 8px;
    background: var(--orange);
    color: #1d2021;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: .4px;
    border-radius: 999px;
}
.badge-hot { background: var(--orange); }
.duration {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 2px 7px;
    background: rgba(20, 18, 12, .85);
    color: var(--fg);
    font-weight: 600;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    border-radius: 6px;
}

.card-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 2px 0; flex: 1; }
.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-title a:hover { color: var(--orange); }
.card-channel { color: var(--yellow); font-weight: 500; }
.card-channel:hover { color: var(--orange); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--fg-muted); font-size: 13px; }
.card-meta .dot { color: var(--fg-dim); }

.empty {
    padding: 72px 20px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--fg-muted);
}
.empty p { margin: 0; }
.empty pre { margin: 0; white-space: pre-wrap; font-family: inherit; }

/* ---------- Pager ---------- */
.pager {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    margin-top: 44px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.pager-info { font-size: 13px; color: var(--fg-muted); }
.pager-info b { color: var(--fg); }

.btn-more {
    padding: 9px 28px;
    background: transparent;
    border: 1px solid var(--orange);
    border-radius: 999px;
    color: var(--orange);
    font-weight: 600;
    transition: border-color .15s, background .15s, color .15s;
}
.btn-more:hover { background: var(--orange); color: var(--on-accent); }
.btn-more:disabled { opacity: .5; cursor: wait; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 13px;
}
.pg-nav { padding: 6px 8px; color: var(--fg); }
.pg-nav:hover { color: var(--orange); }
.pg-nav.disabled { color: var(--fg-dim); pointer-events: none; }
.pg-num {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    background: var(--surface-2);
    border-radius: 2px;
}
.pg-num { border-radius: 8px; }
.pg-num:hover { color: var(--orange); }
.pg-num.active { background: var(--orange); color: var(--on-accent); font-weight: 700; }
.pg-gap { color: var(--fg-dim); padding: 0 4px; }

/* ---------- Footer ---------- */
.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 24px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--fg);
}
.footer-brand { font-family: var(--font-mono); font-weight: 800; letter-spacing: 1px; }
.footer-links { display: flex; gap: 18px; color: var(--fg-muted); }
.footer-adult { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-muted); }
.age-badge {
    padding: 1px 6px;
    border: 1px solid var(--red);
    border-radius: 3px;
    color: var(--red);
    font-size: 11px;
    font-weight: 800;
}
.footer-links a:hover { color: var(--orange); }

/* ---------- Age gate (18+) ---------- */
body.age-locked { overflow: hidden; }
body.age-locked > :not(.age-gate):not(script) { filter: blur(14px); pointer-events: none; user-select: none; }
.age-gate {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(12, 10, 6, .82);
}
.age-box {
    width: 100%;
    max-width: 480px;
    padding: 32px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 0 1px var(--accent-glow);
    text-align: center;
}
.age-logo { width: auto; height: 72px; margin-bottom: 12px; }
.age-box h1 { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 24px; }
.age-box h1 .age-badge { font-size: 14px; padding: 2px 8px; }
.age-box p { margin: 0 0 20px; color: var(--fg-muted); line-height: 1.6; }
.age-box p b { color: var(--fg); }
.age-actions { display: grid; gap: 10px; margin-bottom: 18px; }
.age-actions .btn-primary { padding: 12px; font-size: 16px; border-radius: 999px; background: var(--orange); border-color: var(--orange); }
.age-actions .btn-primary:hover { background: var(--yellow); border-color: var(--yellow); }
.age-actions .btn-ghost { padding: 10px; border-radius: 999px; }
.age-small { font-size: 12px; margin: 0 !important; }
.age-small a { color: var(--orange); }

/* ---------- Watch page extras ---------- */
.tag {
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--yellow);
    font-weight: 500;
}
.tag:hover { border-color: var(--orange); color: var(--orange); }
.count-pill {
    display: inline-block;
    min-width: 24px;
    padding: 0 8px;
    margin-left: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    color: var(--fg-muted);
    font-size: 12px;
    text-align: center;
}
.btn-report { color: var(--fg-muted); }
.btn-report:hover { border-color: var(--red); color: var(--red); }

/* ---------- Legal pages ---------- */
.legal-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.legal-tabs a { padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--fg-muted); font-size: 14px; }
.legal-tabs a:hover { color: var(--fg); }
.legal-tabs a.active { background: var(--fg); border-color: var(--fg); color: var(--on-accent); font-weight: 600; }
.legal-body { line-height: 1.7; }
.legal-body h1 { margin: 0 0 4px; font-size: 26px; }
.legal-body h2 { margin: 26px 0 6px; font-size: 17px; color: var(--yellow); }
.legal-body p, .legal-body li { color: var(--fg-muted); }
.legal-body a:not(.btn-primary) { color: var(--orange); }
.legal-body ul, .legal-body ol { padding-left: 22px; }
.legal-report { margin: 16px 0; padding: 12px 14px; border-left: 3px solid var(--red); background: var(--surface-2); border-radius: 6px; }

/* ---------- Modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, .6);
}
.modal[hidden] { display: none; }
.modal-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--orange);
    border-radius: 4px;
    box-shadow: var(--shadow);
}
.modal-head {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--orange);
    font-weight: 700;
}
.modal-close { background: none; border: 0; color: var(--fg-muted); }
.modal-close:hover { color: var(--red); }
.modal-box ul { list-style: none; margin: 0; padding: 14px; display: grid; gap: 10px; }

/* ---------- Forms & panels ---------- */
.container.narrow { max-width: 760px; margin: 0 auto; }
.container.auth { max-width: 440px; padding-top: 48px; }

.panel {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.panel-title { margin: 0 0 20px; font-size: 18px; font-family: var(--font-mono); }
.admin-tabs, .zone-head h2, .stat b { font-family: var(--font-mono); }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field-label { color: var(--fg-muted); font-size: 13px; }

.input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--fg);
    font: inherit;
    transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--orange); }
textarea.input { resize: vertical; min-height: 64px; }
select.input { cursor: pointer; }

.form-errors {
    margin: 0 0 16px;
    padding: 10px 14px 10px 32px;
    border: 1px solid var(--red);
    border-radius: 4px;
    color: var(--red);
}
.form-errors[hidden] { display: none; }
.form-note { margin: -8px 0 18px; color: var(--fg-muted); font-size: 13px; }
.form-foot { margin: 18px 0 0; color: var(--fg-muted); font-size: 13px; text-align: center; }
.form-foot a { color: var(--orange); }

/* ---------- Upload ---------- */
.dropzone {
    position: relative;
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
    padding: 44px 16px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    text-align: center;
    color: var(--fg-muted);
    transition: border-color .15s, color .15s, background .15s;
}
.dropzone:hover,
.dropzone.dragover { border-color: var(--orange); color: var(--orange); background: var(--surface-2); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-text { font-weight: 700; word-break: break-all; }
.dropzone-hint { font-size: 12px; color: var(--fg-dim); }

.upload-preview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 16px;
    margin-bottom: 18px;
}
.upload-preview[hidden] { display: none; }
.upload-preview video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 4px; }
.thumb-picker { display: grid; gap: 8px; align-content: start; }
.thumb-preview { aspect-ratio: 16 / 9; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.thumb-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-preview img:not([src]) { display: none; }

.progress {
    position: relative;
    height: 28px;
    margin-bottom: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.progress[hidden] { display: none; }
.progress-bar { height: 100%; width: 0; background: var(--orange); transition: width .2s; }
.progress-text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 13px; }

/* ---------- Watch page ---------- */
.watch {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    align-content: start;
    gap: 24px;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 24px 20px 36px;
}

.player {
    aspect-ratio: 16 / 9;
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.player video { width: 100%; height: 100%; display: block; }

.watch-title { margin: 18px 0 10px; font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -.2px; word-break: break-word; }

.watch-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.watch-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--fg-muted); font-size: 14px; font-weight: 500; }
.watch-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }

.description {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.description p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.dot { color: var(--fg-dim); }

/* ---------- Embeds ---------- */
.player { position: relative; }
.player iframe { width: 100%; height: 100%; display: block; border: 0; }

.source-switch {
    display: inline-flex;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.source-switch label { padding: 8px 18px; color: var(--fg-muted); cursor: pointer; }
.source-switch label + label { border-left: 1px solid var(--border); }
.source-switch input { position: absolute; opacity: 0; pointer-events: none; }
.source-switch label:has(input:checked) { background: var(--fg); color: var(--on-accent); font-weight: 700; }
.source-switch label:has(input:focus-visible) { outline: 2px solid var(--yellow); }
[data-source][hidden] { display: none; }

.field-hint { font-size: 12px; color: var(--fg-dim); }
.field-hint.is-error { color: var(--red); }

.embed-frame { aspect-ratio: 16 / 9; background: #000; border-radius: 4px; overflow: hidden; }
.embed-frame iframe, .embed-frame video { width: 100%; height: 100%; display: block; border: 0; }

/* ---------- Pre-roll ad ---------- */
.ad-layer { position: absolute; inset: 0; z-index: 5; background: #000; }
.ad-video { width: 100%; height: 100%; display: block; cursor: pointer; }
.ad-label {
    position: absolute;
    left: 12px;
    bottom: 18px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, .7);
    border-radius: 2px;
    color: var(--yellow);
    font-size: 12px;
    font-weight: 700;
}
.ad-link {
    position: absolute;
    left: 12px;
    top: 12px;
    padding: 6px 12px;
    background: var(--fg);
    border-radius: 4px;
    color: var(--on-accent);
    font-size: 13px;
    font-weight: 700;
}
.ad-link:hover { background: var(--yellow); }
.ad-skip {
    position: absolute;
    right: 0;
    bottom: 24px;
    padding: 10px 18px;
    background: rgba(0, 0, 0, .75);
    border: 1px solid rgba(255, 255, 255, .35);
    border-right: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}
.ad-skip:disabled { cursor: default; color: rgba(255, 255, 255, .7); }
.ad-skip:not(:disabled):hover { background: rgba(0, 0, 0, .9); border-color: var(--yellow); color: var(--yellow); }
.ad-start {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 72px;
    height: 72px;
    border: 0;
    border-radius: 50%;
    background: var(--fg);
    color: var(--on-accent);
    font-size: 28px;
}
.ad-preview-badge { margin-left: 6px; color: var(--orange); }
.ad-status {
    position: absolute;
    inset: 0;
    margin: auto;
    height: fit-content;
    max-width: 80%;
    color: var(--fg-muted);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
}
.ad-status.is-error { color: var(--red); }
.ad-status:empty { display: none; }
.ad-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .2); }
.ad-progress-bar { height: 100%; width: 0; background: var(--yellow); }

/* ---------- Ad zones ---------- */
.adz { position: relative; display: flex; justify-content: center; margin: 0 auto; max-width: 100%; }
.adz img { display: block; max-width: 100%; height: auto; }
.adz iframe { max-width: 100%; }
.adz-label {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
    padding: 0 5px;
    background: rgba(0, 0, 0, .6);
    color: var(--fg-muted);
    font-size: 10px;
    pointer-events: none;
}
/* Height caps so an oversized image can't take over the page */
.adz-header img, .adz-under_player img { max-height: 120px; width: auto; }
.sticky-ad img { max-height: 90px; width: auto; }
.adz-sidebar img, .pause-ad img { max-height: 280px; width: auto; }
.overlay-ad img { max-height: 70px; width: auto; }
.adz-header { padding: 12px 20px 0; }
.adz-under_player { margin-top: 12px; }
.adz-sidebar { margin-bottom: 16px; }

.card-native .card-thumb { box-shadow: 0 0 0 1px var(--border); }
.card-native .card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.badge-sponsored { background: var(--fg); }

.sticky-ad {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    justify-content: center;
    padding: 6px 40px;
    background: var(--bg-header);
    border-top: 1px solid var(--border);
}
body.has-sticky-ad { padding-bottom: 104px; }

.zone-close {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 26px;
    height: 26px;
    padding: 0;
    background: rgba(0, 0, 0, .75);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    line-height: 1;
}
.zone-close:hover { border-color: var(--yellow); color: var(--yellow); }
.sticky-ad .zone-close { top: 50%; right: 10px; transform: translateY(-50%); }

/* Pause ad: centered box over the paused video */
.pause-ad {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .55);
    pointer-events: none;
}
.pause-ad[hidden], .overlay-ad[hidden] { display: none; }
.pause-ad > .adz { position: relative; max-width: 80%; pointer-events: auto; }
.pause-ad .zone-close { pointer-events: auto; top: 12px; right: 12px; }

/* Overlay: strip above the player's control bar */
.overlay-ad {
    position: absolute;
    left: 50%;
    bottom: 56px;
    z-index: 3;
    transform: translateX(-50%);
    max-width: calc(100% - 24px);
}
.overlay-ad .zone-close { top: -10px; right: -10px; }

/* Interstitial: full screen with a countdown close */
.interstitial {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(10, 9, 5, .92);
}
.interstitial[hidden] { display: none; }
.interstitial-box {
    max-width: min(820px, 100%);
    max-height: 100%;
    overflow: auto;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.interstitial-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 10px; font-size: 12px; }
.interstitial-close { padding: 6px 14px; background: var(--fg); border: 0; border-radius: 4px; color: var(--on-accent); font-weight: 700; }
.interstitial-close:disabled { background: var(--surface-2); color: var(--fg-muted); cursor: default; }
body.no-scroll { overflow: hidden; }

/* Zones admin */
.zones-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.zones-top p { margin: 0; font-size: 13px; }
.zones-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.zone-card { display: grid; gap: 10px; padding: 18px; }
.zone-card.is-on { border-color: var(--yellow); }
.zone-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.zone-head h2 { margin: 0; font-size: 15px; }
.zone-where { margin: 0; font-size: 12px; color: var(--fg-muted); }
.zone-card form { margin: 0; }
.zone-card .source-switch { flex-wrap: wrap; margin-bottom: 12px; }
.zone-card .source-switch label { padding: 6px 12px; font-size: 13px; }
.zone-banner-preview { display: block; max-width: 100%; max-height: 140px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 4px; }
.field-inline { grid-template-columns: 1fr 110px; align-items: center; }
.code-input { font-size: 12px; min-height: 100px; }
.ad-badge.is-off { border-color: var(--fg-dim); color: var(--fg-dim); }

/* ---------- Ad cookie consent ---------- */
.consent {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 150;
    display: grid;
    gap: 10px;
    max-width: 420px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 13px;
    animation: fade-in .3s ease both;
}
.consent p { margin: 0; color: var(--fg-muted); }
.consent-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Ads admin ---------- */
.ads-layout { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.ad-card {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.ad-card video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 4px; }
.ad-card.is-paused { opacity: .6; }
.ad-card-body { display: grid; gap: 8px; align-content: start; min-width: 0; }
.ad-card-head { display: flex; align-items: center; gap: 10px; }
.ad-badge { padding: 0 6px; border: 1px solid var(--green); border-radius: 2px; color: var(--green); font-size: 11px; }
.is-paused .ad-badge { border-color: var(--fg-dim); color: var(--fg-dim); }
.ad-card-vast {
    display: grid;
    place-content: center;
    gap: 4px;
    aspect-ratio: 16 / 9;
    background: repeating-linear-gradient(-45deg, var(--surface-2) 0 10px, var(--bg) 10px 20px);
    border-radius: 4px;
    text-align: center;
}
.ad-card-vast b { font-size: 22px; color: var(--yellow); }
.ad-card-vast span { font-size: 12px; color: var(--fg-muted); word-break: break-all; padding: 0 8px; }
code.ad-card-link { font-family: inherit; }
.ad-card-link { color: var(--fg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-card-link:hover { color: var(--yellow); }
.ad-card-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--fg-muted); }
.ad-card-stats b { color: var(--fg); }
.ad-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-card-actions form { margin: 0; }

/* ---------- Anonymous comments ---------- */
.watch-side h2 { display: flex; align-items: center; margin: 0 0 12px; font-size: 17px; font-weight: 700; }

.comment-form {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.comment-form textarea { min-height: 72px; }
.comment-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.comment {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
    animation: fade-in .3s ease both;
}
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 12px; }
.comment-head b { color: var(--yellow); font-size: 13px; }
.comment-admin .comment-head b { color: var(--orange); }
.comment-badge {
    padding: 0 6px;
    border: 1px solid var(--orange);
    border-radius: 2px;
    color: var(--orange);
    font-size: 11px;
}
.comment p { margin: 4px 0 0; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.comment-delete { margin-left: auto; padding: 0; background: none; border: 0; color: var(--fg-dim); font-size: 12px; }
.comment-delete:hover { color: var(--red); }
.comments-empty { padding: 8px 0; font-size: 13px; }

.avatar-letter.sm { width: 30px; height: 30px; font-size: 13px; }

.chip-edit { background: transparent; border-style: dashed; color: var(--fg-muted); }

.rank {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0 8px;
    background: rgba(29, 32, 33, .85);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--fg);
    font-size: 18px;
    font-weight: 800;
}
.rank { z-index: 2; border-radius: 8px; }
.rank-top { color: var(--orange); border-color: var(--orange); }

/* ---------- Admin panel ---------- */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.admin-tabs a {
    padding: 8px 16px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--fg-muted);
    white-space: nowrap;
}
.admin-tabs a:hover { color: var(--fg); }
.admin-tabs a.active { color: var(--yellow); border-bottom-color: var(--yellow); font-weight: 700; }

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

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
    display: grid;
    gap: 2px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.stat b { font-size: 24px; color: var(--yellow); }
.stat span { font-size: 12px; color: var(--fg-muted); }

.admin-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.admin-filters input { flex: 1 1 220px; }
.admin-filters select { flex: 0 1 200px; width: auto; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.admin-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-dim);
    border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 10px 12px; border-bottom: 1px dashed var(--border); vertical-align: middle; font-size: 13px; }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: var(--surface-2); }

.col-video { display: flex; align-items: center; gap: 12px; min-width: 0; }
.col-video > div { display: grid; min-width: 0; }
.admin-thumb {
    position: relative;
    display: block;
    flex-shrink: 0;
    width: 120px;
    aspect-ratio: 16 / 9;
    border-radius: 2px;
    overflow: hidden;
    background: var(--surface-2);
}
.admin-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.admin-title:hover { color: var(--orange); }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions form { display: inline; margin: 0; }

.admin-pagination { justify-content: center; margin-top: 20px; }

.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ---------- Category admin ---------- */
.panel-subtitle { margin: 28px 0 12px; font-size: 15px; }

.cat-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1.4fr) minmax(0, 1fr) 56px auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.cat-row-head { padding-top: 0; color: var(--fg-dim); font-size: 12px; }
.cat-edit { display: none; }
.cat-move, .cat-actions, .cat-actions form { display: flex; gap: 6px; margin: 0; }
.cat-count { text-align: center; color: var(--yellow); }
.cat-count:hover { color: var(--orange); }

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--fg-muted);
    font-size: 11px;
}
.btn-icon:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.btn-icon:disabled { opacity: .35; cursor: default; }

.cat-add { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; }

/* ---------- Error page ---------- */
.error-page { padding: 80px 20px; text-align: center; }
.error-page h1 { margin: 0; font-size: 56px; color: var(--orange); }
.error-page h2 { margin: 8px 0; }
.error-page p { color: var(--fg-muted); margin-bottom: 24px; }

/* ---------- Animations ---------- */
@keyframes blink { 50% { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

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

/* Large screens */
@media (min-width: 1700px) {
    .grid { grid-template-columns: repeat(5, 1fr); }
}

/* Laptops & tablets in landscape */
@media (max-width: 1200px) {
    .topbar { gap: 16px; }
    .main-nav { gap: 12px; }
    .grid { grid-template-columns: repeat(3, 1fr); }

    .ads-layout { grid-template-columns: 1fr; }

    /* Comments move under the player */
    .watch { grid-template-columns: 1fr; }
    .watch-side { max-width: 900px; }
}

/* Tablets in portrait */
@media (max-width: 960px) {
    .topbar { flex-wrap: wrap; gap: 12px 16px; padding: 14px 20px; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .main-nav { margin-left: auto; }
    .grid { grid-template-columns: repeat(2, 1fr); }
    .pager { grid-template-columns: 1fr; justify-items: center; text-align: center; margin-top: 28px; }
    .pagination { justify-content: center; flex-wrap: wrap; }

    /* Admin table becomes stacked cards */
    .stats { grid-template-columns: repeat(2, 1fr); }
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; }
    .admin-table { background: none; border: 0; }
    .admin-table thead { display: none; }
    .admin-table tr {
        display: grid;
        grid-template-columns: repeat(4, auto);
        justify-content: start;
        gap: 4px 20px;
        margin-bottom: 10px;
        padding: 12px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 8px;
    }
    .admin-table td { padding: 0; border: 0; }
    .admin-table td.col-video, .admin-table td.col-actions { grid-column: 1 / -1; }
    .admin-table td.col-video { display: flex; margin-bottom: 6px; }
    .admin-table td.col-actions { margin-top: 6px; text-align: left; }
    .admin-table td[data-label]::before { content: attr(data-label) ': '; color: var(--fg-dim); }
    .admin-title { max-width: none; white-space: normal; }
}

/* Phones */
@media (max-width: 600px) {
    .topbar { gap: 10px; padding: 10px 16px; }
    .logo-img { height: 34px; }
    .logo-x { font-size: 30px; }
    .logo-rest { font-size: 13px; letter-spacing: 1.5px; }
    .main-nav { gap: 12px; }
    .main-nav .nav-home { display: none; }  /* the logo already goes home */
    .topbar-actions { margin-left: auto; gap: 10px; }
    .btn-upload { padding: 6px 10px; }
    .avatar-letter { width: 34px; height: 34px; font-size: 14px; }
    .search { height: 40px; }
    .search button { padding: 0 12px; }

    .flash-stack { padding: 12px 16px 0; }
    .chips { gap: 8px; padding: 12px 16px; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
    .chip { padding: 7px 12px; scroll-snap-align: start; }
    .container { padding: 16px 16px 28px; }

    .grid { grid-template-columns: 1fr; gap: 12px; }
    .card-title { min-height: 0; margin-bottom: 8px; }

    .pager { padding: 14px 10px; }
    .pager-info .muted { display: none; }
    .btn-more { width: 100%; padding: 10px; }
    .pg-num { min-width: 40px; height: 40px; }
    .pg-nav { padding: 10px 6px; }

    .site-footer { flex-direction: column; padding: 20px 16px; }

    /* Watch: edge-to-edge player like the YouTube app */
    .watch { padding: 0 0 24px; gap: 16px; }
    .watch-main > :not(.player) { margin-left: 16px; margin-right: 16px; }
    .watch-side { padding-left: 16px; padding-right: 16px; }
    .player { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
    .watch-title { margin-top: 12px; font-size: 17px; }
    .watch-actions { margin-left: 0; }

    .container.auth { padding-top: 24px; }
    .panel { padding: 18px; }
    .dropzone { padding: 32px 12px; }
    .upload-preview { grid-template-columns: 1fr; }

    /* Category admin: name and slug full width, controls below */
    .cat-row-head { display: none; }
    .cat-row {
        grid-template-columns: auto 1fr auto;
        grid-template-areas: "name name name" "slug slug slug" "move count actions";
    }
    .cat-row > input[name="name"] { grid-area: name; }
    .cat-row > input[name="slug"] { grid-area: slug; }
    .cat-move { grid-area: move; }
    .cat-count { grid-area: count; text-align: left; }
    .cat-count::before { content: 'videos: '; color: var(--fg-dim); }
    .cat-actions { grid-area: actions; justify-content: flex-end; }
    .cat-add { grid-template-columns: 1fr; }

    .admin-table tr { grid-template-columns: repeat(2, auto); }
    .ad-card { grid-template-columns: 1fr; }
    .consent { left: 12px; right: 12px; bottom: 12px; max-width: none; }
    .zones-grid { grid-template-columns: 1fr; }
    .adz-header { padding: 10px 16px 0; }
    .sticky-ad { padding: 4px 36px; }
    body.has-sticky-ad { padding-bottom: 64px; }
    .overlay-ad { bottom: 48px; }
    .pause-ad > .adz { max-width: 90%; }
    .ad-skip { bottom: 16px; padding: 8px 12px; font-size: 13px; }
    .source-switch { display: flex; }
    .source-switch label { flex: 1; text-align: center; }
    .admin-thumb { width: 96px; }
    .admin-filters select, .admin-filters button, .admin-filters a { flex: 1 1 40%; }

    .error-page { padding: 48px 16px; }
    .error-page h1 { font-size: 44px; }
}

/* Very small phones */
@media (max-width: 380px) {
    .btn-label { display: none; }  /* upload button becomes just "+" */
    .logo-rest { letter-spacing: 1px; }
}

/* Touch screens */
@media (hover: none), (pointer: coarse) {
    .input, .search input { font-size: 16px; }  /* stops iOS from zooming into inputs */
    .card:hover { transform: none; box-shadow: none; }
    #shortcuts-link { display: none; }  /* keyboard shortcuts are useless here */
}
