/* ── The creator inbox (views/inbox.js) ─────────────────────────────────────
   Three panes on one screen, like Duoke (owner, 28 Oct 2026): the shop rail, the
   chosen shop's chats, the conversation — each scrolling on its own, the composer
   always at the foot of the conversation. On a phone the panes stack and the
   address says which one shows (data-depth: rail | list | thread), each with ‹ back.
   Its own file, every class ib-*, so nothing here restyles a screen by accident.
   Tokens are app.css's. */

/* The inbox is a workspace: it takes the width and the height of the window. */
main:has(.ib) { max-width: 1840px; padding: 12px 16px; }

.ib {
  display: grid; grid-template-columns: 260px minmax(300px, 380px) minmax(0, 1fr);
  height: calc(100dvh - var(--ib-top, 56px) - 24px); min-height: 420px;   /* --ib-top: the topbar, measured (inbox.js) */
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.ib-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.ib-pane:last-child { border-right: 0; }
.ib-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ib-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.ib-pick { margin: auto; }

.ib-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 60px;
  border-bottom: 1px solid var(--border);
}
.ib-head h2 { font-size: 16px; margin: 0; }
.ib-head-t { min-width: 0; }
.ib-go { margin-left: auto; flex: none; text-decoration: none; white-space: nowrap; }
.ib-back {
  display: none; width: 34px; height: 34px; flex: none; border-radius: 8px; border: 1px solid var(--border);
  background: none; color: var(--text); font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}

/* ── the rail ── */
.ib-warns { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 6px; }
.ib-warn {
  font-size: 12px; padding: 8px 10px; border-radius: 8px; line-height: 1.4;
  background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}
