/* ============================================================================
   IRIS widget — Intercom-grade messenger. Runs inside the isolated iframe.
   Brand-driven: depth comes from layered light/shadow (color-mix), not neon.
   ============================================================================ */
:root {
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --action: var(--brand);   /* accent for buttons/links/CTAs — defaults to brand; set per-tenant (brand.actionColor) */
  --ink: #16161d;
  --ink-2: #2a2a33;         /* article body ink (softer than --ink) */
  --muted: #6a6a78;
  --faint: #9a9aa6;
  --line: #ececf0;
  --surface: #ffffff;
  --surface-2: #f6f6f8;
  --bubble-in: #f1f1f4;
  --card-base: #ffffff;     /* base a tinted card mixes brand INTO (flips in dark) */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Floating-card elevation: layered contact + mid + ambient shadow so the panel
     clearly lifts off a busy dashboard. Horizontal reach ≤14px → fits the 16px
     iframe inset with no clipping (shadow is biased downward, where it has room). */
  --shadow-panel: 0 1px 3px rgba(18, 18, 40, 0.13), 0 10px 24px -6px rgba(18, 18, 40, 0.22), 0 30px 60px -20px rgba(18, 18, 40, 0.42);
  --shadow-launcher: 0 6px 16px -2px color-mix(in srgb, var(--brand) 55%, transparent), 0 10px 28px -8px rgba(18, 18, 40, 0.3);
  --shadow-card: 0 1px 2px rgba(18, 18, 40, 0.04), 0 2px 8px -4px rgba(18, 18, 40, 0.08);
}
/* Dark host / OS dark mode: a light card needs a darker, deeper ambient shadow to
   read as floating against a dark dashboard behind it. */
@media (prefers-color-scheme: dark) {
  :root {
    --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.5), 0 12px 30px -6px rgba(0, 0, 0, 0.55), 0 30px 60px -20px rgba(0, 0, 0, 0.72);
  }
}
/* Dark THEME (brand.theme = 'dark', or 'auto' → prefers-color-scheme). Set as
   data-theme="dark" on <html> by widget.js applyTheme(). Flips the neutral
   palette; --brand / --action / header stay tenant-driven. */
[data-theme="dark"] {
  --ink: #ededf0;
  --ink-2: #d3d3db;
  --muted: #9a9aa4;
  --faint: #70707a;
  --line: rgba(255, 255, 255, 0.09);
  --surface: #17171b;
  --surface-2: #202027;
  --bubble-in: #23232b;
  --card-base: #17171b;
  --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.5), 0 12px 30px -6px rgba(0, 0, 0, 0.55), 0 30px 60px -20px rgba(0, 0, 0, 0.72);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); }
