/* Yulduzcha creator studio: a calm desktop-first admin tool.
   Structure is carried by 1px hairlines and spacing. The warm star yellow is used only for the
   logo and the primary button. Body text uses the system UI stack (no external fonts, CSP). */

@font-face {
  font-family: "Nunito";
  src: url("fonts/Nunito-var.ttf") format("truetype");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Neutral scale */
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --line: #E3E6EB;
  --line-strong: #C9CFD8;
  --text: #1A2433;
  --text-2: #3D4A5C;
  --muted: #5B6676;

  /* Primary (navy) and brand accent (star yellow) */
  --primary: #1F3A5F;
  --primary-hover: #172D4B;
  --primary-tint: #E8EEF6;
  --accent: #FFD54F;
  --accent-hover: #FFB300;
  --on-accent: #1A2433;

  --danger: #B42318;
  --danger-hover: #912018;
  --danger-tint: #FEE4E2;

  /* Status chips: text on tint, all above 4.5:1 */
  --draft-bg: #EEF1F5;
  --draft-fg: #3D4A5C;
  --pending-bg: #FEF0C7;
  --pending-fg: #6B4300;
  --ok-bg: #DCF5E4;
  --ok-fg: #0F5132;
  --rej-bg: #FEE4E2;
  --rej-fg: #912018;

  /* Radius scale: 4 (hairlines, small bars), 8 (controls, chips, cells), 10 (containers), pill (badges). */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-pill: 999px;
  --radius-hair: 2px;
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.14);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Nunito", var(--font);
  --sidebar-w: 240px;

  /* Type scale (7 steps) and touch target */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-kpi: 28px;
  --hit: 44px;

  /* Chart series, thumbnail and media backgrounds, borders (aliases of the neutral scale) */
  --series-1: #2A78D6;
  --series-2: #EB6834;
  --thumb-bg: #E6EAF0;
  --media-bg: #0F1724;
  --border: var(--line);
  --border-strong: var(--line-strong);

  /* Card padding: one value for every card, 18px on a phone (see the 699px block) */
  --card-pad: 24px;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

img, video, svg { display: block; max-width: 100%; }

a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }

h1, h2, h3 { margin: 0; color: var(--text); font-weight: 650; line-height: 1.3; }
h1 { font-size: var(--fs-xl); letter-spacing: -0.01em; text-wrap: balance; overflow-wrap: anywhere; }
h2 { font-size: var(--fs-md); font-weight: 600; }
h3 { font-size: var(--fs-base); font-weight: 600; }
p { margin: 0; text-wrap: pretty; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 12px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); text-decoration: none;
}
.skip-link { box-shadow: none; }
.skip-link:focus { top: 12px; box-shadow: var(--shadow-pop); }

/* Headings and <main> take programmatic focus after navigation; they are not controls. */
#page-title:focus, #main:focus { outline: none; }

