/* An Tâm — giao diện trợ lý phòng chống lừa đảo.
   Thiết kế chuyên nghiệp, đáng tin, chữ lớn dễ đọc cho người lớn tuổi.
   Responsive: desktop (2 cột) · tablet · mobile (1 cột). Sáng + tối. */

:root {
  color-scheme: light dark;
  --bg-1: #eef4f0;
  --bg-2: #e2ede6;
  --surface: #ffffff;
  --surface-2: #f4f8f5;
  --surface-line: #dfe8e2;
  --ink: #15241d;
  --ink-soft: #52635b;
  --ink-faint: #7d8d85;
  --brand: #0f6b48;
  --brand-deep: #0a4e34;
  --brand-tint: #e4f1ea;
  --accent: #d79a28;
  --user-bubble: #0f6b48;
  --user-ink: #ffffff;
  --bot-bubble: #f1f6f2;
  --bot-ink: #16271f;
  --ok: #1f9d57;
  --warn: #d88a2a;
  --alert: #d8663a;
  --ring: #0f6b4855;
  --shadow-sm: 0 1px 2px rgba(16,54,38,.06), 0 2px 8px rgba(16,54,38,.06);
  --shadow-md: 0 6px 24px rgba(16,54,38,.10);
  --shadow-lg: 0 18px 48px rgba(16,54,38,.16);
  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-1: #0c1713;
    --bg-2: #0f1f19;
    --surface: #152620;
    --surface-2: #11201a;
    --surface-line: #26382f;
    --ink: #eaf3ee;
    --ink-soft: #a9bbb1;
    --ink-faint: #7f938a;
    --brand: #3cc189;
    --brand-deep: #2fa273;
    --brand-tint: #16352a;
    --accent: #f0bb53;
    --user-bubble: #1f6b4b;
    --user-ink: #f3fbf7;
    --bot-bubble: #1b2c25;
    --bot-ink: #eaf3ee;
    --bot-bubble: #1b2c25;
    --ring: #3cc18966;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 6px 24px rgba(0,0,0,.4);
    --shadow-lg: 0 18px 48px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg-1: #0c1713; --bg-2: #0f1f19; --surface: #152620; --surface-2: #11201a;
  --surface-line: #26382f; --ink: #eaf3ee; --ink-soft: #a9bbb1; --ink-faint: #7f938a;
  --brand: #3cc189; --brand-deep: #2fa273; --brand-tint: #16352a; --accent: #f0bb53;
  --user-bubble: #1f6b4b; --user-ink: #f3fbf7; --bot-bubble: #1b2c25; --bot-ink: #eaf3ee;
  --ring: #3cc18966;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  min-height: 100svh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg-1) 0%, var(--bg-2) 100%);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}
/* Calm layered depth: two soft brand glows + a faint dotted security texture. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42vw 42vw at 12% -6%, color-mix(in srgb, var(--brand) 14%, transparent) 0%, transparent 60%),
    radial-gradient(46vw 46vw at 108% 112%, color-mix(in srgb, var(--brand) 11%, transparent) 0%, transparent 58%),
    radial-gradient(circle at center, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1.4px);
  background-size: auto, auto, 24px 24px;
  opacity: .9;
}
button, textarea, input { font: inherit; color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important;
  margin: -1px !important; padding: 0 !important; overflow: hidden !important;
  clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important;
}

/* ---- App shell ---- */
.bot-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100svh;
  max-width: 1180px;
  margin-inline: auto;
  padding: clamp(12px, 2.2vw, 26px);
  gap: clamp(12px, 1.8vw, 18px);
  overflow: hidden;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: clamp(12px, 1.6vw, 18px) clamp(16px, 2vw, 24px);
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-badge {
  position: relative;
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--ring);
}
/* Live-presence dot (bottom-right) — subtle "online" cue. */
.brand-badge::after {
  content: ''; position: absolute; right: -2px; bottom: -2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--ok); border: 2.5px solid var(--surface);
  animation: presence 2.6s ease-in-out infinite;
}
@keyframes presence {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  50%      { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ok) 0%, transparent); }
}
.brand-badge svg { width: 26px; height: 26px; }
.brand-logo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* When the official emblem image is present, let it stand on its own (round). */
.brand-badge:has(.brand-logo) { background: none; box-shadow: 0 2px 8px rgba(16,54,38,.18); border-radius: 50%; }
.brand-badge:has(.brand-logo) .brand-fallback { display: none; }
.brand-text { min-width: 0; }
.brand-name { margin: 0; font-size: clamp(19px, 2vw, 23px); font-weight: 800; letter-spacing: -.3px; line-height: 1.15; }
.brand-sub { margin: 2px 0 0; font-size: clamp(12.5px, 1.3vw, 14px); color: var(--ink-soft); font-weight: 500; line-height: 1.3; }
.btn-ghost {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--brand-tint); border-color: var(--brand); }
.btn-ghost svg { width: 17px; height: 17px; }

