/* Bong bóng chat Trợ lý KidSafe (js/chat-widget.js) — specs/web-chat-guest-assistant.md §3/§5.
   Dùng chung cho landing-v2 và /guide/ (help-portal có CSS riêng) ⇒ mọi class tiền tố kscw-, tự đặt
   phông/cỡ chữ/viền thay vì dựa vào style của trang. Màu theo THEME KIDSAFE-ADS (style.css):
   xanh #2541C4, vàng #F2B924 + chữ #1A2445, bo 999px. Mọi cặp chữ/nền ≥ 4.5:1. */

.kscw {
  --kscw-blue: #2541c4;
  --kscw-blue-dark: #1a2f8f;
  --kscw-ink: #16203f;
  --kscw-body: #4a5578;
  --kscw-fine: #59617d;
  --kscw-navy: #1b2c63;
  --kscw-bg: #f7f9ff;
  --kscw-line: #e3e9f8;
  --kscw-chip-line: #c9d4f3;
  --kscw-input-line: #9aa3bd;
  --kscw-gold: #f2b924;
  --kscw-gold-hover: #e5ac14;
  --kscw-gold-ink: #1a2445;
  --kscw-green: #1f7a4a;
  --kscw-red: #b8392e;
  --kscw-z: 2147483000;
  /* Bong bóng = tím Trợ lý của app (AssistantStyle.assistantPurple) để khách nhận ra cùng một trợ lý */
  --kscw-purple: #7c3aed;
  --kscw-purple-dark: #6d28d9;
  --kscw-purple-glow: #a78bfa;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--kscw-ink);
  letter-spacing: normal;
  text-transform: none;
}
.kscw *, .kscw *::before, .kscw *::after { box-sizing: border-box; }
.kscw [hidden], .kscw[hidden] { display: none !important; }
.kscw button, .kscw input, .kscw textarea { font-family: inherit; letter-spacing: normal; text-transform: none; margin: 0; }
.kscw a { color: var(--kscw-blue); }
.kscw :focus-visible { outline: 3px solid var(--kscw-gold); outline-offset: 2px; }
.kscw-sr {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Bong bóng ---------- */
.kscw-bubble {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: var(--kscw-z);
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kscw-purple);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(76, 29, 149, 0.4);
  transition: bottom 0.2s ease, transform 0.15s ease, background-color 0.15s;
}
.kscw-bubble:hover { background: var(--kscw-purple-dark); transform: translateY(-1px); }
.kscw-bubble .kscw-bubble-close { display: none; }
.kscw-bubble.is-open svg { display: none; }
.kscw-bubble.is-open .kscw-bubble-close { display: block; }
.kscw-bubble-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #fff;
}

