/* ==========================================================================
   Krisp visitor widget
   A standalone page shown in the embed iframe (380 x 600) or full-screen on a
   phone. Deliberately small: it does not load app.css or the dashboard shell.

   Theming: widget.js sets --accent, --on-accent, --accent-ink, --accent-soft
   and --accent-line on <html> from the workspace's accent colour. Surfaces
   stay neutral whatever the accent: the colour marks the header, the
   visitor's own messages and the main actions. The values below are the
   defaults used until the workspace loads.

   Contents: 1 tokens  2 base  3 states  4 header + tabs  5 thread  6 details
             7 csat  8 composer  8b images, quotes, edited  9 help
             10 motion + forced colours
   ========================================================================== */

/* -- 1. Tokens ------------------------------------------------------------- */

:root {
  --paper: #FFFFFF;
  --card: #FFFFFF;
  --sunken: #F2F3F5;
  --ink: #121419;
  --ink-2: #3D424C;
  --muted: #646B78;          /* 5.3:1 on white */
  --border: #E6E8EC;
  --border-strong: #D6D9DF;
  --border-control: #8C93A0; /* 3:1 on white */

  --accent: #C8853F;
  --accent-hover: #B17230;
  --on-accent: #1F2421;
  --accent-ink: #8A5413;     /* the accent as text or focus ring on paper */
  --accent-soft: #F5E6CF;
  --accent-line: #E3C69F;

  --success: #1F9D55;
  --danger-ink: #B42318;
  --danger-soft: #FDEEEC;

  /* The visitor's own system font: fast on any site, and native on any phone. */
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 10px;
  --radius-bubble: 16px;
  --shadow: 0 1px 2px rgba(18, 20, 25, 0.06);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --t: 180ms;
  --gutter: 16px;
  --tap: 40px;

  color-scheme: light;
}

@media (pointer: coarse) {
  :root { --tap: 44px; }
}

/* -- 2. Base --------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, p {
  margin: 0;
}

button, input, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-underline-offset: 2px;
}

svg.icon {
  flex: none;
  display: inline-block;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.w-app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: #F8FAFC;
  overflow: hidden;
  overflow: clip;
}

/* Opened directly in a wide window: a centred column instead of a stretched one. */
@media (min-width: 760px) {
  body { background: #EFE8DA; }
  .w-app {
    border-inline: 1px solid var(--border);
    box-shadow: 0 0 0 1px rgba(18, 20, 25, 0.02), 0 12px 40px rgba(18, 20, 25, 0.08);
  }
}

/* -- Buttons --------------------------------------------------------------- */

.w-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease),
    transform var(--t) var(--ease), opacity var(--t) var(--ease);
}

.w-btn-primary {
  background: var(--accent);
  color: var(--on-accent, #ffffff);
}

.w-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover, var(--accent));
}

.w-btn-primary:active:not(:disabled) {
  filter: brightness(0.94);
}

.w-btn-quiet {
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--border-control);
}

.w-btn-quiet:hover:not(:disabled) {
  background: var(--sunken);
}

.w-btn-text {
  padding: 0 10px;
  color: var(--muted);
}

.w-btn-text:hover:not(:disabled) {
  color: var(--ink);
  background: var(--sunken);
}

.w-btn:disabled {
  opacity: 0.5;
}

.w-btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
  opacity: 1;
}

.w-btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--on-accent);
  border-right-color: transparent;
  animation: w-spin 0.7s linear infinite;
}

.w-btn-quiet.is-loading::after {
  border-color: var(--ink);
  border-right-color: transparent;
}

.w-link {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  border-radius: 4px;
  /* A text button still needs a usable hit area on touch screens. */
  padding: 6px 4px;
  margin: -6px -4px;
}

.w-link:hover {
  color: var(--ink);
}

/* -- 3. Full-frame states (loading, unavailable, load error) -------------- */

.w-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 28px;
  text-align: center;
}

.w-state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 6px;
  border-radius: 14px;
  background: var(--sunken);
  color: var(--ink-2);
}

.w-state-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.w-state-text {
  max-width: 30ch;
  color: var(--muted);
  font-size: 14px;
  text-wrap: pretty;
}

.w-state .w-btn {
  margin-top: 10px;
}

/* What failed, in a few words a screenshot can be read by. */
.w-state-detail,
.w-inline-detail {
  color: var(--muted);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.w-state-detail {
  max-width: 34ch;
  margin-top: 6px;
}

.w-inline-detail {
  margin-top: 2px;
}

/* While the chat loads: the Krisp mark, breathing gently. */
.w-loading-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  animation: w-breathe 1.6s ease-in-out infinite;
}

