/* ==========================================================================
   iBoostv Support — chat page
   Light by default. Brand: navy #10182D, blue #007CEB (same as the emails).
   Text on blue uses --brand-strong (#0062BD, 6.0:1) because #007CEB is only
   4.1:1 against white. Every text/background pair below is >= 4.5:1.
   ========================================================================== */

:root {
  --col: 760px;

  --bg:            #F5F7FB;
  --bg-tint:       rgba(0, 124, 235, .07);
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFD;
  --surface-3:     #EEF2F8;
  --line:          #E4E9F1;
  --line-strong:   #D3DBE7;

  --ink:           #0F1B2D;
  --ink-2:         #334155;
  --muted:         #5B6678;
  --placeholder:   #6A7486;

  --brand:         #007CEB;
  --brand-strong:  #0062BD;
  --brand-deep:    #004F99;
  --brand-soft:    #EAF3FD;
  --ring:          rgba(0, 124, 235, .22);

  --ok:            #16A34A;
  --ok-ink:        #047857;
  --ok-soft:       #ECFDF5;
  --ok-line:       #A7F3D0;

  --err:           #D92D20;
  --err-ink:       #B42318;
  --err-soft:      #FEF3F2;
  --err-line:      #FECDCA;

  --wa:            #25D366;
  --wa-ink:        #0B7A3B;
  --wa-soft:       #EDFBF2;
  --tg:            #229ED9;
  --tg-ink:        #0B6E9E;
  --tg-soft:       #EAF6FC;

  --radius-sm:     12px;
  --radius:        16px;
  --radius-lg:     24px;

  --shadow-xs:     0 1px 2px rgba(15, 27, 45, .05);
  --shadow-sm:     0 1px 2px rgba(15, 27, 45, .05), 0 2px 8px rgba(15, 27, 45, .04);
  --shadow-md:     0 2px 4px rgba(15, 27, 45, .04), 0 10px 28px rgba(15, 27, 45, .08);
  --shadow-lg:     0 18px 50px rgba(15, 27, 45, .18);

  --ease:          cubic-bezier(.2, .8, .2, 1);
  --font:          ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:          ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

/* Dark is opt-in only (?theme=dark). The page never follows the OS setting. */
:root[data-theme="dark"] {
  --bg:            #0B1120;
  --bg-tint:       rgba(0, 124, 235, .10);
  --surface:       #121A2B;
  --surface-2:     #172035;
  --surface-3:     #1E2940;
  --line:          #243049;
  --line-strong:   #2F3D5A;
  --ink:           #EEF2F8;
  --ink-2:         #CBD5E1;
  --muted:         #9AA6BA;
  --placeholder:   #8C98AD;
  --brand-strong:  #3B9BFF;
  --brand-deep:    #6CB4FF;
  --brand-soft:    #13294A;
  --ok-soft:       #0F2A1E;
  --ok-line:       #1F5A3B;
  --ok-ink:        #6EE7B7;
  --err-soft:      #2E1614;
  --err-line:      #5B2522;
  --err-ink:       #FCA5A5;
  --wa-soft:       #0F2A1E;
  --wa-ink:        #6EE7B7;
  --tg-soft:       #0E2533;
  --tg-ink:        #7DD3FC;
  --shadow-md:     0 10px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 10px;
}

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

/* ── App shell ───────────────────────────────────────────────────────────── */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 50% -140px, var(--bg-tint), transparent 70%),
    var(--bg);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.hdr {
  flex: none;
  position: relative;
  z-index: 5;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.hdr-in {
  max-width: calc(var(--col) + 32px);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hdr-l { display: flex; align-items: center; gap: 12px; min-width: 0; }

.avatar {
  position: relative;
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 98, 189, .25);
}
.avatar-initial { font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.avatar-online {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--surface);
}

.hdr-text { min-width: 0; }
.title {
  font-size: 15.5px; font-weight: 650; line-height: 1.25;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-sep { color: var(--muted); margin: 0 6px; font-weight: 400; }
.title-brand { color: var(--ink-2); font-weight: 500; }
.status {
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
  font-size: 12.5px; color: var(--muted);
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(22, 163, 74, .45);
  animation: pulse 2.4s ease-out infinite;
}

.hdr-r { display: flex; align-items: center; gap: 6px; flex: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; min-width: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.icon-btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
.icon-btn:active { transform: scale(.97); }
.icon-btn:not(.with-label) { padding: 0; }

/* ── Conversation log ────────────────────────────────────────────────────── */
.log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px max(16px, calc((100% - var(--col)) / 2)) 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.log::-webkit-scrollbar { width: 10px; }
.log::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}
.log > .msg:last-child { animation: msg-in .24s var(--ease) both; }

.msg.user { align-items: flex-end; }
.msg.assistant, .msg.error { align-items: flex-start; }

.bubble {
  position: relative;
  padding: 12px 16px;
  font-size: 15.5px;
  line-height: 1.6;
  border-radius: 20px;
  overflow-wrap: anywhere;
  word-break: normal;
}

.msg.user .bubble {
  max-width: min(82%, 560px);
  background: var(--brand-strong);
  color: #fff;
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
  box-shadow: 0 4px 14px rgba(0, 98, 189, .18);
}

.msg.assistant .bubble {
  max-width: min(92%, 640px);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.msg.error .bubble {
  max-width: min(92%, 640px);
  background: var(--err-soft);
  color: var(--err-ink);
  border: 1px solid var(--err-line);
  border-bottom-left-radius: 6px;
}

/* Rendered markdown inside assistant bubbles */
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 650; color: inherit; }
.bubble em { font-style: italic; }
.bubble ul, .bubble ol { margin: 4px 0 10px; padding-left: 22px; }
.bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble li { margin: 4px 0; padding-left: 2px; }
.bubble li::marker { color: var(--brand); font-weight: 600; }
.bubble a {
  color: var(--brand-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  font-weight: 550;
}
.bubble a:hover { color: var(--brand-deep); text-decoration-thickness: 2px; }
.msg.user .bubble a { color: #fff; }
.bubble code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-3);
  color: var(--ink);
  padding: 2px 7px;
  border-radius: 7px;
  border: 1px solid var(--line);
}
.msg.user .bubble code { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .25); }
.bubble pre {
  margin: 8px 0 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.5;
}
.bubble pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.bubble h1, .bubble h2, .bubble h3 {
  margin: 12px 0 6px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
}
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }
.bubble h1 { font-size: 18px; }
.bubble h2 { font-size: 17px; }
.bubble h3 { font-size: 16px; }

