:root {
  --bg: #0d0e12; --panel: #15171d; --panel2: #1c1f27; --line: #262a34; --text: #eef0f5; --muted: #9298a8;
  --red: #ff3b4e; --red2: #ff6b5a; --green: #2fd480; --amber: #ffb547; --blue: #5aa7ff;
  --r: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h3 { margin: 0; letter-spacing: -.01em; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { margin: 0 0 16px; }
.err { color: var(--red2); min-height: 1.4em; margin: 8px 0 0; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand.big { font-size: 22px; justify-content: center; }
.logo { width: 30px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--red), var(--red2)); position: relative; box-shadow: 0 4px 14px rgba(255,59,78,.4); }
.logo::after { content: ""; position: absolute; left: 12px; top: 6px; border-left: 8px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(800px 400px at 50% 0%, rgba(255,59,78,.16), transparent); }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px 24px; text-align: center; box-shadow: var(--shadow); }
.login-card input { margin: 18px 0 12px; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 26px; background: #0f1015; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.side nav a:hover { background: var(--panel); color: var(--text); }
.side nav a.on { background: var(--panel2); color: var(--text); }
.side nav a.on .ic { background: var(--red); }
.count { margin-left: auto; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); padding: 0 8px; border-radius: 99px; color: var(--text); }
.count:empty { display: none; }
.dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
main { padding: 26px 32px 60px; max-width: 1180px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.top h1 { font-size: 26px; }
section { display: none; }
section.on { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.bottom { display: none; }

/* ---- icons (CSS masks, no icon font) ---- */
.ic { width: 20px; height: 20px; display: inline-block; background: currentColor; -webkit-mask: var(--m) center/contain no-repeat; mask: var(--m) center/contain no-repeat; flex: none; }
.ic-home { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5V21h-6v-6H9v6H3z'/%3E%3C/svg%3E"); }
.ic-queue { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='4' width='18' height='6' rx='2'/%3E%3Cpath d='M3 15h18M3 20h12'/%3E%3C/svg%3E"); }
.ic-up { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4m0 0-5 5m5-5 5 5M4 16v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E"); }
.ic-plus { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.ic-play { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='2.5' y='5' width='19' height='14' rx='4'/%3E%3Cpath d='m10 9 5 3-5 3z' fill='%23000'/%3E%3C/svg%3E"); }
.ic-gear { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h10M18 7h2M4 17h2M10 17h10'/%3E%3Ccircle cx='16' cy='7' r='2'/%3E%3Ccircle cx='8' cy='17' r='2'/%3E%3C/svg%3E"); }
.ic-plug { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0zM12 17v4'/%3E%3C/svg%3E"); }

/* ---- controls ---- */
input, textarea, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; outline: none; transition: border-color .15s; }
input:focus, textarea:focus, select:focus { border-color: #4a5060; }
textarea { resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a3f4c; }
.btn.primary { background: linear-gradient(135deg, var(--red), var(--red2)); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--red2); }
.btn.wide { width: 100%; padding: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
.link:hover { color: var(--text); }
.field { margin: 14px 0; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.row { display: flex; gap: 8px; }
.row input { max-width: 160px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grow { flex: 1; }
.toggle { display: flex; align-items: center; gap: 12px; margin: 14px 0; cursor: pointer; flex-wrap: wrap; }
.toggle input { display: none; }
.toggle span { width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(18px); }
.pill-switch { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; padding: 10px 12px; font: inherit; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.pill-switch::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(47,212,128,.15); }
.pill-switch.paused::before { background: var(--amber); box-shadow: 0 0 0 4px rgba(255,181,71,.15); }
.status-chip { font-size: 13px; padding: 6px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.status-chip b { color: var(--text); }
.saved { margin-left: 10px; color: var(--green); font-size: 14px; }

/* ---- cards ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin-bottom: 16px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; margin-bottom: 10px; border: 1px solid; font-size: 14px; }
.alert.warn { background: rgba(255,181,71,.08); border-color: rgba(255,181,71,.3); }
.alert.bad { background: rgba(255,59,78,.08); border-color: rgba(255,59,78,.3); }
.alert.info { background: rgba(90,167,255,.08); border-color: rgba(90,167,255,.3); }
.alert a { text-decoration: underline; font-weight: 600; }

.channel { display: flex; align-items: center; gap: 16px; background: linear-gradient(120deg, #1d1416, var(--panel) 60%); }
.channel img, .avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--panel2); flex: none; }
.channel h2 { margin: 0; font-size: 19px; }
.channel .stats { display: flex; gap: 18px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.channel .stats b { color: var(--text); }
.channel .grow { flex: 1; min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.kpi .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .s { font-size: 12px; margin-top: 4px; }
.kpi.low .v { color: var(--amber); }

.next { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.next:first-child { border-top: 0; padding-top: 0; }
.next img, .thumb-ph { width: 40px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--panel2); flex: none; }
.next .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.next .w { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }

.chart { height: 150px; display: flex; align-items: flex-end; gap: 3px; }
.chart .bar { flex: 1; background: linear-gradient(to top, rgba(255,59,78,.5), var(--red2)); border-radius: 4px 4px 1px 1px; min-height: 3px; position: relative; }
.chart .bar:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -6px); background: #000; padding: 3px 7px; border-radius: 6px; font-size: 12px; white-space: nowrap; z-index: 2; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow: auto; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--muted); font-size: 12px; min-width: 92px; padding-top: 2px; }
.feed .k { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 7px; flex: none; }
.feed .k.published { background: var(--green); } .feed .k.error, .feed .k.warn { background: var(--red); } .feed .k.write { background: var(--blue); } .feed .k.new { background: var(--amber); }
.feed a { color: var(--blue); }

/* ---- queue ---- */
.qlist { display: flex; flex-direction: column; gap: 12px; }
.q { display: grid; grid-template-columns: 92px 1fr auto; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; align-items: start; }
.q .poster { width: 92px; aspect-ratio: 9/16; border-radius: 10px; object-fit: cover; background: var(--panel2); cursor: pointer; display: block; }
.q .body { min-width: 0; }
.q .t { font-weight: 650; font-size: 15.5px; margin: 6px 0 4px; }
.q .d { color: var(--muted); font-size: 13.5px; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.chip.h { color: var(--blue); }
.meta-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; letter-spacing: .01em; }
.badge.ready { background: rgba(47,212,128,.13); color: var(--green); }
.badge.new { background: rgba(90,167,255,.13); color: var(--blue); }
.badge.needs-approval { background: rgba(255,181,71,.13); color: var(--amber); }
.badge.uploading { background: rgba(255,59,78,.15); color: var(--red2); }
.badge.failed { background: rgba(255,59,78,.15); color: var(--red2); }
.badge.published { background: rgba(47,212,128,.13); color: var(--green); }
.when { color: var(--text); font-weight: 600; }
.warnline { font-size: 13px; color: var(--amber); margin-top: 6px; }
.errline { font-size: 13px; color: var(--red2); margin-top: 6px; }
.acts { display: flex; flex-direction: column; gap: 6px; min-width: 132px; }
.acts .mini { display: flex; gap: 6px; }
.acts .mini .btn { flex: 1; }
.pbar { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--red2)); transition: width .3s; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---- upload ---- */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 44px 16px; border: 2px dashed #343947; border-radius: 18px; background: var(--panel); cursor: pointer; transition: .2s; }
.drop:hover, .drop.over { border-color: var(--red); background: #1a1418; }
.drop strong { font-size: 17px; }
.drop-ic { width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(135deg, var(--red), var(--red2)); margin-bottom: 8px; -webkit-mask: none; position: relative; }
.drop-ic::after { content: ""; position: absolute; inset: 14px; background: #fff; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4m0 0-5 5m5-5 5 5M4 16v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4m0 0-5 5m5-5 5 5M4 16v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E") center/contain no-repeat; }
.upl { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-size: 14px; }
.upl .r { display: flex; justify-content: space-between; gap: 10px; }
.upl .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- published ---- */
.pubgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.pub { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.pub .img { aspect-ratio: 9/16; background: var(--panel2) center/cover; position: relative; display: block; }
.pub .img .views { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.7); padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 700; }
.pub .info { padding: 10px 12px 12px; }
.pub .t { font-size: 13.5px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pub .s { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- settings / setup ---- */
.form { max-width: 680px; }
.form h3 { margin-top: 10px; }
.form h3 + * { margin-top: 10px; }
.times { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.time { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 6px 8px 6px 14px; font-weight: 600; }
.time button { border: 0; background: var(--line); color: var(--text); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; }
.step .n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--panel2); border: 1px solid var(--line); }
.step.done .n { background: var(--green); color: #04220f; border-color: transparent; }
.step h3 { margin: 5px 0 6px; }
.step ol { padding-left: 18px; margin: 8px 0; color: var(--muted); font-size: 14px; }
.step ol li { margin: 4px 0; }
.step ol b { color: var(--text); }
.copy { display: flex; gap: 6px; align-items: center; margin: 8px 0; }
.copy code { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; overflow-x: auto; white-space: nowrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- dialog ---- */
dialog { width: min(920px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 26px); }
.dlg-h, .dlg-f { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-f { border-bottom: 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-h h3 { flex: 1; }
.x { border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.dlg-body { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 6px 18px 12px; overflow: auto; }
.dlg-media video { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: 12px; margin-top: 14px; object-fit: contain; }
.frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.frames img { width: 100%; aspect-ratio: 9/16; object-fit: cover; border-radius: 6px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
pre { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #23262f; border: 1px solid var(--line); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; font-size: 14px; max-width: calc(100vw - 32px); }
.toast.bad { border-color: rgba(255,59,78,.5); }

/* ---- phone ---- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 16px 16px 110px; }
  .top h1 { font-size: 22px; }
  .bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: rgba(15,16,21,.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center; }
  .bottom a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 10px; min-width: 56px; }
  .bottom a.on { color: var(--text); }
  .bottom a.on .ic { background: var(--red); }
  .bottom .fab { width: 50px; height: 50px; min-width: 0; border-radius: 16px; background: linear-gradient(135deg, var(--red), var(--red2)); color: #fff; justify-content: center; margin-top: -18px; box-shadow: 0 6px 20px rgba(255,59,78,.45); }
  .bottom .fab .ic { background: #fff !important; }
  .q { grid-template-columns: 74px 1fr; gap: 12px; }
  .q .poster { width: 74px; }
  .acts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .acts > .btn { flex: 1 1 auto; }
  .acts .mini { flex: 1 1 100%; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .dlg-body { grid-template-columns: 1fr; }
  .dlg-media video { max-height: 50vh; }
  .pubgrid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .channel { flex-wrap: wrap; }
  .feed time { min-width: 70px; }
}
.setup-link { display: flex; justify-content: space-between; align-items: center; max-width: 680px; }
.btn.disabled { opacity: .5; pointer-events: none; }
.top-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.chan-sel { width: auto; max-width: 260px; padding: 7px 10px; font-size: 14px; border-radius: 99px; background: var(--panel); }
.sources { font-size: 13px; margin-top: 6px; color: var(--muted); }
.sources a { color: var(--blue); }
@media (max-width: 760px) { .top { flex-wrap: wrap; } .chan-sel { max-width: 100%; flex: 1; } }
