/* MD HQ — Customer care + Products screens. Uses the tokens from style.css. */
.small { font-size: 12px; }
:root { --ch-ig: #8a3ab9; --ch-fb: #0a7cff; }
:root[data-theme="dark"] { --ch-ig: #b46ee6; --ch-fb: #4aa3ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ch-ig: #b46ee6; --ch-fb: #4aa3ff; } }

/* chips + channel tags */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip b { font-weight: 700; margin-left: 2px; }
.chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-instagram.is-on { background: var(--ch-ig); border-color: var(--ch-ig); color: #fff; }
.chip-messenger.is-on { background: var(--ch-fb); border-color: var(--ch-fb); color: #fff; }
.ch { display: inline-block; font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 99px; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.ch-website { background: var(--ink); color: var(--bg); border-color: transparent; }
.ch-instagram { background: linear-gradient(90deg, #833ab4, #c13584 60%, #e1306c); color: #fff; border-color: transparent; }
.ch-messenger { background: var(--ch-fb); color: #fff; border-color: transparent; }

/* inbox: WhatsApp-style list + chat */
:root { --chat-bg: #efe8df; --b-in: #ffffff; --b-ai: #f6ebe0; --b-team: #dcf5d3; --unread: #1f9d55; }
:root[data-theme="dark"] { --chat-bg: #0e0c0b; --b-in: #1f1c1a; --b-ai: #2e2620; --b-team: #1d3326; --unread: #3ecf7e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chat-bg: #0e0c0b; --b-in: #1f1c1a; --b-ai: #2e2620; --b-team: #1d3326; --unread: #3ecf7e; } }

.inbox { display: grid; grid-template-columns: 370px minmax(0, 1fr); height: calc(100dvh - 140px); min-height: 520px;
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.in-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.in-search { position: relative; margin: 14px 14px 10px; }
.in-search .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.in-search input { width: 100%; border-radius: 99px; padding: 10px 14px 10px 40px; background: var(--surface-2); border-color: transparent; }
.in-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; flex: none; }
.in-tabs::-webkit-scrollbar { display: none; }
.tchip { flex: none; display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 6px 13px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid transparent; color: var(--ink-2); cursor: pointer; }
.tchip b { background: var(--ink-3); color: var(--surface); border-radius: 99px; padding: 0 6px; font-size: 11px; line-height: 17px; }
.tchip.t-waiting b { background: var(--bad); color: #fff; }
.tchip.on { background: var(--ink); color: var(--bg); }
.tchip.on b { background: var(--bg); color: var(--ink); }
.in-paused { margin: 0 14px 10px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 500; }
.conv-list { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; border-top: 1px solid var(--line); }
.in-none { padding: 40px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px; margin: 0; }

.cv { display: flex; gap: 12px; align-items: center; width: 100%; padding: 0 0 0 14px; background: none; border: 0; text-align: left; color: var(--ink); cursor: pointer; }
.cv:hover { background: var(--surface-2); }
.cv.on { background: var(--accent-soft); }
.cv-main { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); }
.cv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cv-top b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-top time { font-size: 12px; color: var(--ink-3); flex: none; }
.cv.unread .cv-top time { color: var(--unread); font-weight: 600; }
.cv-bot { display: flex; align-items: center; gap: 8px; }
.cv-text { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv.unread .cv-text { color: var(--ink); font-weight: 500; }
.mark { flex: none; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 2px 8px; line-height: 16px; }
.mark.n { background: var(--unread); color: #fff; min-width: 20px; text-align: center; padding: 2px 6px; }
.mark.warn { background: var(--warn-soft); color: var(--warn); }
.mark.bad { background: var(--bad); color: #fff; }

.av { position: relative; flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: #fff; background: #3d3833; letter-spacing: .02em; }
.av-instagram { background: linear-gradient(135deg, #833ab4, #c13584 60%, #e1306c); }
.av-messenger { background: var(--ch-fb); }
.av i { position: absolute; right: -2px; bottom: -2px; font-style: normal; font-size: 11px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface); }
.av.sm { width: 40px; height: 40px; font-size: 13.5px; }
.av.sm i { width: 17px; height: 17px; font-size: 9.5px; }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.in-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--ink-3); padding: 24px; }
.in-empty b { display: block; color: var(--ink); font: 600 24px/1.2 "Cormorant Garamond", Georgia, serif; margin-bottom: 4px; }
.in-empty p { margin: 0; font-size: 13.5px; }
.in-empty-ic { display: block; width: 84px; height: 84px; margin: 0 auto 12px; color: var(--accent); opacity: .85; }

.ch-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 64px; flex: none; }
.ch-back { display: none; }
.ch-who { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; background: none; border: 0; padding: 0; text-align: left; color: var(--ink); cursor: pointer; }
.ch-who b { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-who .vf { color: var(--good); font-size: 13px; }
.ch-who .st { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-who .st.bad { color: var(--bad); }
.ch-who .st.warn { color: var(--warn); }
.ch-acts { display: flex; align-items: center; gap: 4px; flex: none; }
.menu-wrap { position: relative; }
.ch-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 12; min-width: 230px; display: grid; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.ch-menu[hidden] { display: none; }
.ch-menu button { text-align: left; padding: 11px 12px; border-radius: 9px; background: none; border: 0; color: var(--ink); font-size: 14px; cursor: pointer; }
.ch-menu button:hover { background: var(--surface-2); }
.ch-menu .danger { color: var(--bad); }

.ch-body { flex: 1; display: flex; min-height: 0; }
.ch-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ch-msgs { flex: 1; overflow-y: auto; padding: 14px 7% 12px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.day { align-self: center; margin: 14px 0 6px; padding: 4px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2);
  background: var(--surface); box-shadow: 0 1px 1px rgba(0, 0, 0, .06); }
.b { max-width: min(78%, 560px); margin-top: 6px; padding: 7px 10px 5px; border-radius: 12px; font-size: 14.5px; line-height: 1.45;
  overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0, 0, 0, .07); color: var(--ink); }
.b.in { align-self: flex-start; background: var(--b-in); border-top-left-radius: 4px; }
.b.out { align-self: flex-end; background: var(--b-ai); border-top-right-radius: 4px; }
.b.human { background: var(--b-team); }
.b-text { white-space: pre-wrap; }
.b-text a { color: var(--accent); }
.b-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 2px; font-size: 11px; color: var(--ink-3); }
.b-meta span { font-weight: 600; }
.b .ph { display: block; max-width: min(260px, 100%); max-height: 320px; border-radius: 8px; margin: 1px 0 4px; background: var(--line); }
.b .voice { display: block; width: 250px; max-width: 100%; margin: 2px 0 4px; }
.b .voice-text { font-style: italic; }
.b-sys { align-self: center; margin: 8px 0 2px; padding: 3px 10px; border-radius: 8px; font-size: 11.5px; color: var(--ink-3);
  background: color-mix(in srgb, var(--surface) 75%, transparent); text-align: center; max-width: 90%; }

.ai-draft { margin: 6px 12px 0; padding: 12px 14px; display: grid; gap: 8px; background: var(--surface); border: 1.5px solid var(--warn);
  border-radius: 16px; box-shadow: var(--shadow); }
.ad-h { font-size: 12.5px; font-weight: 700; color: var(--warn); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-h span { font-weight: 500; color: var(--ink-3); }
.ad-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.45; max-height: 32vh; overflow-y: auto; }
.ad-fix textarea { width: 100%; }
.ad-fix p { margin: 6px 0 0; }
.ad-btns { display: flex; gap: 8px; }
.ad-btns[hidden] { display: none; }
.ad-btns .btn { flex: 1; justify-content: center; }
.ch-note { margin: 6px 12px 0; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 500;
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.ch-note .link-btn { font-size: 12.5px; }
.ch-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); flex: none; }
.ch-compose textarea { flex: 1; resize: none; border-radius: 22px; padding: 11px 16px; line-height: 1.4; max-height: 140px; min-height: 44px;
  background: var(--surface); border: 1px solid var(--line); }
.send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--unread); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send:disabled { opacity: .5; }

.ch-info { display: none; width: 340px; flex: none; overflow-y: auto; padding: 0 16px 20px; background: var(--surface); border-left: 1px solid var(--line); font-size: 13px; }
.thread.info .ch-info { display: grid; gap: 8px; align-content: start; }
.info-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: 14px 0 10px; background: var(--surface); font-size: 15px; }
.ch-info textarea { width: 100%; }

/* message bubbles used by Train → Test chat */
.msg { max-width: 78%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.msg a { overflow-wrap: anywhere; }
.msg .who { display: block; font-size: 11px; font-weight: 600; color: var(--ink-3); margin-bottom: 3px; white-space: normal; }
.msg.customer { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.msg.ai, .msg.human { align-self: flex-end; background: var(--accent-soft); border: 1px solid transparent; }
.msg.human { background: color-mix(in srgb, var(--series-out) 14%, var(--surface)); }
.msg.declined { align-self: flex-end; background: var(--bad-soft); color: var(--ink-3); text-decoration: line-through; opacity: .75; }
.msg.system { align-self: center; background: transparent; color: var(--ink-3); font-size: 12px; text-align: center; max-width: 90%; }
.ph { display: block; max-width: 220px; max-height: 260px; border-radius: 10px; margin: 4px 0; background: var(--line); }
.voice { display: block; width: 240px; max-width: 100%; margin: 4px 0; }
.voice-text { font-style: italic; }
.draft { margin: 0 18px 12px; border: 1.5px dashed var(--warn); background: var(--warn-soft); border-radius: 14px; padding: 14px; display: grid; gap: 8px; }
.draft-h { font-weight: 650; color: var(--warn); }
.draft-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-act { display: flex; gap: 8px; flex-wrap: wrap; }
.draft textarea { width: 100%; }
.takeover-note { margin: 0 18px 12px; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 500; }
.composer { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.card-body .composer { padding: 12px 0 0; }
.composer input:not([type=file]) { flex: 1; }
.good-btn { background: var(--good-soft); color: var(--good); border-color: transparent; }
.good-solid { background: var(--good); color: #fff; border-color: var(--good); }
.danger-btn { color: var(--bad); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pf-box { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.pf-box.warn { border-color: var(--warn); }
.pf-name { font-weight: 650; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pf-row { display: flex; justify-content: space-between; gap: 10px; }
.pf-row > span:first-child { color: var(--ink-3); }
.pf-row b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.pf-sec { font-weight: 650; margin-top: 8px; }
.pf-item { display: grid; gap: 1px; }
.pf-item .muted { font-size: 12px; }
.pf-order { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.profile textarea { width: 100%; }

/* train / settings */
.test-msgs { display: flex; flex-direction: column; gap: 10px; min-height: 260px; max-height: 55vh; overflow-y: auto; padding: 4px 2px 12px; }
.typing { color: var(--ink-3); font-size: 12.5px; font-style: italic; }
.debug { font-size: 12px; color: var(--ink-3); }
.test-pv { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.test-pv img { height: 60px; border-radius: 8px; }
.sel-sm { padding: 6px 8px; font-size: 12.5px; border-radius: 9px; }
.rule { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.rule:first-child { border-top: 0; }
.rule .grow { flex: 1; min-width: 0; display: grid; gap: 3px; overflow-wrap: anywhere; }
.rule.off { opacity: .5; }
.rule-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.rule-sec { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--accent); margin-top: 14px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink); font-weight: 400; }
.switch-row:first-child { border-top: 0; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; border: 0; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .15s; }
.switch:checked { background: var(--good); }
.switch:checked::after { left: 21px; }
.set-form { display: grid; gap: 12px; max-width: 420px; }

/* products */
.q-list { display: grid; }
.q-item { display: flex; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); align-items: flex-start; }
.q-item:first-child { border-top: 0; }
.q-item.working { background: var(--accent-soft); }
.q-item .grow { flex: 1; min-width: 0; display: grid; gap: 4px; }
.q-item .t { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.q-item .s { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item .s a, .q-item .t a { color: var(--ink-3); }
.q-pos { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2); flex: none; }
.q-side { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; max-width: 45%; }
.q-form { display: grid; gap: 12px; }
.q-form textarea { width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg-radio { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.seg-radio label { display: inline-flex; font-weight: 500; position: relative; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { border: 1px solid var(--line-2); border-radius: 99px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); background: var(--surface); }
.seg-radio input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg-radio input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.verdicts { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.verdicts li { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); overflow-wrap: anywhere; }
.verdicts li.added, .verdicts li.requeued { background: var(--good-soft); color: var(--good); }
.verdicts li.rejected { background: var(--bad-soft); color: var(--bad); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.hist-list { display: grid; margin-top: 12px; max-height: 65vh; overflow-y: auto; }
.hist-day { font-weight: 650; font-size: 12.5px; padding: 14px 0 6px; color: var(--accent); }
.hist-row { padding: 9px 0; }
.hist-check { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.link-btn { background: none; border: 0; padding: 0 2px; color: var(--accent); font-size: 12px; font-weight: 600; }
.redo-bar { position: sticky; bottom: 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-color: var(--accent); }
.reel-video { width: 100%; max-height: 60vh; border-radius: 12px; background: #000; }
.reel-caption { white-space: pre-wrap; font-size: 13px; background: var(--surface-2); border-radius: 10px; padding: 10px; margin: 0; max-height: 160px; overflow-y: auto; }
.lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.motion-saved { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.motion-chip { cursor: pointer; }
.ref-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 6px; max-height: 420px; overflow-y: auto; }
.ref-prod { position: relative; display: grid; gap: 6px; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px; cursor: pointer; font-weight: 500; }
.ref-prod.on { border-color: var(--accent); background: var(--accent-soft); }
.ref-prod.off { opacity: .45; cursor: not-allowed; }
.ref-prod input { position: absolute; top: 10px; left: 10px; accent-color: var(--accent); }
.ref-prod img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; background: var(--line); }
.rp-title { font-size: 12px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 1180px) {
  .inbox { grid-template-columns: 320px minmax(0, 1fr); }
  .thread.info .ch-info { position: absolute; right: 0; top: 0; bottom: 0; z-index: 8; box-shadow: var(--shadow); }
  .thread { position: relative; }
  .ch-acts .ch-give span { display: none; }
}
@media (max-width: 900px) {
  /* Phone: the list is the page; an open chat covers the whole screen, like WhatsApp. */
  .inbox { display: block; height: auto; min-height: 0; margin: -18px -16px -48px; border: 0; border-radius: 0; box-shadow: none; }
  .in-search { margin: 12px 12px 10px; }
  .in-tabs { padding: 0 12px 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } /* phones: one row you swipe */
  .in-side { border-right: 0; min-height: calc(100dvh - 110px); }
  .conv-list { overflow: visible; }
  .inbox .thread { display: none; }
  .inbox.open .thread { display: flex; position: fixed; inset: 0; z-index: 40; height: 100dvh; }
  body.chat-open { overflow: hidden; }
  .ch-back { display: inline-grid; margin-left: -6px; }
  .ch-head { padding: 8px 8px 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); min-height: 60px; }
  .ch-msgs { padding: 10px 10px 8px; }
  .b { max-width: 86%; }
  .thread.info .ch-info { position: fixed; inset: 0; z-index: 45; width: 100%; border-left: 0; padding-top: env(safe-area-inset-top); }
  .msg { max-width: 90%; }
  .q-item { flex-wrap: wrap; padding: 12px 16px; }
  .q-side { max-width: none; width: 100%; justify-content: flex-start; padding-left: 38px; }
  .two { grid-template-columns: 1fr; }
}

/* exchange requests waiting for accept / decline */
.xr-list { display: grid; }
.xr { padding: 16px 20px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.xr:first-child { border-top: 0; }
.xr-failed { background: var(--bad-soft); }
.xr-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.xr-top b { font-size: 15px; margin-right: 8px; }
.xr-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 18px; font-size: 13.5px; }
.xr-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }
.xr-err { font-size: 12.5px; color: var(--bad); }
.xr-btns { display: flex; gap: 8px; }
.xr-btns .btn { min-width: 120px; justify-content: center; }
@media (max-width: 900px) {
  .xr { padding: 14px 16px; }
  .xr-grid { grid-template-columns: 1fr 1fr; }
  .xr-btns .btn { flex: 1; }
}

/* tap a message to show its Delete button */
.b { cursor: pointer; }
.b-del { display: none; margin-top: 6px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--bad); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.b.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.b.sel .b-del { display: inline-block; }

/* ================================================================== Reel Studio */
.rs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.rs-tile { display: grid; gap: 6px; text-align: left; color: inherit; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; min-width: 0; }
.rs-cover { aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: grid; }
.rs-cover img, .rs-cover video { width: 100%; height: 100%; object-fit: cover; display: block; }
.rs-tile:hover .rs-cover { border-color: var(--accent); }
.rs-ph { display: grid; place-items: center; font-size: 30px; color: var(--ink-3); width: 100%; height: 100%; }
.rs-ph .i { width: 30px; height: 30px; }
.rs-new .rs-cover { border-style: dashed; }
.rs-tt { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-ts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rs-models { display: flex; gap: 12px; flex-wrap: wrap; }
.rs-model { position: relative; width: 96px; display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; text-align: center; cursor: pointer; }
.rs-model img, .rs-model .rs-ph { width: 96px; height: 128px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.rs-add .rs-ph { border-style: dashed; }
.rs-model .icon-btn { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; background: var(--surface); }
.rs-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.rs-title { flex: 1; min-width: 0; font-size: 18px; font-weight: 600; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 6px 8px; color: var(--ink); }
.rs-title:hover, .rs-title:focus { border-color: var(--line-2); background: var(--surface); }
.rs-cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.rs-sec { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.rs-sec:first-child { border-top: 0; padding-top: 0; }
.rs-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rs-row label.btn { cursor: pointer; }
.rs-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.rs-thumbs:empty { display: none; }
.rs-thumb { position: relative; }
.rs-thumb img { width: 72px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.rs-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; cursor: pointer; }
.rs-ref { display: flex; gap: 10px; align-items: flex-end; }
.rs-ref video { width: 140px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; background: #000; }
#rs-picker { display: grid; gap: 8px; }
#rs-picker input { width: 100%; }
.rs-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 340px; overflow: auto; }
.rs-res { display: grid; gap: 4px; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 4px; font: inherit; font-size: 11.5px; color: inherit; text-align: left; cursor: pointer; }
.rs-res:hover { border-color: var(--accent); }
.rs-res img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 7px; }
.rs-res span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rs-chat { display: grid; gap: 10px; max-height: 420px; overflow: auto; padding: 2px 2px 8px; }
.rs-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; }
.rs-msg.c { background: var(--surface-2); border: 1px solid var(--line); justify-self: start; border-bottom-left-radius: 4px; }
.rs-msg.u { background: var(--accent-soft); justify-self: end; border-bottom-right-radius: 4px; }
.rs-who { font-size: 11px; font-weight: 700; color: var(--ink-3); margin-bottom: 2px; }
.rs-compose { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.rs-compose textarea { flex: 1; min-width: 0; resize: vertical; }
.rs-risks { display: grid; gap: 4px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; }
.rs-shots { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13.5px; }
.rs-prompt { margin-top: 12px; }
.rs-prompt summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.rs-prompt textarea { width: 100%; margin-top: 8px; font-size: 12.5px; }
.rs-takes { display: grid; gap: 18px; }
.rs-take { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.rs-take:first-child { border-top: 0; padding-top: 0; }
.rs-take-h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rs-take video { width: 100%; max-width: 320px; aspect-ratio: 9 / 16; background: #000; border-radius: 12px; }
.rs-wait { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rs-note { width: 100%; }
@media (max-width: 900px) {
  .rs-cols { grid-template-columns: minmax(0, 1fr); }
  .rs-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .rs-take video { max-width: 100%; }
}
.rs-thumb.on img { outline: 3px solid var(--good); outline-offset: -3px; }
.rs-thumb.on::after { content: "✓"; position: absolute; left: 4px; bottom: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.rs-outfit { display: grid; gap: 8px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.rs-outfit:last-of-type { border-bottom: 0; }
.rs-picker { display: grid; gap: 8px; }
.rs-picker input { width: 100%; }
.rs-grm { margin-left: 6px; color: var(--bad); }
/* The AI draft never gets squeezed away: the messages scroll instead. */
#ch-draft, #ch-state { flex-shrink: 0; }
.ch-msgs { min-height: 120px; }
.ad-text { min-height: 2.9em; flex-shrink: 0; }
