:root {
  --blue: #1238b6;
  --blue-dark: #071f83;
  --sky: #eaf9ff;
  --pink: #ff5cac;
  --aqua: #47d9ee;
  --gold: #ffcf4d;
  --green: #37c88a;
  --ink: #11235c;
  --muted: #607099;
  --line: #dbe7ff;
  --white: #fff;
  --danger: #bd264c;
  --shadow: 0 18px 50px rgba(21, 61, 160, .14);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: ui-rounded, "Nunito", "Arial Rounded MT Bold", system-ui, sans-serif; background: radial-gradient(circle at 10% 10%, rgba(255,255,255,.95), transparent 25%), linear-gradient(145deg, #f4fcff, #e9eeff 55%, #fff7fb); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.admin-header { position: sticky; top: 0; z-index: 20; min-height: 86px; padding: 10px clamp(16px, 3vw, 42px); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(18,56,182,.12); }
.admin-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.admin-brand img { width: 64px; height: 64px; object-fit: contain; }
.admin-brand strong { display: block; font-size: 1.05rem; }
.admin-brand small { color: var(--muted); }
.admin-account { display: flex; gap: 12px; align-items: center; }
.admin-account button { border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; color: var(--blue); background: #fff; }
.admin-main { width: min(1480px, calc(100% - 28px)); margin: 26px auto 80px; }
.admin-login-card { width: min(520px, 100%); margin: 7vh auto; padding: clamp(28px, 6vw, 52px); text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 34px; box-shadow: var(--shadow); }
.admin-login-card img { width: 120px; height: 120px; object-fit: contain; }
.eyebrow { display: inline-block; color: var(--pink); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: .75rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: var(--blue-dark); font-size: clamp(2rem, 5vw, 3rem); }
h2 { color: var(--blue-dark); }
p { line-height: 1.55; }
.admin-login-card form, .admin-dialog form { display: grid; gap: 16px; text-align: left; }
label > span { display: block; margin-bottom: 7px; font-size: .82rem; font-weight: 900; color: var(--blue-dark); }
input, textarea, select { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--ink); background: #fff; outline: none; }
input:focus, textarea:focus, select:focus { border-color: #78a8ff; box-shadow: 0 0 0 4px rgba(70,130,255,.12); }
.primary-action, .secondary-action, .danger-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; border-radius: 999px; padding: 10px 18px; border: 0; font-weight: 900; text-decoration: none; }
.primary-action { color: #fff; background: linear-gradient(135deg, var(--blue), #6450db); box-shadow: 0 10px 22px rgba(18,56,182,.2); }
.secondary-action { color: var(--blue); border: 2px solid #cddcff; background: #fff; }
.danger-action { color: #fff; background: var(--danger); }
button:disabled { opacity: .55; cursor: wait; }
.back-link { display: inline-block; margin-top: 24px; color: var(--blue); }
.setup-warning, .privacy-banner { margin-top: 18px; padding: 15px 18px; border-radius: 16px; background: #fff7d7; border: 1px solid #f0d16d; text-align: left; }
.status-message { margin: 8px 0 0; padding: 12px 15px; border-radius: 14px; background: #edf4ff; }
.status-message[data-type="error"] { color: #8d1836; background: #fff0f3; }
.status-message[data-type="success"] { color: #075d40; background: #e7fff5; }
.admin-tabs { display: flex; gap: 7px; position: sticky; top: 98px; z-index: 15; width: fit-content; max-width: 100%; margin: 0 auto 24px; padding: 7px; overflow-x: auto; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 30px rgba(18,56,182,.1); }
.admin-tabs button { border: 0; border-radius: 999px; padding: 11px 18px; white-space: nowrap; color: var(--blue); background: transparent; font-weight: 900; }
.admin-tabs button.is-active { color: #fff; background: var(--blue); }
.admin-panel { display: none; }
.admin-panel.is-active { display: block; }
.panel-title-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-title-row h1 { margin: 3px 0; }
.panel-title-row p { margin: 0; color: var(--muted); }
.admin-card { margin-bottom: 22px; padding: clamp(18px, 3vw, 28px); background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 12px 36px rgba(18,56,182,.08); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-card { min-height: 120px; padding: 18px; border-radius: 22px; background: linear-gradient(145deg, #fff, #eff7ff); border: 1px solid var(--line); }
.summary-card span { color: var(--muted); font-size: .82rem; font-weight: 800; }
.summary-card strong { display: block; margin-top: 9px; color: var(--blue-dark); font-size: clamp(1.65rem, 4vw, 2.6rem); }
.summary-card small { color: var(--muted); }
.card-heading, .order-toolbar, .table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.card-heading h2, .order-toolbar h2 { margin-bottom: 4px; }
.card-heading p, .order-toolbar p { margin: 0; color: var(--muted); }
.status-pill { padding: 8px 13px; border-radius: 999px; background: #eef1f8; color: var(--muted); font-weight: 900; }
.status-pill.is-ready { background: #dbfff0; color: #06704a; }
.status-pill.is-error { background: #ffe8ee; color: #9c1d42; }
.status-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0 0; }
.status-list div { padding: 13px; border-radius: 15px; background: #f6f9ff; }
.status-list dt { color: var(--muted); font-size: .75rem; font-weight: 900; text-transform: uppercase; }
.status-list dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.inline-status { margin: 15px 0 0; color: var(--muted); }
.quick-guide ol { padding-left: 24px; margin-bottom: 0; line-height: 1.7; }
.order-toolbar { align-items: end; }
.order-toolbar label { min-width: 170px; }
.sortable-video-list { display: grid; gap: 9px; margin-top: 18px; }
.sortable-item { display: grid; grid-template-columns: auto 76px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid #e2ebff; border-radius: 17px; background: #fff; }
.sortable-item.is-dragging { opacity: .5; border-color: var(--pink); }
.drag-handle { border: 0; color: #7d8db6; background: transparent; font-size: 1.4rem; cursor: grab; }
.sortable-item img { width: 76px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: #eef4ff; }
.sortable-item strong { display: block; }
.sortable-item small { color: var(--muted); overflow-wrap: anywhere; }
.sort-buttons { display: flex; gap: 4px; }
.sort-buttons button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; color: var(--blue); background: #fff; }
.table-toolbar { margin-bottom: 15px; }
.admin-search { min-width: min(420px, 100%); }
.responsive-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 840px; }
.admin-table th { padding: 11px 10px; text-align: left; color: var(--muted); font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--line); }
.admin-table td { padding: 12px 10px; border-bottom: 1px solid #edf1fa; vertical-align: middle; }
.video-cell { display: flex; align-items: center; gap: 12px; min-width: 270px; }
.video-cell img { width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; background: #eef4ff; }
.video-cell strong, .video-cell small { display: block; }
.video-cell small { color: var(--muted); }
.tag-row { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { padding: 5px 8px; border-radius: 999px; background: #eef4ff; color: var(--blue); font-size: .72rem; font-weight: 900; }
.tag.featured { background: #fff0c8; color: #7d5000; }
.tag.favourite { background: #ffe8f5; color: #9c2266; }
.tag.unpublished { background: #f1f1f4; color: #60606d; }
.tag.missing { background: #ffe7e7; color: #9a2424; }
.object-key { max-width: 280px; color: var(--muted); font-family: ui-monospace, monospace; font-size: .76rem; overflow-wrap: anywhere; }
.icon-action { border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; color: var(--blue); background: #fff; font-weight: 900; }
.playlist-admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.playlist-admin-card { padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 10px 28px rgba(18,56,182,.08); }
.playlist-admin-card.is-dragging { opacity: .55; outline: 3px solid rgba(49,99,223,.28); }
.playlist-admin-order { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }
.playlist-position { min-width: 34px; color: var(--blue-dark); font-weight: 1000; }
.playlist-drag-hint { margin-right: auto; color: var(--muted); font-size: .78rem; font-weight: 900; cursor: grab; }
.playlist-admin-card h2 { margin-bottom: 6px; }
.playlist-admin-card p { min-height: 48px; color: var(--muted); }
.playlist-mini-posters { display: flex; margin: 15px 0; }
.playlist-mini-posters img { width: 70px; aspect-ratio: 16/9; object-fit: cover; margin-right: -13px; border: 3px solid #fff; border-radius: 10px; }
.analytics-actions { display: flex; gap: 9px; align-items: end; flex-wrap: wrap; }
.analytics-actions label { min-width: 120px; }
.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.analytics-grid .admin-card { margin: 0; }
.wide-card, .full-card { grid-column: 1 / -1; }
.metric-list { display: grid; gap: 11px; }
.metric-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(90px, 2fr) auto; gap: 10px; align-items: center; }
.metric-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-bar { height: 10px; border-radius: 999px; background: #e8efff; overflow: hidden; }
.metric-bar i { display: block; width: var(--bar); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--aqua), var(--blue), var(--pink)); }
.metric-row strong { color: var(--blue-dark); }
.top-video-row { display: grid; grid-template-columns: minmax(160px, 2fr) repeat(5, minmax(75px, 1fr)); gap: 9px; padding: 10px 0; border-bottom: 1px solid #edf1fa; align-items: center; }
.top-video-row.header { color: var(--muted); font-size: .72rem; text-transform: uppercase; font-weight: 900; }
.top-video-row small { color: var(--muted); }
.compact-table { min-width: 900px; }
.admin-dialog { width: min(900px, calc(100% - 24px)); max-height: calc(100dvh - 30px); overflow: auto; border: 0; border-radius: 28px; padding: 0; color: var(--ink); background: #fff; box-shadow: 0 28px 90px rgba(6,24,92,.3); }
.admin-dialog::backdrop { background: rgba(4,20,77,.64); backdrop-filter: blur(6px); }
.admin-dialog form { padding: clamp(24px, 5vw, 42px); }
.dialog-close { position: sticky; top: 14px; z-index: 3; float: right; margin: 14px 14px -58px 0; width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--blue); background: #edf3ff; font-size: 1.5rem; }
.video-edit-preview { display: flex; gap: 14px; align-items: center; padding: 12px; background: #f4f8ff; border-radius: 18px; }
.video-edit-preview img { width: 180px; aspect-ratio: 16/9; object-fit: cover; border-radius: 13px; }
.video-edit-preview strong, .video-edit-preview small { display: block; overflow-wrap: anywhere; }
.video-edit-preview small { margin-top: 6px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.full-field { grid-column: 1 / -1; }
.inline-input { display: flex; gap: 7px; }
.inline-input button { border: 1px solid var(--line); border-radius: 12px; color: var(--blue); background: #fff; }
.switch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.switch-grid label { display: flex; gap: 9px; padding: 13px; border: 2px solid var(--line); border-radius: 16px; }
.switch-grid input, .publish-checkbox input { width: 20px; height: 20px; }
.switch-grid strong, .switch-grid small { display: block; }
.switch-grid small { color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.dialog-spacer { flex: 1; }
.publish-checkbox { display: flex; align-items: center; gap: 8px; }
.playlist-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.playlist-builder section { min-width: 0; padding: 15px; background: #f6f9ff; border-radius: 18px; }
.playlist-video-picker { display: grid; gap: 7px; max-height: 430px; overflow: auto; margin-top: 10px; }
.picker-video { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.picker-video input { width: 20px; }
.picker-video img { width: 72px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; }
.picker-video span { min-width: 0; }
.picker-video strong, .picker-video small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.picker-video small { color: var(--muted); }
.admin-toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(430px, calc(100% - 40px)); padding: 13px 18px; border-radius: 16px; color: #fff; background: var(--blue-dark); box-shadow: var(--shadow); opacity: 0; transform: translateY(20px); pointer-events: none; transition: .2s ease; }
.admin-toast.is-visible { opacity: 1; transform: none; }
code { padding: 2px 6px; border-radius: 7px; background: #edf2ff; }
@media (max-width: 1050px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .playlist-admin-grid { grid-template-columns: repeat(2, 1fr); }
  .status-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .admin-header { min-height: 72px; padding: 7px 12px; }
  .admin-brand img { width: 52px; height: 52px; }
  .admin-brand small, .admin-account span { display: none; }
  .admin-main { width: min(100% - 18px, 1480px); margin-top: 15px; }
  .admin-tabs { top: 79px; width: 100%; justify-content: flex-start; border-radius: 18px; }
  .panel-title-row, .card-heading, .order-toolbar, .table-toolbar { align-items: stretch; flex-direction: column; }
  .panel-title-row > button, .order-toolbar > button { width: 100%; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card { min-height: 105px; }
  .status-list, .playlist-admin-grid, .analytics-grid, .form-grid, .switch-grid, .playlist-builder { grid-template-columns: 1fr; }
  .wide-card, .full-card, .full-field { grid-column: auto; }
  .sortable-item { grid-template-columns: auto 64px minmax(0, 1fr); }
  .sort-buttons { grid-column: 1 / -1; justify-content: flex-end; }
  .video-edit-preview { align-items: flex-start; flex-direction: column; }
  .video-edit-preview img { width: 100%; }
  .analytics-actions { width: 100%; }
  .analytics-actions > * { flex: 1 1 140px; }
  .top-video-row { grid-template-columns: minmax(150px, 2fr) repeat(2, minmax(70px, 1fr)); min-width: 520px; }
  .top-video-row > :nth-child(4), .top-video-row > :nth-child(5), .top-video-row > :nth-child(6) { display: none; }
}

.daily-activity {
  overflow-x: auto;
}
.daily-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.4fr) repeat(4, minmax(90px, 1fr));
  gap: 10px;
  min-width: 650px;
  padding: 10px 4px;
  border-bottom: 1px solid #edf1fa;
  align-items: center;
}
.daily-row.daily-header {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}

/* Homepage featured-hero status labels */
.tag.featured.hero {
  color: #ffffff;
  background: linear-gradient(135deg, #1238b6, #7e42e5);
  box-shadow: 0 5px 12px rgba(18, 56, 182, 0.22);
}

.tag.featured.reserve {
  color: #725000;
  background: #fff2c9;
  border: 1px dashed rgba(125, 80, 0, 0.28);
}

.hero-selection-preview {
  margin-top: 16px;
  padding: 15px;
  border: 2px solid rgba(49, 99, 223, 0.18);
  border-radius: 20px;
  background: linear-gradient(145deg, #f7fbff, #eef4ff);
}

.hero-selection-heading {
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hero-selection-heading strong,
.hero-selection-heading small {
  display: block;
}

.hero-selection-heading strong {
  color: var(--blue-dark);
  font-size: 1rem;
}

.hero-selection-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.hero-selection-count {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 0.76rem;
  font-weight: 1000;
}

.hero-selection-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hero-selection-slot {
  min-width: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: auto 78px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 2px solid #dfe8fb;
  border-radius: 15px;
  background: #fff;
}

.hero-selection-slot.is-filled {
  border-color: rgba(49, 99, 223, 0.42);
  box-shadow: 0 7px 17px rgba(18, 56, 182, 0.10);
}

.hero-selection-slot.is-empty {
  color: #7f8ca8;
  background: rgba(255, 255, 255, 0.68);
  border-style: dashed;
}

.hero-selection-slot img,
.hero-selection-placeholder {
  width: 78px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 9px;
  background: #e8f0ff;
}

.hero-selection-placeholder {
  display: grid;
  place-items: center;
  font-size: 1.6rem;
}

.hero-selection-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--pink));
  font-size: 0.75rem;
  font-weight: 1000;
}

.hero-selection-slot strong,
.hero-selection-slot small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-selection-slot strong {
  color: var(--blue-dark);
  white-space: nowrap;
  font-size: 0.83rem;
}

.hero-selection-slot small {
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.68rem;
}

@media (max-width: 950px) {
  .hero-selection-slots {
    grid-template-columns: 1fr;
  }
}


/* R2 upload diagnostics */
.upload-title-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#test-r2-upload[aria-busy="true"] {
  cursor: progress;
  opacity: 0.72;
}

@media (max-width: 720px) {
  .upload-title-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .upload-title-actions .secondary-action {
    min-height: 46px;
  }
}

.tag.mobile-ready {
  color: #075b3a;
  background: #d9fae9;
  border-color: #76d8a9;
}

.tag.mobile-missing {
  color: #83420b;
  background: #fff0d3;
  border-color: #f0bd69;
}


/* Cloudflare Stream adaptive-delivery controls */
.stream-card {
  border-color: rgba(62, 197, 255, .28);
  background:
    radial-gradient(circle at 100% 0, rgba(85, 211, 255, .13), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(242,250,255,.97));
}

.stream-card-actions,
.video-stream-editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stream-card-actions .inline-status {
  flex: 1 1 260px;
  margin: 0;
}

.status-pill.is-working {
  color: #173ea8;
  background: #e1f4ff;
  border-color: #75c7ef;
}

.status-pill.is-warning {
  color: #7d4d00;
  background: #fff3c9;
  border-color: #f1c95b;
}

.tag.stream-ready {
  color: #075c46;
  background: #dcfff2;
  border-color: #74d6b7;
}

.tag.stream-processing {
  color: #1645a5;
  background: #e3f1ff;
  border-color: #87bdec;
}

.tag.stream-error {
  color: #9a2341;
  background: #ffe4eb;
  border-color: #f39ab0;
}

.video-stream-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid rgba(59, 142, 229, .24);
  border-radius: 18px;
  background: linear-gradient(135deg, #effaff, #f7f5ff);
}

.video-stream-editor h3 { margin: 2px 0 5px; }
.video-stream-editor p { margin: 0; color: #405b94; line-height: 1.45; }
.video-stream-editor p[data-state="ready"] { color: #087456; font-weight: 800; }
.video-stream-editor p[data-state="working"] { color: #1d52b6; }
.video-stream-editor p[data-state="error"] { color: #a31f45; font-weight: 800; }

@media (max-width: 760px) {
  .video-stream-editor { grid-template-columns: 1fr; }
  .video-stream-editor-actions > button { flex: 1 1 100%; min-height: 46px; }
  .stream-card-actions > button { flex: 1 1 100%; min-height: 46px; }
}
