/* ========================================
   KENOUSYS 健保AIチャット
   style.css
======================================== */


/* ========================================
   ROOT / BASE
======================================== */

:root {
  --navy: #12324b;
  --navy-dark: #0d273b;
  --blue: #235f87;
  --gold: #d9aa2b;
  --gold-light: #f4e4ad;
  --bg: #f5f7fa;
  --text: #17334a;
  --muted: #71808d;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;

  width: 100%;
  max-width: 100%;

  overflow-x: hidden;
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Noto Sans JP",
    "Yu Gothic",
    sans-serif;

  color: var(--text);
  background: var(--bg);
}


/* ========================================
   SITE HEADER
======================================== */

.site-header {
  background: var(--white);
  border-top: 6px solid var(--gold);
  box-shadow: 0 2px 14px rgba(18, 50, 75, 0.08);
}

.header-inner {
  max-width: 1200px;
  height: 84px;

  margin: 0 auto;
  padding: 0 30px;

  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 13px;
}

.logo-mark {
  width: 45px;
  height: 45px;

  flex: 0 0 45px;

  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--navy);
  color: var(--gold);

  font-size: 22px;
  font-weight: 800;
}

.site-logo strong {
  display: block;

  font-size: 18px;
  letter-spacing: 0.03em;
}

.site-logo small {
  display: block;

  margin-top: 3px;

  color: var(--muted);

  font-size: 9px;
  letter-spacing: 0.08em;
}

nav {
  display: flex;
  gap: 30px;
}

nav a {
  color: var(--text);

  text-decoration: none;

  font-size: 14px;
  font-weight: 600;
}


/* ========================================
   HERO
======================================== */

.hero {
  min-height: 420px;

  background:
    radial-gradient(
      circle at 80% 40%,
      rgba(217, 170, 43, 0.18),
      transparent 27%
    ),
    linear-gradient(
      125deg,
      var(--navy-dark),
      var(--blue)
    );

  color: white;
}

.hero-inner {
  max-width: 1200px;
  min-height: 420px;

  margin: 0 auto;
  padding: 70px 50px;

  display: flex;
  align-items: center;
}

.hero-label {
  display: inline-block;

  margin-bottom: 15px;

  color: var(--gold-light);

  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.hero h1 {
  margin: 0 0 24px;

  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.35;
  letter-spacing: 0.03em;
}

.hero p {
  margin: 0;

  color: #e5edf3;

  font-size: 17px;
  line-height: 1.9;
}


/* ========================================
   GUIDE
======================================== */

.guide {
  max-width: 1200px;

  margin: 0 auto;
  padding: 70px 30px 130px;
}

.section-title {
  margin-bottom: 30px;
}

.section-title span {
  color: var(--gold);

  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.section-title h2 {
  margin: 5px 0 0;

  font-size: 30px;
}

.cards {
  display: grid;

  grid-template-columns: repeat(3, 1fr);

  gap: 22px;
}

.card {
  min-height: 230px;

  padding: 28px;

  background: white;

  border: 1px solid #e4e9ed;
  border-radius: 16px;

  box-shadow:
    0 8px 28px rgba(18, 50, 75, 0.06);

  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-4px);

  box-shadow:
    0 14px 34px rgba(18, 50, 75, 0.12);
}

.card-icon {
  color: var(--gold);

  font-size: 14px;
  font-weight: 800;
}

.card h3 {
  margin: 17px 0 12px;

  font-size: 20px;
}

.card p {
  min-height: 55px;

  color: var(--muted);

  line-height: 1.8;
  font-size: 14px;
}

.card a {
  color: var(--navy);

  text-decoration: none;

  font-size: 13px;
  font-weight: 700;
}


/* ========================================
   CHAT LAUNCHER
======================================== */

#chatLauncher {
  position: fixed;

  z-index: 9998;

  right: 28px;
  bottom: 28px;

  height: 68px;

  padding: 8px 20px 8px 9px;

  display: flex;
  align-items: center;

  gap: 12px;

  border: none;
  border-radius: 36px;

  background: var(--navy);
  color: white;

  box-shadow:
    0 10px 35px rgba(8, 31, 48, 0.32);

  cursor: pointer;

  transition:
    transform 0.2s,
    box-shadow 0.2s;

  animation:
    launcherEntrance 0.65s ease-out 0.4s both,
    launcherAttention 1.2s ease-in-out 1.4s 2;
}

