:root {
  --ink: #18283a;
  --muted: #65778a;
  --line: rgba(42, 74, 112, 0.14);
  --surface: #ffffff;
  --soft: #eef5f8;
  --accent: #1f5b99;
  --accent-2: #1f9eaa;
  --accent-3: #d99b2b;
  --accent-dark: #173f67;
  --good: #237a57;
  --warn: #b45309;
  --bot-surface: #edf4f8;
  --student-surface: #1f5b99;
  --page-bg: #eef4f7;
  --shadow: 0 18px 42px rgba(27, 56, 86, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  background: var(--page-bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 91, 153, 0.28);
  outline-offset: 3px;
}

.standalone-page {
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #f7fbfd 0%, var(--page-bg) 42%, #e8f0f4 100%);
}

.standalone-page::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0));
}

.standalone-page::after {
  display: none;
}

.bot-shell {
  display: grid;
  width: min(780px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 0;
  place-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chat-stage {
  display: grid;
  width: 100%;
  height: min(760px, calc(100dvh - 32px));
  min-height: min(620px, calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 22px 55px rgba(27, 56, 86, 0.13);
}

html.widget-embed-page,
body.widget-embed-page {
  height: 100%;
  min-height: 100%;
  background: transparent;
}

.site-preview {
  position: relative;
  min-height: 100vh;
  background: #fff;
}

.finance-site-frame {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  border: 0;
  background: #fff;
}

.iframe-fallback {
  display: grid;
  min-height: 100vh;
  place-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.iframe-fallback h1,
.iframe-fallback p {
  margin: 0;
}

.iframe-fallback p {
  color: var(--muted);
}

.iframe-fallback a {
  color: var(--accent-dark);
}

.chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: grid;
  justify-items: end;
  gap: 12px;
  pointer-events: none;
}

.widget-embed-page .chat-widget {
  position: static;
  right: auto;
  bottom: auto;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.widget-panel {
  pointer-events: auto;
}

.widget-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(460px, calc(100vw - 32px));
  height: min(710px, calc(100dvh - 92px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.messages,
.category-dock,
.category-dock-grid,
.followup-category-grid,
.faq-option-card,
.composer {
  max-width: 100%;
}

.standalone-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: none;
}

.widget-embed-page .widget-panel {
  width: 100%;
  height: 100%;
  max-width: none;
}

.embedded-panel {
  border-radius: 16px;
}

.widget-panel[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.chat-header h2,
.chat-header p {
  margin: 0;
}

.chat-header h2 {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.chat-header p:not(.eyebrow) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.chat-header p:not(.eyebrow)::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  content: "";
  background: #22b573;
  box-shadow: 0 0 0 3px rgba(34, 181, 115, 0.12);
}

.header-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.info-strip {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.resource-links {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.resource-links::-webkit-scrollbar {
  display: none;
}

.resource-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 5px 11px;
  border: 1px solid rgba(31, 91, 153, 0.14);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  background: #ffffff;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.resource-links a:hover {
  border-color: rgba(31, 91, 153, 0.28);
  background: #eef6fb;
}

.resource-links a:active {
  transform: translateY(1px);
}

.category-dock {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #f8fbfd, #eef4f7);
}

.category-dock.is-collapsed {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fbfd;
}

/* Keep the category switcher outside the scrolling conversation area so it
   remains available while students review answers or continue asking. */
.widget-panel > .category-dock {
  width: auto;
  margin: 14px 20px 0;
}

.messages > .category-dock {
  width: min(100% - 44px, 740px);
  box-sizing: border-box;
  margin-left: 42px;
}

.category-dock-title {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-dock-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.category-dock-toggle {
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid rgba(31, 91, 153, 0.2);
  border-radius: 10px;
  color: var(--accent-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  background: #ffffff;
}

.category-dock-toggle:hover {
  border-color: rgba(31, 91, 153, 0.36);
  background: #eef6fb;
}

.category-dock-toggle:active {
  transform: scale(0.98);
}

.faq-search {
  display: grid;
  gap: 6px;
}

.faq-search label {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.faq-search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 91, 153, 0.2);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
  background: #ffffff;
}

.faq-search input::placeholder {
  color: #6f8191;
}

.faq-search input:disabled {
  cursor: wait;
  background: #f5f8fa;
}

.category-dock-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

@media (prefers-reduced-motion: no-preference) {
  .category-dock-btn {
    animation: faqRise 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: var(--enter-delay, 0ms);
  }

  .faq-content-section,
  .faq-home-intro,
  .faq-feedback-section {
    animation: faqViewIn 460ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .faq-option-btn {
    animation: faqRise 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: var(--enter-delay, 0ms);
  }
}

/* Seven categories leave three items on the final desktop row. Let the final
   item fill the two remaining tracks instead of leaving a visible empty slot. */
.category-dock-grid > :last-child:nth-child(4n + 3) {
  grid-column: span 2;
}

.category-dock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid rgba(31, 91, 153, 0.16);
  border-radius: 14px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(27, 56, 86, 0.05);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.category-dock-btn:hover {
  border-color: rgba(31, 91, 153, 0.3);
  color: var(--accent-dark);
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 91, 153, 0.14);
  transform: translateY(-3px) rotate(-0.4deg);
}

.category-dock-btn:active {
  transform: scale(0.97);
}

.category-dock-btn.is-selected {
  border-color: transparent;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(31, 91, 153, 0.14);
}

.category-dock-btn.is-category {
  background: #ffffff;
}

.category-dock-btn.is-subcategory {
  font-size: 12px;
  background: #ffffff;
}

.category-dock-btn.is-selected.is-category,
.category-dock-btn.is-selected.is-subcategory {
  color: #ffffff;
  background: var(--accent);
}

.category-panel {
  display: grid;
  grid-template-columns: minmax(180px, 250px) 1fr;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(39, 183, 191, 0.08), transparent),
    #ffffff;
}

.category-copy {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
}

.category-copy span {
  color: var(--muted);
  font-size: 13px;
}

.category-copy strong {
  color: var(--ink);
  font-size: 15px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.category-btn {
  min-width: 0;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid rgba(31, 91, 153, 0.14);
  border-radius: 6px;
  color: var(--accent-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
  background: #f7fbff;
}

.category-btn:hover {
  border-color: rgba(39, 183, 191, 0.42);
  background: #ecfbfd;
}

.category-btn.is-selected {
  border-color: transparent;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(31, 91, 153, 0.16);
}

.icon-text-btn,
.close-btn,
.back-btn {
  min-height: 34px;
  border: 1px solid rgba(31, 91, 153, 0.16);
  border-radius: 6px;
  color: var(--accent-dark);
  background: #ffffff;
}

.icon-text-btn {
  padding: 6px 10px;
}

.close-btn {
  width: 34px;
  font-size: 22px;
  line-height: 1;
}

.back-btn {
  width: 26px;
  font-size: 31px;
  line-height: 1;
}

.bot-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 900;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(31, 91, 153, 0.18);
}

.bot-avatar.small {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 20px 24px;
  overflow-y: auto;
  background: #ffffff;
  scroll-padding-bottom: 16px;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(82%, 680px);
  min-width: 0;
}

.message.user {
  align-self: flex-end;
}

.message.bot {
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  max-width: min(88%, 720px);
}

.message.bot::before {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  margin-top: 3px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  content: "財";
  background: var(--accent);
}

.message.bot > * {
  grid-column: 2;
  min-width: 0;
}

.bubble {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bot .bubble {
  color: var(--ink);
  background: #f2f5f7;
  border-top-left-radius: 6px;
}

.user .bubble {
  color: #ffffff;
  font-weight: 700;
  background: var(--student-surface);
  border-top-right-radius: 6px;
}

.feedback-message {
  max-width: min(82%, 560px);
}

.faq-home-intro {
  display: grid;
  gap: 8px;
  max-width: 640px;
  padding: 24px 4px 14px;
}

.faq-home-intro p,
.faq-home-intro h1 {
  margin: 0;
}

.faq-home-intro > p:first-child,
.faq-crumb {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.faq-home-intro h1 {
  color: var(--ink);
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1.25;
}

.faq-home-intro > p:last-child {
  max-width: 36rem;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.faq-content-section,
.faq-feedback-section {
  width: min(100%, 720px);
}

.faq-content-card {
  padding: 16px;
  border: 1px solid rgba(31, 91, 153, 0.14);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(25, 54, 88, 0.09);
}

.faq-list-section .option-bubble {
  gap: 14px;
  padding: 0;
  overflow: hidden;
}

.faq-list-section .option-bubble > strong {
  display: block;
  padding: 18px 18px 2px;
  font-size: 18px;
}

.faq-answer-card {
  display: grid;
  gap: 14px;
}

.faq-answer-card::before {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  content: "";
  background: var(--accent-2);
}

.faq-answer-card h3,
.faq-crumb {
  margin: 0;
}

.faq-answer-card h3 {
  color: var(--ink);
  font-size: 19px;
  line-height: 1.5;
}

.faq-answer-body {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.faq-answer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.faq-answer-links a,
.faq-back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid rgba(31, 91, 153, 0.18);
  border-radius: 10px;
  color: var(--accent-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  background: #f8fbfd;
}

@keyframes faqRise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes faqViewIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.faq-answer-links a:hover,
.faq-back-button:hover {
  background: #eef6fb;
  border-color: rgba(31, 91, 153, 0.35);
}

.faq-back-button {
  min-width: 76px;
  padding: 0 4px;
  border-color: transparent;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  background: transparent;
  justify-self: start;
  cursor: pointer;
  transition:
    color 180ms ease,
    transform 180ms ease;
}

.faq-back-button:hover {
  border-color: transparent;
  color: var(--accent-2);
  background: transparent;
  transform: translateX(-5px);
}

.faq-back-button:active {
  transform: translateX(-2px) scale(0.94);
}

.message.bot.feedback-message::before {
  display: grid;
  visibility: hidden;
}

.message.bot.feedback-message > * {
  grid-column: 2;
}

.feedback-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-question {
  width: 100%;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.feedback-question-helper {
  width: 100%;
  margin: -1px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.feedback-reason-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  width: 100%;
  margin-top: 2px;
}

.feedback-reason-panel strong {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.feedback-panel button {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid rgba(31, 91, 153, 0.16);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  background: #ffffff;
}

.feedback-panel button:hover {
  border-color: rgba(31, 91, 153, 0.3);
  color: var(--accent-dark);
  background: #eef6fb;
}

.feedback-panel button:disabled {
  cursor: default;
  opacity: 0.55;
}

.feedback-form {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(31, 91, 153, 0.16);
  border-radius: 14px;
  background: #f8fbfd;
}

.feedback-form label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}

.feedback-helper {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.feedback-form textarea,
.feedback-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 91, 153, 0.2);
  border-radius: 10px;
  color: var(--ink);
  line-height: 1.55;
  resize: vertical;
  background: #ffffff;
}

.feedback-form textarea::placeholder,
.feedback-form input::placeholder {
  color: #7b8b9a;
}

.feedback-form > button,
.feedback-form-actions button {
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  background: var(--accent);
}

.feedback-form > button:hover,
.feedback-form-actions button:hover {
  background: var(--accent-dark);
}

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

.feedback-form-actions .secondary-action {
  color: var(--accent-dark);
  background: #ffffff;
  border: 1px solid rgba(31, 91, 153, 0.2);
}

.feedback-form-actions .secondary-action:hover {
  background: #eef6fb;
}

.feedback-panel button:active,
.followup-category-btn:active,
.faq-option-btn:active,
.category-card-btn:active {
  transform: translateY(1px);
}

.option-message {
  max-width: min(96%, 760px);
}

.option-bubble {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  overflow: hidden;
}

.option-bubble strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.followup-message {
  max-width: min(96%, 760px);
}

.followup-bubble {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  padding: 12px;
  background: #edf4f8;
}

.followup-bubble strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

/* With an odd number of follow-up categories, the final option gets its own
   full row so the panel never ends with a conspicuous blank half. */
.followup-category-grid > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.followup-category-btn {
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(31, 91, 153, 0.16);
  border-radius: 999px;
  color: var(--accent-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
  background: #ffffff;
}

.followup-category-btn:hover {
  border-color: rgba(31, 91, 153, 0.3);
  color: var(--accent-dark);
  background: #eef6fb;
}

.followup-category-btn.is-subcategory {
  font-size: 12px;
  background: #f9fcff;
}

.followup-category-btn.is-category {
  background: #ffffff;
}

.faq-option-stack {
  display: grid;
  gap: 8px;
}

.faq-option-card {
  overflow: hidden;
  border: 1px solid rgba(31, 91, 153, 0.14);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(25, 54, 88, 0.06);
}

.faq-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--ink);
  background: #edf5f9;
}

.faq-card-header span {
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.faq-option-list {
  display: grid;
}

.faq-option-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 11px 14px;
  border: 0;
  border-top: 1px solid rgba(31, 91, 153, 0.11);
  border-radius: 0;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 500;
  line-height: 1.55;
  text-align: left;
  background: #ffffff;
  transition:
    background 160ms ease,
    color 160ms ease,
    padding-left 160ms ease;
}

.faq-option-question {
  min-width: 0;
}

.popular-faq-badge {
  flex: 0 0 auto;
  color: #a74d00;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.faq-option-btn:hover {
  color: var(--accent-dark);
  background: #f0f7fb;
  padding-left: 18px;
}

.faq-search-empty {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.category-option-card {
  width: 100%;
}

.category-card-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 14px;
  border: 0;
  color: var(--accent-dark);
  font: inherit;
  text-align: left;
  background: #ffffff;
}

.category-card-btn span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.category-card-btn b {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.35;
}

.category-card-btn:hover {
  background: #f0f7fb;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-width: min(100%, 680px);
}

.meta-note {
  flex-basis: 100%;
  margin: 5px 0 0;
  color: #3d5872;
  font-size: 13px;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 750;
  background: #e8f2fb;
  border: 1px solid rgba(31, 91, 153, 0.1);
}

.pill.warn {
  color: #7c2d12;
  background: #ffedd5;
}

.source-link {
  color: var(--accent-dark);
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 14px 20px 18px;
  padding: 8px;
  border: 1px solid rgba(31, 91, 153, 0.16);
  border-radius: 14px;
  background: #f8fafc;
  box-shadow: none;
}

.composer input {
  min-width: 0;
  min-height: 42px;
  padding: 0 8px 0 14px;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
}

.composer input::placeholder {
  color: #7b8b9a;
}

.composer input:focus {
  box-shadow: none;
}

.composer input:disabled {
  color: #6b7f90;
  cursor: not-allowed;
  background: transparent;
}

.composer button {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  background: var(--accent);
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.composer button:hover {
  background: var(--accent-dark);
}

.composer button:active {
  transform: translateY(1px);
}

.composer button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

@media (max-width: 860px) {
  .bot-shell {
    width: min(100% - 22px, 700px);
    padding: 11px 0;
  }

  .chat-stage,
  .standalone-panel {
    min-height: calc(100dvh - 22px);
  }

  .message {
    max-width: 92%;
  }

  .category-dock-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-dock-grid > :last-child:nth-child(4n + 3) {
    grid-column: auto;
  }

  .category-dock-grid > :last-child:nth-child(3n + 1) {
    grid-column: 1 / -1;
  }

  .followup-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .chat-stage,
  .standalone-panel {
    min-height: calc(100dvh - 22px);
  }

  .chat-header {
    padding: 14px;
  }

  .info-strip {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  .chat-header {
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
    margin-left: 52px;
    justify-content: flex-start;
  }

  .category-dock {
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
  }

  .category-dock.is-collapsed {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .category-dock-toggle {
    width: 100%;
  }

  .messages > .category-dock {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }

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

  .category-dock-grid > :last-child:nth-child(3n + 1) {
    grid-column: auto;
  }

  .category-dock-grid > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .category-dock-btn {
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 13px;
  }

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

  .followup-category-btn {
    min-width: 0;
    min-height: 44px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .messages {
    padding: 14px 12px;
  }

  .message.bot {
    grid-template-columns: 28px minmax(0, 1fr);
    max-width: 96%;
  }

  .message.bot::before {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .category-panel {
    grid-template-columns: 1fr;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) auto;
    margin: 10px 12px 12px;
  }

  .widget-panel > .category-dock {
    margin: 10px 12px 0;
  }

  .composer button {
    width: 42px;
  }
}

@media (max-width: 760px) {
  html,
  body,
  .standalone-page {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .bot-shell {
    width: 100%;
    max-width: 100vw;
    padding: 0;
  }

  .chat-stage,
  .standalone-panel {
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .messages {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* The full category picker is useful on desktop, but this compact version
     still occupies a large part of a phone viewport while an answer is read. */
  .category-dock.is-collapsed {
    display: none;
  }

  .faq-back-button {
    order: -1;
    margin-bottom: -6px;
  }

  .chat-widget {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .widget-panel {
    width: 100%;
    height: min(640px, calc(100dvh - 92px));
  }

  .widget-embed-page .widget-panel,
  .standalone-page .widget-panel {
    height: 100%;
  }
}