@keyframes w-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.w-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-ink);
  animation: w-spin 0.8s linear infinite;
}

.w-spinner-sm {
  width: 14px;
  height: 14px;
}

.w-noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 32px;
  background: var(--paper);
  text-align: center;
  color: var(--ink-2);
}

@keyframes w-spin {
  to { transform: rotate(360deg); }
}

/* -- 4. Header + tabs ------------------------------------------------------ */

.w-head {
  flex: none;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.w-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--gutter) 10px;
}

.w-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.w-brand-text {
  min-width: 0;
}

.w-name-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.w-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.011em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.w-social-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}

.w-social-toggle:hover,
.w-social-toggle.is-open {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.w-social-toggle.is-open svg {
  transform: rotate(180deg);
}

.w-social-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 10px 26px rgba(24, 24, 27, 0.14), 0 2px 6px rgba(24, 24, 27, 0.06);
}

.w-social-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #475569;
  text-decoration: none;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}

.w-social-item:hover {
  background: var(--sunken);
  color: var(--ink);
}

.w-social-item.is-telegram:hover { color: #229ED9; }
.w-social-item.is-twitter:hover { color: #0F1419; }
.w-social-item.is-discord:hover { color: #5865F2; }
.w-social-item.is-whatsapp:hover { color: #25D366; }
.w-social-item.is-messenger:hover { color: #0084FF; }
.w-social-item.is-instagram:hover { color: #E1306C; }
.w-social-item.is-email:hover { color: var(--accent-ink); }
.w-social-item.is-phone:hover { color: var(--success); }

.w-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.3;
}

.w-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-control);
}

.w-status[data-state="online"] .w-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(60, 138, 91, 0.16);
}

.w-status[data-state="connecting"] .w-dot {
  background: var(--accent);
  animation: w-pulse 1.2s ease-in-out infinite;
}

@keyframes w-pulse {
  50% { opacity: 0.35; }
}

.w-tabs {
  display: flex;
  gap: 4px;
  padding: 0 calc(var(--gutter) - 8px);
}

.w-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  transition: color var(--t) var(--ease);
}

.w-tab::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent-ink);
  transform: scaleX(0);
  transition: transform var(--t) var(--ease);
}

.w-tab:hover {
  color: var(--ink);
}

.w-tab[aria-selected="true"] {
  color: var(--ink);
}

.w-tab[aria-selected="true"]::after {
  transform: scaleX(1);
}

.w-tab:focus-visible {
  outline-offset: -3px;
}

.w-tab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.w-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* -- 5. Thread ------------------------------------------------------------- */

.w-scroll {
  /* Positioned, so visually hidden (absolute) text inside the thread scrolls
     with it instead of stretching the page. */
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px var(--gutter) 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.w-scroll:focus-visible {
  outline-offset: -2px;
}

.w-earlier {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.w-thread {
  display: flex;
  flex-direction: column;
}

.w-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 3px;
}

.w-msg.is-first {
  margin-top: 14px;
}

.w-intro > .w-msg:first-child {
  margin-top: 0;
}

.w-msg.is-me {
  justify-content: flex-end;
}

.w-msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: min(84%, 520px);
}

.w-msg.is-me .w-msg-col {
  align-items: flex-end;
}

.w-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px var(--border);
}

.w-avatar.is-ai,
.w-avatar.is-brand {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.w-avatar.is-brand {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}

.w-avatar-gap {
  flex: none;
  width: 28px;
}

/* Sit level with the bubble, not with the timestamp line under it. */
.w-msg.has-meta > .w-avatar {
  margin-bottom: 20px;
}

.w-author {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  margin: 0 2px 4px;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink-2);
  font-weight: 600;
}

.w-author-tag {
  color: var(--muted);
  font-weight: 400;
}

.w-bubble {
  max-width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-bubble);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03), inset 0 0 0 1px #E2E8F0;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.w-msg.is-them .w-bubble {
  border-bottom-left-radius: 5px;
}

.w-msg.is-them:not(.is-first) .w-bubble {
  border-top-left-radius: 5px;
}

