:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #161a2b;
  --muted: #6b7189;
  --primary: #5b5bf0;
  --primary-ink: #ffffff;
  --primary-soft: #ececfe;
  --success: #12a150;
  --success-soft: #e3f6eb;
  --warning: #c27803;
  --warning-soft: #fdf3dc;
  --danger: #dc2626;
  --danger-soft: #fde7e7;
  --info: #2563eb;
  --info-soft: #e5eefe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 12px;
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1020; --surface: #161a2e; --surface-2: #1d2238; --border: #2a3050; --text: #e8eaf6; --muted: #9aa0bd;
    --primary: #7c7cff; --primary-soft: #26285a; --success-soft: #133524; --warning-soft: #3a2c0c; --danger-soft: #3d1717; --info-soft: #172a52;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1020; --surface: #161a2e; --surface-2: #1d2238; --border: #2a3050; --text: #e8eaf6; --muted: #9aa0bd;
  --primary: #7c7cff; --primary-soft: #26285a; --success-soft: #133524; --warning-soft: #3a2c0c; --danger-soft: #3d1717; --info-soft: #172a52;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
img { max-width: 100%; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand img { width: 32px; height: 32px; }
.ws-chip { margin: -8px 4px 14px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; background: var(--primary); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; }
.sidebar .spacer { flex: 1; }
.user-box { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); margin-top: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.main { min-width: 0; padding: 24px 28px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
  .main { padding: 16px 16px 60px; }
}

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.icon { padding: 6px; }
.btn svg { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }
.btn-group .btn.active { background: var(--primary-soft); color: var(--primary); }

label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.draft { background: var(--surface-2); color: var(--muted); }
.badge.scheduled, .badge.pending { background: var(--info-soft); color: var(--info); }
.badge.pending_approval, .badge.retrying, .badge.partial, .badge.expired, .badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.publishing { background: var(--primary-soft); color: var(--primary); }
.badge.published, .badge.active, .badge.success { background: var(--success-soft); color: var(--success); }
.badge.failed, .badge.error, .badge.cancelled, .badge.disabled { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.pf { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: #fff; font-weight: 800; font-size: 10px; flex: none; letter-spacing: -.02em; }
.pf.mini { width: 14px; height: 14px; font-size: 6px; border-radius: 4px; }
.pf-stack .pf.mini { width: 16px; height: 16px; margin-left: -4px; border-width: 1px; }
.pf.lg { width: 40px; height: 40px; border-radius: 11px; font-size: 14px; }
.pf-stack { display: inline-flex; }
.pf-stack .pf { margin-left: -6px; border: 2px solid var(--surface); width: 26px; height: 26px; }
.pf-stack .pf:first-child { margin-left: 0; }
.acc-avatar { position: relative; flex: none; }
.acc-avatar .pf { position: absolute; right: -4px; bottom: -4px; width: 16px; height: 16px; font-size: 7px; border-radius: 5px; border: 2px solid var(--surface); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }
.tabs button .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

/* Toasts & modal */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow); animation: slide .2s; font-weight: 500; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 25, .5); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.wide { width: min(920px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: var(--surface); }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, var(--primary-soft), transparent 50%), var(--bg); }
.auth .card { width: min(420px, 100%); }
.auth .brand { justify-content: center; font-size: 22px; padding-bottom: 6px; }

