/*
 * SUMUIE Chatbot - Production final
 * Namespaced with .sumuie-chat- to avoid collisions with the LP.
 */
:root {
  --sumuie-chat-blue: #0674c8;
  --sumuie-chat-blue-dark: #0c3d73;
  --sumuie-chat-blue-soft: #eaf6ff;
  --sumuie-chat-red: #e60012;
  --sumuie-chat-red-dark: #c60010;
  --sumuie-chat-text: #14263e;
  --sumuie-chat-muted: #667489;
  --sumuie-chat-border: #d8e6f2;
  --sumuie-chat-bg: #ffffff;
  --sumuie-chat-shadow: 0 18px 50px rgba(20, 52, 90, 0.20);
  --sumuie-chat-radius: 20px;
  --sumuie-chat-mobile-bottom: 136px;
  --sumuie-chat-desktop-bottom: 24px;
  --sumuie-chat-z: 2147482000;
}

.sumuie-chat-root,
.sumuie-chat-root * {
  box-sizing: border-box;
}

.sumuie-chat-root {
  position: fixed;
  inset: 0;
  z-index: var(--sumuie-chat-z);
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--sumuie-chat-text);
}

.sumuie-chat-launcher-wrap {
  position: fixed;
  right: 18px;
  bottom: var(--sumuie-chat-desktop-bottom);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
  transform: translateY(16px) scale(.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

.sumuie-chat-launcher-wrap.is-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

.sumuie-chat-teaser {
  max-width: 235px;
  background: #fff;
  border: 1px solid var(--sumuie-chat-border);
  box-shadow: 0 10px 28px rgba(20, 52, 90, .16);
  border-radius: 16px 16px 4px 16px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 700;
  color: var(--sumuie-chat-blue-dark);
  position: relative;
}

.sumuie-chat-teaser small {
  display: block;
  color: var(--sumuie-chat-muted);
  font-weight: 500;
  margin-top: 2px;
}

.sumuie-chat-teaser-close {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--sumuie-chat-border);
  background: #fff;
  color: #64748b;
  font-size: 15px;
  line-height: 20px;
  cursor: pointer;
  padding: 0;
}

.sumuie-chat-launcher {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid #fff;
  padding: 0;
  background: #fff;
  box-shadow: 0 10px 28px rgba(11, 61, 115, .28);
  overflow: visible;
  cursor: pointer;
  position: relative;
}

.sumuie-chat-launcher img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
}

.sumuie-chat-online {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1bb76e;
  border: 3px solid #fff;
}

.sumuie-chat-launcher-label {
  position: absolute;
  right: 58px;
  bottom: -2px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--sumuie-chat-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 92, 164, .25);
}


@media (min-width: 768px) {
  /* v5: PCではラベルを顔アイコン下へ分離し、左の吹き出しと重ならない配置にする */
  .sumuie-chat-launcher-wrap {
    bottom: calc(var(--sumuie-chat-desktop-bottom) + 28px);
  }
  .sumuie-chat-launcher-label {
    right: 50%;
    bottom: -30px;
    transform: translateX(50%);
    min-width: 140px;
    text-align: center;
  }
}

.sumuie-chat-panel {
  position: fixed;
  right: 18px;
  bottom: calc(var(--sumuie-chat-desktop-bottom) + 80px);
  width: min(400px, calc(100vw - 36px));
  max-height: min(720px, calc(100dvh - 130px));
  background: var(--sumuie-chat-bg);
  border: 1px solid var(--sumuie-chat-border);
  border-radius: var(--sumuie-chat-radius);
  box-shadow: var(--sumuie-chat-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(14px) scale(.985);
  visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.sumuie-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.sumuie-chat-header {
  min-height: 74px;
  padding: 11px 46px 11px 12px;
  background: linear-gradient(135deg, #087ccf 0%, #0563ad 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.sumuie-chat-header-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  flex: 0 0 auto;
  background: #fff;
}

.sumuie-chat-header-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: .01em;
}

.sumuie-chat-header-sub {
  margin-top: 3px;
  font-size: 11px;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sumuie-chat-header-sub::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #53e59f;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,.2);
}

.sumuie-chat-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 23px;
  line-height: 30px;
  cursor: pointer;
  padding: 0;
}

.sumuie-chat-progress {
  height: 4px;
  background: #e7eef5;
  overflow: hidden;
}

.sumuie-chat-progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #ffd74d, #ffb900);
  transition: width .3s ease;
}