.w-msg.is-me .w-bubble {
  background: var(--accent);
  color: var(--on-accent, #ffffff);
  border-bottom-right-radius: 5px;
}

.w-msg.is-me:not(.is-first) .w-bubble {
  border-top-right-radius: 5px;
}

.w-msg.is-pending .w-bubble {
  opacity: 0.72;
}

.w-msg.is-failed .w-bubble {
  background: var(--danger-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(166, 58, 40, 0.35);
}

.w-bubble a {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.w-bubble code,
.w-article-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.w-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 2px 6px;
  margin: 4px 3px 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.w-msg.is-me .w-meta {
  justify-content: flex-end;
  text-align: right;
}

.w-meta.is-failed {
  color: var(--danger-ink);
  font-size: 12.5px;
}

/* Choices under an assistant message (order lookup: "Get my credentials" /
   "Talk to an agent"). Only the newest message shows them. */
.w-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 2px;
  animation: w-choices-in 260ms var(--ease) both;
}

.w-choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 15px;
  border-radius: 999px;
  background: var(--card);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: inset 0 0 0 1.5px var(--accent-line), var(--shadow);
  transition: background-color var(--t) var(--ease), box-shadow var(--t) var(--ease),
    transform var(--t) var(--ease), color var(--t) var(--ease);
}

.w-choice:hover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.w-choice.is-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 1px rgba(18, 20, 25, 0.1), 0 2px 8px rgba(18, 20, 25, 0.12);
}

.w-choice.is-primary:hover {
  filter: brightness(1.05);
  box-shadow: inset 0 0 0 1px rgba(18, 20, 25, 0.1), 0 6px 16px rgba(18, 20, 25, 0.16);
}

.w-choice svg {
  flex: none;
}

@keyframes w-choices-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .w-choices { animation: none; }
  .w-choice, .w-choice:hover { transform: none; }
}

.w-meta.is-failed .w-link {
  color: var(--danger-ink);
}

.w-day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 2px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.w-day::before,
.w-day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Loading / inline error rows inside the thread */

.w-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 13.5px;
}

.w-inline.is-error {
  align-items: flex-start;
  background: var(--danger-soft);
  color: var(--ink);
}

.w-inline.is-error > .icon {
  margin-top: 1px;
  color: var(--danger-ink);
}

.w-inline-body {
  flex: 1;
  min-width: 0;
}

.w-inline-title {
  font-weight: 600;
}

.w-inline .w-link {
  flex: none;
  color: var(--ink);
}

/* Operator typing */

.w-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.w-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: 5px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border);
}

.w-typing-bubble i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-control);
  animation: w-bounce 1.2s ease-in-out infinite;
}

.w-typing-bubble i:nth-child(2) { animation-delay: 0.15s; }
.w-typing-bubble i:nth-child(3) { animation-delay: 0.3s; }