/* ---- Main grid ---- */
.app-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(12px, 1.8vw, 20px);
  min-height: 0;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-height: 0;
  min-width: 0;
}

/* ---- Stage (avatar + live caption) ---- */
.stage-panel {
  --halo: var(--brand);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(6px, 1vw, 12px);
  min-height: 0;
  padding: clamp(16px, 2.4vw, 30px) clamp(16px, 2.4vw, 28px) clamp(18px, 2.4vw, 26px);
  overflow: hidden;
  transition: --halo .5s;
}
body[data-state='listening'] .stage-panel { --halo: #28b06a; }
body[data-state='thinking']  .stage-panel { --halo: #e0a62e; }
body[data-state='speaking']  .stage-panel { --halo: #1aa6c4; }
body[data-state='paused']    .stage-panel { --halo: #93a39a; }
body[data-state='error']     .stage-panel { --halo: #d8663a; }
/* Animated glow halo behind the avatar; colour follows the live state (--halo). */
.stage-halo {
  position: absolute;
  top: -8%; left: 50%; transform: translateX(-50%);
  width: min(104%, 560px); aspect-ratio: 1/1;
  background:
    radial-gradient(circle at 50% 44%, color-mix(in srgb, var(--halo) 40%, transparent) 0%, transparent 58%),
    radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--halo) 22%, transparent) 0%, transparent 66%);
  filter: blur(4px);
  z-index: 0; pointer-events: none;
  animation: halo-breathe 6.5s ease-in-out infinite;
}
body[data-state='listening'] .stage-halo { animation-duration: 2.6s; }
body[data-state='thinking']  .stage-halo { animation-duration: 1.8s; }
body[data-state='speaking']  .stage-halo { animation-duration: 1.5s; }
@keyframes halo-breathe {
  0%,100% { transform: translateX(-50%) scale(1); opacity: .72; }
  50%     { transform: translateX(-50%) scale(1.07); opacity: 1; }
}

.avatar-stage {
  position: relative; z-index: 1;
  width: min(100%, 340px, 36vh);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  display: grid; place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}
/* Big hero avatar while idle; a touch smaller during a live exchange so the
   answer / typing indicator always has room and is never covered. */
body:not([data-state='idle']) .avatar-stage { width: min(100%, 300px, 30vh); }
/* State rings / aura drawn behind the character (absolute = not a grid item). */
.avatar-stage::before, .avatar-stage::after {
  content: ''; position: absolute; inset: 9%; border-radius: 50%;
  z-index: 0; pointer-events: none; opacity: 0;
}
body[data-state='listening'] .avatar-stage::before { border: 2px solid var(--halo); animation: ring-pulse 2.4s ease-out infinite; }
body[data-state='listening'] .avatar-stage::after  { border: 2px solid var(--halo); animation: ring-pulse 2.4s ease-out 1.2s infinite; }
@keyframes ring-pulse {
  0%   { transform: scale(.74); opacity: .5; }
  70%  { opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}
body[data-state='speaking'] .avatar-stage::before {
  inset: 3%;
  background: radial-gradient(circle, color-mix(in srgb, var(--halo) 30%, transparent) 0%, transparent 68%);
  animation: aura-pulse 1.5s ease-in-out infinite;
}
@keyframes aura-pulse {
  0%,100% { transform: scale(.94); opacity: .45; }
  50%     { transform: scale(1.08); opacity: .85; }
}
body[data-state='thinking'] .avatar-stage::after {
  inset: 2%;
  border: 3px dashed color-mix(in srgb, var(--halo) 70%, transparent);
  opacity: .55; animation: ring-spin 7s linear infinite;
}
@keyframes ring-spin { to { transform: rotate(360deg); } }

.chibi-character {
  --voice-level: 0;
  position: relative; z-index: 1;
  width: 100%;
  aspect-ratio: 1 / 1;
  isolation: isolate;
  transform-origin: 50% 88%;
  margin-inline: auto;
  animation: chibi-enter .7s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes chibi-enter { from { opacity: 0; transform: translateY(12px) scale(.95); } to { opacity: 1; transform: none; } }
.chibi-art {
  position: relative; display: block; width: 100%; height: 100%;
  animation: chibi-breathe 7s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.chibi-pose {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 22px rgba(16,54,38,.22));
  pointer-events: none;
  transition: filter .4s;
}
body[data-state='listening'] .chibi-pose,
body[data-state='speaking'] .chibi-pose {
  filter: drop-shadow(0 16px 22px rgba(16,54,38,.22))
          drop-shadow(0 0 16px color-mix(in srgb, var(--halo) 48%, transparent));
}
.chibi-pose[hidden] { display: none; }
.chibi-unavailable {
  position: absolute; inset: 18% 6%; height: fit-content; margin: auto;
  padding: 16px; border-radius: 16px; background: var(--brand-tint);
  color: var(--ink); font-size: 17px; line-height: 1.5; text-align: center;
}
.avatar-stage[data-avatar-state='thinking'] .chibi-art { animation-duration: 10s; }
.avatar-stage[data-avatar-state='listening'] .chibi-art { animation-duration: 9s; }
.avatar-stage[data-avatar-state='speaking'] .chibi-art { animation: chibi-speaking 4s ease-in-out infinite; }
.avatar-stage[data-avatar-state='paused'] .chibi-art { animation: none; }
@keyframes chibi-breathe { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes chibi-speaking { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(.4deg); } }

/* Status pill */
/* Big, obvious "press to talk" button — the main action, clear for everyone. */
.talk-button {
  position: relative; z-index: 2;
  display: inline-flex; align-items: center; gap: 12px;
  margin-top: 14px;
  padding: 14px 26px;
  border: 0; border-radius: 999px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff; cursor: pointer;
  font-size: clamp(17px, 2vw, 20px); font-weight: 750; letter-spacing: -.2px;
  box-shadow: 0 8px 22px var(--ring);
  transition: transform .1s, box-shadow .2s, background .3s;
  -webkit-tap-highlight-color: transparent;
}
.talk-button:hover { transform: translateY(-1px); box-shadow: 0 11px 26px var(--ring); }
.talk-button:active { transform: translateY(1px); }
.talk-mic { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto;
  background: rgba(255,255,255,.22); border-radius: 50%; }
.talk-mic svg { width: 18px; height: 18px; }
.talk-label { line-height: 1.2; }
/* State-driven colour + mic pulse. */
body[data-state='listening'] .talk-button { background: linear-gradient(145deg,#2fb36a,#1f8f52); animation: talk-glow 1.6s ease-in-out infinite; }
body[data-state='listening'] .talk-mic { animation: mic-pulse 1.2s ease-in-out infinite; }
body[data-state='thinking'] .talk-button { background: linear-gradient(145deg,#e0a62e,#c98a16); }
body[data-state='speaking'] .talk-button { background: linear-gradient(145deg,#1aa6c4,#1488a3); }
body[data-state='paused'] .talk-button { background: linear-gradient(145deg,#8a978f,#6f7d74); }
body[data-state='error'] .talk-button { background: linear-gradient(145deg,#d8663a,#b94e27); }
@keyframes talk-glow { 0%,100% { box-shadow: 0 8px 22px color-mix(in srgb,#2fb36a 45%,transparent); } 50% { box-shadow: 0 8px 30px color-mix(in srgb,#2fb36a 70%,transparent); } }
@keyframes mic-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* Live caption (current exchange) */
.live-caption {
  position: relative; z-index: 2;
  width: 100%;
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: flex-start;
  margin-top: clamp(10px, 1.6vw, 16px);
  text-align: center;
}
body[data-state='idle'] .live-caption { justify-content: center; }
.heard-text {
  margin: 0 auto 10px;
  max-width: 44ch;
  color: var(--ink-soft);
  font-size: clamp(15px, 1.7vw, 18px);
  font-weight: 600;
  line-height: 1.45;
}
.heard-text::before { content: "Bạn: "; color: var(--brand); font-weight: 700; }
.heard-text:empty { display: none; }
.reply-text {
  margin: 0 auto;
  max-width: 52ch;
  color: var(--ink);
  font-size: clamp(19px, 2.2vw, 25px);
  font-weight: 650;
  line-height: 1.48;
  letter-spacing: -.2px;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.tap-hint {
  margin: 12px auto 0;
  max-width: 42ch;
  color: var(--ink-faint); font-size: 14.5px; font-weight: 600;
  line-height: 1.45; text-align: center; text-wrap: pretty;
}
.tap-hint svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
body:not([data-state='idle']) .tap-hint { display: none; }
.welcome-long { font-weight: 500; color: var(--ink-soft); }

/* ---- Conversation panel ---- */
.convo-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 1.8vw, 20px);
  min-height: 0;
}
.convo-head {
  display: flex; align-items: center; gap: 9px;
  padding-bottom: 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--surface-line);
  font-size: 14px; font-weight: 700; letter-spacing: .02em;
  color: var(--ink-soft); text-transform: uppercase;
}
.convo-head svg { width: 17px; height: 17px; color: var(--brand); }
.chat-history {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 10px 4px 2px;
  display: flex; flex-direction: column;
}
.chat-history[hidden] { display: none; }
#chat-log { display: flex; flex-direction: column; gap: 12px; }
.chat-row { max-width: 86%; display: flex; flex-direction: column; gap: 3px; }
.chat-row.chat-user { align-self: flex-end; align-items: flex-end; }
.chat-row.chat-assistant { align-self: flex-start; align-items: flex-start; }
.chat-who { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); padding-inline: 4px; }
.chat-text {
  margin: 0; padding: 11px 15px; border-radius: 16px;
  font-size: clamp(15.5px, 1.6vw, 17px); line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: var(--shadow-sm);
}
.chat-user .chat-text { background: var(--user-bubble); color: var(--user-ink); border-bottom-right-radius: 5px; }
.chat-assistant .chat-text { background: var(--bot-bubble); color: var(--bot-ink); border-bottom-left-radius: 5px; }
.convo-empty {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: flex-start;
  gap: 9px; padding: 14px 4px 4px;
}
.starter-title { margin: 0; font-size: 17px; font-weight: 750; color: var(--ink); }
.starter-sub { margin: 0 0 4px; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip {
  text-align: left; padding: 11px 14px;
  border: 1px solid var(--surface-line); border-radius: 12px;
  background: var(--surface-2); color: var(--ink);
  font-size: 15px; font-weight: 600; line-height: 1.35; cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
}
.chip:hover { border-color: var(--brand); background: var(--brand-tint); transform: translateY(-1px); }
.chip:active { transform: translateY(0); }
.trust-line {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 8px 2px 2px; font-size: 12.5px; line-height: 1.5; color: var(--ink-faint);
}
.trust-line svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--brand); margin-top: 2px; }
body:not([data-state='idle']) .convo-empty,
.chat-history:not([hidden]) ~ .convo-empty { display: none; }

/* ---- Composer (typed question, always available) ---- */
.composer {
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: clamp(12px, 1.6vw, 16px) clamp(14px, 1.8vw, 18px);
}
#fallback-form { display: flex; gap: 10px; align-items: flex-end; }
.composer-field { flex: 1 1 auto; min-width: 0; }
#fallback-input {
  width: 100%; min-height: 50px; max-height: 120px; resize: none;
  padding: 13px 16px;
  border: 1.5px solid var(--surface-line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 16.5px; line-height: 1.45;
  transition: border-color .15s, background .15s;
}
#fallback-input::placeholder { color: var(--ink-faint); }
#fallback-input:focus { border-color: var(--brand); background: var(--surface); outline: none; }
#fallback-send {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 50px; padding: 0 20px;
  border: 0; border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 14px var(--ring);
  transition: filter .15s, transform .05s;
}
#fallback-send:hover { filter: brightness(1.06); }
#fallback-send:active { transform: translateY(1px); }
#fallback-send svg { width: 18px; height: 18px; }
.composer-note {
  margin: 10px 2px 0; font-size: 13px; line-height: 1.45; color: var(--ink-faint);
}
.composer-note strong { color: var(--alert); font-weight: 700; }

/* ---- Site footer (ownership + developer credit) ---- */
.site-footer {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 9px;
  padding: 4px 10px 8px;
}
.partner-logo-link { display: inline-flex; line-height: 0; }
.partner-logo {
  height: 34px; width: auto; display: block;
  background: #fff; padding: 4px 9px; border-radius: 9px;
  border: 1px solid var(--surface-line);
  box-shadow: 0 1px 3px rgba(16,54,38,.08);
  transition: transform .12s;
}
.partner-logo-link:hover .partner-logo { transform: translateY(-1px); }
.copyright {
  margin: 0; font-size: 12.5px; line-height: 1.4; text-align: center;
  color: var(--ink-faint);
}
.copyright strong { color: var(--ink-soft); font-weight: 700; }
.copyright a { color: var(--brand); text-decoration: none; font-weight: 700; }
.copyright a:hover { text-decoration: underline; }

.noscript-note {
  margin: 16px; padding: 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--surface-line);
  color: var(--ink); font-size: 17px;
}

/* ---- Polish & micro-interactions ---- */
/* "Thinking" typing dots (replace the reply line while An Tâm is composing). */
.typing-dots { display: none; justify-content: center; gap: 8px; margin: 12px 0 2px; }
body[data-state='thinking'] .typing-dots { display: flex; }
body[data-state='thinking'] #reply-text { display: none; }
.typing-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--halo); opacity: .5; animation: typing 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .16s; }
.typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes typing { 0%,100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-5px); opacity: 1; } }

/* Message bubble entrance (only the newest row animates). */
#chat-log .chat-row:last-child { animation: bubble-in .34s cubic-bezier(.2,.8,.2,1); }
@keyframes bubble-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Chip affordance: a chevron that slides in on hover/focus. */
.chip { position: relative; padding-right: 34px; }
.chip::after {
  content: '›'; position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
  font-size: 20px; font-weight: 800; line-height: 1; color: var(--brand);
  opacity: 0; transition: opacity .15s, right .15s;
}
.chip:hover::after, .chip:focus-visible::after { opacity: 1; right: 12px; }

/* Send button icon nudges forward on hover. */
#fallback-send svg { transition: transform .15s; }
#fallback-send:hover svg { transform: translateX(3px); }

/* Refined thin scrollbars. */
.chat-history, .convo-empty, .live-caption { scrollbar-width: thin; scrollbar-color: var(--surface-line) transparent; }
.chat-history::-webkit-scrollbar, .convo-empty::-webkit-scrollbar, .live-caption::-webkit-scrollbar { width: 9px; }
.chat-history::-webkit-scrollbar-thumb, .convo-empty::-webkit-scrollbar-thumb, .live-caption::-webkit-scrollbar-thumb {
  background: var(--surface-line); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
.chat-history::-webkit-scrollbar-thumb:hover, .convo-empty::-webkit-scrollbar-thumb:hover, .live-caption::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint); background-clip: padding-box;
}

/* ---- Tablet ---- */
@media (max-width: 920px) {
  .app-main { grid-template-columns: minmax(0, 1fr); }
  .convo-panel { min-height: 180px; }
  .chat-history { max-height: 30vh; }
  .avatar-stage { width: min(100%, 400px, 48vh); }
}

/* ---- Mobile: natural vertical scroll instead of cramming one viewport ---- */
@media (max-width: 600px) {
  html, body { height: auto; }
  body { overflow-y: auto; }
  .bot-app { height: auto; min-height: 100svh; overflow: visible; padding: 10px; gap: 10px; }
  .app-header { padding: 11px 13px; border-radius: 18px; }
  .brand-badge { width: 40px; height: 40px; border-radius: 11px; }
  .brand-badge svg { width: 22px; height: 22px; }
  .brand-sub { font-size: 12px; }
  .btn-ghost { padding: 10px; }
  .btn-ghost .btn-label { display: none; }
  .panel { border-radius: 18px; }
  .app-main { gap: 10px; }
  .stage-panel { justify-content: flex-start; padding: 18px 14px 20px; }
  .avatar-stage { width: min(80vw, 300px); }
  .talk-button { margin-top: 12px; padding: 13px 22px; font-size: 17px; }
  .reply-text { font-size: 19.5px; }
  .welcome-long { display: none; }
  .convo-panel { padding: 14px; min-height: 180px; }
  .chat-history { max-height: 42vh; }
  .composer { padding: 11px 12px; border-radius: 18px; }
  #fallback-send { padding: 0 15px; }
  #fallback-send .btn-label { display: none; }
  #fallback-input { font-size: 16px; }
  .site-footer { gap: 8px; padding-bottom: 10px; }
  .partner-logo { height: 30px; }
  .copyright { font-size: 11.5px; }
}
@media (max-width: 380px) {
  .avatar-stage { width: min(76vw, 250px); }
  .reply-text { font-size: 18.5px; }
}

/* ---- Short / landscape phones ---- */
@media (max-height: 560px) and (min-width: 601px) {
  .avatar-stage { max-width: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