#chatLauncher:hover {
  transform: translateY(-3px) scale(1.02);

  box-shadow:
    0 14px 40px rgba(8, 31, 48, 0.4);
}

.launcher-icon {
  width: 50px;
  height: 50px;

  flex: 0 0 50px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: var(--gold);
  color: white;

  font-size: 17px;
  font-weight: 800;
}

.launcher-text {
  text-align: left;
}

.launcher-text strong {
  display: block;

  font-size: 14px;
}

.launcher-text small {
  display: block;

  margin-top: 2px;

  color: #d8e3eb;

  font-size: 10px;
}


/* ========================================
   CHAT LAUNCHER ANIMATION
======================================== */

@keyframes launcherEntrance {

  0% {
    opacity: 0;

    transform:
      translateY(30px)
      scale(0.85);
  }

  70% {
    opacity: 1;

    transform:
      translateY(-4px)
      scale(1.03);
  }

  100% {
    opacity: 1;

    transform:
      translateY(0)
      scale(1);
  }
}

@keyframes launcherAttention {

  0%,
  100% {
    transform: scale(1);

    box-shadow:
      0 10px 35px rgba(8, 31, 48, 0.32);
  }

  50% {
    transform: scale(1.07);

    box-shadow:
      0 14px 45px rgba(217, 170, 43, 0.48);
  }
}


/* ========================================
   CHAT WINDOW
======================================== */

.chat-window {
  position: fixed;

  z-index: 9999;

  right: 28px;
  bottom: 28px;

  width: 400px;

  height:
    min(
      650px,
      calc(100vh - 55px)
    );

  display: flex;
  flex-direction: column;

  background: white;

  border-radius: 20px;

  overflow: hidden;

  box-shadow:
    0 25px 70px rgba(7, 29, 45, 0.28);

  opacity: 0;
  visibility: hidden;

  transform:
    translateY(25px)
    scale(0.96);

  transform-origin: bottom right;

  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0.22s;
}

.chat-window.open {
  opacity: 1;
  visibility: visible;

  transform:
    translateY(0)
    scale(1);
}


/* ========================================
   CHAT HEADER
======================================== */

.chat-header {
  min-height: 82px;

  padding: 16px 18px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  background:
    linear-gradient(
      135deg,
      var(--navy-dark),
      var(--navy)
    );

  color: white;
}

.chat-brand {
  min-width: 0;

  display: flex;
  align-items: center;

  gap: 12px;
}

.chat-logo {
  width: 47px;
  height: 47px;

  flex: 0 0 47px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: var(--gold);
  color: white;

  font-size: 15px;
  font-weight: 800;
}

.chat-brand strong {
  display: block;

  font-size: 16px;
}

.chat-brand span {
  display: flex;
  align-items: center;

  gap: 6px;

  margin-top: 4px;

  color: #cddbe4;

  font-size: 11px;
}

.chat-brand i {
  width: 7px;
  height: 7px;

  flex: 0 0 7px;

  border-radius: 50%;

  background: #56d38b;

  box-shadow:
    0 0 0 3px rgba(86, 211, 139, 0.14);
}


/* ========================================
   CHAT WINDOW CONTROLS
======================================== */

.chat-window-controls {
  display: flex;
  align-items: center;

  gap: 7px;
}

.window-button,
.close-button {
  width: 38px;
  height: 38px;

  flex: 0 0 38px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 50%;

  background:
    rgba(255, 255, 255, 0.08);

  color: white;

  cursor: pointer;

  transition:
    background 0.15s,
    transform 0.15s;
}

.window-button {
  font-size: 19px;
}

.close-button {
  font-size: 25px;
  line-height: 1;
}

.window-button:hover,
.close-button:hover {
  background:
    rgba(255, 255, 255, 0.16);

  transform: scale(1.05);
}


/* ========================================
   CHAT MESSAGES
======================================== */

.chat-messages {
  flex: 1;

  min-width: 0;
  min-height: 0;

  overflow-x: hidden;
  overflow-y: auto;

  padding: 22px 18px;

  background:
    linear-gradient(
      180deg,
      #f5f8fa,
      #f8fafb
    );

  -webkit-overflow-scrolling: touch;
}

.bot-row {
  width: 100%;

  min-width: 0;

  display: flex;
  align-items: flex-start;

  gap: 9px;
}

.bot-avatar {
  width: 34px;
  height: 34px;

  flex: 0 0 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: var(--navy);
  color: var(--gold);

  font-size: 11px;
  font-weight: 800;
}

