/* Scoped widget styles. Appearance and launcher position remain configurable. */
.sefc-root {
  --sefc-blue: #1769c2;
  --sefc-border: #dce5ef;
  --sefc-avatar-size: 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  position: fixed;
  right: var(--sefc-desktop-x, 20px);
  bottom: var(--sefc-desktop-y, 20px);
  z-index: 99998;
  color: #21364c;
  font-size: 16px;
  line-height: 1.65;
  text-align: left;
  -webkit-text-size-adjust: 100%;
}
.sefc-root.sefc-side-left { right: auto; left: var(--sefc-desktop-x, 20px); }
.sefc-root *, .sefc-root *::before, .sefc-root *::after { box-sizing: border-box; }
.sefc-panel[hidden], .sefc-root [hidden] { display: none !important; }
.sefc-root button, .sefc-root a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.sefc-root button { font-family: inherit; }
.sefc-root :is(button, a):focus-visible { outline: 3px solid var(--sefc-blue); outline-offset: 3px; }
.sefc-launcher-wrap { position: relative; display: inline-block; }
.sefc-launcher {
  display: flex; align-items: center; gap: 10px; min-height: 56px;
  border: 1px solid #ffffff22; border-radius: 30px;
  background: var(--sefc-header-bg, #1769c2); color: var(--sefc-header-text, #fff);
  padding: 14px 50px 14px 20px; box-shadow: 0 6px 22px #14386026;
  font: inherit; font-weight: 700; cursor: pointer;
  transition: filter .16s ease, box-shadow .16s ease;
}
.sefc-launcher:hover, .sefc-compact-launcher:hover { filter: brightness(.94); box-shadow: 0 8px 28px #14386033; }
.sefc-launcher-icon { display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid currentColor; border-radius: 50%; font-size: 16px; }
.sefc-minimize {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid #ffffff66; border-radius: 50%; background: #fff;
  color: var(--sefc-header-bg, #1769c2); font: inherit; font-size: 23px; line-height: 1; cursor: pointer;
}
.sefc-minimize:hover { background: #eef5fd; }
.sefc-root .sefc-minimize:focus-visible { outline-color: #fff; }
.sefc-compact-launcher {
  display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--sefc-header-bg, #1769c2); color: var(--sefc-header-text, #fff);
  box-shadow: 0 6px 22px #14386026; font: inherit; font-size: 27px; font-weight: 700; cursor: pointer;
}
.sefc-panel {
  position: absolute; right: 0; bottom: 72px;
  width: min(420px, calc(100vw - var(--sefc-desktop-x, 20px) - 14px));
  height: min(720px, calc(100vh - var(--sefc-desktop-y, 20px) - 92px));
  height: min(720px, calc(100dvh - var(--sefc-desktop-y, 20px) - 92px));
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--sefc-border); border-radius: 22px;
  background: #f4f6f9; box-shadow: 0 18px 60px #16345229, 0 3px 12px #16345212;
  isolation: isolate;
}
.sefc-side-left .sefc-panel { right: auto; left: 0; }
.sefc-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 0 0 auto;
  background: var(--sefc-header-bg, #1769c2); color: var(--sefc-header-text, #fff);
  padding: 14px 16px 14px 20px; font-size: var(--sefc-header-size, 17px); line-height: 1.45;
}
.sefc-header strong { min-width: 0; font-size: inherit; font-weight: 700; overflow-wrap: anywhere; }
.sefc-header-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.sefc-restore, .sefc-panel-minimize, .sefc-close {
  display: grid; place-items: center; min-height: 40px; border: 0; border-radius: 12px;
  background: transparent; color: var(--sefc-header-text, #fff); font: inherit; cursor: pointer;
}
.sefc-restore { padding: 0 8px; font-size: 12px; white-space: nowrap; }
.sefc-panel-minimize { width: 40px; padding: 0; font-size: 25px; line-height: 1; }
.sefc-close { width: 40px; padding: 0; font-size: 29px; line-height: 1; }
.sefc-root .sefc-header button:focus-visible { outline-color: var(--sefc-header-text, #fff); outline-offset: -3px; }
.sefc-header button:hover { background: #ffffff22; }
.sefc-messages {
  display: flex; flex-direction: column; flex: 1 1 230px; gap: 18px;
  min-height: 84px; overflow: auto; overscroll-behavior: contain;
  padding: 22px 18px; background: #f4f6f9; scrollbar-width: thin; scrollbar-color: #c6d2df transparent;
}
.sefc-message-row { display: flex; flex-shrink: 0; gap: 9px; align-items: flex-start; min-width: 0; }
.sefc-message-row-bot { align-self: flex-start; width: 100%; }
.sefc-bot-icon {
  display: grid; place-items: center; flex: 0 0 var(--sefc-avatar-size); width: var(--sefc-avatar-size); height: var(--sefc-avatar-size);
  border: 1px solid #dce7f3; border-radius: 50%; background: #e9f2fc; font-size: calc(var(--sefc-avatar-size) * .5); line-height: 1;
}
.sefc-bot-icon-ai { font-family: Arial, sans-serif; font-size: calc(var(--sefc-avatar-size) * .35); font-weight: 800; color: var(--sefc-blue); letter-spacing: -.5px; }
.sefc-bot-icon-logo { overflow: hidden; border-radius: 11px; background: #fff; }
.sefc-bot-icon-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sefc-bot-content { min-width: 0; max-width: calc(100% - var(--sefc-avatar-size) - 9px); }
.sefc-message { margin: 0; padding: 13px 16px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--sefc-answer-size, 16px); line-height: 1.75; }
.sefc-message-bot { display: block; max-width: 100%; border: 1px solid #e0e7ef; border-top-left-radius: 5px; background: var(--sefc-answer-bg, #fff); color: var(--sefc-answer-text, #21364c); box-shadow: 0 2px 4px #183b5e04; }
.sefc-message-row-visitor { align-self: flex-end; max-width: 88%; }
.sefc-message-visitor { border-top-right-radius: 5px; background: #e0edff; color: #163f70; }
.sefc-answer-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; min-height: 46px; margin-top: 10px;
  border: 1px solid var(--sefc-answer-cta-bg, #1769c2); border-radius: 13px;
  background: var(--sefc-answer-cta-bg, #1769c2); color: var(--sefc-answer-cta-text, #fff);
  padding: 11px 16px; font: inherit; font-size: var(--sefc-answer-cta-size, 16px); font-weight: 700; line-height: 1.45;
  text-decoration: none; overflow-wrap: anywhere; cursor: pointer;
}
.sefc-answer-cta::after { content: "›"; flex-shrink: 0; font-size: 22px; line-height: 1; }
.sefc-answer-cta:hover { filter: brightness(.94); color: var(--sefc-answer-cta-text, #fff); }
.sefc-question-area { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; max-height: 38%; background: var(--sefc-question-bg, #f4f7fb); border-top: 1px solid var(--sefc-border); }
.sefc-section-title { margin: 14px 18px 0; font-size: 15px; line-height: 1.5; font-weight: 700; color: var(--sefc-question-text, #20466e); }
.sefc-question-hint { margin: 3px 18px 0; color: #5c6c7f; font-size: 13px; line-height: 1.5; }
.sefc-questions { display: grid; gap: 8px; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px 18px 16px; scrollbar-width: thin; }
.sefc-question-button, .sefc-link-button {
  display: block; width: 100%; min-width: 0; min-height: 48px; border: 1px solid #cddbea; border-radius: 13px;
  background: #fff; color: var(--sefc-question-text, #20466e); padding: 12px 15px;
  text-align: left; font: inherit; font-weight: 600; line-height: 1.5; cursor: pointer; text-decoration: none; overflow-wrap: anywhere;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.sefc-question-button { position: relative; padding-right: 36px; font-size: var(--sefc-question-size, 16px); }
.sefc-question-button::after { content: "›"; position: absolute; right: 15px; top: 50%; transform: translateY(-50%); font-size: 23px; color: var(--sefc-blue); }
.sefc-question-button:hover { border-color: var(--sefc-blue); background: #edf4fd; color: var(--sefc-question-text, #20466e); }
.sefc-question-button:disabled { cursor: wait; opacity: .62; }
/* Cap the action shelf so long, user-configured lists cannot hide the chat. */
.sefc-links { flex: 0 0 auto; max-height: 30%; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; border-top: 1px solid var(--sefc-border); background: var(--sefc-action-bg, #fff); padding: 13px 18px 16px; }
.sefc-links p { margin: 0 0 10px; color: var(--sefc-action-text, #3d5671); font-size: var(--sefc-action-title-size, 14px); line-height: 1.5; font-weight: 700; }
.sefc-link-buttons, .sefc-link-buttons.sefc-layout-vertical { display: flex; flex-direction: column; gap: 8px; }
.sefc-link-buttons.sefc-layout-wrap { flex-direction: row; flex-wrap: wrap; }
.sefc-link-buttons.sefc-layout-wrap .sefc-link-button { flex: 1 1 auto; width: auto; max-width: 100%; }
.sefc-link-buttons.sefc-layout-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sefc-link-button { min-height: 46px; border-color: #cbdced; background: var(--sefc-action-button-bg, #f2f7fd); color: var(--sefc-action-button-text, #175aa4); font-size: var(--sefc-action-size, 16px); text-align: center; padding: 10px 12px; }
.sefc-link-button:hover { border-color: var(--sefc-blue); filter: brightness(.97); color: var(--sefc-action-button-text, #175aa4); }
.sefc-link-button.sefc-primary { background: var(--sefc-answer-cta-bg, #1769c2); border-color: var(--sefc-answer-cta-bg, #1769c2); color: var(--sefc-answer-cta-text, #fff); font-weight: 700; }
.sefc-link-button.sefc-primary:hover { filter: brightness(.94); color: var(--sefc-answer-cta-text, #fff); }
.sefc-fade-in { animation: sefcFadeIn .24s ease-out both; }
@keyframes sefcFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
/* Consultation keeps FAQ state intact; its document isolates theme CSS. */
.sefc-consulting {
  position: fixed !important; left: auto !important; right: 16px !important; top: 16px; bottom: 16px !important;
  width: min(1060px, calc(100vw - 32px)); max-height: none;
  height: calc(100vh - 32px); height: calc(100dvh - 32px);
}
.sefc-side-left .sefc-consulting { left: 16px !important; right: auto !important; }
.sefc-consult-frame { display: block; border: 0; width: 100%; flex: 1 1 0; min-height: 0; background: #f4f6f9; }
.sefc-consult-bar { flex: 0 0 auto; padding: 4px 16px; background: #fff; border-bottom: 1px solid var(--sefc-border); }
.sefc-consult-bar button { border: 0; border-radius: 9px; background: transparent; color: #175aa4; padding: 5px 8px; font: inherit; font-size: 14px; min-height: 40px; cursor: pointer; }
.sefc-consult-bar button:hover { background: #eef5fd; }
.sefc-consulting .sefc-header { padding: 8px 16px; }
@media (max-width: 699px), (max-width: 959px) and (max-height: 500px) {
  .sefc-root { right: var(--sefc-mobile-x, 12px); bottom: var(--sefc-mobile-y, 12px); }
  .sefc-root.sefc-side-left { right: auto; left: var(--sefc-mobile-x, 12px); }
  .sefc-panel, .sefc-side-left .sefc-panel, .sefc-consulting, .sefc-side-left .sefc-consulting {
    position: fixed !important; inset: 0 !important; width: 100%; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0;
  }
  .sefc-header { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  .sefc-consulting .sefc-header { padding-top: max(8px, env(safe-area-inset-top)); }
  .sefc-messages { padding: 20px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left)); }
  .sefc-question-area { max-height: 36%; }
  .sefc-links { padding: 13px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
}
@media (prefers-reduced-motion: reduce) {
  .sefc-root *, .sefc-root *::before, .sefc-root *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Use the visible viewport when a mobile keyboard covers part of the page. */
.sefc-consulting { top: calc(var(--sefc-visible-top, 0px) + 16px); bottom: auto !important; height: calc(var(--sefc-visible-height, 100dvh) - 32px); }
@media (max-width: 699px), (max-width: 959px) and (max-height: 500px) {
  .sefc-panel, .sefc-side-left .sefc-panel, .sefc-consulting, .sefc-side-left .sefc-consulting { top: var(--sefc-visible-top, 0px) !important; bottom: auto !important; height: var(--sefc-visible-height, 100dvh); }
}
/* Short FAQ windows use a whole-panel scroll rather than crushing questions. */
@media (max-height: 420px) {
  .sefc-panel:not(.sefc-consulting) { overflow-y: auto; }
  .sefc-panel:not(.sefc-consulting) .sefc-messages { flex: 0 0 100px; min-height: 100px; max-height: 100px; }
  .sefc-panel:not(.sefc-consulting) .sefc-question-area { flex: 0 0 auto; max-height: none; }
  .sefc-panel:not(.sefc-consulting) .sefc-questions { overflow: visible; }
  .sefc-panel:not(.sefc-consulting) .sefc-links { max-height: none; overflow: visible; }
}
