/* ================= THEME TOKENS ================= */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --surface-3: #e8ebf2;
  --seg-on: #ffffff;
  --border: #e2e5ee;
  --border-strong: #cdd2de;
  --text: #141722;
  --muted: #5d6578;
  --faint: #8b93a6;
  --accent: #6a4cff;
  --accent-soft: rgba(106, 76, 255, .11);
  --cyan: #0891b2;
  --ok: #15803d;   --ok-soft: rgba(22, 163, 74, .12);
  --warn: #b45309; --warn-soft: rgba(217, 119, 6, .13);
  --bad: #dc2626;  --bad-soft: rgba(220, 38, 38, .11);
  --info: #2563eb; --info-soft: rgba(37, 99, 235, .11);
  --shadow: 0 1px 2px rgba(16, 20, 40, .04), 0 6px 20px rgba(16, 20, 40, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c11;
    --surface: #11141b;
    --surface-2: #171b24;
    --surface-3: #202533;
    --seg-on: #2a3040;
    --border: #232837;
    --border-strong: #323949;
    --text: #e8eaf0;
    --muted: #979fb2;
    --faint: #6b7386;
    --accent: #8b6dff;
    --accent-soft: rgba(139, 109, 255, .16);
    --cyan: #22d3ee;
    --ok: #34d399;   --ok-soft: rgba(52, 211, 153, .13);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
    --bad: #f87171;  --bad-soft: rgba(248, 113, 113, .13);
    --info: #60a5fa; --info-soft: rgba(96, 165, 250, .13);
    --shadow: 0 8px 24px rgba(0, 0, 0, .28);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0c11;
  --surface: #11141b;
  --surface-2: #171b24;
  --surface-3: #202533;
  --seg-on: #2a3040;
  --border: #232837;
  --border-strong: #323949;
  --text: #e8eaf0;
  --muted: #979fb2;
  --faint: #6b7386;
  --accent: #8b6dff;
  --accent-soft: rgba(139, 109, 255, .16);
  --cyan: #22d3ee;
  --ok: #34d399;   --ok-soft: rgba(52, 211, 153, .13);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
  --bad: #f87171;  --bad-soft: rgba(248, 113, 113, .13);
  --info: #60a5fa; --info-soft: rgba(96, 165, 250, .13);
  --shadow: 0 8px 24px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

/* ================= BASE ================= */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small, small { font-size: 12px; }
kbd { font-family: inherit; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface-2); }