.sumuie-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px 8px;
  background: linear-gradient(#f8fcff, #fff 72%);
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.sumuie-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 12px;
}

.sumuie-chat-row.is-user {
  justify-content: flex-end;
}

.sumuie-chat-msg-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  border: 1px solid #dbe7f1;
  background: #fff;
  object-fit: cover;
}

.sumuie-chat-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px 16px 16px 4px;
  background: #fff;
  border: 1px solid var(--sumuie-chat-border);
  box-shadow: 0 5px 14px rgba(20, 52, 90, .06);
  font-size: 13px;
  line-height: 1.62;
  word-break: break-word;
}

.sumuie-chat-row.is-user .sumuie-chat-bubble {
  border-radius: 16px 16px 4px 16px;
  background: var(--sumuie-chat-blue);
  border-color: var(--sumuie-chat-blue);
  color: #fff;
}

.sumuie-chat-bubble strong {
  color: var(--sumuie-chat-blue-dark);
}

.sumuie-chat-row.is-user .sumuie-chat-bubble strong {
  color: #fff;
}

.sumuie-chat-actions {
  flex: 0 0 auto;
  padding: 10px 12px 12px;
  border-top: 1px solid #e8eef5;
  background: #fff;
  max-height: 43dvh;
  overflow-y: auto;
}

.sumuie-chat-question {
  font-size: 12px;
  color: var(--sumuie-chat-muted);
  font-weight: 700;
  margin: 0 0 8px;
}