.ib-shops { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.ib-shop {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border-radius: 8px;
  border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.ib-shop:hover { background: var(--bg); }
.ib-shop.is-on { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ib-shop.is-off { opacity: .55; }
.ib-shop-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ib-shop-n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-shop-s { font-size: 12px; color: var(--muted); }
.ib-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.ib-badge {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 600; text-align: center;
}
.ib-unread { font-size: 11px; color: var(--muted); }
.ib-foot { padding: 8px 14px 12px; margin: 0; border-top: 1px solid var(--border); }

/* ── the chats ── */
.ib-tools { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.ib-search { width: 100%; }
.ib-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.ib-filter {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: none;
  color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
}
.ib-filter.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ib-row {
  display: flex; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; align-items: flex-start;
}
.ib-row:hover { background: var(--bg); }
.ib-row.is-open { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.ib-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ib-row-top { display: flex; justify-content: space-between; gap: 8px; }
.ib-user { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-row.is-unread .ib-user { color: var(--accent); }
.ib-time { font-size: 12px; color: var(--muted); flex: none; }
.ib-row-who { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-row-last { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-marks { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; padding-top: 2px; }
.ib-mark {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px;
  color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent);
}
.ib-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.ib-more { margin: 10px auto; display: block; }

.ib-ava {
  position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.ib-ava.is-big { width: 42px; height: 42px; }
.ib-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* A shop: a rounded square, so it never reads as a creator. A logo keeps its whole shape, on white
   in both themes (a dark logo on a dark avatar would vanish). */
.ib-ava.is-shop { width: 32px; height: 32px; border-radius: 8px; font-size: 11px; }
.ib-ava.is-shop img { object-fit: contain; background: #fff; }
.ib-ava.is-all svg { width: 16px; height: 16px; }
.ib-ava.is-mini { width: 16px; height: 16px; border-radius: 4px; font-size: 7px; vertical-align: -4px; margin-right: 4px; }

/* ── the conversation ── */
.ib-conv-who { flex: 1; min-width: 0; }
.ib-conv-state { font-size: 12px; color: var(--warn); flex: none; }
.ib-msgs { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ib-earlier { text-align: center; }
.ib-msg { display: flex; flex-direction: column; max-width: min(78%, 620px); }
.ib-msg.is-in { align-self: flex-start; align-items: flex-start; }
.ib-msg.is-out { align-self: flex-end; align-items: flex-end; }
.ib-msg.is-system { align-self: center; align-items: center; max-width: 90%; text-align: center; }
.ib-bubble {
  padding: 8px 11px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg);
  overflow-wrap: anywhere; white-space: normal;
}
.ib-msg.is-out .ib-bubble { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.ib-msg.is-shop .ib-bubble { background: var(--bg); border-style: dashed; }
.ib-msg.is-failed .ib-bubble { opacity: .6; border-color: var(--bad); }
.ib-sys { font-size: 12px; color: var(--muted); padding: 4px 10px; border: 1px dashed var(--border); border-radius: 10px; overflow-wrap: anywhere; }
.ib-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ib-state { font-size: 11px; color: var(--muted); }
.ib-state.is-warn { color: var(--warn); }
.ib-state.is-bad { color: var(--bad); }
.ib-img { display: block; max-width: min(280px, 100%); height: auto; border-radius: 8px; }
.ib-note { font-size: 12px; color: var(--muted); font-style: italic; }
.ib-card { display: flex; flex-direction: column; gap: 3px; min-width: 200px; }
.ib-card-k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ib-card-l { font-size: 13px; }
.ib-card-n { color: var(--muted); font-size: 12px; }
.ib-card code { font-size: 12px; overflow-wrap: anywhere; }
.ib-conv-note { min-height: 0; padding: 0 16px; color: var(--warn); }
.ib-conv-note:not(:empty) { padding: 6px 16px; border-top: 1px solid var(--border); }

.ib-composer { border-top: 1px solid var(--border); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.ib-composer.is-off { color: var(--muted); font-size: 13px; }
.ib-text { width: 100%; resize: vertical; min-height: 64px; max-height: 40vh; }
.ib-text[readonly] { opacity: .7; }
/* It wraps: the emoji, Saved replies and Image buttons and the count need more room than a narrow
   pane has, and Send must never be pushed out of sight. Send stays at the end, on the right. */
.ib-comp-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ib-comp-foot [data-ib-send] { margin-left: auto; }
.ib-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.ib-count.is-over { color: var(--bad); font-weight: 600; }
.ib-comp-msg { flex: 1; min-width: 0; font-size: 12px; color: var(--warn); }
.ib-comp-msg.is-bad { color: var(--bad); }

/* ── narrower screens: the rail and the list give up width first ── */
@media (max-width: 1200px) {
  .ib { grid-template-columns: 220px minmax(260px, 320px) minmax(0, 1fr); }
}

/* ── a phone: one pane at a time, the address says which ── */
@media (max-width: 860px) {
  main:has(.ib) { padding: 8px; }
  .ib { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--ib-top, 56px) - 16px); }
  .ib-pane { display: none; border-right: 0; }
  .ib[data-depth="rail"] .ib-rail, .ib[data-depth="list"] .ib-list, .ib[data-depth="thread"] .ib-thread { display: flex; }
  .ib-back { display: inline-flex; align-items: center; justify-content: center; }
  .ib-conv-state { display: none; }          /* the list says it; the name needs the room */
  .ib-comp-foot { flex-wrap: wrap; }
  .ib-comp-msg { order: -1; flex-basis: 100%; }
  .ib-msg { max-width: 88%; }
  /* With the sample Assigned button the header's buttons take a second line, so the name keeps its own. */
  .ib-conv-head:has([data-act="pv-assign"]) { flex-wrap: wrap; }
  .ib-conv-head:has([data-act="pv-assign"]) .ib-conv-who { flex-basis: calc(100% - 100px); }
}

/* Star and Archive (routes/inbox-status.js): a starred chat's ★ in the list, the header's buttons. */
.ib-star { color: #f5b301; font-size: 13px; line-height: 1; }
.ib-star-btn.is-on { color: #f5b301; }

/* The creator above the chat (views/inbox-creator.js), as in the owner's mockup: a line
   of facts led by where they stand with CREA, then the actions, Add to the pool first. */
.ib-creator { border-bottom: 1px solid var(--border); padding: 10px 16px 12px; }
.ib-cc { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.ib-cc-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.ib-cc-state { font-weight: 600; }
.ib-cc-state.is-out { color: #f2b544; }
.ib-cc-state.is-in { color: #4cc38a; }
.ib-cc-name { font-weight: 600; color: var(--text); text-decoration: none; }
.ib-cc-name:hover { text-decoration: underline; }
.ib-cc-fact .muted { margin-right: 2px; }
.ib-cc-chip { margin-right: 0; font-size: 12px; padding: 2px 9px; text-decoration: none; }
.ib-cc-chip:hover { color: var(--text); }
.ib-cc-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.ib-cc-acts .btn { white-space: nowrap; }

/* The parts still to build, with sample data, on Deploy Previews only
   (views/inbox-preview-logic.js): outlined and tagged, so no one takes a sample for
   CreatorTrack's own data. */
.ib-pv { outline: 1px dashed color-mix(in srgb, var(--warn) 75%, transparent); outline-offset: 2px; border-radius: 6px; }
.ib-pv-tag {
  display: inline-block; padding: 0 6px; border: 1px dashed var(--warn); border-radius: 4px; color: var(--warn);
  font-size: 10px; font-weight: 600; letter-spacing: .02em; line-height: 1.6; vertical-align: middle;
}
.ib-pv-banner { margin: 10px 12px 0; padding: 6px 10px; font-size: 12px; color: var(--muted); border: 1px dashed var(--warn); border-radius: 8px; }
.ib-pv-shops { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 10px 12px 0; padding: 2px; }
.ib-pv-quota { margin-top: 2px; }
.ib-pv-facts { display: inline-flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 1px 4px; }
.ib-msg.is-note { align-self: stretch; max-width: none; }
.ib-msg.is-note .ib-bubble { background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent); }
.ib-pv-tools { border-top: 1px solid var(--border); padding: 10px 14px 0; }
.ib-pv-tools + .ib-composer { border-top: 0; }
.ib-pv-box { display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.ib-pv-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Who answers, and internal notes (inbox-owners.js) */
.ib-which { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 10px 12px 0; padding: 2px; }
.ib-which-note { margin: 6px 14px 0; }
.ib-row-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 4px; }
.ib-owner { font-size: 11px; color: var(--muted); padding: 0 6px; border: 1px solid var(--border); border-radius: 999px; }

/* Filters: Campaign and In CreatorTrack; each chat's campaign tags (inbox-filters.js) */
.ib-fl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ib-fl-panel { flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; padding: 4px 0 2px; }
.ib-fl-panel[hidden] { display: none; }
.ib-fl-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ib-fl-group > .muted { min-width: 104px; }
.ib-tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted);
  padding: 0 6px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 999px; }
.ib-tag.is-more { border-style: dashed; }
.ib-tag.is-found { border-color: var(--border); font-style: italic; }
.ib-owner.is-none { border-style: dashed; }
.ib-assigned { margin-top: 6px; }
.ib-shop-owner { display: inline-block; margin-top: 2px; font-size: 12px; }
.ib-write { border-top: 1px solid var(--border); }
.ib-write .ib-composer, .ib-write .ib-pv-tools { border-top: 0; }
.ib-modes { display: flex; gap: 4px; padding: 8px 14px 0; }
.ib-noteform { display: flex; flex-direction: column; gap: 6px; padding: 8px 14px 10px; }
.ib-write:not([data-mode="note"]) .ib-noteform { display: none; }
/* Note mode: the note form takes the reply box's place, so a note can never be sent to TikTok. */
.ib-write[data-mode="note"] .ib-composer, .ib-write[data-mode="note"] .ib-pv-tools { display: none; }

/* Saved replies (inbox-saved-html.js) */
.ib-saved-btn { white-space: nowrap; }
.ib-sr-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.ib-sr-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.ib-sr-lang { flex: none; min-width: 52px; font-size: 11px; color: var(--muted); padding-top: 2px; }
.ib-sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ib-sr-body { white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ib-sr-acts { flex: none; display: flex; gap: 4px; }
.ib-sr-text { min-height: 120px; }
.ib-sr-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: -4px; }
.ib-sr-foot .is-over { color: var(--bad); font-weight: 600; }

/* The reply box: the pictures in a tray above the text, inside one border, as in a chat app
   (inbox-image.js). The text has no border of its own; the box takes the focus ring. */
.ib-box { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ib-box:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.ib-box.is-drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--bg); }
.ib-box .ib-text { border: 0; background: transparent; color: var(--text); font: inherit; padding: 7px 10px; outline: none; }
.ib-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px 0; }
.ib-tray[hidden] { display: none; }
.ib-tile { position: relative; width: 72px; height: 72px; flex: none; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg); padding: 0; }
.ib-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ib-tile-x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 14px; line-height: 20px; text-align: center; cursor: pointer; }
.ib-tile-x[disabled] { display: none; }
.ib-tile-state { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px; font-size: 10px; text-align: center; background: rgba(0, 0, 0, .6); color: #fff; }
.ib-tile.is-sending img, .ib-tile.is-checking img { opacity: .5; }
.ib-tile.is-bad { border-color: var(--bad); }
.ib-tile.is-bad .ib-tile-state { background: var(--bad); font-weight: 700; }
.ib-tile-add { display: flex; align-items: center; justify-content: center; border-style: dashed; color: var(--muted); font-size: 26px; cursor: pointer; }
.ib-tile-add:hover { color: var(--text); border-color: var(--text); }
.ib-img-btn { display: inline-flex; align-items: center; }