@keyframes w-bounce {
  0%, 60%, 100% { transform: none; opacity: 0.55; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.w-typing-name {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
}

/* Calm system lines ("a teammate will reply", "conversation closed") */

.w-note {
  margin: 16px auto 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
}

/* "New message" pill */

.w-pill {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 2;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #FBF7F0;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(18, 20, 25, 0.28);
  animation: w-rise var(--t) var(--ease);
}

.w-pill:hover {
  background: #2F3531;
}

.w-pill:focus-visible {
  outline-color: var(--ink);
}

.w-pill-anchor {
  position: relative;
  flex: none;
  height: 0;
}

@keyframes w-rise {
  from { opacity: 0; transform: translate(-50%, 6px); }
}

/* Offline banner (above the composer) */

.w-offline {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 10px var(--gutter);
  background: var(--sunken);
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}

.w-offline > .icon {
  margin-top: 1px;
  color: var(--ink-2);
}

.w-offline-title {
  font-weight: 600;
}

.w-offline-text {
  color: var(--muted);
}

/* -- 6. Follow-up details -------------------------------------------------- */

.w-details {
  margin: 14px 0 0 36px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--sunken);
  font-size: 13.5px;
}

.w-details.is-open {
  border-style: solid;
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.w-details-text {
  color: var(--ink-2);
}

.w-details-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.w-details-actions .w-btn {
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

@media (pointer: coarse) {
  .w-details-actions .w-btn { min-height: 44px; }
}

.w-details.is-done {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-style: solid;
  border-color: var(--border);
  color: var(--ink-2);
}

.w-details.is-done > .icon {
  margin-top: 2px;
  color: var(--success);
}

.w-field {
  display: block;
  margin-top: 10px;
}

.w-label {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}

.w-input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background: #fff;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  line-height: 1.3;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.w-input::placeholder {
  color: #74716A;
}

.w-input:focus-visible {
  outline: none;
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.w-input[aria-invalid="true"] {
  border-color: var(--danger-ink);
}

.w-error {
  margin-top: 6px;
  color: var(--danger-ink);
  font-size: 12.5px;
}

/* -- 7. CSAT --------------------------------------------------------------- */

.w-csat {
  margin-top: 18px;
  padding: 16px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow);
  text-align: center;
}

.w-csat-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.w-csat-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.w-stars {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.w-star {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--border-control);
  cursor: pointer;
  transition: color var(--t) var(--ease), transform var(--t) var(--ease);
}

.w-star input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.w-star .icon {
  pointer-events: none;
}

.w-star.is-on {
  color: var(--accent-ink);
}

.w-star.is-on .icon {
  fill: var(--accent);
}

.w-star:hover {
  transform: scale(1.08);
}

.w-star:has(input:focus-visible) {
  outline: 2px solid var(--accent-ink);
  outline-offset: -2px;
}

.w-csat-word {
  min-height: 19px;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.w-csat .w-field {
  text-align: left;
}

.w-csat textarea.w-input {
  min-height: 64px;
  resize: vertical;
  font-size: 16px;
}

.w-csat-actions {
  margin-top: 12px;
}

.w-csat-actions .w-btn {
  width: 100%;
}

.w-csat.is-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.w-csat.is-done > .icon {
  margin-bottom: 4px;
  color: var(--success);
}

/* -- 8. Composer ----------------------------------------------------------- */

.w-composer {
  flex: none;
  padding: 10px 12px 6px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.w-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.w-textarea {
  flex: 1;
  min-width: 0;
  display: block;
  min-height: var(--tap);
  max-height: 132px;
  padding: 9px 14px;
  border: 1px solid var(--border-control);
  border-radius: 20px;
  background: #fff;
  font-size: 16px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

@media (pointer: coarse) {
  .w-textarea { padding-block: 11px; }
}

.w-textarea::placeholder {
  color: #74716A;
}

.w-textarea:focus-visible {
  outline: none;
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.w-send {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent, #ffffff);
  transition: transform var(--t) var(--ease), filter var(--t) var(--ease),
    background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.w-send:hover:not(:disabled) {
  background: var(--accent-hover, var(--accent));
}

.w-send:active:not(:disabled) {
  transform: scale(0.96);
}

.w-send:disabled {
  background: var(--sunken);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
}

.w-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 16px;
  margin-top: 6px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}

.w-composer-foot:empty {
  display: none;
}

.w-counter {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.w-counter.is-full {
  color: var(--danger-ink);
  font-weight: 600;
}

.w-powered {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px calc(7px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  font-size: 11.5px;
  line-height: 1.2;
  color: var(--muted);
}

.w-powered-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--t) var(--ease), background-color var(--t) var(--ease);
}

.w-powered-link strong {
  color: var(--ink-2);
  font-weight: 600;
}

.w-powered-link:hover {
  color: var(--ink);
  background: var(--sunken);
}

.w-powered-link:hover strong {
  color: var(--ink);
}

.w-powered-mark {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: none;
}

/* -- 8b. Images, quotes, edited ------------------------------------------- */

.w-attach {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  color: var(--ink-2);
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

.w-attach:hover:not(:disabled) {
  background: var(--sunken);
  color: var(--ink);
}

.w-attach:disabled {
  color: var(--border-strong);
}

.w-composer.is-dropping {
  background: var(--accent-soft);
}

.w-tray-slot:empty,
.w-problems:empty {
  display: none;
}

.w-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 10px;
  padding: 6px 6px 0;
  list-style: none;
}

.w-tray-item {
  position: relative;
  width: 56px;
  height: 56px;
}

.w-tray-img {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--sunken);
  box-shadow: 0 0 0 1px var(--border);
  object-fit: cover;
}

.w-tray-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 0 0 2px var(--card);
}

.w-tray-remove:focus-visible {
  outline-offset: 3px;
}

.w-problems {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.w-problem {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger-ink);
  font-size: 12.5px;
  line-height: 1.35;
}

.w-problem .icon {
  margin-top: 1px;
}

.w-pics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.w-pics + .w-bubble-text {
  display: block;
  margin-top: 7px;
}

.w-pic {
  position: relative;
  display: block;
  max-width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: var(--sunken);
  line-height: 0;
}

/* A picture whose size is not known yet gets a plain tile. */
.w-pics.is-single .w-pic:not([style]) {
  width: 200px;
  aspect-ratio: 4 / 3;
}

.w-pics.is-grid .w-pic {
  width: 104px;
  aspect-ratio: 1;
}

.w-pic-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.w-pic-img:not([src]) {
  visibility: hidden;
}

/* A video attachment plays in place; a frame without a known size is 4:3 like a picture. */
.w-pic.is-video { cursor: default; background: #111; }
.w-pic-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #111; }
.w-pic-video:not([src]) { visibility: hidden; }
.w-tray-item { position: relative; }
.w-tray-badge { position: absolute; left: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, 0.65); color: #fff; display: inline-flex; align-items: center; justify-content: center; pointer-events: none; }
video.w-tray-img { object-fit: cover; background: #111; }

.w-pic.is-loading {
  animation: w-pulse 1.2s ease-in-out infinite;
}

.w-pic-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--danger-ink);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
}

@keyframes w-pulse {
  50% { opacity: 0.55; }
}

/* Pictures and nothing else: no bubble around them. */
.w-msg.is-me .w-bubble.is-bare,
.w-msg.is-them .w-bubble.is-bare {
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
}

.w-quote {
  display: block;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-left: 3px solid var(--accent-ink);
  border-radius: 6px;
  background: rgba(18, 20, 25, 0.07);
  font-size: 12.5px;
  line-height: 1.35;
  white-space: normal;
}

.w-msg.is-me .w-quote {
  border-left-color: currentColor;
  background: rgba(255, 255, 255, 0.24);
}

.w-quote-who {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
}

.w-quote-what {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.w-edited {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.72;
  text-align: right;
}

/* One picture, as large as the chat allows. */
.w-viewer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: rgba(18, 20, 25, 0.95);
}

.w-viewer-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px;
}

.w-viewer-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  object-fit: contain;
}

.w-viewer-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
}

.w-viewer-bar .w-btn {
  text-decoration: none;
}

.w-viewer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -- 9. Help --------------------------------------------------------------- */

.w-help {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px var(--gutter) 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.w-search {
  position: relative;
}

.w-search > .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.w-search .w-input {
  padding-left: 40px;
  border-radius: 999px;
}

.w-search .w-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.w-help-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 2px 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* The visitor's own words keep their case. */
.w-help-heading q {
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
}

.w-articles {
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 12px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}

.w-articles.is-stale {
  opacity: 0.6;
}

.w-articles li + li {
  border-top: 1px solid var(--border);
}

.w-article-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 10px 12px 14px;
  transition: background-color var(--t) var(--ease);
}

.w-article-link:hover {
  background: var(--paper);
}

.w-article-link:focus-visible {
  outline-offset: -3px;
  border-radius: 12px;
}

.w-article-link > .icon {
  color: var(--border-control);
  transition: transform var(--t) var(--ease), color var(--t) var(--ease);
}

.w-article-link:hover > .icon {
  color: var(--ink);
  transform: translateX(2px);
}

.w-article-main {
  flex: 1;
  min-width: 0;
}

.w-article-title {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.w-article-excerpt {
  display: -webkit-box;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.w-skel {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--sunken) 0%, #F8F9FB 50%, var(--sunken) 100%);
  background-size: 200% 100%;
  animation: w-shimmer 1.4s linear infinite;
}

.w-skel-row {
  display: grid;
  gap: 8px;
  padding: 14px;
}

@keyframes w-shimmer {
  to { background-position: -200% 0; }
}

.w-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 16px 8px;
  text-align: center;
}

.w-empty .w-state-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
}