/* Empty */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* Compose */
.compose { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1150px) { .compose { grid-template-columns: 1fr; } }
.acc-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-chip { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--border); border-radius: 99px; padding: 4px 12px 4px 4px; cursor: pointer; background: var(--surface); user-select: none; font-weight: 500; }
.acc-chip.selected { border-color: var(--primary); background: var(--primary-soft); }
.acc-chip.off { opacity: .5; cursor: not-allowed; }
.acc-chip .avatar { width: 28px; height: 28px; font-size: 12px; }
.editor { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.editor textarea { border: none; min-height: 180px; border-radius: 12px 12px 0 0; padding: 14px; font-size: 15px; }
.editor textarea:focus { outline: none; }
.editor-tools { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.counters { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.counter { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.counter.over { background: var(--danger-soft); color: var(--danger); }
.media-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 104px; height: 104px; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .6); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.thumb .kind { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 5px; font-weight: 700; }
.thumb .order { position: absolute; left: 4px; top: 4px; background: var(--primary); color: #fff; font-size: 10px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.thumb.drop { display: grid; place-items: center; border: 2px dashed var(--border); color: var(--muted); cursor: pointer; text-align: center; font-size: 12px; padding: 6px; background: transparent; }
.thumb.drop:hover, .dragover { border-color: var(--primary) !important; color: var(--primary); background: var(--primary-soft); }
.issues { border-radius: 10px; background: var(--danger-soft); color: var(--danger); padding: 10px 14px; font-size: 13px; }
.issues ul { margin: 4px 0 0; padding-left: 18px; }
.ok-box { border-radius: 10px; background: var(--success-soft); color: var(--success); padding: 10px 14px; font-size: 13px; font-weight: 600; }
.schedule-box { display: grid; gap: 12px; }
.mode-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 700px) { .mode-pick { grid-template-columns: repeat(2, 1fr); } }
.mode-pick label { border: 1.5px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer; text-align: center; font-weight: 600; font-size: 13px; }
.mode-pick label small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.mode-pick input { display: none; }
.mode-pick label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* Previews */
.preview { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 12px; }
.preview-text { padding: 0 12px 12px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.preview-media { display: grid; gap: 2px; background: #000; }
.preview-media.n2, .preview-media.n4 { grid-template-columns: 1fr 1fr; }
.preview-media.n3 { grid-template-columns: 1fr 1fr; }
.preview-media.n3 > :first-child { grid-column: 1 / -1; }
.preview-media img, .preview-media video { width: 100%; max-height: 360px; object-fit: cover; display: block; aspect-ratio: 1 / 1; }
.preview-media.n1 img, .preview-media.n1 video { aspect-ratio: auto; object-fit: contain; }
.preview.vertical .preview-media img, .preview.vertical .preview-media video { aspect-ratio: 9 / 16; max-height: 460px; }
.preview-foot { display: flex; gap: 18px; padding: 10px 12px; color: var(--muted); border-top: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.preview .yt-title { padding: 10px 12px 0; font-weight: 700; font-size: 15px; }
.preview .hl { color: var(--primary); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.cal .dow { padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal .day { min-height: 118px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal .day.other { background: var(--surface-2); }
.cal .day.other .num { opacity: .5; }
.cal .day.today .num { background: var(--primary); color: #fff; }
.cal .day .num { font-size: 12px; font-weight: 700; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.cal .day .add { visibility: hidden; margin-left: auto; }
.cal .day:hover .add { visibility: visible; }
.cal .ev { font-size: 11px; padding: 3px 6px; border-radius: 6px; cursor: pointer; display: flex; gap: 5px; align-items: center; background: var(--surface-2); border-left: 3px solid var(--muted); min-width: 0; }
.cal .ev .t { font-weight: 700; flex: none; }
.cal .ev.scheduled { border-color: var(--info); }
.cal .ev.published { border-color: var(--success); }
.cal .ev.failed, .cal .ev.cancelled { border-color: var(--danger); }
.cal .ev.partial, .cal .ev.pending_approval { border-color: var(--warning); }
.cal .ev.publishing { border-color: var(--primary); }
.cal .ev.draft { border-left-style: dashed; opacity: .85; }
.cal .more { font-size: 11px; color: var(--muted); cursor: pointer; padding-left: 4px; }
@media (max-width: 700px) { .cal .day { min-height: 70px; } .cal .ev .x { display: none; } }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.hbar { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; margin-bottom: 10px; }
.hbar .track { background: var(--surface-2); border-radius: 99px; height: 10px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 99px; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.media-item { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); position: relative; cursor: pointer; }
.media-item.selected { outline: 3px solid var(--primary); }
.media-item .pic { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.media-item .pic img, .media-item .pic video { width: 100%; height: 100%; object-fit: cover; }
.media-item .meta { padding: 8px 10px; font-size: 12px; }
.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .2s; }

/* Accounts */
.platform-card { display: flex; gap: 14px; padding: 16px; align-items: flex-start; }
.platform-card .desc { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.acc-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.acc-row:last-child { border-bottom: none; }

/* Post list */
.post-cell { display: flex; gap: 12px; align-items: center; min-width: 260px; }
.post-cell .mini { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); }
.post-cell .mini svg { width: 20px; height: 20px; }
.post-cell .mini img, .post-cell .mini video { width: 100%; height: 100%; object-fit: cover; }
.target-list { display: flex; flex-direction: column; gap: 8px; }
.target-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.target-item .err { color: var(--danger); font-size: 12px; }
.slot-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .slot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.slot-day h4 { font-size: 13px; margin-bottom: 8px; }
.slot { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); border-radius: 8px; padding: 4px 8px; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.slot button { background: none; border: none; color: var(--muted); cursor: pointer; }
.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; max-height: 280px; overflow: auto; }
.dropdown-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit; color: var(--text); }
.dropdown-menu button:hover { background: var(--surface-2); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hộp thư tin nhắn */
.inbox { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .inbox { grid-template-columns: 1fr; } }
.inbox-list { max-height: calc(100vh - 170px); overflow: auto; }
.conv { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; border-top: 1px solid var(--border); }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--primary-soft); }
.dot-unread { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; }
.inbox-thread { display: flex; flex-direction: column; min-height: 460px; max-height: calc(100vh - 170px); }
.chat { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.bubble-row { display: flex; }
.bubble-row.page { justify-content: flex-end; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--border); }
.bubble.page { background: var(--primary); color: #fff; border-color: var(--primary); }
.bubble-time { font-size: 10px; opacity: .65; margin-top: 2px; }

/* Studio video */
.studio { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 18px; align-items: start; }
.studio-side { position: sticky; top: 16px; }
@media (max-width: 1000px) { .studio { grid-template-columns: 1fr; } .studio-side { position: static; } }
.title-input { font-size: 22px; font-weight: 700; border: 1px solid transparent; background: transparent; padding: 2px 6px; margin-left: -6px; width: 100%; max-width: 560px; }
.title-input:hover, .title-input:focus { border-color: var(--border); background: var(--surface); }
.studio-card { color: inherit; text-decoration: none; overflow: hidden; transition: transform .12s; }
.studio-card:hover { transform: translateY(-2px); }
.studio-thumb { aspect-ratio: 9/12; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.studio-thumb.wide { aspect-ratio: 16/10; }
.studio-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tpl-card { display: flex; flex-direction: column; gap: 4px; border: 1.5px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--surface); }
.tpl-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.chip-opt { border: 1.5px solid var(--border); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-weight: 500; background: var(--surface); }
.chip-opt.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.clip-row { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.clip-thumb { position: relative; width: 84px; height: 84px; flex: none; border-radius: 10px; overflow: hidden; background: #000; display: grid; place-items: center; color: #fff; }
.clip-thumb img, .clip-thumb video { width: 100%; height: 100%; object-fit: cover; }
.clip-no { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.clip-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.clip-fields label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.clip-fields input, .clip-fields select { padding: 6px 8px; font-size: 13px; }
.se-video { width: 100%; max-height: 46vh; background: #000; border-radius: 10px; }
.se-track { position: relative; display: flex; height: 46px; border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; user-select: none; }
.se-part { position: relative; flex: none; min-width: 3px; border-right: 2px solid var(--surface); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; opacity: .75; overflow: hidden; }
.se-part span { pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.5); white-space: nowrap; }
.se-part.c0 { background: #4F6BED; } .se-part.c1 { background: #0E9F6E; } .se-part.c2 { background: #D97706; } .se-part.c3 { background: #9333EA; }
.se-part.on { opacity: 1; box-shadow: inset 0 0 0 3px #FFD400; }
.se-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #E53935; pointer-events: none; z-index: 2; }
.se-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 96px 96px 60px auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; }
.se-row.on { background: var(--primary-soft); }
.se-row label:not(.check) { display: flex; align-items: center; gap: 4px; }
.se-row input[type=number] { padding: 4px 6px; font-size: 13px; width: 100%; }
@media (max-width: 640px) { .se-row { grid-template-columns: 40px minmax(0, 1fr) 1fr 1fr; } }
.fd-wrap { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.fd-stage { position: relative; background: #000; border-radius: 8px; overflow: hidden; user-select: none; touch-action: none; cursor: crosshair; }
.fd-stage video, .fd-stage img { width: 100%; height: 100%; display: block; pointer-events: none; }
.fd-crop { position: absolute; border: 2px solid #FFD400; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .6); cursor: move; box-sizing: border-box; }
.seg-list { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow: auto; }
.seg-row { display: grid; grid-template-columns: 74px 74px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.seg-row input { padding: 5px 7px; font-size: 13px; }
.phone { position: relative; margin: 0 auto; border-radius: 14px; overflow: hidden; background: #000; container-type: inline-size; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.phone-bg, .phone-fg { position: absolute; inset: 0; }
.phone-bg img, .phone-bg video { width: 100%; height: 100%; object-fit: cover; filter: blur(14px) brightness(.8); transform: scale(1.1); }
.phone-fg img, .phone-fg video { width: 100%; height: 100%; object-fit: contain; }
.phone-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 13px; }
.phone-text { font-family: 'DejaVu Sans', Inter, system-ui, sans-serif; position: absolute; left: 6%; right: 6%; text-align: center; font-weight: 800; line-height: 1.25; z-index: 2; }
