/* K.F. Fong & Co. — Ask AI widget ------------------------------------------------ */

.kff-ai,
.kff-ai * {
  box-sizing: border-box;
}

/* Root must stay static so the panel can out-rank the other floating
   buttons (WhatsApp z99999, bottom nav z99999) when it is open. */
.kff-ai {
  position: static;
}

[hidden].kff-ai-panel {
  display: none !important;
}

/* Launcher pill ------------------------------------------------------------ */
/* Desktop: sits above the theme's #scroll_up back-to-top circle
   (bottom 10px, 50px tall -> top edge at 60px) so both stay clickable. */
.kff-ai-fab {
  position: fixed;
  right: 20px;
  bottom: 80px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #354b70 0%, #46608f 100%);
  color: #fff;
  font: 600 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(26, 32, 44, .22);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  z-index: 99997;
}

.kff-ai-fab:hover,
.kff-ai-fab:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(26, 32, 44, .28);
  background: linear-gradient(135deg, #3d557d 0%, #4d6898 100%);
}

.kff-ai-fab:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

.kff-ai-fab:active {
  transform: translateY(0);
}

.kff-ai-fab .kff-ai-spark {
  color: #f5b942;
  font-size: 18px;
  line-height: 1;
}

/* Hide the FAB while the panel is open. */
#kffAiPanel:not([hidden]) ~ #kffAiFab {
  display: none !important;
}

/* Panel -------------------------------------------------------------------- */
.kff-ai-panel {
  position: fixed;
  right: 24px;
  bottom: 88px;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(26, 32, 44, .1);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(26, 32, 44, .24);
  overflow: hidden;
  /* Above the site's floating controls (z 99999) while open. */
  z-index: 100000;
}

@supports (height: 100dvh) {
  .kff-ai-panel {
    height: min(640px, calc(100dvh - 140px));
  }
}

.kff-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #354b70 0%, #46608f 100%);
  color: #fff;
}

.kff-ai-head-left {
  flex: 1 1 auto;
  min-width: 0;
}

.kff-ai-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.kff-ai-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 700 15px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kff-ai-head-title .kff-ai-spark {
  color: #f5b942;
  font-size: 17px;
}