/* ================= LAYOUT ================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
}
.brand-mark svg { width: 16px; height: 16px; margin-left: 2px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: -.01em; }
.brand-text span { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 10px; text-align: left;
  color: var(--muted); font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item span { flex: 1; }
.nav-count { font-style: normal; font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 7px; }
.nav-count.zero { display: none; }

.sidebar-foot { margin-top: auto; }
.flow-card { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.flow-head { display: flex; align-items: center; gap: 8px; }
.flow-head .muted { margin-left: auto; font-size: 12px; }
.flow-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .25s ease; }
.bar.ok i { background: var(--ok); }

.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.page-title { min-width: 0; }
.page-title h1 { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
.page-title p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 8px; width: 240px; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--faint);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 16px; height: 16px; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); }
.icon-btn {
  position: relative; width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.pip { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); }
.menu-btn { display: none; }

.content { padding: 24px 28px 56px; width: 100%; max-width: 1480px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; white-space: nowrap;
  font-weight: 600; border: 1px solid var(--border); background: var(--surface);
  transition: filter .15s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 50px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; filter: none; }

/* ================= KPIs ================= */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-ico { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi-ico svg { width: 16px; height: 16px; }
.kpi strong { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.kpi small b { color: var(--text); font-weight: 600; }
.up { color: var(--ok); font-weight: 600; }

/* ================= CARDS ================= */
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.card-head p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.card-head .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.step { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--accent-soft); color: var(--accent); }
.recent { margin-top: 20px; }

/* ================= PROMPT ================= */
.prompt-box { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.prompt-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.prompt-box textarea { display: block; width: 100%; min-height: 128px; resize: vertical; border: 0; outline: 0; background: transparent; padding: 14px 16px; font-size: 15px; line-height: 1.55; }
.prompt-box textarea::placeholder { color: var(--faint); }
.prompt-foot { display: flex; align-items: center; gap: 10px; padding: 9px 12px 10px; border-top: 1px dashed var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); white-space: nowrap; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip em { font-style: normal; opacity: .7; margin-left: 4px; }
.counter { margin-left: auto; font-style: normal; font-size: 12px; font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.counter.over { color: var(--bad); font-weight: 700; }

.settings-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field > span b { font-weight: 600; }
.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); outline: 0; transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; min-height: 112px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.input {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93a6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.seg { display: flex; height: 38px; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.seg button { flex: 1; padding: 0 8px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.toggles { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 16px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 36px; height: 20px; flex: none; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ================= PLATFORMS PICKER ================= */
.platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pf { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); text-align: left; transition: border-color .15s, background .15s; min-width: 0; }
.pf:hover { border-color: var(--border-strong); }
.pf.on { border-color: var(--accent); background: var(--accent-soft); }
.pf-ico { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); }
.pf-ico svg { width: 20px; height: 20px; }
.pf-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pf-body strong { font-size: 13px; font-weight: 600; }
.pf-body small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf.off .pf-body small { color: var(--faint); }
.pf-check { width: 18px; height: 18px; flex: none; border-radius: 6px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: #fff; }
.pf-check svg { width: 12px; height: 12px; stroke-width: 3; opacity: 0; }
.pf.on .pf-check { background: var(--accent); border-color: var(--accent); }
.pf.on .pf-check svg { opacity: 1; }
.pf-connect { font-size: 12px; font-weight: 600; color: var(--accent); }
.hint { margin-top: 12px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 500; }
.hint svg { width: 16px; height: 16px; }
.hint button { margin-left: auto; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

/* ================= METADATA ================= */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab svg { width: 15px; height: 15px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .mod { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.meta-grid { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; }
.meta-fields, .side-fields { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.inherit-note { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--muted); font-size: 12px; }
.inherit-note svg { width: 14px; height: 14px; }
.inherit-note button { margin-left: auto; color: var(--accent); font-weight: 600; white-space: nowrap; }

.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 38px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); cursor: text; }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-input input { flex: 1; min-width: 140px; height: 26px; border: 0; outline: 0; background: transparent; }
.tag-input input::placeholder { color: var(--faint); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 5px 0 10px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 500; }
.tag.hash { color: var(--accent); }
.tag button { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); }
.tag button:hover { background: var(--surface-3); color: var(--text); }
.tag button svg { width: 12px; height: 12px; }

.thumb-drop {
  width: 100%; aspect-ratio: 16 / 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2) center / cover no-repeat;
  color: var(--muted); font-size: 12px; text-align: center;
}
.thumb-drop:hover { border-color: var(--accent); color: var(--accent); }
.thumb-drop b { font-weight: 600; color: var(--text); }
.thumb-drop.has { border-style: solid; }
.thumb-drop.has > * { display: none; }

/* ================= PUBLISH ================= */
.publish-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.publish-row .field { min-width: 220px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 16px 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.summary b { color: var(--text); font-weight: 600; }
.foot-note { margin-top: 10px; text-align: center; color: var(--faint); font-size: 12px; }

/* ================= PIPELINE ================= */
.pipeline { position: sticky; top: 88px; }
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 0 auto 18px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; color: #fff; background: #07080d; transition: width .3s ease; }
.preview[data-ratio="9:16"] { aspect-ratio: 9 / 16; width: 54%; }
.preview[data-ratio="1:1"] { aspect-ratio: 1; width: 74%; }
.pv-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 20%, rgba(139, 109, 255, .55), transparent 55%),
    radial-gradient(circle at 80% 85%, rgba(34, 211, 238, .4), transparent 55%),
    #0b0d14;
  opacity: .55; transition: opacity .3s;
}
.preview.generating .pv-bg { opacity: 1; animation: hue 5s linear infinite; }
.preview.ready .pv-bg { opacity: 1; }
.preview.generating::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .12) 50%, transparent 70%);
  background-size: 250% 100%; animation: shimmer 1.6s linear infinite;
}
@keyframes hue { to { filter: hue-rotate(360deg); } }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.pv-center { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; text-align: center; }
.pv-play { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .16); backdrop-filter: blur(6px); }
.pv-play svg { width: 20px; height: 20px; margin-left: 3px; fill: #fff; stroke: none; }
.pv-label { font-size: 12px; opacity: .8; max-width: 220px; }
.pv-pct { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pv-meta { position: absolute; z-index: 1; left: 10px; bottom: 10px; display: flex; gap: 6px; }
.pv-meta span { font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px; background: rgba(0, 0, 0, .55); }

.stages { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; }
.stage:last-child { padding-bottom: 0; }
.stage::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--border); }
.stage:last-child::before { display: none; }
.stage.done::before { background: var(--accent); }
.st-ico { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); color: var(--faint); font-size: 11px; font-weight: 700; }
.st-ico svg { width: 14px; height: 14px; stroke-width: 2.6; }
.stage.active .st-ico { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stage.done .st-ico { border-color: var(--accent); background: var(--accent); color: #fff; }
.stage.wait .st-ico { border-color: var(--warn); color: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.stage.wait .st-ico svg { stroke-width: 2; }
.st-body { padding-top: 4px; min-width: 0; }
.st-body strong { display: block; font-size: 13px; font-weight: 600; }
.stage:not(.active):not(.done):not(.wait) .st-body strong { color: var(--muted); }
.st-body small { display: block; color: var(--muted); }
.st-progress { margin-top: 8px; }
.up-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.up-list:empty { display: none; }
.up-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 38px; align-items: center; gap: 8px; font-size: 12px; }
.up-row svg { width: 16px; height: 16px; }
.up-row .bar { height: 5px; }
.up-row em { font-style: normal; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.up-row.ok em { color: var(--ok); font-weight: 600; }
.approve { margin-top: 16px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.log { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); max-height: 160px; overflow: auto; display: flex; flex-direction: column; gap: 4px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px; color: var(--muted); }
.log .t { color: var(--faint); margin-right: 8px; }
.log-empty { color: var(--faint); font-family: Inter, system-ui, sans-serif; font-size: 12px; }

/* ================= BADGES ================= */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.generating { background: var(--info-soft); color: var(--info); }
.badge.uploading { background: var(--accent-soft); color: var(--accent); }
.badge.review, .badge.scheduled { background: var(--warn-soft); color: var(--warn); }
.badge.published { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.generating::before, .badge.uploading::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.err { display: block; margin-top: 4px; color: var(--bad); font-size: 11px; }

/* ================= TABLE ================= */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; border-top: 1px solid var(--border); }
.table-wrap.spaced { margin-top: 16px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th { text-align: left; padding: 10px 20px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.when { color: var(--muted); white-space: nowrap; }
.vid { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thumb { position: relative; width: 68px; height: 42px; flex: none; border-radius: 8px; overflow: hidden; }
.thumb span { position: absolute; right: 3px; bottom: 3px; padding: 1px 4px; border-radius: 4px; font-size: 9px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .55); }
.vid-text { min-width: 0; }
.vid-text strong { display: block; max-width: 360px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vid-text small { display: block; max-width: 360px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-icons { display: flex; gap: 4px; }
.pf-icons span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); }
.pf-icons svg { width: 14px; height: 14px; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.row-actions button:hover { background: var(--surface-3); color: var(--text); }
.row-actions svg { width: 16px; height: 16px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters .chip { font-size: 13px; padding: 6px 12px; }

/* ================= LIBRARY ================= */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.lib-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.lib-thumb { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; color: #fff; }
.lib-thumb .dur { position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 600; background: rgba(0, 0, 0, .55); }
.lib-thumb .badge { position: absolute; left: 8px; top: 8px; }
.lib-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.lib-body strong { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.lib-thumb .badge { background: rgba(0, 0, 0, .55); color: #fff; }

/* ================= CONNECTIONS ================= */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.conn { display: flex; flex-direction: column; gap: 14px; }
.conn-head { display: flex; align-items: center; gap: 12px; }
.conn-head .pf-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); }
.conn-head .pf-ico svg { width: 24px; height: 24px; }
.conn-head strong { display: block; font-size: 15px; }
.conn-head .badge { margin-left: auto; }
.conn-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.conn-stats div { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.conn-stats b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.conn-stats small { color: var(--muted); }
.conn p { color: var(--muted); }
.limits { font-size: 12px; color: var(--muted); }
.limits b { color: var(--text); font-weight: 600; }
.conn-actions { display: flex; gap: 8px; margin-top: auto; }

/* ================= ANALYTICS ================= */
.an-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.an-updated { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.an-body { display: flex; flex-direction: column; gap: 20px; transition: opacity .2s; }
.an-body.loading { opacity: .55; }
.an-body .kpis { margin-bottom: 0; }
.an-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 24px; }
.an-empty svg { width: 28px; height: 28px; color: var(--accent); }
.an-empty b { color: var(--text); font-size: 15px; }
.an-empty span { max-width: 460px; }
.an-empty .btn { margin-top: 8px; }
.banner-btn { margin-left: auto; font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

.an-chart { position: relative; min-height: 240px; border-radius: 10px; }
.an-chart svg { display: block; overflow: visible; }
.an-chart .grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.an-chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.an-chart .peak { fill: var(--text); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.an-chart .bar-mark { fill: var(--accent); transition: filter .12s ease; }
.an-chart .bar-mark.hot { filter: brightness(1.22); }
.an-chart .pending { fill: var(--surface-2); }
.an-chart .pending-label { fill: var(--faint); font-size: 11px; font-weight: 500; }
.an-chart .hit { fill: transparent; }
.an-chart-empty { display: grid; place-items: center; min-height: 240px; padding: 0 16px; color: var(--muted); text-align: center; }
.an-tip {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; white-space: nowrap;
  border-radius: 9px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.an-tip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.an-tip small { color: var(--muted); }
.an-day-table .table-wrap { max-height: 380px; overflow: auto; }
.an-day-table table { min-width: 0; }
.an-day-table thead th { position: sticky; top: 0; }

.an-table { min-width: 940px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num small { margin-left: 4px; }
.th-sort { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; font-weight: 600; color: inherit; }
.th-sort small { font-size: 11px; font-weight: 500; color: var(--faint); }
.th-sort:hover, .th-sort.on { color: var(--text); }
.an-table .vid-text strong a { color: inherit; text-decoration: none; }
.an-table .vid-text strong a:hover { color: var(--accent); }
.an-table .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.an-pf { display: inline-flex; align-items: center; gap: 4px; }
.an-pf svg { width: 12px; height: 12px; }
.an-foot { margin-top: -6px; }

/* ================= REVIEW ================= */
.review-box { margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--warn-soft); display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.review-box b { font-weight: 700; color: var(--warn); }
.rb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rb-actions .btn { justify-content: center; min-width: 0; padding: 0 10px; }
.review-box .link-btn { display: inline-flex; align-items: center; gap: 6px; }
.review-box .link-btn svg { width: 14px; height: 14px; }
.row-actions .row-review { width: auto; padding: 0 10px; gap: 6px; display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--accent); }
.row-actions .row-review:hover { background: var(--accent); color: #fff; filter: brightness(1.1); }
.row-actions .row-review svg { width: 14px; height: 14px; }
td small.attempt { display: block; margin-top: 4px; }
.lib-review { align-self: flex-start; }

.dlg { width: min(940px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); padding: 0; border: 0; background: transparent; color: var(--text); }
.dlg::backdrop { background: rgba(6, 8, 14, .6); }
.dlg[open] { animation: dlgIn .18s ease; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.dlg-inner { display: flex; flex-direction: column; max-height: calc(100vh - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 64px rgba(0, 0, 0, .35); }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.dlg-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.dlg-head p { margin-top: 2px; font-size: 13px; }
.dlg-head .icon-btn { margin-left: auto; }
.dlg-body { padding: 18px 20px; overflow: auto; min-height: 0; }
.dlg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.dlg-foot .spacer { margin-right: auto; }
.rv-steps { display: flex; align-items: center; gap: 10px; padding: 0 20px 14px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.rv-step { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--faint); white-space: nowrap; }
.rv-step + .rv-step::before { content: ""; width: 24px; height: 2px; border-radius: 2px; background: var(--border-strong); }
.rv-step i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.rv-step i svg { width: 12px; height: 12px; stroke-width: 3; }
.rv-step.on { color: var(--text); }
.rv-step.on i { background: var(--accent); color: #fff; }
.rv-step.done { color: var(--muted); }
.rv-step.done i { background: var(--ok); color: #fff; }

.rv-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.rv-grid.meta { grid-template-columns: minmax(0, .8fr) minmax(0, 1.5fr); }
.rv-video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
/* Vertical: fix the height and let the width follow (only absolutely placed children, so width:auto alone collapses). */
.rv-video[data-ratio="9:16"] { aspect-ratio: 9 / 16; width: auto; height: min(62vh, 560px); max-width: 100%; margin: 0 auto; }
.rv-video.small[data-ratio="9:16"] { height: min(40vh, 340px); }
.rv-video video { display: block; width: 100%; height: 100%; object-fit: contain; }
.rv-novideo { display: grid; place-items: center; height: 100%; color: #fff; opacity: .7; }
.rv-info, .rv-side, .rv-metaform { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rv-info h3 { margin: 4px 0 -4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.rv-prompt { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; }
.rv-prompt.small { font-size: 12px; max-height: 120px; color: var(--muted); }
.rv-facts, .rv-pfs { display: flex; flex-wrap: wrap; gap: 6px; }
.rv-facts span, .rv-pfs span { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 7px; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.rv-pfs svg { width: 14px; height: 14px; }
.rv-metaform .tabs { margin-bottom: 0; }
.rv-hint { margin-top: -2px; }
.rv-fields { display: flex; flex-direction: column; gap: 12px; }
.rv-fields .field > span small { font-weight: 500; }
.rv-decline { display: flex; flex-direction: column; gap: 10px; max-width: 680px; }
.rv-wait { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; text-align: center; }
.rv-wait b { font-size: 16px; }
.rv-wait .bar { width: min(320px, 80%); margin-top: 6px; }
.rv-spin { width: 28px; height: 28px; border-width: 3px; color: var(--accent); }
.rv-wait-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.rv-wait-ico.ok { background: var(--ok); }
.rv-wait-ico.bad { background: var(--bad); }

/* Demo stand-in for a video (no file is made in demo mode) */
.demo-reel { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; padding: 14px; color: #fff; overflow: hidden; text-align: left; background: hsl(var(--h) 45% 18%); }
.demo-reel::before {
  content: ""; position: absolute; inset: -50%;
  background: conic-gradient(from 0deg, hsl(var(--h) 85% 58%), hsl(calc(var(--h) + 70) 70% 32%), hsl(calc(var(--h) + 150) 80% 50%), hsl(var(--h) 85% 58%));
  filter: blur(36px); opacity: .85; animation: reelSpin 10s linear infinite;
}
.demo-reel > * { position: relative; }
.reel-chip { align-self: flex-start; margin-bottom: auto; padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, .5); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.demo-reel p { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; text-shadow: 0 1px 10px rgba(0, 0, 0, .55); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.reel-bar { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.reel-bar i { display: block; width: 0; height: 100%; background: #fff; animation: reelPlay var(--dur, 8s) linear infinite; }
.rv-video.small .demo-reel { padding: 10px; gap: 8px; }
.rv-video.small .demo-reel p { font-size: 12px; -webkit-line-clamp: 3; }
.rv-video.small .reel-chip { font-size: 10px; }
.preview .pv-center:has(> .demo-reel) { position: static; }
.preview:has(.demo-reel) .pv-meta { display: none; }
@keyframes reelSpin { to { transform: rotate(360deg); } }
@keyframes reelPlay { to { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .demo-reel::before, .reel-bar i { animation: none; } }
@media (max-width: 760px) {
  .rv-grid, .rv-grid.meta { grid-template-columns: minmax(0, 1fr); }
  .dlg-foot .btn { flex: 1 1 auto; justify-content: center; }
  .dlg-foot .spacer { margin-right: 0; }
}

/* ================= SETTINGS ================= */
.settings-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.stack-sm { gap: 12px; padding-top: 4px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ================= ACCOUNT ================= */
.section-title { font-size: 15px; font-weight: 700; margin: 32px 0 14px; }
.row-end { flex-direction: row; justify-content: flex-end; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.user-chip .icon-btn { margin-left: auto; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; background: var(--accent); }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text strong em { font-style: normal; font-weight: 500; }
.user-text small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.user-row .btn { margin-left: auto; }
.add-user { padding-top: 4px; }

/* ================= SIGN-IN PAGE ================= */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; }
.auth-card { display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.auth-card h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.auth-card > p { margin: -8px 0 4px; font-size: 14px; }
.auth-error { padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 13px; font-weight: 500; }
.auth-foot { font-size: 12px; text-align: center; margin: 0; }

/* ================= TOASTS ================= */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: 0 12px 32px rgba(0, 0, 0, .25); animation: toastIn .25s ease; }
.toast svg { width: 18px; height: 18px; color: #34d399; }
.toast.warn svg { color: #fbbf24; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ================= BACKEND STATES ================= */
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-3); }
.banner { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 11px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.banner svg { width: 16px; height: 16px; }
.banner b { font-weight: 700; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.flow-meta span:last-child { color: var(--text); font-weight: 500; text-align: right; }

.stage.failed .st-ico { border-color: var(--bad); background: var(--bad); color: #fff; }
.stage.failed .st-body small { color: var(--bad); }
.up-row a { color: var(--accent); font-weight: 600; text-decoration: none; text-align: right; }
.up-row.failed em { color: var(--bad); font-weight: 600; }
.up-row.failed .bar i { background: var(--bad); }
.up-row.scheduled em { color: var(--warn); font-weight: 600; }
.pipe-error { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 12px; line-height: 1.5; word-break: break-word; }
.preview video { position: relative; z-index: 2; width: 100%; height: 100%; object-fit: contain; background: #000; }
.badge.queued, .badge.processing { background: var(--info-soft); color: var(--info); }
.badge.partial { background: var(--warn-soft); color: var(--warn); }

.pf.soon { opacity: .55; cursor: not-allowed; }
.pf.soon .pf-connect { color: var(--faint); }
.link-btn { align-self: flex-start; color: var(--accent); font-size: 12px; font-weight: 600; }
.links { display: flex; gap: 6px; flex-wrap: wrap; }
.links a { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; text-decoration: none; }
.links a:hover { border-color: var(--accent); color: var(--accent); }
.links svg { width: 13px; height: 13px; }
.lib-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lib-thumb .pv-play { position: relative; z-index: 1; }
.key-list { display: flex; flex-direction: column; gap: 10px; }
.key-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.key-row div { flex: 1; min-width: 0; }
.key-row small { display: block; color: var(--muted); }
.conn-note { font-size: 12px; color: var(--muted); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1220px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .pipeline { position: static; }
  .preview { max-width: 520px; }
  .preview[data-ratio="9:16"] { width: 40%; }
}
@media (max-width: 1060px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; }
  .search { display: none; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .page-title p { display: none; }
  .content { padding: 16px 16px 48px; }
  .meta-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi strong { font-size: 22px; }
  .kpi-ico { display: none; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card-head { flex-wrap: wrap; }
  .card-head .actions { margin-left: 40px; }
  .pipeline .card-head .actions, .recent .card-head .actions { margin-left: auto; }
  #newBtn span, #enhanceBtn span { display: none; }
  #newBtn { width: 38px; padding: 0; }
  .preview[data-ratio="9:16"] { width: 56%; }
  .publish-row .field { min-width: 0; flex: 1 1 100%; }
  .an-toolbar .seg { flex: 1 1 100%; }
  .an-updated { margin-left: 0; flex: 1 1 100%; justify-content: space-between; }
  .toasts { left: 16px; right: 16px; }
  .toast { min-width: 0; max-width: none; }
}
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