.bubble .img-link {
  display: block;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  transition: transform .15s, box-shadow .15s;
}
.bubble .img-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.bubble .img-link:active { transform: scale(.99); }
.bubble .msg-img { display: block; width: 100%; max-width: 100%; height: auto; }

.bubble .yt-card {
  display: block;
  margin: 8px 0;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform .15s, box-shadow .15s;
}
.bubble .yt-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.bubble .yt-card:active { transform: scale(.99); }
.bubble .yt-thumb-wrap { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--surface-3); }
.bubble .yt-thumb { display: block; width: 100%; height: 100%; object-fit: cover; }
.bubble .yt-play {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 56px;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(15, 27, 45, .72);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.bubble .yt-play svg { width: 22px; height: 22px; margin-left: 3px; }
.bubble .yt-label { display: block; padding: 10px 14px 12px; font-size: 14.5px; font-weight: 600; }

/* Streaming caret (kept for compatibility, the reply is revealed in chunks) */
.bubble.streaming::after {
  content: '';
  display: inline-block;
  width: 2px; height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: currentColor;
  opacity: .8;
  animation: caret 1s steps(2) infinite;
}

/* Typing indicator */
.typing { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 2px; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .35;
  animation: typing 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

/* Pills that sit under a message */
.next-step-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px;
  padding: 0 16px 0 8px;
  border-radius: 999px;
  border: 1px solid var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok-ink);
  font-size: 14.5px; font-weight: 650;
  cursor: pointer;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.next-step-btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.next-step-btn:active { transform: scale(.98); }
.next-step-btn .check {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 13px; font-weight: 800;
}
.next-step-btn.disabled { opacity: .6; pointer-events: none; }

.step-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.retry-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--err-line);
  background: var(--surface);
  color: var(--err-ink);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.retry-btn:hover { background: var(--err-soft); }
.retry-btn:active { transform: scale(.97); }

/* ── Welcome screen ──────────────────────────────────────────────────────── */
.greet { margin-block: auto; padding: 8px 0 12px; }
.greet-card { display: flex; flex-direction: column; gap: 22px; }

