@font-face { font-family: "Fredoka"; src: url("fonts/Fredoka.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("fonts/Poppins-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("fonts/Poppins-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #fbf7f2; --panel: #ffffff; --panel-2: #f5efe8; --ink: #2e2a36; --muted: #6f6878; --line: #e8e0d6;
  --rose: #c56b83; --rose-soft: #f6e4e8; --sky: #5f8fb8; --sky-soft: #e3edf6; --mint: #3f8b6c; --mint-soft: #e2f1ea;
  --amber: #a8742a; --amber-soft: #f7ecd9; --red: #b04a55; --red-soft: #f7e2e4;
  --radius: 14px; --shadow: 0 1px 2px rgba(46,42,54,.06), 0 4px 16px rgba(46,42,54,.05);
  --head: "Fredoka", "Poppins", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18161c; --panel: #222028; --panel-2: #2a2731; --ink: #efeaf2; --muted: #a59db0; --line: #35313d;
    --rose: #e08ba1; --rose-soft: #3a2730; --sky: #8ab4d9; --sky-soft: #22303d; --mint: #7cc4a5; --mint-soft: #1f3129;
    --amber: #dcae66; --amber-soft: #352b1c; --red: #e0838d; --red-soft: #3b2226;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }
small, .muted { color: var(--muted); }

/* ---------- layout ---------- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { flex: none; white-space: nowrap; display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--head); font-weight: 600; font-size: 1.1rem; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a, .nav button { padding: 7px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; font: inherit;
  background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--rose-soft); color: var(--rose); font-weight: 600; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 16px 60px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.cols-2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); } .nav a span.hide-sm { display: none; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: .8rem; }
.card.flush { padding: 0; overflow: hidden; }

/* ---------- controls ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.help { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=datetime-local], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); font: inherit; }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
textarea.script { min-height: 380px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--rose) 45%, transparent); outline-offset: 1px; border-color: var(--rose); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 600 .92rem var(--body); cursor: pointer;
  text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 12px; font-size: .84rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.inline { display: inline; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--rose); }

/* engine picker */
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 500; }
.choice input { margin-top: 4px; accent-color: var(--rose); }
.choice:has(input:checked) { border-color: var(--rose); background: var(--rose-soft); }
.choice b { display: block; font-weight: 600; }
.choice small { display: block; }

/* ---------- status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-queued { background: var(--sky-soft); color: var(--sky); }
.s-running, .s-posting { background: var(--amber-soft); color: var(--amber); }
.s-running::before, .s-posting::before { animation: pulse 1.2s ease-in-out infinite; }
.s-review { background: var(--rose-soft); color: var(--rose); }
.s-clips { background: #fff3d6; color: #8a5a00; }
.s-approved, .s-posted, .s-scheduled { background: var(--mint-soft); color: var(--mint); }
.s-scheduled { background: var(--sky-soft); color: var(--sky); }
.s-failed { background: var(--red-soft); color: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--mint-soft); color: var(--mint); }
.flash.error { background: var(--red-soft); color: var(--red); }
.banner { padding: 10px 14px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); font-size: .9rem; margin-bottom: 14px; }

/* ---------- lists / tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 44px; height: 78px; border-radius: 8px; object-fit: cover; background: var(--panel-2); flex: none; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }
.table-wrap { overflow-x: auto; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font: 600 1.5rem var(--head); }
.stat span { color: var(--muted); font-size: .84rem; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- episode page ---------- */
.player { background: #111; border-radius: var(--radius); overflow: hidden; aspect-ratio: 9 / 16; max-height: 72vh; margin: 0 auto; display: block; width: 100%; max-width: 420px; }
.player video { width: 100%; height: 100%; display: block; }
.placeholder { aspect-ratio: 9 / 16; max-width: 420px; max-height: 62vh; margin: 0 auto; border-radius: var(--radius); border: 1px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); background: var(--panel-2); gap: 10px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--rose); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.log { background: #1c1a21; color: #d9d3df; border-radius: 12px; padding: 12px; max-height: 340px; overflow: auto; white-space: pre-wrap;
  word-break: break-word; font-size: 12px; line-height: 1.45; margin: 0; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.stages .pill { font-weight: 500; }
details { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
details summary { cursor: pointer; font-weight: 600; }
.platform { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.platform-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.platform-body { margin-top: 12px; }
.platform:not(:has(.toggle:checked)) .platform-body { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg label { margin: 0; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 500; font-size: .85rem; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--rose-soft); color: var(--rose); font-weight: 600; }
.qa { white-space: pre-wrap; font-size: .85rem; max-height: 420px; overflow: auto; background: var(--panel-2); padding: 12px; border-radius: 12px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- auth / public ---------- */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth { width: 100%; max-width: 380px; }
.auth .logo { width: 84px; height: 84px; border-radius: 50%; display: block; margin: 0 auto 12px; }
.public { max-width: 760px; margin: 0 auto; padding: 40px 18px 60px; }
.hero { text-align: center; padding: 30px 0 10px; }
.hero img { width: 140px; height: 140px; border-radius: 50%; }
.hero h1 { font-size: 2.2rem; margin-top: 10px; }
footer.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px; }

@media (max-width: 520px) { .brand span.word { display: none; } .wrap { padding-top: 16px; } h1 { font-size: 1.45rem; } }
.help code, p code { overflow-wrap: anywhere; word-break: break-all; }

.libList { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.libItem { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; margin: 0; font-weight: 400; border-top: 1px solid var(--line); cursor: pointer; }
.libItem:first-child { border-top: 0; }
.libItem input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--rose); flex: none; }
.libItem.made { color: var(--muted); }
.madeTag { color: var(--mint); font-weight: 600; }