.bot-message {
  min-width: 0;
  max-width: 82%;

  padding: 14px 15px;

  background: white;

  border-radius:
    5px 15px 15px 15px;

  box-shadow:
    0 3px 12px rgba(18, 50, 75, 0.07);

  color: #334e61;

  font-size: 13px;
  line-height: 1.7;

  overflow-wrap: anywhere;
  word-break: break-word;
}

.bot-message p {
  margin: 0 0 8px;
}

.bot-message p:last-child {
  margin-bottom: 0;
}

.bot-message .bot-name {
  margin-bottom: 6px;

  color: var(--navy);

  font-size: 11px;
  font-weight: 800;
}


/* ========================================
   QUICK ACTIONS
======================================== */

.quick-actions {
  margin: 16px 0 0 43px;

  display: flex;
  flex-direction: column;

  gap: 8px;
}

.quick-actions button {
  width: fit-content;
  max-width: 100%;

  padding: 10px 15px;

  border: 1px solid #dfbd61;
  border-radius: 20px;

  background: white;
  color: var(--navy);

  font-size: 12px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.15s;
}

.quick-actions button:hover {
  background: #fff9e9;
}


/* ========================================
   USER MESSAGE
======================================== */

.user-row {
  width: 100%;

  min-width: 0;

  display: flex;
  justify-content: flex-end;

  margin-top: 17px;
}

.user-message {
  min-width: 0;
  max-width: 80%;

  padding: 12px 15px;

  border-radius:
    15px 5px 15px 15px;

  background: var(--navy);
  color: white;

  font-size: 13px;
  line-height: 1.65;

  overflow-wrap: anywhere;
  word-break: break-word;
}


/* ========================================
   TYPING
======================================== */

.typing {
  height: 20px;

  display: flex;
  align-items: center;

  gap: 4px;
}

.typing span {
  width: 6px;
  height: 6px;

  background: #94a5b0;

  border-radius: 50%;

  animation:
    typing 1.2s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-4px);
  }
}


/* ========================================
   CAUTION
======================================== */

.chat-caution {
  padding: 7px 15px;

  border-top:
    1px solid #edf0f2;

  background: #fafbfc;

  color: #8a969f;

  text-align: center;

  font-size: 9px;
}


/* ========================================
   INPUT AREA
======================================== */

.chat-input-area {
  min-width: 0;
  min-height: 69px;

  display: flex;
  align-items: flex-end;

  gap: 8px;

  padding: 11px 13px;

  border-top:
    1px solid #edf0f2;

  background: white;
}

#messageInput {
  width: auto;

  min-width: 0;
  min-height: 44px;

  max-width: 100%;
  max-height: 100px;

  flex: 1 1 auto;

  padding: 12px 15px;

  resize: none;

  border:
    1px solid #dce2e6;

  border-radius: 22px;

  outline: none;

  font: inherit;
  font-size: 13px;

  overflow-y: hidden;

  scrollbar-width: none;
}

#messageInput::-webkit-scrollbar {
  display: none;
}

#messageInput:focus {
  border-color: var(--gold);
}

#sendButton {
  width: 44px;
  height: 44px;

  flex: 0 0 44px;

  border: none;
  border-radius: 50%;

  background: var(--gold);
  color: white;

  font-size: 17px;

  cursor: pointer;
}


/* ========================================
   CHAT FOOTER
======================================== */

.chat-footer {
  padding: 7px;

  background: white;

  color: #a0aab1;

  text-align: center;

  font-size: 8px;
}


/* ========================================
   CHAT SIZE - STANDARD
======================================== */

.chat-window.size-standard {
  width: 400px;

  height:
    min(
      650px,
      calc(100vh - 55px)
    );
}


/* ========================================
   CHAT SIZE - LARGE
======================================== */

.chat-window.size-large {
  width:
    min(
      800px,
      calc(100vw - 56px)
    );

  height:
    min(
      850px,
      calc(100vh - 56px)
    );
}

.chat-window.size-large .chat-messages {
  padding-left: 28px;
  padding-right: 28px;
}

.chat-window.size-large .bot-message {
  max-width: 75%;
}

.chat-window.size-large .user-message {
  max-width: 70%;
}


/* ========================================
   CHAT SIZE - FULLSCREEN
======================================== */

.chat-window.size-fullscreen {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  width: 100vw;
  height: 100dvh;

  max-width: none;
  max-height: none;

  border-radius: 0;

  transform-origin: center;
}