.greet-hero { text-align: center; display: flex; flex-direction: column; align-items: center; }
.greet-avatar {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 50%;
  display: grid; place-items: center;
  margin-bottom: 14px;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
  font-size: 26px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 98, 189, .28), inset 0 0 0 1px rgba(255, 255, 255, .2);
}
.greet-avatar-dot {
  position: absolute; right: 1px; bottom: 1px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ok);
  border: 3px solid var(--bg);
}
.greet-eyebrow {
  margin: 0 0 6px;
  font-size: 13px; font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
}
.greet-title {
  margin: 0;
  font-size: clamp(26px, 5.2vw, 34px);
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -.02em;
  color: var(--ink);
  text-wrap: balance;
}
.greet-text {
  margin: 10px 0 0;
  max-width: 460px;
  font-size: 16px;
  color: var(--muted);
  text-wrap: pretty;
}

.intents {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.intent {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px;
  padding: 12px 14px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}
.intent:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.intent:hover .ic { background: var(--brand-strong); color: #fff; }
.intent:hover .lbl { color: var(--ink); }
.intent:active { transform: scale(.985); box-shadow: var(--shadow-xs); }
.intent .ic {
  flex: none;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  transition: background .15s, color .15s;
}
.intent .ic svg { width: 21px; height: 21px; }
.intent .lbl { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ink); }

.greet-trust {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px 18px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.gt-item { display: inline-flex; align-items: center; gap: 7px; }
.gt-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }

/* Legacy chip styles (not rendered by default) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center;
  min-height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand-strong); }
.chip:active { transform: scale(.97); }

/* ── Bottom dock ─────────────────────────────────────────────────────────── */
.dock {
  flex: none;
  position: relative;
  z-index: 4;
  padding: 8px max(16px, calc((100% - var(--col)) / 2)) calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}

.actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 2px 0 10px;
}

.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--brand-strong);
  background: var(--brand-strong);
  color: #fff;
  font-size: 14.5px; font-weight: 650;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 98, 189, .22);
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.action-btn:hover { background: var(--brand-deep); border-color: var(--brand-deep); transform: translateY(-1px); }
.action-btn:active { transform: scale(.97); }
.action-btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}
.action-btn.secondary:hover {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  color: var(--brand-deep);
}

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 6px 6px 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  box-shadow: var(--shadow-md);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring), var(--shadow-md);
}
.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 140px;
  margin: 0;
  padding: 11px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;               /* 16px stops iOS from zooming on focus */
  line-height: 22px;             /* 11 + 22 + 11 = 44: no fractional overflow, no stray scrollbar */
  overflow-y: auto;
  scrollbar-width: thin;
}
.composer textarea::placeholder { color: var(--placeholder); opacity: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer textarea:focus { outline: none; }
.composer textarea:focus-visible { outline: none; }

.send {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--brand-strong);
  color: #fff;
  cursor: pointer;
  transition: background .15s, transform .15s, opacity .15s;
}
.send:hover { background: var(--brand-deep); }
.send:active { transform: scale(.94); }
.send:disabled { opacity: .45; cursor: not-allowed; }
.send svg { width: 20px; height: 20px; }
.send .ic-stop { display: none; }
.send.streaming { background: var(--ink); }
.send.streaming .ic-send { display: none; }
.send.streaming .ic-stop { display: block; }

.foot {
  display: flex; justify-content: center;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .3s var(--ease), opacity .2s, padding .3s var(--ease);
}
.foot.show { max-height: 64px; opacity: 1; padding-top: 8px; }
.foot-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px; font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, transform .15s;
}
.foot-btn svg { color: var(--wa-ink); }
.foot-btn:hover { background: var(--wa-soft); border-color: color-mix(in srgb, var(--wa) 55%, var(--line)); }
.foot-btn:active { transform: scale(.97); }

.fineprint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ── "Talk to a person" sheet ────────────────────────────────────────────── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 27, 45, .42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in .2s ease both;
}
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  max-height: min(92dvh, 780px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up .3s var(--ease) both;
}
.sheet-grip {
  width: 40px; height: 5px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--line-strong);
}
.sheet-close {
  position: absolute; top: 12px; right: 12px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--surface-3);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.sheet-close svg { width: 18px; height: 18px; }
.sheet-close:hover { background: var(--line); color: var(--ink); }

.sheet-title {
  margin: 4px 52px 4px 0;
  font-size: 21px; font-weight: 750;
  letter-spacing: -.01em;
  line-height: 1.25;
  color: var(--ink);
}
.sheet-sub { margin: 0 0 16px; font-size: 15px; color: var(--muted); }