.num, .kpi-value, .metric-value, .tab-count, td.num, .stat-table td {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: min(280px, 86vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  overflow-y: auto;
  transform: translateX(-102%);
  transition: transform 0.2s ease;
}
body.nav-open .sidebar { transform: none; }
body.nav-open { overflow: hidden; }
.sidebar { overscroll-behavior: contain; }
body:not(.is-authed) .sidebar { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 12px;
  min-width: 0;
}
.logo { width: 24px; height: 24px; flex: 0 0 auto; fill: var(--accent); }
.brand-name {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: var(--fs-md);
  color: var(--text);
  line-height: 1.2;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
/* Drawer close button: shown only where the sidebar is a drawer (see the responsive block). */
.sidebar .drawer-close { display: none; position: absolute; top: 10px; right: 10px; }
.nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600; /* one weight for every item: the active state must not change the width */
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-tint); color: var(--primary); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  border: 0;
  padding: 0;
  background: rgba(16, 24, 40, 0.4);
  cursor: pointer;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-section {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: var(--fs-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-toggle { display: inline-flex; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.lang { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.lang-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--line-strong); }
.lang-btn[aria-pressed="true"] { background: var(--primary); color: #fff; }
.lang-btn:hover:not([aria-pressed="true"]) { background: var(--surface-2); }

.account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 700;
  overflow: hidden;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-name {
  max-width: 180px;
  font-size: var(--fs-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}
.page.page-auth { max-width: none; padding: 0; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.lede { margin-top: 6px; color: var(--muted); max-width: 68ch; text-wrap: pretty; }
.section-title { margin: 0 0 12px; font-size: var(--fs-md); }

/* ---------------------------------------------------------------- primitives */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--card-pad);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.meta { color: var(--muted); font-size: var(--fs-sm); }
.hint { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.req { color: var(--danger); }
.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--primary-tint);
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
}

.fact-list {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: 10px 20px;
  margin: 0;
  font-size: var(--fs-base);
}
.fact-list dt { color: var(--muted); }
.fact-list dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.chip-draft, .chip-unpublished, .chip-neutral { background: var(--draft-bg); color: var(--draft-fg); }
.chip-pending { background: var(--pending-bg); color: var(--pending-fg); }
.chip-approved, .chip-published { background: var(--ok-bg); color: var(--ok-fg); }
.chip-rejected { background: var(--rej-bg); color: var(--rej-fg); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover:not(:disabled) { background: var(--danger-tint); color: var(--danger-hover); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-wide { width: 100%; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.actions-end { justify-content: flex-end; }
.actions-center { justify-content: center; }

/* Forms */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #7A8494; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }

.form { display: flex; flex-direction: column; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}
.field > label, .field > legend, .field-label {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  padding: 0;
}
.field > legend { margin-bottom: 4px; float: left; width: 100%; }
.field > legend + * { clear: left; }
.field-error { color: var(--danger); font-size: var(--fs-sm); margin: 0; }
.field-error[hidden] { display: none; }
.field input[type="file"] { font-size: var(--fs-sm); color: var(--text-2); }
input[type="file"] { font-size: var(--fs-sm); color: var(--text-2); }
input[type="file"]::file-selector-button {
  min-height: 40px;
  margin-right: 12px;
  padding: 0 16px;
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-2); }
input[type="file"]::file-selector-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-base);
}
.choice:hover { background: var(--surface-2); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); color: var(--primary); font-weight: 600; }

.form-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-tint);
  color: var(--danger-hover);
  font-size: var(--fs-base);
}

.avatar-row { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; }
.avatar-row .field { flex: 1 1 auto; margin: 0; }
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-tint);
  flex: 0 0 auto;
}
.avatar-empty {
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: var(--fs-kpi);
  font-weight: 700;
}

.progress-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.progress-wrap .hint { margin: 0; color: var(--text-2); font-weight: 600; }
progress {
  width: 100%;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: var(--radius-xs);
  background: var(--line);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--primary); }
progress::-moz-progress-bar { background: var(--primary); }

/* ---------------------------------------------------------------- states, toasts, dialog */

.loading { color: var(--muted); }

.state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.state h2 { font-size: var(--fs-lg); }
.state p { color: var(--muted); max-width: 52ch; }
.state .actions { justify-content: center; margin-top: 12px; }

.state.state--inline,
.empty-inline {
  display: block;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 0;
  border-radius: var(--radius-sm);
}
.state--inline h2 { font-size: var(--fs-base); }
.state--inline p { max-width: none; }

.toasts {
  position: fixed;
  bottom: 24px; /* bottom, so a toast never covers a page heading or the topbar */
  right: 24px;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-pop);
}
.toast p { flex: 1 1 auto; font-size: var(--fs-base); }
.toast-error { background: #7A271A; }
.toast-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: pointer;
}
.toast-close:hover { background: rgba(255, 255, 255, 0.14); }
.toast-close:focus-visible { outline-color: #fff; }

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: rgba(16, 24, 40, 0.45); }
.dialog-body { display: grid; gap: 12px; padding: 24px; }
.dialog-body h2 { font-size: var(--fs-lg); }
.dialog-body p { color: var(--text-2); }
.dialog-body .actions { margin-top: 8px; }