.w-empty-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.w-empty-text {
  max-width: 32ch;
  color: var(--muted);
  font-size: 13.5px;
  text-wrap: pretty;
}

.w-empty .w-btn {
  margin-top: 10px;
}

/* Article reader */

.w-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap);
  margin: -8px 0 4px -8px;
  padding: 0 12px 0 6px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}

.w-back:hover {
  background: var(--sunken);
  color: var(--ink);
}

.w-article-heading {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.w-article-heading:focus-visible {
  outline: none;
}

.w-article-date {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.w-article-body {
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}

.w-article-body p {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.w-article-body p + p {
  margin-top: 12px;
}

.w-article-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.w-article-foot-text {
  font-weight: 600;
  font-size: 14px;
}

/* -- 10. Motion + forced colours ------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .w-spinner,
  .w-btn.is-loading::after {
    animation: w-spin 1.6s linear infinite !important;
  }

  .w-typing-bubble i {
    opacity: 0.8;
  }
}

@media (forced-colors: active) {
  .w-bubble,
  .w-mark,
  .w-avatar,
  .w-send,
  .w-btn,
  .w-csat,
  .w-articles {
    border: 1px solid CanvasText;
  }

  .w-tab[aria-selected="true"]::after {
    background: Highlight;
  }

  .w-star.is-on .icon {
    fill: Highlight;
  }
}

/* The workspace's logo, where the first letter of its name would be. */
.w-mark img,
.w-avatar.is-brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.w-mark:has(img),
.w-avatar.is-brand:has(img) {
  overflow: hidden;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(18, 20, 25, 0.14);
}

/* Nobody online: a quiet grey dot, never a warning. */
.w-status[data-state="away"] .w-dot {
  background: var(--border-control);
}
