:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #15181e;
  --muted: #5f6673;
  --accent: #1f5eff;
  --accent-soft: #e8efff;
  --accent-text: #ffffff;
  --hot: #e5482f;
  --hot-soft: #fdebe7;
  --ok: #138a4b;
  --ok-soft: #e3f5ea;
  --warn: #a86500;
  --warn-soft: #fdf1dc;
  --danger: #c62a2a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #1f232c;
    --border: #2b303b;
    --text: #eef0f4;
    --muted: #98a0ae;
    --accent: #5b8cff;
    --accent-soft: #1d2a4d;
    --hot: #ff6b52;
    --hot-soft: #3a1d18;
    --ok: #3ccf7f;
    --ok-soft: #14301f;
    --warn: #f0b04a;
    --warn-soft: #36290f;
    --danger: #ff6464;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 14px; font-weight: 800;
}
.tabs { display: flex; gap: 4px; margin-left: 12px; height: 100%; }
.tab {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: 13px;
  letter-spacing: .04em; padding: 0 14px; cursor: pointer; border-bottom: 2px solid transparent; height: 100%;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.topbar .spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

.banner {
  display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-size: 13px; margin-bottom: 18px;
}

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 9px; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.danger { color: var(--danger); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 20px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  background: var(--surface-2); color: var(--muted);
}
.badge.hot { background: var(--hot-soft); color: var(--hot); }
.badge.ok, .badge.active, .badge.approved { background: var(--ok-soft); color: var(--ok); }
.badge.paused, .badge.pending, .badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.error, .badge.rejected { background: var(--hot-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.toggle { position: relative; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border); cursor: pointer; transition: .15s;
}
.toggle span::after {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%;
  background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:disabled + span { opacity: .5; cursor: wait; }

/* ---------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 18px; }
.auth-card h1 { text-align: center; margin-bottom: 6px; }
.auth-card .sub { text-align: center; margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; }
.error { color: var(--danger); font-size: 13px; margin: 4px 0 12px; min-height: 1em; }

/* ---------- wizard */
.wizard { max-width: 900px; margin: 0 auto; }
.stepper { display: flex; gap: 6px; margin-bottom: 26px; }
.stepper .step { flex: 1; }
.stepper .bar { height: 4px; border-radius: 4px; background: var(--border); }
.stepper .step.done .bar, .stepper .step.current .bar { background: var(--accent); }
.stepper .label { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.stepper .step.current .label { color: var(--text); }
.wizard h1 { font-size: 30px; margin-bottom: 8px; }
.wizard .lead { font-size: 17px; margin-bottom: 28px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.choice {
  position: relative; font: inherit; color: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 190px; padding: 32px 24px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.choice:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }
.choice .title { font-weight: 700; font-size: 24px; letter-spacing: -.01em; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.choice .title .badge { font-size: 12px; padding: 3px 10px; }
.choice .desc { color: var(--muted); font-size: 16px; margin-top: 10px; max-width: 260px; }
.choice .check {
  position: absolute; top: 16px; right: 16px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center; font-size: 14px; font-weight: 800; color: transparent;
}
.choice.selected .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; }
.segmented button {
  border: 0; background: none; font: inherit; font-weight: 600; font-size: 16px; color: var(--muted);
  padding: 10px 24px; border-radius: 9px; cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 26px 0 10px; }
.wizard-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border);
}

/* ad library */
.lib-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.counter { font-weight: 700; }
.counter .muted { font-weight: 500; }
.ad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.ad-tile {
  position: relative; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column; text-align: left; font: inherit; color: inherit; padding: 0;
}
.ad-tile:hover { border-color: var(--accent); }
.ad-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ad-tile .thumb { aspect-ratio: 1; background: var(--surface-2); position: relative; overflow: hidden; }
.ad-tile .thumb img, .ad-tile .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-tile .tags { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.ad-tile .tags .badge { background: rgba(0,0,0,.65); color: #fff; }
.ad-tile .tags .badge.hot { background: var(--hot); color: #fff; }
.ad-tile .pick {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: 1.5px solid rgba(0,0,0,.15); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: transparent;
}
.ad-tile.selected .pick { background: var(--accent); color: #fff; border-color: var(--accent); }
.ad-tile .body { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.ad-tile .name { font-weight: 700; font-size: 14px; }
.ad-tile .copy { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ad-tile .preview-link { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 4px; }

/* budget + states */
.budget-input { display: flex; align-items: center; gap: 10px; max-width: 360px; }
.budget-input .dollar { font-size: 26px; font-weight: 700; color: var(--muted); }
.budget-input input { font-size: 26px; font-weight: 700; padding: 8px 12px; }
.quick { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.states-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.state {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; user-select: none;
}
.state input { width: auto; margin: 0; accent-color: var(--accent); }
.state.on { border-color: var(--accent); background: var(--accent-soft); }

.summary { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.confirm { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 14px; }
.confirm input { width: auto; margin-top: 3px; accent-color: var(--accent); }

.success { text-align: center; padding: 40px 20px; }
.success .icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center; font-size: 30px; margin: 0 auto 16px;
}

/* ---------- manage campaigns */
.landing-card { margin-bottom: 22px; }
.landing-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.landing-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); word-break: break-all; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { padding: 16px 18px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.campaign { margin-bottom: 18px; overflow: hidden; }
.campaign-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.campaign-head .titles { flex: 1; min-width: 200px; }
.campaign-head .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.adset { border-bottom: 1px solid var(--border); }
.adset:last-child { border-bottom: 0; }
.adset-row {
  display: grid; grid-template-columns: 44px minmax(180px, 1.8fr) repeat(4, minmax(80px, 1fr)) 36px;
  align-items: center; gap: 10px; padding: 12px 20px;
}
.adset-row .name { font-weight: 600; font-size: 14px; }
.adset-row .sub { font-size: 12px; color: var(--muted); }
.stat { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }
.stat .s-label { display: block; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.budget-edit { display: inline-flex; align-items: center; gap: 4px; }
.budget-edit button { padding: 0 4px; border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.expand { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; width: 32px; height: 32px; border-radius: 6px; }
.expand:hover { background: var(--surface-2); }
.adset-ads { background: var(--surface-2); padding: 14px 20px 18px; }
.adset-ads .ads-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.mini-ads { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.mini-ad { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.mini-ad img, .mini-ad .vthumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex: none; background: var(--border); }
.mini-ad .vthumb { display: grid; place-items: center; font-size: 16px; }
.mini-ad .info { flex: 1; min-width: 0; }
.mini-ad .info .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 48px 20px; }
.empty p { margin: 8px auto 18px; max-width: 420px; }

/* ---------- create new ads */
.create-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.my-ads-list { max-height: calc(100vh - 160px); overflow: auto; }
.my-ad-item {
  display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font: inherit; color: inherit;
}
.my-ad-item:hover { background: var(--surface-2); }
.my-ad-item.active { background: var(--accent-soft); }
.my-ad-item img, .my-ad-item .vthumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; }
.my-ad-item .n { font-weight: 600; font-size: 14px; }
.list-head { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 1px solid var(--border); }
.ai-box { background: var(--accent-soft); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.ai-box h3 { color: var(--accent); margin-bottom: 4px; }
.variations { display: grid; gap: 10px; margin-top: 14px; }
.variation { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.variation .v-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.variation pre { white-space: pre-wrap; font: inherit; font-size: 13px; margin: 6px 0 0; color: var(--muted); }
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; cursor: pointer;
  display: block; background: var(--surface-2);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone img, .dropzone video { max-width: 100%; max-height: 260px; border-radius: 8px; display: block; margin: 0 auto 8px; }
.dropzone input { display: none; }
.review-note { background: var(--hot-soft); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.editor-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

/* ---------- modal + toast */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 12, 18, .55); z-index: 50; display: grid; place-items: center; padding: 16px;
}
.modal { width: 100%; max-width: 980px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.narrow { max-width: 520px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.preview-ad { max-width: 420px; margin: 0 auto; }
.preview-ad .pa-head { display: flex; gap: 10px; align-items: center; padding: 12px; }
.preview-ad .pa-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); }
.preview-ad .pa-text { padding: 0 12px 12px; font-size: 14px; white-space: pre-wrap; }
.preview-ad img, .preview-ad video { width: 100%; display: block; }
.preview-ad .pa-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); }
.preview-ad .pa-foot .h { font-weight: 700; font-size: 14px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); color: #fff; }
.spinner {
  width: 16px; height: 16px; 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); } }

/* ---------- responsive */
@media (max-width: 820px) {
  .create-layout { grid-template-columns: 1fr; }
  .my-ads-list { max-height: 280px; }
  .adset-row { grid-template-columns: 44px 1fr 36px; }
  .adset-row .stat { display: none; }
  .adset-row .stat.keep { display: block; grid-column: 2; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 8px; height: auto; min-height: 56px; flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; margin: 0; height: 44px; }
  .tab { flex: 1; padding: 0 6px; font-size: 12px; }
  .brand .brand-name { display: none; }
  main { padding: 20px 16px 48px; }
  .summary { grid-template-columns: 1fr; gap: 2px; }
  .summary dd { margin-bottom: 10px; }
  .stepper .label { display: none; }
  .ad-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .wizard h1 { font-size: 24px; }
  .choice { min-height: 130px; padding: 24px 18px; }
  .choice .title { font-size: 20px; }
  .kpi .k-value { font-size: 20px; }
}

/* ---------- prepay */
.pay-card { margin-top: 16px; }
.modal .pay-card { margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.pay-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 15px; }
.pay-line.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; font-size: 18px; }
.pay-btn { width: 100%; }
.pay-wait { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 14px; }

/* ---------- create new ads: assistant */
.create-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.chat { position: relative; display: flex; flex-direction: column; height: calc(100vh - 230px); min-height: 460px; overflow: hidden; }
.chat-new { position: absolute; top: 10px; right: 12px; z-index: 2; }
.chat-log { flex: 1; overflow-y: auto; padding: 52px max(20px, calc((100% - 720px) / 2)) 12px; scroll-behavior: smooth; }
.chat-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px; }
.chat-empty p { max-width: 420px; }
.chat-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 20px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; max-width: 640px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.msg { display: flex; margin: 0 0 18px; }
.msg.user { justify-content: flex-end; }
.msg.user .msg-body { background: var(--accent-soft); padding: 10px 14px; border-radius: 16px 16px 4px 16px; max-width: 80%; white-space: pre-wrap; }
.msg.assistant .msg-body { max-width: 100%; font-size: 15px; line-height: 1.6; }
.msg-body p { margin: 0; }
.msg-body .gap { height: 10px; }
.msg-body ul, .msg-body ol { margin: 4px 0 4px; padding-left: 22px; }
.msg-body h4 { margin: 10px 0 4px; font-size: 15px; }
.msg-body pre.code { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; font-size: 13px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ad-draft { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 10px 0; background: var(--surface); }
.ad-draft.drafting { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.ad-draft-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.ad-draft-title { font-weight: 700; margin-bottom: 4px; }
.ad-draft-text { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
.ad-draft details { margin-top: 8px; font-size: 14px; }
.ad-draft summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.ad-draft-actions { display: flex; gap: 8px; margin-top: 12px; }
.chat-input { display: flex; align-items: flex-end; gap: 8px; margin: 0 max(16px, calc((100% - 720px) / 2)) 16px; padding: 8px 8px 8px 16px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.chat-input:focus-within { border-color: var(--accent); }
.chat-input textarea { border: 0; padding: 8px 0; resize: none; min-height: 24px; max-height: 200px; background: none; outline: none; line-height: 1.5; }
.chat-input textarea:focus { outline: none; }
.chat-input .send { width: 36px; height: 36px; flex: none; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font-size: 18px; font-weight: 700; cursor: pointer; }
.chat-input .send:disabled { opacity: .4; cursor: default; }
.myads-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.thumb-empty { width: 100%; height: 100%; display: grid; place-items: center; font-size: 28px; color: var(--muted); }
.back-link { margin-bottom: 10px; }
.editor { max-width: 820px; }
@media (max-width: 600px) {
  .chat { height: calc(100vh - 200px); }
  .chat-log { padding: 52px 14px 8px; }
}

.editor-top { display: flex; justify-content: space-between; max-width: 820px; margin-bottom: 10px; }
.create-head .segmented button { font-size: 13px; padding: 9px 18px; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 600px) {
  .create-head .segmented { width: 100%; }
  .create-head .segmented button { flex: 1; padding: 9px 4px; font-size: 11px; letter-spacing: .02em; }
}

.ad-draft-title { font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ad-draft-script { white-space: pre-wrap; font-size: 15px; line-height: 1.6; color: var(--text); }
.caret { display: inline-block; width: 7px; height: 16px; margin-left: 2px; vertical-align: text-bottom; background: var(--accent); animation: blink 1s infinite; }

/* ---------- Higgsfield video */
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.gen-box { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.gen-video { width: 100%; max-width: 300px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; background: #000; }
.gen-wait { display: flex; gap: 12px; align-items: center; }
.ai-disclaimer { font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 8px; }
.len-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.len-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.len-pick select { width: auto; padding: 6px 10px; }

/* ---------- field help (?) tooltips */
.help {
  position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 4px; vertical-align: 1px;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; font-weight: 700; cursor: help; outline: none;
}
.help:hover, .help:focus { background: var(--accent); border-color: var(--accent); color: #fff; }
.help::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: 8px 10px; border-radius: 8px; z-index: 30;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.45; text-align: left; white-space: normal;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.help:hover::after, .help:focus::after { opacity: 1; }
@media (max-width: 600px) { .help::after { left: 0; transform: none; max-width: 220px; } }
.gen-btn { width: 100%; padding: 16px 24px; font-size: 17px; border-radius: 12px; }
.lib-section { margin-bottom: 30px; }
.lib-title { font-size: 18px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.lib-title .muted { font-weight: 500; font-size: 15px; }