.sumuie-chat-btn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.sumuie-chat-choice,
.sumuie-chat-primary,
.sumuie-chat-secondary,
.sumuie-chat-back,
.sumuie-chat-submit {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

.sumuie-chat-choice {
  border: 1px solid #cfe0ee;
  background: #fff;
  color: var(--sumuie-chat-blue-dark);
  text-align: left;
  padding: 10px 12px;
}

.sumuie-chat-choice:hover,
.sumuie-chat-choice:focus-visible {
  border-color: var(--sumuie-chat-blue);
  background: #f4faff;
  outline: none;
}

.sumuie-chat-choice.is-selected {
  border-color: var(--sumuie-chat-blue);
  background: var(--sumuie-chat-blue-soft);
  box-shadow: inset 0 0 0 1px var(--sumuie-chat-blue);
}

.sumuie-chat-primary,
.sumuie-chat-submit {
  border: 0;
  background: linear-gradient(180deg, #f32637, var(--sumuie-chat-red));
  color: #fff;
  box-shadow: 0 7px 16px rgba(230,0,18,.2);
  padding: 10px 14px;
}

.sumuie-chat-primary:hover,
.sumuie-chat-submit:hover {
  background: linear-gradient(180deg, #eb1a2c, var(--sumuie-chat-red-dark));
}

.sumuie-chat-secondary {
  border: 1px solid #bdd6e9;
  background: #eff8ff;
  color: var(--sumuie-chat-blue-dark);
  padding: 10px 14px;
}

.sumuie-chat-back {
  border: 0;
  background: transparent;
  color: #6b7b8f;
  min-height: 34px;
  padding: 4px;
  font-weight: 600;
}

.sumuie-chat-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.sumuie-chat-multi-note {
  margin: -1px 0 8px;
  color: var(--sumuie-chat-muted);
  font-size: 11px;
}

.sumuie-chat-form {
  display: grid;
  gap: 10px;
}

.sumuie-chat-field {
  display: grid;
  gap: 5px;
}

.sumuie-chat-field label {
  font-size: 11px;
  font-weight: 800;
  color: var(--sumuie-chat-blue-dark);
}

.sumuie-chat-required {
  color: var(--sumuie-chat-red);
  font-size: 10px;
  margin-left: 4px;
}

.sumuie-chat-input,
.sumuie-chat-select,
.sumuie-chat-textarea {
  width: 100%;
  border: 1px solid #cad9e7;
  border-radius: 10px;
  background: #fff;
  color: var(--sumuie-chat-text);
  font: inherit;
  font-size: 14px;
  padding: 10px 11px;
  outline: none;
}

.sumuie-chat-input:focus,
.sumuie-chat-select:focus,
.sumuie-chat-textarea:focus {
  border-color: var(--sumuie-chat-blue);
  box-shadow: 0 0 0 3px rgba(6,116,200,.10);
}

.sumuie-chat-textarea {
  min-height: 70px;
  resize: vertical;
}

.sumuie-chat-radio-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sumuie-chat-radio-row label {
  border: 1px solid #d1deea;
  border-radius: 10px;
  padding: 8px 5px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: #42566d;
}

.sumuie-chat-radio-row input {
  margin-right: 4px;
}

.sumuie-chat-privacy {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: #596b80;
  font-size: 10px;
  line-height: 1.45;
}

.sumuie-chat-privacy input {
  margin-top: 2px;
  flex: 0 0 auto;
}

.sumuie-chat-privacy a {
  color: var(--sumuie-chat-blue);
}

.sumuie-chat-error {
  color: #b42318;
  background: #fff0f0;
  border: 1px solid #ffd0d0;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.45;
  display: none;
}

.sumuie-chat-error.is-visible {
  display: block;
}

.sumuie-chat-summary {
  background: #f4f9fd;
  border: 1px solid #d8e8f4;
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 11px;
  line-height: 1.6;
  color: #40546b;
}

.sumuie-chat-summary b {
  color: var(--sumuie-chat-blue-dark);
}

.sumuie-chat-complete {
  text-align: center;
  padding: 8px 4px 4px;
}

.sumuie-chat-complete-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  margin: 0 auto 10px;
  background: #e8f8f0;
  color: #0b9255;
  font-size: 34px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.sumuie-chat-phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  color: var(--sumuie-chat-blue-dark);
  text-decoration: none;
  font-size: 17px;
  margin-top: 8px;
}

.sumuie-chat-footer-note {
  font-size: 9px;
  color: #8592a2;
  text-align: center;
  margin-top: 8px;
}

.sumuie-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 52px;
}
.sumuie-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9cb3c7;
  animation: sumuieTyping 1.2s infinite ease-in-out;
}
.sumuie-chat-typing span:nth-child(2){ animation-delay:.16s; }
.sumuie-chat-typing span:nth-child(3){ animation-delay:.32s; }
@keyframes sumuieTyping {
  0%, 70%, 100% { transform: translateY(0); opacity:.45; }
  35% { transform: translateY(-4px); opacity:1; }
}

@media (max-width: 767px) {
  .sumuie-chat-launcher-wrap {
    right: 10px;
    bottom: calc(var(--sumuie-chat-mobile-bottom) + env(safe-area-inset-bottom, 0px));
  }

  .sumuie-chat-launcher {
    width: 58px;
    height: 58px;
  }

  .sumuie-chat-launcher-label {
    display: none;
  }

  .sumuie-chat-teaser {
    max-width: min(210px, calc(100vw - 92px));
    font-size: 12px;
    padding: 9px 11px;
  }

  .sumuie-chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: calc(var(--sumuie-chat-mobile-bottom) + env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - var(--sumuie-chat-mobile-bottom) - 18px - env(safe-area-inset-top, 0px));
    border-radius: 18px;
  }

  .sumuie-chat-header {
    min-height: 66px;
    padding: 9px 44px 9px 10px;
  }

  .sumuie-chat-header-avatar {
    width: 44px;
    height: 44px;
  }

  .sumuie-chat-bubble {
    font-size: 12px;
    max-width: 84%;
  }

  .sumuie-chat-actions {
    padding: 9px 10px 10px;
    max-height: 40dvh;
  }

  .sumuie-chat-choice,
  .sumuie-chat-primary,
  .sumuie-chat-secondary,
  .sumuie-chat-submit {
    min-height: 42px;
    font-size: 12px;
  }

  .sumuie-chat-radio-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  :root { --sumuie-chat-mobile-bottom: 130px; }
  .sumuie-chat-panel { right: 6px; left: 6px; }
  .sumuie-chat-teaser { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sumuie-chat-launcher-wrap,
  .sumuie-chat-panel,
  .sumuie-chat-progress > span,
  .sumuie-chat-typing span {
    transition: none !important;
    animation: none !important;
  }
}