* { box-sizing: border-box; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
html, body { margin: 0; height: 100%; background: transparent; }
body { font-family: var(--font); color: var(--ink); font-size: 14px; }
#iris-root { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- Avatars ---------- */
.iris-av {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff;
  font-weight: 600; font-size: 12px; line-height: 1; letter-spacing: 0; text-align: center;
  flex: none; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.iris-av img { width: 100%; height: 100%; object-fit: cover; }
.iris-g0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.iris-g1 { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.iris-g2 { background: linear-gradient(135deg, #ec4899, #d946ef); }
.iris-g3 { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.iris-g4 { background: linear-gradient(135deg, #f59e0b, #f43f5e); }
.iris-g5 { background: linear-gradient(135deg, #10b981, #06b6d4); }
.iris-g6 { background: linear-gradient(135deg, #ef4444, #f97316); }
.iris-g7 { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.iris-g8 { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.iris-g9 { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.iris-g10 { background: linear-gradient(135deg, #db2777, #9d174d); }
.iris-g11 { background: linear-gradient(135deg, #ea580c, #c2410c); }

/* ---------- Launcher ---------- */
.iris-launcher {
  position: absolute; right: 16px; bottom: 16px; width: 60px; height: 60px; border: 0; cursor: pointer;
  border-radius: 50%; background: var(--brand); box-shadow: var(--shadow-launcher);
  display: grid; place-items: center; transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.iris-launcher::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.28), transparent 55%);
}
.iris-launcher:hover { transform: scale(1.05); }
.iris-launcher:active { transform: scale(0.94); }
.iris-launcher svg { width: 26px; height: 26px; fill: #fff; position: relative; transition: transform .3s ease, opacity .2s ease; }
.iris-launcher .ic-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(.6); }
.iris-open .iris-launcher .ic-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.iris-open .iris-launcher .ic-close { opacity: 1; transform: rotate(0) scale(1); }
.iris-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: #ff4d4f; color: #fff; font-size: 11px; font-weight: 700;
  display: none; place-items: center; border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.iris-badge.show { display: grid; }
/* One-time attention pulse when a reply lands on the CLOSED bubble (F1): a soft
   pop of the launcher + an expanding brand ring. Added/removed in JS per reply. */
.iris-launcher.iris-ping { animation: iris-launcher-pop .6s cubic-bezier(.34, 1.56, .64, 1); }
.iris-launcher.iris-ping::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  animation: iris-launcher-ring 1s ease-out;
}
@keyframes iris-launcher-pop { 0% { transform: scale(1); } 32% { transform: scale(1.14); } 60% { transform: scale(.97); } 100% { transform: scale(1); } }
@keyframes iris-launcher-ring {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 55%, transparent); }
  to { box-shadow: 0 0 0 16px transparent; }
}

/* ---------- Panel ---------- */
.iris-panel {
  position: absolute; right: 16px; bottom: 88px; left: 16px; top: 16px;
  background: var(--surface); border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-panel); display: flex; flex-direction: column;
  opacity: 0; transform: translateY(12px) scale(.98); transform-origin: bottom right;
  pointer-events: none; transition: opacity .26s ease, transform .26s cubic-bezier(.22,1,.36,1);
}
.iris-open .iris-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ---------- Header ---------- */
.iris-header {
  position: relative; color: #fff; padding: 22px 22px 24px; flex: none;
  /* Tenant background wins when set (brand.background solid/gradient → --header-bg);
     otherwise the rich default gradient (the var() fallback) renders. */
  background: var(--header-bg,
    radial-gradient(130% 120% at 0% 0%, color-mix(in srgb, #fff 22%, transparent), transparent 55%),
    radial-gradient(120% 130% at 100% 0%, color-mix(in srgb, #000 26%, transparent), transparent 60%),
    linear-gradient(150deg, color-mix(in srgb, var(--brand) 82%, #fff), var(--brand) 45%, color-mix(in srgb, var(--brand) 78%, #000)));
}
.iris-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
}
.iris-logo { display: none; height: 28px; max-width: 150px; object-fit: contain; object-position: left; border-radius: 6px; margin-bottom: 12px; }
.iris-has-logo .iris-logo { display: block; } /* brand.logo set → tenant logo above the greeting */
.iris-avatars { display: flex; margin-bottom: 14px; }
.iris-avatars .iris-av { width: 38px; height: 38px; font-size: 13px; margin-left: -10px; box-shadow: 0 0 0 2.5px var(--brand), inset 0 0 0 1px rgba(255,255,255,.25); }
.iris-avatars .iris-av:first-child { margin-left: 0; }
.iris-avatars .iris-status-dot { position: relative; }
.iris-greeting h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.iris-greeting .sub { margin: 6px 0 0; font-size: 15px; font-weight: 400; color: rgba(255,255,255,.82); letter-spacing: -.01em; }

/* header sub-views — one shows per view */
.iris-greeting, .iris-convo-head, .iris-simple-head { display: none; }
.iris-view-home .iris-greeting { display: block; }
.iris-view-conversation .iris-convo-head { display: flex; align-items: center; gap: 12px; }
.iris-view-messages .iris-simple-head, .iris-view-article .iris-simple-head, .iris-view-checklist .iris-simple-head { display: flex; align-items: center; gap: 12px; }
/* Reserve room for the top-right control cluster (expand + close, ~66px) so a
   long title/agent-name never slides under the buttons. */
.iris-view-conversation .iris-convo-head, .iris-view-messages .iris-simple-head, .iris-view-article .iris-simple-head, .iris-view-checklist .iris-simple-head { padding-right: 72px; }
.iris-simple-head { min-width: 0; }
.iris-simple-head #iris-simple-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* compact conversation header */
.iris-convo-head { align-items: center; gap: 12px; }
.iris-convo-head .iris-back {
  background: rgba(255,255,255,.16); border: 0; width: 30px; height: 30px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; flex: none; transition: background .15s;
}
.iris-convo-head .iris-back:hover { background: rgba(255,255,255,.26); }
.iris-convo-head .iris-back svg { width: 16px; height: 16px; fill: #fff; }
.iris-convo-head .iris-av { width: 40px; height: 40px; box-shadow: 0 0 0 2px rgba(255,255,255,.3); }
.iris-convo-head .who { line-height: 1.25; }
.iris-convo-head .who b { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.iris-convo-head .who small { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: rgba(255,255,255,.78); }
.dot-online { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 70%, #000); }
/* away hint — muted, wraps (may be a full sentence) */
.iris-convo-head .who small.iris-away { display: block; color: rgba(255,255,255,.7); font-style: italic; white-space: normal; }

/* ---------- Body ---------- */
.iris-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; background: var(--surface); }

/* Home */
.iris-home { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.iris-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card);
  overflow: hidden;
}
.iris-card-pad { padding: 16px 16px 18px; }
.iris-card h3 { margin: 0 0 3px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.iris-card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.iris-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line); font: inherit; text-align: left; transition: background .14s;
}
.iris-row:hover { background: var(--surface-2); }
.iris-row .grow { flex: 1; min-width: 0; }
.iris-row .grow b { display: block; font-size: 14px; font-weight: 600; }
.iris-row .grow span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iris-row .chev { color: var(--action); flex: none; }
.iris-row .chev svg { width: 18px; height: 18px; fill: currentColor; }
.iris-compose-row b { color: var(--action); }
.iris-mini-avatars { display: flex; flex: none; }
.iris-mini-avatars .iris-av { width: 26px; height: 26px; font-size: 10px; margin-left: -9px; box-shadow: 0 0 0 2px var(--surface), inset 0 0 0 1px rgba(255,255,255,.2); }
.iris-mini-avatars .iris-av:first-child { margin-left: 0; }
.iris-search {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid var(--line);
  border-radius: 12px; color: var(--faint); font-size: 14px; background: var(--surface); box-shadow: var(--shadow-card);
}
.iris-search svg { width: 18px; height: 18px; fill: var(--faint); }

/* ---------- Messages ---------- */
.iris-messages { padding: 18px 16px 8px; display: flex; flex-direction: column; }
.iris-group { display: flex; gap: 10px; margin-bottom: 14px; }
.iris-group.out { flex-direction: row-reverse; }
.iris-group .iris-av { width: 28px; height: 28px; font-size: 11px; align-self: flex-end; }
.iris-group.out .iris-av { display: none; }
.iris-group .stack { display: flex; flex-direction: column; gap: 7px; max-width: 80%; min-width: 0; }
.iris-group.out .stack { align-items: flex-end; }
.iris-meta { font-size: 11.5px; color: var(--faint); margin: 0 4px 3px; letter-spacing: .01em; }
.iris-meta b { color: var(--muted); font-weight: 600; }
.iris-msg {
  padding: 10px 14px; font-size: 14px; line-height: 1.45; border-radius: 18px; word-wrap: break-word;
}
.iris-group.in .iris-msg { background: var(--bubble-in); color: var(--ink); border-bottom-left-radius: 6px; }
.iris-group.out .iris-msg { background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; }
.iris-group .iris-msg + .iris-msg { border-radius: 18px; }
.iris-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.iris-msg a:hover { opacity: .85; }
.iris-msg strong { font-weight: 600; }
.iris-group.in .iris-msg:not(:last-child) { border-bottom-left-radius: 18px; }
.iris-group.out .iris-msg:not(:last-child) { border-bottom-right-radius: 18px; }
@keyframes iris-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.iris-seen { font-size: 11px; color: var(--faint); margin: 1px 6px 0; }

.iris-empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 28px 24px; }

/* typing */
.iris-typing-row { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-end; }
.iris-typing-row .iris-av { width: 28px; height: 28px; font-size: 11px; }
.iris-typing { display: flex; gap: 4px; padding: 13px 15px; background: var(--bubble-in); border-radius: 18px; border-bottom-left-radius: 6px; }
.iris-typing i { width: 7px; height: 7px; border-radius: 50%; background: #b4b4c0; animation: iris-bounce 1.3s infinite ease-in-out; }
.iris-typing i:nth-child(2) { animation-delay: .16s; }
.iris-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes iris-bounce { 0%, 64%, 100% { transform: translateY(0); opacity: .45; } 32% { transform: translateY(-5px); opacity: 1; } }

/* ---------- Composer ---------- */
.iris-composer { flex: none; border-top: 1px solid var(--line); padding: 10px 12px 12px; background: var(--surface); display: none; }
.iris-view-conversation .iris-composer { display: block; }
.iris-input-wrap { display: flex; align-items: flex-end; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px; transition: border-color .15s, box-shadow .15s; }
.iris-input-wrap:focus-within { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.iris-composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; font: inherit; font-size: 14px; line-height: 1.4; max-height: 100px; padding: 6px 0; color: var(--ink); }
.iris-composer textarea::placeholder { color: var(--faint); }
.iris-send { border: 0; background: var(--action); color: #fff; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; flex: none; transition: transform .15s, opacity .15s, filter .15s; }
.iris-send:hover { filter: brightness(1.06); }
.iris-send:active { transform: scale(.92); }
.iris-send:disabled { opacity: .35; cursor: default; }
.iris-send svg { width: 17px; height: 17px; fill: #fff; }

/* ---------- Footer ---------- */
.iris-footer { flex: none; text-align: center; font-size: 11.5px; color: var(--faint); padding: 9px; background: var(--surface); border-top: 1px solid var(--line); }
.iris-footer b { color: var(--muted); font-weight: 600; }
.iris-footer .bolt { color: var(--brand); }

/* ---------- Image attachments ---------- */
.iris-att { display: block; max-width: 240px; max-height: 280px; width: auto; border-radius: 12px; margin-top: 4px; cursor: pointer; object-fit: cover; }
.iris-msg.img-only { background: transparent !important; padding: 0 !important; }
.iris-msg.img-only .iris-att { margin: 0; }

/* CSAT rating — 5-emoji faces in a centered card (AiSensy/Intercom parity) */
.iris-rate { margin: 12px 6px 6px; padding: 16px 14px 14px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-card); }
.iris-rate .rate-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.iris-rate .faces { display: flex; gap: 4px; justify-content: center; margin-top: 12px; }
.iris-rate .face { border: 0; background: none; cursor: pointer; font-size: 27px; line-height: 1; padding: 4px; border-radius: 12px; filter: grayscale(1) opacity(.55); transform: scale(.92); transition: filter .14s, transform .14s; }
.iris-rate .face:hover { filter: grayscale(0) opacity(1); transform: scale(1.08); }
.iris-rate .face.sel { filter: grayscale(0) opacity(1); transform: scale(1.16); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.iris-rate .face-label { margin-top: 8px; min-height: 16px; font-size: 12px; font-weight: 600; color: var(--brand); letter-spacing: .2px; }
.iris-rate .rate-comment { width: 100%; box-sizing: border-box; margin-top: 10px; padding: 8px 10px; font: inherit; font-size: 13px; line-height: 1.4; color: inherit; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; resize: none; outline: none; transition: border-color .12s; }
.iris-rate .rate-comment:focus { border-color: var(--brand); }
.iris-rate .rate-actions { margin-top: 10px; }
.iris-rate .rate-send { border: 0; border-radius: 999px; background: var(--action); color: var(--brand-ink); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 22px; cursor: pointer; transition: filter .12s; }
.iris-rate .rate-send:hover { filter: brightness(.94); }
.iris-rate .rate-thanks { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.iris-rate .rate-thanks.low { color: #b4432f; }

/* attach button in composer */
.iris-attach { flex: none; width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); border-radius: 9px; cursor: pointer; display: grid; place-items: center; align-self: flex-end; transition: background .15s, color .15s; }
.iris-attach:hover { background: var(--surface-2); color: var(--brand); }
.iris-attach svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; }

/* header control cluster (expand + close) — top-right, all views */
.iris-header-ctl { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; z-index: 2; }
.iris-hbtn { width: 30px; height: 30px; border: 0; border-radius: 9px; background: rgba(255,255,255,.16); color: #fff; cursor: pointer; display: grid; place-items: center; transition: background .15s; }
.iris-hbtn:hover { background: rgba(255,255,255,.28); }
.iris-hbtn svg { width: 16px; height: 16px; fill: #fff; }
.iris-hbtn#iris-expand svg { fill: none; stroke: #fff; }

/* simple header (Messages / Article / Checklist) — slimmer than the greeting header */
.iris-view-messages .iris-header, .iris-view-article .iris-header, .iris-view-checklist .iris-header { padding: 18px 20px; }
.iris-simple-head #iris-simple-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.iris-view-messages #iris-simple-back { display: none; } /* Messages is a top-level tab, no back */
.iris-simple-head .iris-back {
  background: rgba(255,255,255,.16); border: 0; width: 30px; height: 30px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; flex: none; transition: background .15s;
}
.iris-simple-head .iris-back:hover { background: rgba(255,255,255,.26); }
.iris-simple-head .iris-back svg { width: 16px; height: 16px; fill: #fff; }

/* ---------- Bottom nav (Home | Messages) ---------- */
.iris-nav { display: none; flex: none; border-top: 1px solid var(--line); background: var(--surface); padding: 6px 8px; }
.iris-view-home .iris-nav, .iris-view-messages .iris-nav { display: flex; }
.iris-nav-btn {
  flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; cursor: pointer; font: inherit; padding: 8px 4px; color: var(--faint);
  border-radius: 12px; transition: color .14s, background .14s;
}
.iris-nav-btn span { font-size: 11.5px; font-weight: 600; letter-spacing: .01em; }
.iris-nav-btn svg { width: 22px; height: 22px; }
.iris-nav-btn:hover { background: var(--surface-2); }
.iris-nav-btn.active { color: var(--action); }
.iris-nav-badge {
  display: none; position: absolute; top: 4px; right: 50%; margin-right: -22px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: #ff4d4f; color: #fff; font-size: 10px; font-weight: 700; place-items: center; font-style: normal;
  border: 2px solid var(--surface);
}
.iris-nav-badge.show { display: grid; }

/* ---------- Help Center (Home search + article list) ---------- */
.iris-help { display: flex; flex-direction: column; gap: 4px; }
.iris-search .ic { display: inline-grid; place-items: center; }
.iris-search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 14px; color: var(--ink); padding: 0; }
.iris-search input::placeholder { color: var(--faint); }
.iris-help-list { display: flex; flex-direction: column; }
.iris-help-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 8px; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; text-align: left; transition: background .14s;
}
.iris-help-item:last-child { border-bottom: 0; }
.iris-help-item:hover { background: var(--surface-2); }
.iris-help-item .grow { flex: 1; min-width: 0; }
.iris-help-item .grow b { display: block; font-size: 14px; font-weight: 600; }
.iris-help-item .grow span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.iris-help-item .chev { color: var(--action); flex: none; }
.iris-help-item .chev svg { width: 18px; height: 18px; fill: currentColor; }
.iris-help-hint { padding: 12px 8px; font-size: 13px; color: var(--muted); }

/* ---------- Fin-style AI answer card (Home search) ---------- */
.iris-ai-answer:empty { display: none; }
.iris-ai-card {
  margin: 6px 0 10px; padding: 14px; border-radius: 14px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 7%, var(--card-base)), color-mix(in srgb, var(--brand) 3%, var(--card-base)));
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  box-shadow: var(--shadow-card);
}
.iris-ai-head { margin-bottom: 8px; }
.iris-ai-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .02em; text-transform: uppercase; color: var(--brand);
}
.iris-ai-badge svg { width: 14px; height: 14px; }
.iris-ai-body { font-size: 14px; line-height: 1.6; color: var(--ink); }
.iris-ai-body a { color: var(--brand); }
.iris-ai-body p { margin: 0 0 8px; } .iris-ai-body p:last-child { margin-bottom: 0; }
.iris-ai-sources { margin-top: 12px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line)); }
.iris-ai-srch { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin: 0 0 4px 2px; }
.iris-ai-src {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 8px; cursor: pointer;
  background: none; border: 0; border-radius: 9px; font: inherit; text-align: left; color: var(--ink); transition: background .14s;
}
.iris-ai-src:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.iris-ai-src .ic { display: inline-grid; place-items: center; color: var(--brand); flex: none; }
.iris-ai-src .ic svg { width: 16px; height: 16px; }
.iris-ai-src .grow { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iris-ai-src .chev { color: var(--brand); flex: none; }
.iris-ai-src .chev svg { width: 16px; height: 16px; fill: currentColor; }
/* AI-answer loading — brand-tinted skel bars on the same sweep primitive below */
.iris-ai-skel { display: flex; flex-direction: column; gap: 7px; padding: 2px 0; }
.iris-ai-skel span { height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--brand) 12%, var(--line)); }
.iris-ai-skel span::after { background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--brand) 22%, transparent), transparent); }
.iris-ai-skel span:nth-child(1) { width: 92%; } .iris-ai-skel span:nth-child(2) { width: 100%; } .iris-ai-skel span:nth-child(3) { width: 62%; }

/* ── Skeleton loaders — ONE primitive (.iris-skel) + ONE shimmer keyframe. A quiet
   --bubble-in base with a subtle --surface highlight sweeping across; matches each
   surface's real shape so content swaps in with no shift. Light + dark. ──────── */
.iris-skel { position: relative; overflow: hidden; background: var(--bubble-in); border-radius: 7px; flex: none; }
.iris-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 62%, transparent), transparent);
  animation: iris-skel-sweep 1.5s ease infinite; }
@keyframes iris-skel-sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .iris-skel::after { animation: none; } }
.iris-skel-line { height: 11px; border-radius: 6px; }
.iris-skel-circle { border-radius: 50%; }
.iris-skel-rect { border-radius: 14px; }
/* Home / Help list rows */
.iris-skel-item { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.iris-skel-item:last-child { border-bottom: 0; }
.iris-skel-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
/* Messages-tab conversation rows */
.iris-skel-convo { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.iris-skel-convo .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
/* Message-thread bubbles */
.iris-skel-msgs { padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.iris-skel-grp { display: flex; gap: 10px; }
.iris-skel-grp.out { flex-direction: row-reverse; }
.iris-skel-bub { border-radius: 18px; }
.iris-skel-grp.in .iris-skel-bub { border-bottom-left-radius: 6px; }
.iris-skel-grp.out .iris-skel-bub { border-bottom-right-radius: 6px; }

/* ---------- Conversation list (Messages tab) ---------- */
.iris-convo-list { display: flex; flex-direction: column; }
.iris-convo-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; text-align: left; transition: background .14s;
}
.iris-convo-item:hover { background: var(--surface-2); }
.iris-convo-item .iris-av { width: 40px; height: 40px; font-size: 13px; }
.iris-convo-item .grow { flex: 1; min-width: 0; }
.iris-convo-item .grow b { display: block; font-size: 14px; font-weight: 600; }
.iris-convo-item .prev { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.iris-convo-item.unread .prev { color: var(--ink); font-weight: 500; }
.iris-convo-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.iris-convo-item .meta time { font-size: 11.5px; color: var(--faint); }
.iris-convo-item .iris-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }

/* ---------- Article reader ---------- */
.iris-article { padding: 20px 18px 28px; }
.iris-article > h1 { margin: 0 0 14px; font-size: 22px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; color: var(--ink); }
.iris-article-body { font-size: 14.5px; line-height: 1.62; color: var(--ink-2); }
.iris-article-body h1 { font-size: 19px; }
.iris-article-body h2 { font-size: 17px; }
.iris-article-body h3 { font-size: 15px; }
.iris-article-body h4 { font-size: 14px; }
.iris-article-body h1, .iris-article-body h2, .iris-article-body h3, .iris-article-body h4 { margin: 20px 0 8px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; color: var(--ink); }
.iris-article-body p { margin: 0 0 12px; }
.iris-article-body ul, .iris-article-body ol { margin: 0 0 12px; padding-left: 22px; }
.iris-article-body li { margin: 4px 0; }
.iris-article-body a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.iris-article-body strong { font-weight: 700; }
.iris-article-body code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.iris-article-body blockquote { margin: 0 0 12px; padding: 6px 14px; border-left: 3px solid color-mix(in srgb, var(--brand) 55%, var(--line)); color: var(--muted); }
.iris-article-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.iris-help-cta { width: 100%; border: 0; border-radius: 12px; background: var(--action); color: var(--brand-ink); font: inherit; font-size: 14px; font-weight: 600; padding: 12px; cursor: pointer; transition: filter .12s; }
.iris-help-cta:hover { filter: brightness(1.05); }

/* ---------- Checklists ("Get started" walks) ---------- */
/* Home card — a normal .iris-card row led by a small brand-arc progress ring */
.iris-ck-ring { flex: none; transform: rotate(-90deg); }
.iris-ck-ring .track { fill: none; stroke: var(--line); stroke-width: 2.5; }
.iris-ck-ring .arc { fill: none; stroke: var(--action); stroke-width: 2.5; stroke-linecap: round; }
.iris-ck-cta { border-top: 0; } /* it IS the card — no inner divider */
/* Checklist view — progress bar + count + the step list */
.iris-ck { padding: 16px 14px 24px; }
.iris-ck-progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.iris-ck-progress i { display: block; height: 100%; border-radius: 2px; background: var(--action); transition: width .3s ease; }
.iris-ck-count { margin: 8px 2px 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
.iris-ck-steps { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.iris-ck-step {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 13px 14px; cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line); font: inherit; text-align: left; color: var(--ink); transition: background .14s;
}
.iris-ck-step:first-child { border-top: 0; }
.iris-ck-step:hover { background: var(--surface-2); }
.iris-ck-check {
  flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid var(--faint); display: inline-grid; place-items: center; color: #fff;
  transition: background .14s, border-color .14s;
}
.iris-ck-check svg { width: 10px; height: 10px; }
.iris-ck-step.done .iris-ck-check { background: var(--action); border-color: var(--action); }
.iris-ck-step .grow { flex: 1; min-width: 0; }
.iris-ck-step .grow b { display: block; font-size: 14px; font-weight: 600; }
.iris-ck-step .grow span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.iris-ck-step.done .grow b { color: var(--faint); font-weight: 500; text-decoration: line-through; }
.iris-ck-step.done { cursor: default; }
.iris-ck-step .chev { color: var(--action); flex: none; margin-top: 1px; }
.iris-ck-step .chev svg { width: 16px; height: 16px; fill: currentColor; }
.iris-ck-done-note { margin-top: 14px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Expanded / maximized reading view (#36) ---------- */
.iris-expanded .iris-home, .iris-expanded .iris-convo-list, .iris-expanded .iris-messages,
.iris-expanded .iris-article, .iris-expanded .iris-ck { max-width: 640px; margin: 0 auto; }
.iris-expanded .iris-group .stack { max-width: 88%; }

/* ---------- Mobile: full-screen panel ---------- */
@media (max-width: 480px) {
  .iris-panel { right: 0; bottom: 0; left: 0; top: 0; border-radius: 0; }
  .iris-open .iris-launcher { display: none; }   /* use the header close instead */
  #iris-expand { display: none; }                /* expand is a no-op on full-screen mobile */
  .iris-expanded .iris-home, .iris-expanded .iris-convo-list,
  .iris-expanded .iris-messages, .iris-expanded .iris-article, .iris-expanded .iris-ck { max-width: none; }
  .iris-att { max-width: 70vw; }
}

/* ============================================================================
   Per-tenant brand toggles (root classes set by widget.js applyBrand). Each is
   backward-compatible — absent config = the class is off = the default look.
   ============================================================================ */
/* Launcher position (brand.launcher.position). The loader re-anchors the iframe
   to the matching edge; here we flip the launcher + panel transform-origin. */
.iris-pos-left .iris-launcher { left: 16px; right: auto; }
.iris-pos-left .iris-panel { transform-origin: bottom left; }
.iris-pos-left .iris-badge { right: auto; left: -3px; }

/* Launcher hidden (brand.launcher.show = false) — host opens via window.Iris.open(). */
.iris-no-launcher .iris-launcher { display: none; }

/* Custom launcher icon (brand.launcher.iconUrl) — swaps the chat glyph for an img. */
.iris-launcher img.ic-custom { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; position: relative; transition: transform .3s ease, opacity .2s ease; }
.iris-open .iris-launcher img.ic-custom { opacity: 0; transform: rotate(90deg) scale(.6); }

/* Teammate avatars hidden (brand.teammateAvatars = false). */
.iris-no-avatars .iris-avatars,
.iris-no-avatars .iris-mini-avatars,
.iris-no-avatars .iris-convo-head .iris-av,
.iris-no-avatars .iris-convo-item .iris-av,
.iris-no-avatars .iris-group.in .iris-av,
.iris-no-avatars .iris-typing-row .iris-av { display: none; }
/* keep the inbound message left-aligned once its avatar is hidden */
.iris-no-avatars .iris-group.in { padding-left: 2px; }

/* "Powered by Iris" hidden (brand.poweredBy = false). */
.iris-no-poweredby .iris-footer { display: none; }

/* Spaces (brand.spaces) — hide individual nav tabs; hide the whole nav if ≤1. */
.iris-no-home .iris-nav-btn[data-nav="home"] { display: none; }
.iris-no-messages .iris-nav-btn[data-nav="messages"] { display: none; }
.iris-single-space .iris-nav { display: none !important; }

/* ---- Pre-chat workflow (qualification flow) ---- */
/* Option pills for a 'choice' step — one quiet row under the bot prompt,
   indented to the bubble line (avatar 28px + 10px gap). Outlined in the
   tenant's action color; hover fills. Pop in with the same iris-pop feel
   as bubbles; dark theme rides the same vars. */
.iris-wf-opts { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px 38px; animation: iris-pop .18s ease both; }
.iris-no-avatars .iris-wf-opts { margin-left: 2px; }
.iris-wf-opt {
  border: 1.5px solid var(--action); background: transparent; color: var(--action);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 600;
  line-height: 1.2; cursor: pointer; transition: background .12s ease, color .12s ease, transform .12s ease;
}
.iris-wf-opt:hover { background: var(--action); color: var(--brand-ink); }
.iris-wf-opt:active { transform: scale(.97); }

/* ============================================================================
   Inline checklist embed ("Checklists anywhere") — widget.html?embed=checklist,
   its OWN iframe per host target node (loader.js Iris('checklist', {target})).
   Every selector is .iris-ckembed*-prefixed or html.iris-embed-scoped, so
   nothing leaks and none of the messenger chrome applies. Brand vars + the
   dark-theme palette flip ride the same custom properties as the messenger.
   ============================================================================ */
html.iris-embed, html.iris-embed body { height: auto; overflow: hidden; }
html.iris-embed #iris-root { position: static; inset: auto; display: block; }

.iris-ckembed {
  font-family: var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card); overflow: hidden;
}
.iris-ckembed-head { display: flex; align-items: flex-start; gap: 10px; padding: 18px 18px 0; }
.iris-ckembed-head .grow { flex: 1; min-width: 0; }
.iris-ckembed-title { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.iris-ckembed-count { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.iris-ckembed-dismiss {
  flex: none; width: 26px; height: 26px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--faint); display: grid; place-items: center;
  transition: background .14s, color .14s;
}
.iris-ckembed-dismiss:hover { background: var(--surface-2); color: var(--muted); }
.iris-ckembed-dismiss svg { width: 14px; height: 14px; fill: currentColor; }
.iris-ckembed-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin: 12px 18px 14px; }
.iris-ckembed-bar i { display: block; height: 100%; border-radius: 2px; background: var(--action); transition: width .3s ease; }
.iris-ckembed-step {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 13px 18px; cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line); font: inherit; text-align: left;
  color: var(--ink); transition: background .14s;
}
.iris-ckembed-step:hover { background: var(--surface-2); }
.iris-ckembed-check {
  flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid var(--faint); display: inline-grid; place-items: center; color: #fff;
  transition: background .14s, border-color .14s;
}
.iris-ckembed-check svg { width: 10px; height: 10px; }
.iris-ckembed-step.done .iris-ckembed-check { background: var(--action); border-color: var(--action); }
.iris-ckembed-step .grow { flex: 1; min-width: 0; }
.iris-ckembed-step .grow b { display: block; font-size: 14px; font-weight: 600; }
.iris-ckembed-step .grow span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.iris-ckembed-step .grow span a { color: var(--action); }
.iris-ckembed-step.done { cursor: default; }
.iris-ckembed-step.done .grow b { color: var(--faint); font-weight: 500; text-decoration: line-through; }
.iris-ckembed-step .chev { color: var(--action); flex: none; margin-top: 1px; }
.iris-ckembed-step .chev svg { width: 16px; height: 16px; fill: currentColor; }
.iris-ckembed-done-note { padding: 12px 18px 16px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); border-top: 1px solid var(--line); }
/* Narrow host containers (sidebars, phone columns) — tighten, never overflow. */
@media (max-width: 380px) {
  .iris-ckembed-head, .iris-ckembed-step { padding-left: 14px; padding-right: 14px; }
  .iris-ckembed-bar { margin-left: 14px; margin-right: 14px; }
}

/* chat marathon (2026-07-05) */
.iris-audio { display: block; margin-top: 6px; max-width: 240px; height: 34px; }
.iris-edited { display: inline-block; font-size: 10.5px; opacity: .6; margin-left: 6px; font-style: italic; }
.iris-rx { display: flex; gap: 4px; margin-top: 4px; }
.iris-rx i { font-style: normal; font-size: 12px; background: rgba(127,127,127,.12); border-radius: 999px; padding: 1px 7px; }
.iris-q { display: block; border-left: 3px solid currentColor; opacity: .75; border-radius: 5px; padding: 5px 9px; margin-bottom: 6px; font-size: 12px; background: rgba(127,127,127,.1); }
.iris-q b { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