.chat-window.size-fullscreen .chat-messages {
  padding-left:
    max(
      30px,
      calc((100vw - 1000px) / 2)
    );

  padding-right:
    max(
      30px,
      calc((100vw - 1000px) / 2)
    );
}

.chat-window.size-fullscreen .chat-input-area {
  padding-left:
    max(
      30px,
      calc((100vw - 1000px) / 2)
    );

  padding-right:
    max(
      30px,
      calc((100vw - 1000px) / 2)
    );
}

.chat-window.size-fullscreen .chat-caution {
  padding-left:
    max(
      30px,
      calc((100vw - 1000px) / 2)
    );

  padding-right:
    max(
      30px,
      calc((100vw - 1000px) / 2)
    );
}


/* ========================================
   TABLET / SMARTPHONE
======================================== */

@media (max-width: 700px) {

  /* ----------------------------------------
     SITE
  ----------------------------------------- */

  .header-inner {
    height: 70px;

    padding: 0 18px;
  }

  nav {
    display: none;
  }

  .site-logo {
    min-width: 0;
  }

  .site-logo strong {
    font-size: 15px;
  }

  .site-logo small {
    font-size: 8px;
  }

  .hero {
    min-height: 350px;
  }

  .hero-inner {
    min-height: 350px;

    padding: 55px 25px;
  }

  .hero h1 {
    font-size: 37px;
  }

  .hero p br {
    display: none;
  }

  .guide {
    padding:
      70px 30px
      130px;
  }

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


  /* ----------------------------------------
     CHAT LAUNCHER
  ----------------------------------------- */

  #chatLauncher {
    right: 16px;
    bottom:
      calc(
        18px + env(safe-area-inset-bottom)
      );

    height: 62px;

    max-width:
      calc(100vw - 32px);

    padding:
      8px 17px 8px 9px;
  }

  .launcher-icon {
    width: 46px;
    height: 46px;

    flex: 0 0 46px;
  }


  /* ----------------------------------------
     CHAT WINDOW
     iPhone / Safari 横幅拡大防止
  ----------------------------------------- */

  .chat-window,
  .chat-window.size-standard,
  .chat-window.size-large,
  .chat-window.size-fullscreen {
    position: fixed;

    top: 0;
    left: 0;
    right: auto;
    bottom: 0;

    width: 100%;
    max-width: 100%;

    height: 100dvh;
    max-height: 100dvh;

    margin: 0;

    border-radius: 0;

    overflow: hidden;

    transform-origin: center;
  }

  .chat-window.open {
    transform:
      translateY(0)
      scale(1);
  }


  /* スマホではサイズ変更ボタンを非表示 */

  #resizeChat {
    display: none;
  }


  /* ----------------------------------------
     CHAT HEADER
  ----------------------------------------- */

  .chat-header {
    width: 100%;

    min-width: 0;
    min-height: 74px;

    padding: 12px 16px;

    flex: 0 0 auto;
  }

  .chat-brand {
    min-width: 0;
  }

  .chat-logo {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    font-size: 13px;
  }

  .chat-brand strong {
    font-size: 15px;
  }

  .chat-brand span {
    font-size: 10px;
  }

  .chat-window-controls {
    flex: 0 0 auto;
  }

  .close-button {
    width: 36px;
    height: 36px;

    flex: 0 0 36px;

    font-size: 22px;
  }


  /* ----------------------------------------
     CHAT MESSAGES
  ----------------------------------------- */

  .chat-messages {
    width: 100%;
    max-width: 100%;

    min-width: 0;
    min-height: 0;

    padding: 18px 14px;

    flex: 1 1 auto;

    overflow-x: hidden;
    overflow-y: auto;

    -webkit-overflow-scrolling: touch;
  }

  .bot-row {
    width: 100%;
    max-width: 100%;

    min-width: 0;
  }

  .bot-avatar {
    width: 32px;
    height: 32px;

    flex: 0 0 32px;
  }

  .bot-message,
  .chat-window.size-large .bot-message {
    min-width: 0;

    max-width:
      calc(100% - 42px);

    padding: 13px 14px;

    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .user-row {
    width: 100%;

    min-width: 0;
  }

  .user-message,
  .chat-window.size-large .user-message {
    min-width: 0;

    max-width: 85%;

    overflow-wrap: anywhere;
    word-break: break-word;
  }


  /* ----------------------------------------
     QUICK ACTIONS
  ----------------------------------------- */

  .quick-actions {
    margin:
      16px 0
      0 41px;
  }

  .quick-actions button {
    max-width:
      calc(100vw - 70px);

    padding: 10px 14px;

    font-size: 12px;

    white-space: normal;
  }


  /* ----------------------------------------
     CAUTION
  ----------------------------------------- */

  .chat-caution,
  .chat-window.size-fullscreen .chat-caution {
    width: 100%;

    flex: 0 0 auto;

    padding: 6px 10px;

    font-size: 9px;
  }


  /* ----------------------------------------
     INPUT AREA
  ----------------------------------------- */

  .chat-input-area,
  .chat-window.size-fullscreen .chat-input-area {
    width: 100%;
    max-width: 100%;

    min-width: 0;
    min-height: 66px;

    flex: 0 0 auto;

    align-items: center;

    padding:
      10px 12px
      calc(
        10px + env(safe-area-inset-bottom)
      );

    gap: 8px;
  }

  #messageInput {
    width: auto;

    min-width: 0;
    min-height: 46px;

    height: 46px;

    max-width: 100%;
    max-height: 90px;

    flex: 1 1 0;

    padding: 12px 16px;

    /*
      iPhone Safari:
      16px未満だとフォーカス時に
      自動ズームする場合がある
    */
    font-size: 16px;

    overflow-y: hidden;
  }

  #sendButton {
    width: 46px;
    height: 46px;

    flex: 0 0 46px;
  }


  /* ----------------------------------------
     FOOTER
  ----------------------------------------- */

  .chat-footer {
    width: 100%;

    flex: 0 0 auto;

    padding: 6px;

    font-size: 8px;
  }


  /* ----------------------------------------
     FULLSCREEN PADDING RESET
     PC用1000px中央寄せをスマホでは解除
  ----------------------------------------- */

  .chat-window.size-fullscreen .chat-messages {
    padding: 18px 14px;
  }

}