.kff-ai-head-sub {
  display: block;
  font: 400 11.5px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  opacity: .85;
  margin-top: 2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kff-ai-close {
  border: 0;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.kff-ai-close:hover {
  background: rgba(255, 255, 255, .26);
}

.kff-ai-close:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

/* Back button -------------------------------------------------------------- */
.kff-ai-back {
  border: 0;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kff-ai-back:hover {
  background: rgba(255, 255, 255, .26);
}

.kff-ai-back:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

/* Mobile: ensure back button meets 40x40 touch target and is distinct from close */
@media (max-width: 767.98px) {
  .kff-ai-back {
    width: 40px;
    height: 40px;
  }
}

/* Stage 6: pre-chat "Important notice" gate -------------------------------- */
.kff-ai-notice {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: #fff;
  overflow-y: auto;
}

.kff-ai-notice[hidden] {
  display: none !important;
}

.kff-ai-notice-inner {
  width: 100%;
  max-width: 360px;
  margin: auto;
}

.kff-ai-notice-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 700 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1a202c;
  margin: 0 0 10px;
}

.kff-ai-notice-body p {
  font: 400 13px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #4a5568;
  margin: 0 0 10px;
}

.kff-ai-notice-body p:last-child {
  margin-bottom: 0;
}

.kff-ai-notice-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.kff-ai-notice-privacy {
  color: #2f5bd0;
  font: 600 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  text-decoration: underline;
}

.kff-ai-notice-privacy:focus-visible {
  outline: 2px solid #f5b942;
  outline-offset: 2px;
}

.kff-ai-notice-continue {
  border: 0;
  border-radius: 999px;
  background: #354b70;
  color: #fff;
  font: 700 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 12px 26px;
  min-height: 44px;
  cursor: pointer;
  transition: background .15s ease;
}

.kff-ai-notice-continue:hover {
  background: #46608f;
}

.kff-ai-notice-continue:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

/* Messages ----------------------------------------------------------------- */
.kff-ai-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 6px;
  background: #f7f8fb;
  scroll-behavior: smooth;
}

.kff-ai-row {
  display: flex;
  margin-bottom: 10px;
}

.kff-ai-row.is-user {
  justify-content: flex-end;
}

.kff-ai-bubble {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  font: 400 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kff-ai-row.is-assistant .kff-ai-bubble {
  background: #fff;
  color: #1a202c;
  border: 1px solid rgba(26, 32, 44, .08);
  border-top-left-radius: 4px;
}

.kff-ai-row.is-user .kff-ai-bubble {
  background: #354b70;
  color: #fff;
  border-top-right-radius: 4px;
}

/* Image wrapper in user message bubble */
.kff-ai-row.is-user .kff-ai-bubble .kff-ai-imgwrap {
  margin-bottom: 6px;
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

.kff-ai-row.is-user .kff-ai-bubble .kff-ai-imgwrap img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.kff-ai-cite {
  color: #2f5bd0;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kff-ai-cite:hover,
.kff-ai-cite:focus-visible {
  text-decoration: underline;
}

.kff-ai-row.is-user .kff-ai-cite {
  color: #ffe9b3;
}

/* Sources ------------------------------------------------------------------ */
.kff-ai-sources {
  max-width: 92%;
  margin: -4px 0 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid rgba(26, 32, 44, .08);
  border-radius: 10px;
  font: 400 11.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #4a5568;
}

.kff-ai-sources-label {
  display: block;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 4px;
}

.kff-ai-sources ol {
  margin: 0;
  padding-left: 18px;
}

.kff-ai-sources li {
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}

.kff-ai-sources li:last-child {
  margin-bottom: 0;
}

.kff-ai-source-title {
  color: #2f5bd0;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

a.kff-ai-source-title:hover,
a.kff-ai-source-title:focus-visible {
  text-decoration: underline;
}

.kff-ai-source-meta {
  color: #6b7280;
}

.kff-ai-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fdf3e0;
  border: 1px solid #f0d9a8;
  color: #7a5b12;
  font: 600 10.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  vertical-align: 1px;
}

/* Knowledge availability (restrained) -------------------------------------- */
.kff-ai-kstatus {
  max-width: 92%;
  margin: -4px 0 10px;
  font: 400 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #6b7280;
}

.kff-ai-kstatus.is-unverified::before {
  content: "◦ ";
  color: #b7791f;
}

.kff-ai-kstatus.is-none::before {
  content: "◦ ";
  color: #9aa3b5;
}

/* Welcome note + starter prompts ------------------------------------------- */
.kff-ai-note-inline {
  max-width: 92%;
  margin: -2px 0 10px;
  font: 400 11.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #6b7280;
}

.kff-ai-note-inline a {
  color: #2f5bd0;
  text-decoration: underline;
}

.kff-ai-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.kff-ai-starter {
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid rgba(53, 75, 112, .45);
  border-radius: 999px;
  background: #fff;
  color: #354b70;
  font: 600 12.5px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.kff-ai-starter:hover {
  background: #eef2f8;
}

.kff-ai-starter:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

/* Stage 4.1 escalation CTA — solid, clearly distinct from starter chips ---- */
.kff-ai-cta-wrap {
  margin: 0 0 10px;
}

.kff-ai-cta {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: #354b70;
  color: #fff;
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(26, 32, 44, .18);
}

.kff-ai-cta:hover {
  background: #46608f;
}

/* Stage 5.2: contact link chip on complaint / navigation replies. */
a.kff-ai-cta {
  display: inline-block;
  text-decoration: none;
}

.kff-ai-cta:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

/* Stage 20: service-interest CTA block — heading, body, controlled buttons
   row and the confidentiality reminder, rendered after the Sources list. */
.kff-ai-cta-heading {
  margin: 12px 0 4px;
  font: 700 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.kff-ai-cta-body {
  margin: 0 0 8px;
  font: 400 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.kff-ai-cta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}

.kff-ai-cta-privacy {
  margin: 2px 0 0;
  font: 400 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  opacity: .75;
}

.kff-ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 11px 13px;
}

.kff-ai-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa3b5;
  animation: kff-ai-blink 1.2s infinite ease-in-out;
}

.kff-ai-typing i:nth-child(2) {
  animation-delay: .18s;
}

.kff-ai-typing i:nth-child(3) {
  animation-delay: .36s;
}

@keyframes kff-ai-blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Lead form ---------------------------------------------------------------- */
.kff-ai-lead {
  flex: 0 0 auto;
  max-height: 60%;
  overflow-y: auto;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid rgba(26, 32, 44, .1);
}

.kff-ai-lead-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #354b70;
  font: 600 12.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 6px 0;
  margin: 0 0 4px;
  min-height: 32px;
  cursor: pointer;
}

.kff-ai-lead-back:hover {
  text-decoration: underline;
}

.kff-ai-lead-back:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

.kff-ai-lead-title {
  font: 700 13.5px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a202c;
  margin: 0 0 2px;
}

.kff-ai-lead-intro {
  font: 400 11.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #6b7280;
  margin: 0 0 10px;
}

.kff-ai-lead .kff-ai-field {
  margin-bottom: 8px;
}

.kff-ai-field-pair {
  display: flex;
  gap: 8px;
}

.kff-ai-field-pair > div {
  flex: 1 1 0;
  min-width: 0;
}

.kff-ai-lead label {
  display: block;
  font: 600 11.5px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #4a5568;
  margin-bottom: 3px;
}

.kff-ai-field-hint {
  font: 400 11px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #6b7280;
  margin: -4px 0 8px;
}

.kff-ai-field-err {
  font: 600 11.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #b3261e;
  margin: -2px 0 8px;
}

.kff-ai-lead input[type="text"],
.kff-ai-lead input[type="email"],
.kff-ai-lead input[type="tel"],
.kff-ai-lead select,
.kff-ai-lead textarea {
  width: 100%;
  border: 1px solid rgba(26, 32, 44, .2);
  border-radius: 8px;
  padding: 8px 10px;
  font: 400 13.5px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a202c;
  background: #fff;
}

.kff-ai-lead input:focus,
.kff-ai-lead select:focus,
.kff-ai-lead textarea:focus {
  outline: none;
  border-color: #354b70;
  box-shadow: 0 0 0 2px rgba(53, 75, 112, .14);
}

.kff-ai-lead input:focus-visible,
.kff-ai-lead select:focus-visible,
.kff-ai-lead textarea:focus-visible {
  outline: none;
}

.kff-ai-consent {
  display: flex !important;
  align-items: flex-start;
  gap: 7px;
  font-weight: 500 !important;
  color: #4a5568 !important;
}

.kff-ai-consent input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
}

.kff-ai-lead-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.kff-ai-lead-submit {
  border: 0;
  border-radius: 999px;
  background: #354b70;
  color: #fff;
  font: 600 13.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 11px 22px;
  min-height: 40px;
  cursor: pointer;
}

.kff-ai-lead-submit:hover {
  background: #46608f;
}

.kff-ai-lead-submit:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

.kff-ai-lead-cancel {
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
  min-height: 40px;
}

.kff-ai-lead-cancel:focus-visible {
  outline: 3px solid #f5b942;
  outline-offset: 2px;
}

.kff-ai-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Input bar ---------------------------------------------------------------- */
.kff-ai-input {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid rgba(26, 32, 44, .1);
}

.kff-ai-input textarea {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid rgba(26, 32, 44, .2);
  border-radius: 10px;
  padding: 9px 11px;
  max-height: 96px;
  min-height: 40px;
  font: 400 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1a202c;
}

.kff-ai-input textarea:focus {
  outline: none;
  border-color: #354b70;
  box-shadow: 0 0 0 2px rgba(53, 75, 112, .14);
}

.kff-ai-send {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  background: #f5b942;
  color: #1f2a44;
  font: 700 13.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 40px;
  min-width: 64px;
  padding: 0 15px;
  cursor: pointer;
  transition: background .15s ease;
}

.kff-ai-send:hover:not(:disabled) {
  background: #ffc857;
}

.kff-ai-send:disabled {
  opacity: .5;
  cursor: default;
}

.kff-ai-send:focus-visible {
  outline: 3px solid #354b70;
  outline-offset: 2px;
}

/* Stage 9.2: image + voice-typing tools --------------------------------- */
.kff-ai-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 0;
  background: #fff;
}

.kff-ai-tool {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(26, 32, 44, .18);
  border-radius: 10px;
  background: #fff;
  color: #354b70;
  cursor: pointer;
  padding: 0;
  transition: background .15s ease;
}

.kff-ai-tool:hover {
  background: #f3f6fb;
}

.kff-ai-tool:focus-visible {
  outline: 3px solid #354b70;
  outline-offset: 2px;
}

.kff-ai-tool.is-active {
  background: #f5b942;
  border-color: #f5b942;
  color: #1f2a44;
}

.kff-ai-imgchip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  padding: 4px 4px 4px 10px;
  border: 1px solid rgba(26, 32, 44, .18);
  border-radius: 999px;
  background: #f3f6fb;
  max-width: 60%;
}