/* v1.1 usability refinements */
.sumuie-chat-header-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.sumuie-chat-header-title {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sumuie-chat-speedbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: #d8e7f4;
  border-bottom: 1px solid #d8e7f4;
}

.sumuie-chat-speedbar span {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f4faff;
  color: var(--sumuie-chat-blue-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .01em;
}

.sumuie-chat-speedbar b {
  color: var(--sumuie-chat-red);
  font-size: 18px;
  line-height: 1;
}

.sumuie-chat-msg-person {
  flex: 0 0 42px;
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sumuie-chat-msg-person .sumuie-chat-msg-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

.sumuie-chat-msg-name {
  width: 42px;
  color: #52677e;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.sumuie-chat-inline-usp {
  display: inline-flex;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff5d8;
  color: #9a5700;
  font-size: 11px;
  font-weight: 800;
}

.sumuie-chat-auto-next {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f9fd;
  color: #65758a;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.sumuie-chat-input-hint {
  color: #7b8b9d;
  font-size: 10px;
  line-height: 1.4;
}

@media (max-width: 767px) {
  .sumuie-chat-launcher-label {
    display: block;
    right: 0;
    bottom: 63px;
    max-width: 148px;
    padding: 5px 8px;
    font-size: 9px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }

  .sumuie-chat-speedbar span {
    min-height: 34px;
    font-size: 10px;
  }

  .sumuie-chat-speedbar b {
    font-size: 16px;
  }

  .sumuie-chat-header-title {
    font-size: 12px;
  }

  .sumuie-chat-header-sub {
    font-size: 9px;
  }

  .sumuie-chat-msg-person {
    flex-basis: 40px;
    width: 40px;
  }

  .sumuie-chat-msg-name {
    width: 40px;
    font-size: 7px;
  }
}


.sumuie-chat-privacy-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}

.sumuie-chat-privacy-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sumuie-chat-privacy-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 29, 51, .58);
  backdrop-filter: blur(2px);
}

.sumuie-chat-privacy-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 32px));
  max-height: min(82dvh, 780px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  overflow: hidden;
}

.sumuie-chat-privacy-header {
  position: relative;
  flex: 0 0 auto;
  padding: 16px 54px 14px 18px;
  background: linear-gradient(135deg, #087ccf 0%, #0563ad 100%);
  color: #fff;
}

.sumuie-chat-privacy-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 800;
}

.sumuie-chat-privacy-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.sumuie-chat-privacy-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 24px;
  color: #28384b;
  font-size: 12px;
  line-height: 1.85;
  background: #fff;
}

.sumuie-chat-privacy-body h3 {
  margin: 22px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #dce9f3;
  color: var(--sumuie-chat-blue-dark);
  font-size: 14px;
  line-height: 1.5;
}

.sumuie-chat-privacy-body h3:first-of-type {
  margin-top: 14px;
}

.sumuie-chat-privacy-body p {
  margin: 0 0 9px;
}

.sumuie-chat-privacy-footer {
  flex: 0 0 auto;
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e5edf4;
  background: #fff;
}

.sumuie-chat-privacy-done {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--sumuie-chat-blue);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 767px) {
  .sumuie-chat-privacy-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
    border-radius: 16px;
  }
  .sumuie-chat-privacy-header {
    padding: 13px 48px 12px 14px;
  }
  .sumuie-chat-privacy-header h2 {
    font-size: 15px;
  }
  .sumuie-chat-privacy-body {
    padding: 14px 14px 20px;
    font-size: 11px;
    line-height: 1.78;
  }
  .sumuie-chat-privacy-body h3 {
    font-size: 13px;
    margin-top: 18px;
  }
}