.sheet-benefits {
  list-style: none;
  margin: 0 0 18px;
  padding: 14px 16px;
  display: grid; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.sheet-benefits li {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 14.5px; line-height: 1.45;
  color: var(--ink-2);
}
.sheet-benefits .b-ic {
  flex: none;
  width: 20px; height: 20px;
  margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok-ink);
  border: 1px solid var(--ok-line);
}
.sheet-benefits .b-ic svg { width: 11px; height: 11px; }

.sheet-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--err-ink); margin-left: 2px; }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field select {
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6678' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  cursor: pointer;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--placeholder); opacity: 1; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}
.field input.invalid,
.field select.invalid,
.field textarea.invalid {
  border-color: var(--err);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--err) 15%, transparent);
}
.field-err { font-size: 13px; color: var(--err-ink); }
.field-err:empty { display: none; }

.optional-toggle { margin-top: -4px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--brand-strong);
  font-size: 14.5px; font-weight: 600;
  cursor: pointer;
}
.link-btn svg { transition: transform .2s var(--ease); }
.link-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.link-btn:hover { color: var(--brand-deep); text-decoration: underline; text-underline-offset: 3px; }

.sf-optional {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: fade-in .2s ease both;
}

.sheet-summary {
  white-space: pre-wrap;
  max-height: 170px;
  overflow: auto;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.sheet-actions { display: grid; gap: 10px; margin-top: 2px; }

.big-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s, opacity .15s;
}
.big-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.big-btn:active { transform: scale(.99); }
.big-btn.wa:hover { border-color: color-mix(in srgb, var(--wa) 60%, var(--line)); background: var(--wa-soft); }
.big-btn.tg:hover { border-color: color-mix(in srgb, var(--tg) 60%, var(--line)); background: var(--tg-soft); }
.big-btn[disabled],
.big-btn[disabled]:hover {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--surface);
  border-color: var(--line-strong);
}
.big-btn.loading { pointer-events: none; opacity: .75; }
.big-btn.loading .big-btn-arrow { animation: spin .8s linear infinite; }

.big-btn-ic {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: #fff;
}
.big-btn.wa .big-btn-ic { background: var(--wa); }
.big-btn.tg .big-btn-ic { background: var(--tg); }
.big-btn-ic svg { width: 26px; height: 26px; }
.big-btn-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.big-btn-title { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.big-btn-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big-btn-arrow { flex: none; width: 20px; height: 20px; margin-left: auto; color: var(--muted); }

.sheet-form-err {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--err-ink);
  background: var(--err-soft);
  border: 1px solid var(--err-line);
  border-radius: var(--radius-sm);
}
.sheet-ref { font-size: 12.5px; color: var(--muted); text-align: center; }
.sheet-ref:empty { display: none; }

/* ── Motion ──────────────────────────────────────────────────────────────── */
@keyframes msg-in   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop-in   { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes typing   { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes caret    { 0%, 100% { opacity: 0; } 50% { opacity: .8; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulse    {
  0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
  70%  { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

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

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-panel {
    border-radius: var(--radius-lg);
    padding: 22px 24px 24px;
    animation: pop-in .24s var(--ease) both;
  }
  .sheet-grip { display: none; }
  .log { padding-top: 32px; }
}

@media (max-width: 420px) {
  .icon-btn.with-label { padding: 0; width: 38px; }
  .icon-btn .btn-label { display: none; }
}

@media (max-width: 340px) {
  .title-sep, .title-brand { display: none; }
}

/* Phones: two-column tiles, icon above the label, so all 8 topics fit on screen */
@media (max-width: 559px) {
  .greet-card { gap: 18px; }
  .greet-avatar { width: 56px; height: 56px; font-size: 23px; margin-bottom: 12px; }
  .greet-text { font-size: 15px; }
  .intents { gap: 8px; }
  .intent {
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    min-height: 88px;
    padding: 12px;
  }
  .intent .ic { width: 36px; height: 36px; }
  .intent .ic svg { width: 19px; height: 19px; }
  .intent .lbl { font-size: 14.5px; }
}

@media (max-width: 329px) {
  .intents { grid-template-columns: 1fr; }
  .intent { flex-direction: row; align-items: center; justify-content: flex-start; min-height: 58px; }
}