.kff-ai-imgchip-name {
  font: 500 12px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2a44;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kff-ai-imgchip-x {
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 20px;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
  border-radius: 50%;
}

.kff-ai-imgchip-x:hover {
  color: #b91c1c;
}

.kff-ai-imgwarn {
  margin: 0;
  padding: 6px 14px 0;
  background: #fff;
  font: 400 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #b45309;
}

.kff-ai-note {
  padding: 7px 14px 9px;
  background: #fff;
  font: 400 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #6b7280;
  border-top: 1px dashed rgba(26, 32, 44, .08);
}

.kff-ai-privacy {
  color: #2f5bd0;
  text-decoration: underline;
  margin-left: 6px;
  white-space: nowrap;
}

.kff-ai-privacy:focus-visible {
  outline: 2px solid #f5b942;
  outline-offset: 1px;
}

/* Mobile: full-screen sheet ------------------------------------------------ */
@media (max-width: 767.98px) {
  .kff-ai-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    /* max-width: 100vw is removed — on iOS Safari 100vw includes the scrollbar
       width, making the panel slightly wider than the visual viewport and
       causing right-edge clipping via overflow-x: hidden. Using width: 100%
       with left/right: 0 is sufficient and avoids the viewport unit quirk. */
    max-width: none;
    overflow-x: hidden;
    /* Full-screen sheet must out-rank WhatsApp / bottom nav (z 99999). */
    z-index: 100001;
  }

  .kff-ai-msgs {
    padding-bottom: 10px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    max-width: 100%;
    box-sizing: border-box;
  }

  .kff-ai-lead {
    max-height: 65%;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  /* Hide the launcher while the panel is open (no overlap with the sheet). */
  .kff-ai-panel:not([hidden]) ~ .kff-ai-fab {
    display: none !important;
  }

  .kff-ai-input {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .kff-ai-note {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .kff-ai-head {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .kff-ai-close {
    width: 40px;
    height: 40px;
  }

  .kff-ai-notice {
    padding-top: calc(24px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .kff-ai-bubble {
    max-width: 92%;
    box-sizing: border-box;
  }

  .kff-ai-sources,
  .kff-ai-kstatus,
  .kff-ai-note-inline {
    max-width: 96%;
    box-sizing: border-box;
  }

  .kff-ai-sources {
    box-sizing: border-box;
  }

  .kff-ai-kstatus {
    box-sizing: border-box;
  }

  .kff-ai-field-pair {
    flex-direction: row;
  }



  .kff-ai-tool {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .kff-ai-send {
    height: 44px !important;
    min-height: 44px !important;
    min-width: 64px !important;
  }

  .kff-ai-imgchip-x {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .kff-ai-imgchip {
    min-width: 0;
    overflow: hidden;
    padding-left: 8px;
  }

  .kff-ai-imgchip-name {
    min-width: 0;
  }

  .kff-ai-tools {
    padding: 6px 10px 0;
    gap: 6px;
  }

  .kff-ai-imgwarn {
    padding: 3px 12px 0;
    font-size: 10px;
    line-height: 1.35;
  }

  .kff-ai-input {
    padding-top: 6px;
    gap: 6px;
  }

  .kff-ai-input textarea {
    height: 56px;
    min-width: 0;
    padding: 6px 10px;
  }

  .kff-ai-head {
    padding-top: calc(9px + env(safe-area-inset-top, 0px));
    padding-bottom: 9px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .kff-ai-head-title {
    font-size: 14px;
  }

  .kff-ai-head-sub {
    font-size: 11px;
    margin-top: 1px;
  }

  .kff-ai-note {
    padding-top: 4px;
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    font-size: 10.5px;
    line-height: 1.35;
}

  /* Mobile keeps the full labelled pill (same as desktop); only its slot moves
   up so the base pill (right: 20px / bottom: 80px) clears the bottom bar. */
@media (max-width: 991.98px) {
  button.kff-ai-fab {
    right: 20px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* Desktop / large tablet: hug the corner beside #scroll_up (right: 10px)
   while the "Ask Fong AI" label stays visible. */
@media (min-width: 992px) {
  button.kff-ai-fab {
    right: 10px;
  }
}

/* Launcher gutter: between 992-1089px and 1200-1269px the fixed 960px /
   1140px grid otherwise runs under the floating launcher. Ease container
   content in from the right (0 at the end of each range, worst case ~54px
   at 992px) so sidebar links, cards and the footer form stay clear.
   Nested containers keep the base gutter, so content is inset once. */
@media (min-width: 992px) and (max-width: 1089px) {
  .container {
    padding-right: calc(15px + max(0px, (1089px - 100vw) / 2));
  }

  .container .container {
    padding-right: 15px;
  }
}

@media (min-width: 1200px) and (max-width: 1269px) {
  .container {
    padding-right: calc(15px + max(0px, (1269px - 100vw) / 2));
  }

  .container .container {
    padding-right: 15px;
  }
}

@media (max-width: 380px) {
  .kff-ai-field-pair {
    flex-direction: column;
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kff-ai-fab {
    transition: none;
  }

  .kff-ai-fab:hover,
  .kff-ai-fab:focus-visible {
    transform: none;
  }

  .kff-ai-typing i {
    animation: none;
  }

  .kff-ai-msgs {
    scroll-behavior: auto;
  }
}

@media (max-width: 340px) {
  .kff-ai-head-sub {
    display: none;
  }

  .kff-ai-imgwarn {
    font-size: 9.5px;
  }
}