/* ========================================
   VERY SMALL SMARTPHONE
======================================== */

@media (max-width: 390px) {

  .site-logo strong {
    font-size: 14px;
  }

  .site-logo small {
    font-size: 7px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .chat-header {
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-messages {
    padding-left: 12px;
    padding-right: 12px;
  }

  .quick-actions {
    margin-left: 39px;
  }

  .launcher-text strong {
    font-size: 13px;
  }

  .launcher-text small {
    font-size: 9px;
  }

}


/* ========================================
   REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {

  #chatLauncher {
    animation: none;
  }

  .chat-window {
    transition: none;
  }

  .typing span {
    animation: none;
  }

}

/* ========================================
   AI ANSWER / MARKDOWN
======================================== */

.bot-answer {
  font-size: var(--chat-text-size);
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bot-answer strong {
  font-weight: 700;
  color: #1d344d;
}

.bot-answer h2,
.bot-answer h3,
.bot-answer h4 {
  color: #1d344d;
  font-weight: 700;
  line-height: 1.4;
  margin: 10px 0 4px;
}

.bot-answer h2 { font-size: 1.15em; }
.bot-answer h3 { font-size: 1.08em; }
.bot-answer h4 { font-size: 1.03em; }

.bot-answer h2:first-child,
.bot-answer h3:first-child,
.bot-answer h4:first-child {
  margin-top: 0;
}

.bot-answer a {
  color: #245b8f;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.bot-answer a:hover {
  text-decoration-thickness: 2px;
}

.bot-answer .md-paragraph-space {
  height: 5px;
}

.bot-answer .md-list-item,
.bot-answer .md-number-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 3px 0;
  line-height: 1.65;
}

.bot-answer .md-list-item > span,
.bot-answer .md-number-item > span {
  flex: 0 0 auto;
  color: var(--navy);
  font-weight: 700;
}

.bot-answer .md-list-item + br,
.bot-answer .md-number-item + br {
  display: none;
}

.bot-answer .md-list-item + .md-list-item,
.bot-answer .md-number-item + .md-number-item,
.bot-answer .md-list-item + .md-number-item,
.bot-answer .md-number-item + .md-list-item {
  margin-top: 5px;
}


/* ========================================
   FULLSCREEN ANSWER WIDTH
======================================== */

.chat-window.size-fullscreen .chat-messages {
  padding-left: 3%;
  padding-right: 3%;
}

.chat-window.size-fullscreen .bot-row {
  width: 100%;
  max-width: none;
}

.chat-window.size-fullscreen .bot-message {
  width: calc(100% - 58px);
  max-width: none;
}

.chat-window.size-fullscreen .user-row {
  width: 100%;
}

.chat-window.size-fullscreen .user-message {
  max-width: 65%;
}


/* ========================================
   CHAT FONT SIZE
   PC     : 14px -> 20px -> 24px
   Mobile : 14px -> 18px -> 22px
======================================== */

.chat-window {
  --chat-text-size: 14px;
}

.chat-window.font-small  { --chat-text-size: 14px; }
.chat-window.font-medium { --chat-text-size: 20px; }
.chat-window.font-large  { --chat-text-size: 24px; }

/* Apply the same size to initial message, streamed answer and user message. */
.chat-window .bot-message,
.chat-window .bot-answer,
.chat-window .user-message,
.chat-window .quick-actions button {
  font-size: var(--chat-text-size) !important;
}

.chat-window .bot-message .bot-name {
  font-size: 0.82em !important;
}

.chat-window .chat-caution {
  font-size: calc(var(--chat-text-size) * 0.82) !important;
}

.chat-window .chat-input textarea {
  font-size: var(--chat-text-size);
}

.chat-window .chat-notice,
.chat-window .stream-error {
  font-size: var(--chat-text-size);
}


/* ========================================
   FONT SIZE TOGGLE BUTTON
======================================== */

.chat-font-controls {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  margin-right: 8px;
}

.font-size-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.font-size-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
}

.font-size-toggle:active {
  transform: scale(0.95);
}


/* ========================================
   SMARTPHONE PORTRAIT / NARROW VIEW
======================================== */

@media (max-width: 700px) {

  .chat-window.font-small  { --chat-text-size: 14px; }
  .chat-window.font-medium { --chat-text-size: 18px; }
  .chat-window.font-large  { --chat-text-size: 22px; }

  .chat-window.font-small .chat-input textarea  { font-size: 16px; }
  .chat-window.font-medium .chat-input textarea { font-size: 18px; }
  .chat-window.font-large .chat-input textarea  { font-size: 22px; }

  .chat-font-controls {
    margin-left: auto;
    margin-right: 5px;
  }

  .font-size-toggle {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .bot-answer a {
    word-break: break-all;
  }

  .bot-answer .md-paragraph-space {
    height: 2px;
  }

  .bot-answer .md-list-item,
  .bot-answer .md-number-item {
    margin-top: 2px;
    margin-bottom: 2px;
    line-height: 1.6;
  }
}


/* ========================================
   SMARTPHONE LANDSCAPE
   Keep mobile font sizes even when width exceeds 700px.
======================================== */

@media (orientation: landscape) and (pointer: coarse) { 

  .chat-window.font-small  { --chat-text-size: 14px; }
  .chat-window.font-medium { --chat-text-size: 18px; }
  .chat-window.font-large  { --chat-text-size: 22px; }

  /* Explicitly apply the variable to the whole answer bubble.
     Descendants inherit it; headings keep their relative em sizing. */
  .chat-window .bot-message,
  .chat-window .bot-answer,
  .chat-window .user-message,
  .chat-window .quick-actions button {
    font-size: var(--chat-text-size) !important;
  }

  .chat-window.font-small .chat-input textarea  { font-size: 16px; }
  .chat-window.font-medium .chat-input textarea { font-size: 18px; }
  .chat-window.font-large .chat-input textarea  { font-size: 22px; }
}

/* ========================================
   CHAT LAUNCHER - PC HOVER ANIMATION
========================================= */

@media (hover: hover) and (pointer: fine) {

  #chatLauncher {
    transition:
      transform 0.25s ease,
      box-shadow 0.25s ease;
  }

  #chatLauncher:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow:
      0 12px 28px rgba(0, 0, 0, 0.22);
  }

  #chatLauncher .launcher-icon {
    transition:
      transform 0.3s ease,
      box-shadow 0.3s ease;
  }

  #chatLauncher:hover .launcher-icon {
    animation: launcherIconBounce 0.55s ease;
    box-shadow:
      0 0 0 5px rgba(232, 178, 35, 0.16);
  }

  @keyframes launcherIconBounce {

    0% {
      transform: scale(1);
    }

    35% {
      transform: scale(1.14) rotate(-5deg);
    }

    65% {
      transform: scale(0.96) rotate(3deg);
    }

    100% {
      transform: scale(1) rotate(0deg);
    }

  }

}