/* ---------------------------------------------------------------- page heads, KPIs */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi, .metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.kpi-value, .metric-value { font-size: var(--fs-kpi); font-weight: 650; line-height: 1.2; color: var(--text); overflow-wrap: anywhere; }
.kpi-label, .metric-label { color: var(--muted); font-size: var(--fs-sm); }
.kpi-note { color: var(--muted); font-size: var(--fs-xs); }

.chart-card { margin-bottom: 24px; }
/* Realtime, traffic sources, retention (stats.js) */
.stats-block { margin-bottom: 24px; display: grid; gap: 8px; min-width: 0; }
.stats-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stats-pair .stats-block { align-content: start; }
.realtime-bars { width: 100%; height: 64px; display: block; }
.realtime-bars .bar { fill: var(--series-1); }
.realtime-bars .bar.is-hidden { fill: var(--line-strong); }
.retention-curve { width: 100%; height: 140px; display: block; border-bottom: 1px solid var(--line); }
.stats-pair { align-items: start; }
.mini-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.mini-table th, .mini-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.mini-table thead th { color: var(--muted); font-weight: 600; }
.mini-table tbody th { font-weight: 500; }
.mini-table .num { text-align: right; white-space: nowrap; }
.mini-table tbody tr:last-child > * { border-bottom: 0; }
.retention-curve polyline { fill: none; stroke: var(--series-1); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart { overflow-x: auto; }
.bar-chart { width: 100%; height: auto; }
.bar-chart .grid-line { stroke: var(--line); stroke-width: 1; }
.bar-chart .bar { fill: var(--primary); }
.bar-chart .bar-value { fill: var(--text); font-size: var(--fs-xs); font-weight: 600; text-anchor: middle; }
.bar-chart .axis, .bar-chart .bar-label { fill: var(--muted); font-size: var(--fs-xs); }
.bar-chart .bar-label { text-anchor: middle; }
.bar-chart .axis { text-anchor: end; }

/* ---------------------------------------------------------------- tables (desktop) and cards (phone) */

.table-wrap {
  position: relative; /* clips the visually hidden column header inside the scroller */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.data-table th {
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td.num { text-align: right; white-space: nowrap; }
.data-table th.num { text-align: right; }
.cell-main { width: 100%; min-width: 280px; }
.cell-action { text-align: right; white-space: nowrap; }

.row-main { display: flex; align-items: flex-start; gap: 16px; min-width: 0; }
.row-text { min-width: 0; flex: 1 1 auto; }
.video-title { font-size: var(--fs-base); font-weight: 600; overflow-wrap: anywhere; }
.video-title a { color: var(--text); text-decoration: none; }
.video-title a:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.row-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reason { margin-top: 6px; color: var(--rej-fg); font-size: var(--fs-sm); overflow-wrap: anywhere; }

.thumb {
  position: relative;
  flex: 0 0 120px;
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--thumb-bg);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.thumb-empty svg { width: 22px; height: 22px; fill: currentColor; }

.stat-title { font-size: var(--fs-base); overflow-wrap: anywhere; }

/* Status banner on the video detail page */
.banner { display: grid; gap: 4px; padding: 14px 16px; margin-bottom: 20px; border-radius: var(--radius); }
.banner-title { font-weight: 600; }
.banner-rejected { background: var(--rej-bg); color: var(--rej-fg); }
.banner-rejected .reason { margin: 0; color: var(--text); }
.banner-rejected .meta { color: var(--rej-fg); }
.banner-pending { background: var(--pending-bg); color: var(--pending-fg); }
.banner-approved { background: var(--ok-bg); color: var(--ok-fg); }
.banner p { font-size: var(--fs-base); }

/* Filter tabs above the video list */
.tabs,
.filter-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-base);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current="true"], .tab[aria-current="page"], .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }
.tab-count {
  min-width: 24px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: 20px;
  text-align: center;
}
.tab[aria-current="true"] .tab-count { background: var(--primary-tint); border-color: transparent; color: var(--primary); }

/* Stats table rows are .stat-item, so the same responsive rules apply */
.stat-table td.num { font-size: var(--fs-base); }

/* ---------------------------------------------------------------- upload form */

.card-form { padding: var(--card-pad); }

