/* サイトAIアシスタント */
.saia-root {
  --saia-accent: #4f6fe0;
  --saia-ink: #1f2430;
  --saia-sub: #6b7280;
  --saia-line: #e6e8ee;
  --saia-bg: #ffffff;
  --saia-soft: #f4f6fb;
  position: fixed;
  right: 16px;
  bottom: var(--saia-bottom-pc, 20px);
  z-index: 99990;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  color: var(--saia-ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}
.saia-root *, .saia-root *::before, .saia-root *::after { box-sizing: border-box; }
/* サイトのテーマがボタンに付ける色・枠・影を打ち消す */
.saia-root button.saia-launcher,
.saia-root button.saia-launcher:hover,
.saia-root button.saia-launcher:focus,
.saia-root button.saia-launcher:active {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 0 0 auto !important;
  min-height: 0 !important;
  width: auto !important;
  height: auto !important;
  color: inherit !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  border-radius: 0 !important;
}
.saia-root button.saia-launcher:focus:not(:focus-visible) { outline: none !important; }
.saia-root button { text-transform: none; letter-spacing: normal; box-shadow: none; min-height: 0; }
.saia-root button.saia-send { background: var(--saia-accent) !important; color: #fff !important; border: 0 !important; border-radius: 12px !important; }
.saia-root button.saia-close { background: rgba(255, 255, 255, .18) !important; color: #fff !important; border: 0 !important; border-radius: 50% !important; padding: 0 !important; }
.saia-root button.saia-example { background: #fff !important; color: var(--saia-accent) !important; border: 1px solid var(--saia-accent) !important; border-radius: 999px !important; }
.saia-root button.saia-example:hover { background: var(--saia-accent) !important; color: #fff !important; }

/* ---- 右下のマスコット ---- */
.saia-launcher {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* 上下にゆっくり揺れる */
.saia-figure {
  position: relative;
  display: block;
  line-height: 0;
  animation: saia-bob 2.6s ease-in-out infinite;
}
@keyframes saia-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
/* 1秒に1回まばたき（まぶたを一瞬だけ重ねる） */
.saia-lid {
  position: absolute;
  border-radius: 50%;
  background: var(--saia-lid, #13253c);
  opacity: 0;
  pointer-events: none;
  animation: saia-blink 1s infinite;
}
.saia-lid::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 30%;
  height: 45%;
  border-bottom: 2px solid var(--saia-lid-line, #45e8ff);
  border-radius: 0 0 50% 50%;
}
.saia-woman .saia-lid::after { border-bottom-width: 1px; }
@keyframes saia-blink {
  0%, 84%, 100% { opacity: 0; }
  88%, 95% { opacity: 1; }
}
.saia-mascot {
  display: block;
  width: auto;
  height: 132px;
  filter: drop-shadow(0 6px 10px rgba(20, 30, 60, .18));
  transition: transform .25s ease;
  transform-origin: 50% 100%;
}
.saia-woman .saia-mascot { height: 190px; }
.saia-launcher:hover .saia-mascot,
.saia-launcher:focus-visible .saia-mascot { transform: translateY(-4px); }
.saia-launcher:focus-visible { outline: 3px solid var(--saia-accent); outline-offset: 4px; border-radius: 12px; }

.saia-bubble {
  position: relative;
  align-self: flex-start;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--saia-bg);
  color: var(--saia-ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(20, 30, 60, .16);
  border: 2px solid var(--saia-accent);
  animation: saia-float 3s ease-in-out infinite;
}
.saia-bubble::after {
  content: "";
  position: absolute;
  right: -9px;
  top: 50%;
  margin-top: -6px;
  border-style: solid;
  border-width: 6px 0 6px 9px;
  border-color: transparent transparent transparent var(--saia-accent);
}
@keyframes saia-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.saia-root.is-open .saia-bubble { visibility: hidden; }

/* ---- チャット画面 ---- */
.saia-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 370px;
  height: min(560px, calc(100vh - 220px));
  min-height: 360px;
  display: flex;
  flex-direction: column;
  background: var(--saia-bg);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(20, 30, 60, .25);
  overflow: hidden;
  animation: saia-in .22s ease-out;
}
.saia-woman .saia-panel { height: min(560px, calc(100vh - 260px)); }
.saia-panel[hidden] { display: none; }
@keyframes saia-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.saia-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--saia-accent);
  color: #fff;
}
.saia-face {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  flex: none;
  border: 2px solid rgba(255, 255, 255, .7);
}
.saia-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.saia-title strong { font-size: 15px; }
.saia-title span { font-size: 11.5px; opacity: .9; }
.saia-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.saia-close:hover { background: rgba(255, 255, 255, .3); }

.saia-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: var(--saia-soft);
  overscroll-behavior: contain;
}
.saia-msg { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; }
.saia-msg-face {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  flex: none;
  border: 1px solid var(--saia-line);
}
.saia-text {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.saia-assistant .saia-text { background: #fff; border: 1px solid var(--saia-line); border-top-left-radius: 4px; }
.saia-user { justify-content: flex-end; }
.saia-user .saia-text { background: var(--saia-accent); color: #fff; border-top-right-radius: 4px; }
.saia-text a { color: var(--saia-accent); text-decoration: underline; word-break: break-all; }
.saia-user .saia-text a { color: #fff; }

.saia-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px 38px; }
.saia-example {
  padding: 6px 12px;
  border: 1px solid var(--saia-accent);
  border-radius: 999px;
  background: #fff;
  color: var(--saia-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}
.saia-example:hover { background: var(--saia-accent); color: #fff; }

.saia-typing .saia-text { display: flex; gap: 4px; padding: 13px 14px; }
.saia-typing .saia-text span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #aab1c2;
  animation: saia-dot 1.2s infinite ease-in-out;
}
.saia-typing .saia-text span:nth-child(2) { animation-delay: .15s; }
.saia-typing .saia-text span:nth-child(3) { animation-delay: .3s; }
@keyframes saia-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.saia-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 6px;
  border-top: 1px solid var(--saia-line);
  background: #fff;
}
.saia-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #cfd4de;
  border-radius: 12px;
  font: inherit;
  font-size: 16px; /* スマホで拡大されないように */
  line-height: 1.5;
  color: var(--saia-ink);
  background: #fff;
}
.saia-input:focus { outline: none; border-color: var(--saia-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--saia-accent) 20%, transparent); }
.saia-send {
  flex: none;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--saia-accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.saia-send:disabled { opacity: .5; cursor: default; }
.saia-note {
  padding: 2px 12px 10px;
  background: #fff;
  font-size: 11px;
  color: var(--saia-sub);
  line-height: 1.5;
}
.saia-note a { color: var(--saia-sub); }

@media (prefers-reduced-motion: reduce) {
  .saia-bubble, .saia-panel, .saia-typing .saia-text span, .saia-figure { animation: none; }
  .saia-lid { animation-duration: 4s; }
}

/* ---- スマホ（縦向き、または横向きで高さの低い画面） ---- */
@media (max-width: 600px), (max-height: 500px) {
  .saia-text { font-size: 16px; }
  .saia-root button.saia-example { min-height: 44px; padding: 10px 14px; }
  .saia-root { right: 10px; bottom: var(--saia-bottom-sp, 16px); }
  .saia-mascot { height: 92px; }
  .saia-woman .saia-mascot { height: 132px; }
  .saia-bubble { font-size: 13px; padding: 6px 11px; }
  .saia-root.is-open { left: 0; right: 0; bottom: 0; }
  .saia-root.is-open .saia-launcher { display: none; }
  .saia-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 88vh;
    height: 88dvh;
    min-height: 0;
    border-radius: 18px 18px 0 0;
  }
  .saia-woman .saia-panel { height: 88vh; height: 88dvh; }
}
