:root {
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f0efec; --border: #e3e1dc;
  --text: #1d1c1a; --muted: #6f6b63; --accent: #e5484d; --accent-ink: #ffffff;
  --accent-soft: #fdecec; --ok: #1f8a4c; --ok-soft: #e6f4ec; --warn: #a15c00; --warn-soft: #fdf1dc;
  --info: #2457c5; --info-soft: #e8eefb; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1c1b; --surface-2: #262523; --border: #33312e;
    --text: #f1efea; --muted: #a39e94; --accent: #ff5a5f; --accent-soft: #3a1d1e;
    --ok: #4cc27f; --ok-soft: #173225; --warn: #f0a640; --warn-soft: #3a2a12;
    --info: #7da2ff; --info-soft: #1b2440; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1c1b; --surface-2: #262523; --border: #33312e;
  --text: #f1efea; --muted: #a39e94; --accent: #ff5a5f; --accent-soft: #3a1d1e;
  --ok: #4cc27f; --ok-soft: #173225; --warn: #f0a640; --warn-soft: #3a2a12;
  --info: #7da2ff; --info-soft: #1b2440; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 "Plus Jakarta Sans", system-ui, sans-serif; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--accent); font-size: 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.icon { padding: 8px 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-size: 12px; color: var(--muted); font-weight: 500; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 24px; margin: 18px 0 4px; }
.login-card .btn { margin-top: 18px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.logo-mark::after { content: ""; position: absolute; left: 11px; top: 8px; border-left: 9px solid #fff;
  border-top: 6px solid transparent; border-bottom: 6px solid transparent; }

/* layout */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 16px; display: flex;
  flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.switcher-box { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.switcher-box select { font-weight: 600; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); object-fit: cover; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; text-decoration: none;
  font-weight: 500; color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.quota { margin-top: auto; background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 13px; }
.quota-top { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--ok); border-radius: 99px; transition: width .3s; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 20px; }
.spacer { flex: 1; }
#menuBtn { display: none; }
.view { padding: 24px 28px 60px; max-width: 1180px; }

/* banners */
.banner { margin: 16px 28px 0; padding: 12px 16px; border-radius: 12px; font-size: 14px; display: flex; gap: 10px; }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(3, 1fr); margin: 18px 0; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.channel-head { display: flex; gap: 16px; align-items: center; }
.channel-head img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.channel-head h1 { font-size: 22px; }
.two-col { grid-template-columns: 1.4fr 1fr; align-items: start; }

/* video list */
.vlist { display: flex; flex-direction: column; }
.vrow { display: grid; grid-template-columns: 160px 1fr auto; gap: 16px; align-items: center; padding: 12px 0;
  border-top: 1px solid var(--border); }
.vrow:first-child { border-top: 0; }
.thumb { width: 160px; aspect-ratio: 16/9; border-radius: 10px; object-fit: cover; background: var(--surface-2); display: block; }
.vrow .title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 6px;
  font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px;
  border-radius: 99px; }
.badge.public { background: var(--ok-soft); color: var(--ok); }
.badge.unlisted { background: var(--info-soft); color: var(--info); }
.badge.private { background: var(--surface-2); color: var(--muted); }
.badge.scheduled { background: var(--warn-soft); color: var(--warn); }
.mini { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-radius: 10px; }
.mini:hover { background: var(--surface-2); }
.mini .thumb { width: 120px; }
.mini .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; cursor: pointer; font-weight: 500; margin: 0; }
.choice input { width: auto; margin-top: 4px; }
.choice small { display: block; color: var(--muted); font-weight: 400; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  cursor: pointer; background: var(--surface); }
.drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 16px; margin-bottom: 4px; }
.thumb-preview { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--surface-2);
  margin-top: 8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.progress { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.job { padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.job:first-child { border-top: 0; }

/* empty, steps */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; }
.steps { padding-left: 20px; margin: 8px 0 0; }
.steps li { margin: 6px 0; }
.ch-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.ch-row:first-child { border-top: 0; }
.ch-row .grow { flex: 1; min-width: 0; }
table.log { width: 100%; border-collapse: collapse; font-size: 14px; }
table.log td { padding: 10px 8px; border-top: 1px solid var(--border); vertical-align: top; }
table.log tr:first-child td { border-top: 0; }

/* dialog & toast */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100% - 32px)); background: var(--surface);
  color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-card { padding: 24px; }
.dialog-card h3 { font-size: 18px; margin-bottom: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50;
  max-width: calc(100% - 40px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; }
.toast.err { background: var(--accent); color: #fff; }
.skeleton { background: var(--surface-2); border-radius: 10px; min-height: 90px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  #menuBtn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px 16px 60px; }
  .banner { margin: 12px 16px 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .vrow { grid-template-columns: 110px 1fr; }
  .vrow .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .thumb { width: 110px; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .stat .value { font-size: 26px; }
  .topbar .btn.primary { display: none; }
}