.submission {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  column-gap: 32px;
  align-items: start;
}
.submission > .field-drop,
.submission > .progress-wrap,
.submission > .form-alert,
.submission > .form-actions { grid-column: 1 / -1; }
.form-main { grid-column: 1; min-width: 0; }
.form-side { grid-column: 2; min-width: 0; }

.field-drop { margin-bottom: 24px; }
.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 176px;
  padding: 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.dropzone:hover, .dropzone.is-over { background: var(--primary-tint); border-color: var(--primary); }
.dropzone:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.dropzone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  border: 0;
}
.dropzone-body { display: grid; justify-items: center; gap: 6px; text-align: center; pointer-events: none; }
.dropzone-icon { width: 36px; height: 36px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.dropzone-sub { color: var(--text-2); font-size: var(--fs-base); }
.dropzone-file { margin-top: 6px; color: var(--primary); font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.dropzone-file:empty { display: none; }

.side-card {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.side-title { margin-bottom: 12px; font-size: var(--fs-base); font-weight: 600; }
.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--thumb-bg);
  overflow: hidden;
}
.preview img, .preview video { width: 100%; height: 100%; object-fit: cover; }
.preview-empty { padding: 12px; color: var(--muted); font-size: var(--fs-sm); text-align: center; }
.rules { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: var(--text-2); font-size: var(--fs-sm); }
.form-actions { margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Detail page (read-only): metadata left, player right */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  gap: 24px;
  align-items: start;
}
.media-frame {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--thumb-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-frame video, .media-frame img { width: 100%; height: 100%; object-fit: contain; background: var(--media-bg); }
.media-col .side-title { margin-bottom: 8px; }
.media-col .media-frame + .side-title { margin-top: 16px; }
.media-frame.thumb { flex: none; width: 100%; border-radius: var(--radius-sm); }
.media-frame .thumb-empty { position: static; }

/* ---------------------------------------------------------------- moderation split view */

.review-split {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.queue-col { min-width: 0; }
.queue-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.queue-list li + li { border-top: 1px solid var(--line); }
.queue-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.queue-item:hover { background: var(--surface-2); }
.queue-item[aria-current="true"] { background: var(--primary-tint); }
.queue-title { font-weight: 600; font-size: var(--fs-base); overflow-wrap: anywhere; }
.queue-item .meta { font-size: var(--fs-xs); }

.review-pane { min-width: 0; }
.review-card {
  padding: var(--card-pad);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.review-media video {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: var(--radius-sm);
  background: var(--media-bg);
}
.review-title { margin-top: 18px; font-size: var(--fs-lg); overflow-wrap: anywhere; }
.review-info .meta { margin-top: 2px; }
.review-info .meta + .meta { margin-top: 8px; }
.review-info .fact-list { margin-top: 18px; }
.reject-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------- dashboard */

.recent-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
}
.recent-item + .recent-item { border-top: 1px solid var(--line); }
.recent-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; text-decoration: none; }
.recent-title:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.dash-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 32px 0 12px; }
.dash-head-row .section-title { margin: 0; }

/* ---------------------------------------------------------------- auth: split screen on desktop */

.auth-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}
.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 56px 56px;
  background: var(--primary);
  color: #fff;
  overflow: hidden;
}
.auth-brand-mark { display: flex; align-items: center; gap: 10px; font-family: var(--font-brand); font-weight: 800; font-size: var(--fs-lg); }
.auth-brand-mark .logo { width: 28px; height: 28px; }
.auth-brand-sentence { font-size: var(--fs-xl); line-height: 1.4; font-weight: 600; max-width: 30ch; text-wrap: balance; }
.auth-benefits { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; max-width: 44ch; }
.auth-benefits li { position: relative; padding-left: 22px; color: #E4EBF5; font-size: var(--fs-md); }
.auth-benefits li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.auth-mascot { position: absolute; right: 40px; bottom: 32px; width: 120px; height: auto; opacity: 0.95; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: var(--surface);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: var(--fs-xl); }
.auth-card .lede { margin-bottom: 24px; }
.auth-card .form { gap: 0; }
.auth-switch { margin-top: 20px; color: var(--muted); font-size: var(--fs-base); text-align: center; }

/* ---------------------------------------------------------------- responsive */

@media (min-width: 1024px) {
  body.is-authed .app-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  body.is-authed .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: none;
    transition: none;
    width: auto;
    box-shadow: none;
  }
  .menu-toggle { display: none; }
  .scrim { display: none !important; }
}