/* ---------- Lời mời ---------- */
.kscw-teaser {
  position: fixed;
  right: 20px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: var(--kscw-z);
  max-width: min(300px, calc(100vw - 40px));
  display: flex;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--kscw-line);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 16px 40px rgba(17, 28, 63, 0.22);
  animation: kscw-pop 0.2s ease-out;
  transition: bottom 0.2s ease;
}
.kscw-teaser-text {
  flex: 1;
  min-height: 44px;
  padding: 12px 4px 12px 16px;
  border: 0;
  background: none;
  color: var(--kscw-ink);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.kscw-teaser-close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--kscw-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.kscw-teaser-close:hover { color: var(--kscw-ink); }
@keyframes kscw-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Mobile: thanh CTA dính đáy (main.js đặt body.has-sticky) ⇒ nâng bong bóng lên trên thanh. */
@media (max-width: 899px) {
  body.has-sticky .kscw-bubble { bottom: calc(82px + env(safe-area-inset-bottom)); }
  body.has-sticky .kscw-teaser { bottom: calc(158px + env(safe-area-inset-bottom)); }
}
@media (max-width: 639px) {
  .kscw-bubble { right: 16px; width: 60px; height: 60px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .kscw-teaser { right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
}

/* ---------- Khung chat ---------- */
.kscw-panel {
  position: fixed;
  right: 20px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: var(--kscw-z);
  width: 400px;
  max-width: calc(100vw - 40px);
  height: min(680px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(17, 28, 63, 0.28);
  animation: kscw-pop 0.18s ease-out;
}
.kscw-panel:focus { outline: none; }
.kscw-panel[data-mode="off"] { height: auto; max-height: calc(100vh - 120px); }
@media (max-width: 899px) {
  body.has-sticky .kscw-panel { bottom: calc(158px + env(safe-area-inset-bottom)); height: min(680px, calc(100vh - 180px)); }
}
@media (max-width: 639px) {
  .kscw-panel,
  body.has-sticky .kscw-panel,
  .kscw-panel[data-mode="off"] {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  .kscw-open .kscw-bubble, .kscw-open .kscw-teaser { display: none; }
  .kscw-body-off { flex: 1 1 auto; }
}

.kscw-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--kscw-blue);
  color: #fff;
}
.kscw-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kscw-hinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kscw-title { font-size: 16px; font-weight: 700; line-height: 1.3; color: #fff; }
.kscw-status { font-size: 12.5px; line-height: 1.35; display: flex; align-items: center; gap: 6px; color: #fff; }
.kscw-sdot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: #c3cceb; }
.kscw-sdot-on { background: #4ade80; }
.kscw-sdot-off { background: #fbbf24; }
.kscw-icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.kscw-icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

.kscw-menu {
  position: absolute;
  top: 58px;
  right: 10px;
  z-index: 2;
  min-width: 250px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--kscw-line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(17, 28, 63, 0.22);
}
.kscw-menu-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--kscw-navy);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.kscw-menu-item:hover, .kscw-menu-item:focus-visible { background: #eef2fb; color: var(--kscw-navy); }

/* ---------- Dòng thời gian ---------- */
.kscw-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--kscw-bg);
}
.kscw-body:focus-visible { outline-offset: -3px; }
.kscw-turn { display: flex; flex-direction: column; gap: 10px; }
.kscw-empty { display: none; }
.kscw-msg {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.kscw-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--kscw-line);
  border-radius: 4px 16px 16px 16px;
  color: var(--kscw-ink);
}
.kscw-me {
  align-self: flex-end;
  background: var(--kscw-blue);
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}
.kscw-err-msg { border-color: #f1c6c1; background: #fff6f5; }
.kscw-staff { align-self: flex-start; display: flex; flex-direction: column; gap: 4px; max-width: 85%; }
.kscw-staff .kscw-msg { max-width: 100%; border-color: #9ed8b4; }
.kscw-staff-name { font-size: 12.5px; font-weight: 700; color: var(--kscw-green); padding-left: 4px; }
.kscw-sys { margin: 0; align-self: center; text-align: center; font-size: 12.5px; color: var(--kscw-fine); padding: 2px 8px; }
.kscw-sys-ok { color: var(--kscw-green); font-weight: 600; }
.kscw-note { margin: 0; font-size: 13px; color: var(--kscw-red); }

.kscw-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--kscw-line);
  border-radius: 4px 16px 16px 16px;
}
.kscw-dot { width: 7px; height: 7px; border-radius: 50%; background: #8d97b5; animation: kscw-blink 1.2s infinite ease-in-out; }
.kscw-dot:nth-child(3) { animation-delay: 0.2s; }
.kscw-dot:nth-child(4) { animation-delay: 0.4s; }
@keyframes kscw-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Chip */
.kscw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kscw-chips-col { flex-direction: column; align-items: flex-start; padding-left: 4px; }
.kscw-choices { display: flex; flex-direction: column; gap: 10px; }
.kscw-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--kscw-chip-line);
  border-radius: 999px;
  background: #fff;
  color: var(--kscw-navy);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}
.kscw-chip:hover { border-color: var(--kscw-blue); background: #eef2fb; }
.kscw-chip-accent { border-color: var(--kscw-gold); background: #fff6dc; color: #4a3500; font-weight: 700; }
.kscw-chip-accent:hover { border-color: var(--kscw-gold-hover); background: #ffefc2; }
.kscw-chip-gold { border-color: var(--kscw-gold); background: var(--kscw-gold); color: var(--kscw-gold-ink); font-weight: 800; }
.kscw-chip-gold:hover { border-color: var(--kscw-gold-hover); background: var(--kscw-gold-hover); }

/* Phản hồi 👍/👎 */
.kscw-fb { display: flex; align-items: center; gap: 4px; padding-left: 2px; }
.kscw-fb-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--kscw-fine);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.kscw-fb-btn:hover { background: #eef2fb; color: var(--kscw-navy); }
.kscw-fb-btn[aria-pressed="true"] { color: var(--kscw-blue); background: #eef2fb; }
.kscw-fb-thanks { font-size: 12.5px; color: var(--kscw-fine); }

/* ---------- Thẻ ---------- */
.kscw-card {
  align-self: stretch;
  margin-right: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--kscw-line);
  border-radius: 16px;
}
.kscw-card-title { font-size: 13.5px; font-weight: 800; color: var(--kscw-blue); letter-spacing: 0.04em; }
.kscw-card-note { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--kscw-fine); }
.kscw-card-link { font-size: 14px; font-weight: 600; text-decoration: underline; min-height: 32px; display: inline-flex; align-items: center; }
.kscw-table-wrap { overflow-x: auto; }
.kscw-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kscw-table th, .kscw-table td { padding: 8px 4px; border-bottom: 1px solid #eef0f6; text-align: left; font-weight: 500; color: var(--kscw-ink); white-space: nowrap; background: none; }
.kscw-table thead th { color: var(--kscw-body); font-weight: 600; font-size: 13px; border-bottom-color: var(--kscw-line); }
.kscw-table tbody tr:last-child th, .kscw-table tbody tr:last-child td { border-bottom: 0; }
.kscw-table .kscw-num { text-align: right; }
.kscw-table .kscw-strong { font-weight: 700; }
.kscw-table .kscw-hl { background: #fff6dc; }
.kscw-table thead .kscw-hl { color: #4a3500; border-radius: 8px 8px 0 0; }

.kscw-btn-row { display: flex; gap: 8px; align-items: stretch; }
.kscw-btn-row > * { flex: 1; }
.kscw-btn-row > .kscw-grow2 { flex: 2; }
.kscw-link-row { display: flex; padding-right: 16px; }
.kscw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.kscw-btn:disabled { opacity: 0.6; cursor: default; }
.kscw .kscw-btn-gold { background: var(--kscw-gold); color: var(--kscw-gold-ink); font-weight: 800; box-shadow: 0 8px 18px rgba(242, 185, 36, 0.32); }
.kscw .kscw-btn-gold:hover { background: var(--kscw-gold-hover); color: var(--kscw-gold-ink); }
.kscw .kscw-btn-outline { background: #fff; border: 1.5px solid #b3bedb; color: var(--kscw-navy); }
.kscw .kscw-btn-outline:hover { border-color: var(--kscw-blue); background: #eef2fb; color: var(--kscw-navy); }
.kscw .kscw-btn-text { background: transparent; color: var(--kscw-body); font-weight: 600; text-decoration: underline; }

/* Cài đặt 3 bước */
.kscw-step { display: flex; gap: 10px; }
.kscw-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--kscw-blue);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kscw-step-gold { background: var(--kscw-gold); color: var(--kscw-gold-ink); }
.kscw-step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.kscw-step-desc { font-size: 13.5px; color: var(--kscw-body); line-height: 1.45; }
.kscw-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kscw-dl { display: flex; flex-direction: column; gap: 6px; }
.kscw .kscw-store {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 10px;
  background: #0c1430;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.kscw .kscw-store:hover { background: #1b2c63; color: #fff; }

/* Thẻ liên hệ */
.kscw-cform {
  align-self: stretch;
  margin: 0 16px 0 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border: 2px solid var(--kscw-gold);
  border-radius: 16px;
}
.kscw-cform-off { margin: 0; }
.kscw-cform-title { font-size: 15px; font-weight: 700; line-height: 1.4; }
.kscw-cform-sub { font-size: 13px; color: var(--kscw-body); line-height: 1.45; }
.kscw-field { display: flex; flex-direction: column; gap: 4px; }
.kscw-field label, .kscw-fieldset legend { font-size: 13px; font-weight: 600; color: var(--kscw-ink); padding: 0; }
.kscw-hint { font-weight: 400; color: var(--kscw-fine); }
.kscw .kscw-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--kscw-input-line);
  border-radius: 10px;
  background: #fff;
  color: var(--kscw-ink);
  font-size: 16px;
  box-shadow: none;
}
.kscw .kscw-input:focus { border-color: var(--kscw-blue); outline: none; box-shadow: 0 0 0 3px rgba(37, 65, 196, 0.18); }
.kscw-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.kscw-fieldset legend { margin-bottom: 6px; }
.kscw-toggles { display: grid; gap: 8px; }
.kscw-cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kscw-cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kscw-toggle {
  min-height: 44px;
  padding: 4px 8px;
  border: 1.5px solid var(--kscw-chip-line);
  border-radius: 12px;
  background: #fff;
  color: var(--kscw-navy);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
}
.kscw-toggle-pill { border-radius: 999px; }
.kscw-toggle[aria-pressed="true"] { border: 2px solid var(--kscw-blue); background: #eef2fb; font-weight: 700; }
.kscw-form-err { margin: 0; font-size: 13px; color: var(--kscw-red); font-weight: 600; }
.kscw-form-err:empty { display: none; }

/* Đã gửi liên hệ */
.kscw-saved {
  align-self: stretch;
  margin-right: 16px;
  padding: 14px;
  display: flex;
  gap: 12px;
  background: #e8f7ee;
  border: 1.5px solid #9ed8b4;
  border-radius: 16px;
}
.kscw-body-off .kscw-saved { margin-right: 0; }
.kscw-saved-ic {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--kscw-green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kscw-saved-body { display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.5; color: #1f3d2c; }
.kscw-saved-body b { font-size: 15px; color: #145c34; }
.kscw-saved-meta { font-size: 13px; }

/* Chế độ tắt */
.kscw-body-off { flex: 0 1 auto; }
.kscw .kscw-tile {
  min-height: 84px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--kscw-line);
  border-radius: 16px;
  color: var(--kscw-navy);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.kscw .kscw-tile:hover { border-color: var(--kscw-blue); background: #eef2fb; color: var(--kscw-navy); }

/* ---------- Chân khung ---------- */
.kscw-foot {
  flex-shrink: 0;
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--kscw-line);
  background: #fff;
}
.kscw-ts:empty { display: none; }
.kscw-ts { display: flex; justify-content: center; }
.kscw-foot-err { margin: 0; font-size: 13px; color: var(--kscw-red); font-weight: 600; }
.kscw-compose { display: flex; gap: 8px; align-items: flex-end; }
.kscw .kscw-textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 16px;
  border: 1.5px solid var(--kscw-chip-line);
  border-radius: 22px;
  background: #fff;
  color: var(--kscw-ink);
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  box-shadow: none;
}
.kscw .kscw-textarea:focus { border-color: var(--kscw-blue); outline: none; box-shadow: 0 0 0 3px rgba(37, 65, 196, 0.18); }
.kscw .kscw-textarea::placeholder { color: #6b7493; opacity: 1; }
.kscw-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kscw-blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.kscw-send:hover { background: var(--kscw-blue-dark); }
.kscw-send:disabled { background: #8d97b5; cursor: default; }
.kscw-fine { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--kscw-fine); text-align: center; }
.kscw-fine-left { text-align: left; }
.kscw .kscw-fine-link { color: var(--kscw-blue); text-decoration: underline; }
@media (max-width: 639px) {
  .kscw .kscw-textarea { font-size: 16px; } /* iOS không phóng to khi chạm ô nhập */
  .kscw-msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .kscw-panel, .kscw-teaser { animation: none; }
  .kscw-bubble, .kscw-teaser { transition: none; }
  .kscw-dot { animation: none; opacity: 0.7; }
}

/* ---------- Bong bóng "thở" + chữ chạy (tới lần đầu khách mở chat) ---------- */
.kscw-bubble.kscw-breathe { animation: kscw-breathe 2.8s ease-in-out infinite; }
.kscw-bubble.kscw-breathe::before,
.kscw-bubble.kscw-breathe::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* Tím nhạt: thấy được trên cả hero xanh lẫn mục nền trắng */
  background: var(--kscw-purple-glow);
  opacity: 0;
  z-index: -1;
  animation: kscw-ripple 2.8s ease-out infinite;
  pointer-events: none;
}
.kscw-bubble.kscw-breathe::after { animation-delay: 1.4s; }
@keyframes kscw-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes kscw-ripple { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.8); opacity: 0; } }

.kscw-ticker {
  position: fixed;
  right: 96px;
  bottom: calc(31px + env(safe-area-inset-bottom));
  z-index: var(--kscw-z);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: calc(100vw - 128px);
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--kscw-ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(17, 28, 63, 0.22);
  animation: kscw-pop 0.25s ease-out;
}
.kscw-ticker[hidden] { display: none; }
.kscw-ticker:hover { color: var(--kscw-purple); }
.kscw-ticker-text { overflow: hidden; text-overflow: ellipsis; }
.kscw-ticker-caret {
  width: 2px;
  height: 18px;
  margin-left: 3px;
  flex-shrink: 0;
  background: var(--kscw-purple);
  animation: kscw-caret 1s steps(1) infinite;
}
@keyframes kscw-caret { 50% { opacity: 0; } }
@media (max-width: 639px) {
  .kscw-ticker { right: 84px; bottom: calc(24px + env(safe-area-inset-bottom)); font-size: 14px; min-height: 40px; }
  body.has-sticky .kscw-ticker { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (min-width: 640px) {
  body.has-sticky .kscw-ticker { bottom: calc(31px + env(safe-area-inset-bottom)); }
}
.kscw-open .kscw-ticker { display: none; }
/* Giảm chuyển động (Windows tắt "Animation effects" cũng rơi vào đây — rất nhiều máy): không phóng to/lan
   vòng, chỉ phát sáng nhẹ bằng độ mờ; chữ đổi câu bằng mờ dần thay vì gõ (xem stepTicker). */
@media (prefers-reduced-motion: reduce) {
  .kscw-bubble.kscw-breathe { animation: none; }
  .kscw-bubble.kscw-breathe::after { display: none; }
  .kscw-bubble.kscw-breathe::before { animation: kscw-glow 3.2s ease-in-out infinite; transform: scale(1.25); }
  .kscw-ticker-caret { display: none; }
  .kscw-ticker-text { transition: opacity 0.45s ease; }
  .kscw-ticker-text.kscw-fade { opacity: 0; }
}
@keyframes kscw-glow { 0%, 100% { opacity: 0; } 50% { opacity: 0.45; } }
