:root {
  color-scheme: light;
  --bg: #faf5f3;
  --panel: #ffffff;
  --ink: #2b2122;
  --muted: #776a6b;
  --line: #ede2df;
  --brand: #b76e79;
  --brand-strong: #9d5b66;
  --brand-ink: #ffffff;
  --brand-soft: #f9e9ec;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --live: #175cd3;
  --live-bg: #eff8ff;
  --skip: #667085;
  --skip-bg: #f2f4f7;
  --danger: #b42318;
  --radius: 14px;
  --grad: linear-gradient(135deg, #b76e79 0%, #c98a7d 55%, #d9a878 100%);
  --shadow: 0 1px 2px rgba(43, 33, 34, 0.04), 0 6px 18px rgba(43, 33, 34, 0.06);
  --shadow-lg: 0 10px 30px rgba(183, 110, 121, 0.16);
  --ring: 0 0 0 3px rgba(183, 110, 121, 0.18);
  --ink-soft: #344054;
  --accent-border: #ecc9cd;
  --accent-bg: #fdf7f6;
  --accent-text: #8c4a55;
  --danger-border: #fecdca;
  --danger-hover: #fffbfa;
  --header-bg: rgba(255, 255, 255, 0.85);
  --glow: #f9e9ec;
  --toast-bg: #2b2122;
  --toast-fg: #ffffff;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--glow) 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

.appbar {
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.appbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand .dot {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--grad);
  box-shadow: 0 4px 10px rgba(183, 110, 121, 0.35);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  color: var(--muted);
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 9px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}

.nav a:hover {
  text-decoration: none;
  background: var(--brand-soft);
  color: var(--brand);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.btn-logout {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 13px;
}

.btn-logout:hover {
  background: var(--bg);
}

/* ---------- Cards & buttons ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 18px 0;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.card .sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(183, 110, 121, 0.28);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(183, 110, 121, 0.34);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--brand-soft);
  border-color: var(--accent-border);
}

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

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

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Forms ---------- */
label.field {
  display: block;
  margin: 13px 0;
}

label.field span {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 5px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 13px 0;
  font-size: 14px;
}

.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
}

/* ---------- Auth ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(900px 500px at 50% -10%, var(--glow) 0%, transparent 60%), var(--bg);
}

.auth-card {
  background: var(--panel);
  width: 100%;
  max-width: 410px;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: 34px;
}

.auth-card .brand {
  justify-content: center;
  font-size: 20px;
  margin-bottom: 6px;
}

.auth-card .sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 14px;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Feed box ---------- */
.feedbox {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--brand-soft);
  border: 1px dashed var(--accent-border);
  border-radius: 10px;
  padding: 8px 8px 8px 14px;
  margin: 14px 0;
}

.feedbox code {
  flex: 1;
  font-size: 13px;
  color: var(--accent-text);
  overflow-wrap: anywhere;
}

/* ---------- Episodes ---------- */
.ep-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ep {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ep:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.ep img.thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
}

.thumbph {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  flex: none;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 700;
}

.ep .body {
  flex: 1;
  min-width: 0;
}

.ep h3 {
  margin: 0 0 2px;
  font-size: 15.5px;
}

.ep .meta {
  color: var(--muted);
  font-size: 12.5px;
}

.ep p.desc {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ep .actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pill.live {
  background: var(--ok-bg);
  color: var(--ok);
}

.pill.draft {
  background: var(--skip-bg);
  color: var(--skip);
}

.status-live {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-in-review {
  background: var(--live-bg);
  color: var(--live);
}

.status-not-submitted {
  background: var(--skip-bg);
  color: var(--skip);
}

.status-skipped {
  background: var(--line);
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 42px 20px;
  margin: 18px 0;
}

/* ---------- Dropzones ---------- */
.drop {
  border: 1.5px dashed var(--accent-border);
  background: var(--accent-bg);
  border-radius: 12px;
  padding: 16px;
  margin: 8px 0;
}

.drop .row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drop input[type="file"] {
  display: none;
}

.file-pick {
  flex: 1;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-size {
  color: var(--muted);
  font-size: 12px;
}

.progress {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.progress div {
  height: 100%;
  width: 0%;
  background: var(--grad);
  transition: width 0.2s;
}

.drop img.preview {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
}

/* ---------- Distribution grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 6px;
}

.dir {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.dir:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.dir .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dir-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dir h3 {
  margin: 0;
  font-size: 14.5px;
}

.dir p {
  margin: 0;
  font-size: 12.8px;
  color: var(--muted);
  flex: 1;
}

.dir .bottom {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dir select {
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 9px;
}

.dir a.portal {
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- Analytics ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stats-grid .stat {
  text-align: center;
  padding: 18px;
  margin: 0;
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  padding-top: 8px;
}

.bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.bar {
  width: 100%;
  max-width: 22px;
  background: var(--grad);
  border-radius: 4px 4px 0 0;
}

.bar-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

table.analytics {
  width: 100%;
  border-collapse: collapse;
}

table.analytics th,
table.analytics td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

table.analytics th {
  color: var(--muted);
  font-weight: 600;
}

table.analytics td.num,
table.analytics th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Toast ---------- */
#toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-fg);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s ease;
}

.toast.err {
  background: var(--danger);
  color: #fff;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

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

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 2px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 23px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

@media (max-width: 640px) {
  .appbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
  }

  .nav {
    order: 3;
    width: 100%;
    margin: 0;
  }

  .row2 {
    grid-template-columns: 1fr;
  }

  .auth-card {
    margin: 10px;
  }

  .ep {
    flex-wrap: wrap;
  }

  .dir {
    min-width: 0;
  }

  .wrap {
    padding: 0 14px 48px;
  }
}

/* ---------- Theme toggle ---------- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-icon:hover {
  background: var(--brand-soft);
  border-color: var(--accent-border);
}

.theme-float {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171213;
  --panel: #221b1c;
  --ink: #ede3e4;
  --muted: #a7979a;
  --line: #3a3031;
  --brand: #cd8a93;
  --brand-strong: #dd9aa3;
  --brand-soft: #3a272b;
  --ok: #4cc38a;
  --ok-bg: #12312a;
  --warn: #f0a35a;
  --warn-bg: #33261a;
  --live: #6ea8ff;
  --live-bg: #16233a;
  --skip: #9aa3ad;
  --skip-bg: #272b30;
  --danger: #f26d6d;
  --ink-soft: #c9bbbc;
  --accent-border: #5a4146;
  --accent-bg: #2a2022;
  --accent-text: #e0a2ab;
  --danger-border: #5a2a2a;
  --danger-hover: #2a1b1b;
  --header-bg: rgba(23, 18, 19, 0.85);
  --glow: #3a272b;
  --toast-bg: #0d0a0b;
  --toast-fg: #ffffff;
  --grad: linear-gradient(135deg, #b76e79 0%, #c98a7d 55%, #d9a878 100%);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(205, 138, 147, 0.25);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171213;
    --panel: #221b1c;
    --ink: #ede3e4;
    --muted: #a7979a;
    --line: #3a3031;
    --brand: #cd8a93;
    --brand-strong: #dd9aa3;
    --brand-soft: #3a272b;
    --ok: #4cc38a;
    --ok-bg: #12312a;
    --warn: #f0a35a;
    --warn-bg: #33261a;
    --live: #6ea8ff;
    --live-bg: #16233a;
    --skip: #9aa3ad;
    --skip-bg: #272b30;
    --danger: #f26d6d;
    --ink-soft: #c9bbbc;
    --accent-border: #5a4146;
    --accent-bg: #2a2022;
    --accent-text: #e0a2ab;
    --danger-border: #5a2a2a;
    --danger-hover: #2a1b1b;
    --header-bg: rgba(23, 18, 19, 0.85);
    --glow: #3a272b;
    --toast-bg: #0d0a0b;
    --toast-fg: #ffffff;
    --grad: linear-gradient(135deg, #b76e79 0%, #c98a7d 55%, #d9a878 100%);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
    --ring: 0 0 0 3px rgba(205, 138, 147, 0.25);
  }
}