@media (max-width: 1023px) {
  .topbar { padding: 8px 16px; }
  .page { padding: 24px 24px 48px; }
  .sidebar { box-shadow: var(--shadow-pop); }
  .review-split { grid-template-columns: minmax(0, 1fr); }
  .queue-list { display: flex; overflow-x: auto; }
  .queue-list li { flex: 0 0 240px; }
  .queue-list li + li { border-top: 0; border-left: 1px solid var(--line); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .submission { grid-template-columns: minmax(0, 1fr); }
  .form-main, .form-side { grid-column: 1; }
  .auth-brand { padding: 40px 32px; }
  .auth-mascot { width: 96px; }
}

@media (max-width: 899px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .auth-brand { padding: 28px 24px; gap: 12px; }
  .auth-brand-sentence { font-size: var(--fs-lg); }
  .auth-benefits, .auth-mascot { display: none; }
  .auth-panel { padding: 32px 20px 40px; }
}

@media (max-width: 699px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar-section { display: none; }
  .account-name { display: none; }
  .page { padding: 16px 16px 40px; }
  .page-head { margin-bottom: 18px; }
  h1 { font-size: var(--fs-xl); }
  :root { --card-pad: 18px; }
  .kpi-value, .metric-value { font-size: var(--fs-xl); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Tables become stacked cards */
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tbody tr {
    margin-bottom: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .data-table tbody tr:hover { background: var(--surface); }
  .data-table td { padding: 5px 0; border: 0; text-align: left; }
  .data-table td[data-label] { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .data-table td::before {
    content: attr(data-label);
    display: block;
    flex: none;
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 600;
  }
  .data-table td.num { text-align: left; }
  .data-table td.cell-main { min-width: 0; padding-bottom: 10px; }
  .data-table td.cell-main::before, .data-table td.cell-action::before { display: none; }
  .cell-action { text-align: left; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 6px; }
  .thumb { flex-basis: 96px; width: 96px; }
  .row-desc { -webkit-line-clamp: 1; }
  .recent-item { grid-template-columns: minmax(0, 1fr) auto; }
  .recent-item .meta { grid-column: 1 / -1; }

  .actions { margin-top: 12px; }
  .actions .btn { flex: 1 1 auto; }
  .actions-end .btn { flex: 1 1 auto; }
  .avatar-row { flex-direction: column; align-items: flex-start; }
  .choice { flex: 1 1 auto; justify-content: center; }
  .choices { gap: 6px; }
  .toasts { right: 12px; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; }
  .dialog-body { padding: 20px; }
  .dash-head-row { margin-top: 24px; }
  .chart { overflow-x: auto; }
  .bar-chart { min-width: 620px; }
  .filter-tabs { margin-left: -4px; margin-right: -4px; }
}

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

/* poster picker: native input kept focusable but visually hidden, localized button */
.file-pick { display: flex; align-items: center; gap: 10px; min-width: 0; position: relative; }
.file-pick-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-pick-input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.file-pick label { cursor: pointer; margin: 0; }
.file-pick-name { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------------------------------------------------------------- additions */

/* Password reveal (login and signup) */
.input-wrap { position: relative; }
.input-wrap input { padding-right: 84px; }
.field-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.field-toggle:hover { background: var(--surface-2); }

/* Busy state on submit buttons: the label stays, a spinner runs */
.spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Person silhouette for avatars without a name */
.person-icon { width: 1em; height: 1em; fill: currentColor; }
.avatar-empty .person-icon { width: 48px; height: 48px; }
.account-avatar .person-icon { width: 16px; height: 16px; }

/* Row actions: edit and delete share one size; the slot keeps the edit button in its column */
.row-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; align-items: center; gap: 8px; }
.row-actions .btn-danger-text { min-width: 92px; }
.row-slot { display: inline-block; flex: 0 0 auto; width: 92px; }

/* Media that could not get a token */
.media-missing { display: flex; align-items: center; justify-content: center; padding: 8px; text-align: center; line-height: 1.3; }

/* Detail page footer: the back link lines up with the card edge */
.detail-foot { padding-top: 16px; margin-top: 24px; border-top: 1px solid var(--line); }
.detail-foot .btn-ghost { margin-left: -16px; }
.detail-foot .btn-danger-text { margin-left: auto; }

/* Dashboard: rejected items that need the creator's action */
.attention { margin-bottom: 24px; }
.attention .section-title { margin-bottom: 12px; }
.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.attention-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 16px;
}
.attention-item + .attention-item { border-top: 1px solid var(--line); }
.attention-text { min-width: 0; flex: 1 1 260px; }
.attention-title { font-weight: 600; overflow-wrap: anywhere; }
.attention-reason { margin-top: 4px; color: var(--rej-fg); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.attention-reason strong { font-weight: 600; }

/* Tablet: the format and age columns go, so the date stays visible */
@media (min-width: 700px) and (max-width: 1239px) {
  .col-optional { display: none; }
}
@media (min-width: 700px) {
  .col-ages { white-space: nowrap; }
}

/* Drawer: the sidebar has its own close button below 1024px */
@media (max-width: 1023px) {
  .sidebar .drawer-close { display: inline-grid; place-items: center; }
  .sidebar .brand { padding-right: 52px; }
}

@media (max-width: 699px) {
  /* Upload and edit: the action bar stays at the bottom of the screen while scrolling */
  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 8px -18px -18px;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .row-actions { justify-content: flex-start; }
  .row-slot { display: none; }
  .detail-foot .btn-danger-text { margin-left: 0; }
}

/* Touch: targets of 44px and no double-tap zoom delay on a coarse pointer (hybrid laptops keep the compact sizes) */
@media (pointer: coarse) {
  .btn, .btn-sm, .lang-btn, .nav a, .choice, .icon-btn, .toast-close, .field-toggle, .tab, .queue-item {
    min-height: var(--hit);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }
  .icon-btn, .toast-close { width: var(--hit); height: var(--hit); }
  .lang-btn { padding: 0 14px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select {
    min-height: var(--hit);
  }
}

/* Tablet table: narrower thumbnail and title minimum so the action column fits the wrapper */
@media (min-width: 700px) and (max-width: 1239px) {
  .data-table .thumb { flex-basis: 96px; width: 96px; }
  .data-table .cell-main { min-width: 0; }
  .row-actions .btn-danger-text { min-width: 0; }
  .row-slot { width: 0; }
}

/* ---------------------------------------------------------------- shared components (core/markup.js) */

/* Segmented control: a filter or range inside a form (radio group). The active choice is tinted, not filled. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 100%;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.segmented-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.segmented-item:hover { background: var(--surface-2); color: var(--text); }
.segmented-item:has(input:checked) { background: var(--primary-tint); color: var(--primary); }
.segmented-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.segmented-item:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (pointer: coarse) { .segmented-item { min-height: var(--hit); } }

/* Filter bar: one grid for every row of filters (search, selects, apply). */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 16px;
  align-items: end;
  margin: 0 0 16px;
}
.filter-bar .field, .filter-bar .filter-field { margin: 0; max-width: none; }

/* Section header: a titled block above a list or table, with an optional action on the right. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-head .section-title { margin: 0; }

/* KPI tiles on one row share a height. */
.kpis { grid-auto-rows: 1fr; }
.kpi, .metric { height: 100%; }
.kpi-note { min-height: 2lh; }

/* Loading placeholder (loadingHTML): blocks the size of the content, so the page does not jump. The shimmer moves a
   pseudo-element with transform. Reduced motion stops it (the global rule above). */
.skel-stack { display: grid; gap: 12px; width: 100%; margin-top: 16px; }
.skel {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  transform: translateX(-100%);
  animation: skel 1.4s ease-in-out infinite;
}
.skel-line { height: 16px; width: 40%; }
.skel-block { height: 96px; border-radius: var(--radius); }
@keyframes skel { to { transform: translateX(100%); } }
