/* Floating chat SUNNY — blue theme */
.sunny-chat {
  --sc-blue: #2563eb;
  --sc-blue-dark: #1d4ed8;
  --sc-blue-deep: #1e3a8a;
  --sc-blue-soft: #eff6ff;
  --sc-blue-mid: #93c5fd;
  position: fixed;
  z-index: 1048;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  font-family: "Google Sans Flex", "Segoe UI", system-ui, sans-serif;
}

.sunny-chat__fab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 3.15rem;
  padding: 0 1.15rem 0 0.95rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  box-shadow:
    0 10px 28px -8px rgba(37, 99, 235, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.18) inset;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.sunny-chat__fab:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 14px 32px -8px rgba(37, 99, 235, 0.72),
    0 0 0 1px rgba(255, 255, 255, 0.22) inset;
}
.sunny-chat__fab:focus-visible {
  outline: 3px solid rgba(147, 197, 253, 0.9);
  outline-offset: 3px;
}
.sunny-chat__fab-icon {
  display: inline-flex;
  width: 1.65rem;
  height: 1.65rem;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.sunny-chat__fab.is-open {
  padding: 0;
  width: 3.15rem;
  justify-content: center;
}
.sunny-chat__fab.is-open .sunny-chat__fab-label { display: none; }

.sunny-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  width: min(28rem, calc(100vw - 1.5rem));
  height: min(40rem, calc(100vh - 6rem));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 1.15rem;
  overflow: hidden;
  box-shadow:
    0 24px 60px -20px rgba(30, 58, 138, 0.45),
    0 0 0 1px rgba(37, 99, 235, 0.12);
  transform-origin: bottom right;
  animation: sunnyChatIn 0.22s ease;
}
.sunny-chat__panel[hidden] {
  display: none !important;
}
@keyframes sunnyChatIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.sunny-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
}
.sunny-chat__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.sunny-chat__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 1.15rem;
  flex-shrink: 0;
}
.sunny-chat__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.2;
}
.sunny-chat__status {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  opacity: 0.92;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.sunny-chat__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #86efac;
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.25);
}
.sunny-chat__close {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sunny-chat__close:hover { background: rgba(255, 255, 255, 0.24); }

.sunny-chat__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f8fbff 0%, #fff 40%);
}

.sunny-chat__gate {
  padding: 1.15rem 1.1rem 1.25rem;
}
.sunny-chat__lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #334155;
}
.sunny-chat__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sunny-chat__hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
}
.sunny-chat__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.sunny-chat__field > span {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}
.sunny-chat__field input {
  min-height: 2.65rem;
  border: 1px solid #dbeafe;
  border-radius: 0.75rem;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sunny-chat__field input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.sunny-chat__error {
  margin: 0;
  font-size: 0.8rem;
  color: #dc2626;
}
.sunny-chat__start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.85rem;
  margin-top: 0.25rem;
  border: 0;
  border-radius: 0.85rem;
  cursor: pointer;
  color: #fff;
  font: inherit;
  font-weight: 750;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 10px 22px -10px rgba(37, 99, 235, 0.7);
}
.sunny-chat__start:hover { filter: brightness(1.05); }
.sunny-chat__start:disabled {
  opacity: 0.7;
  cursor: wait;
}

.sunny-chat__room {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.sunny-chat__room[hidden] { display: none !important; }
.sunny-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}
.sunny-chat__bubble {
  max-width: 85%;
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.98rem;
  line-height: 1.55;
  word-break: break-word;
  color: #0f172a;
}
.sunny-chat__bubble--bot + .sunny-chat__bubble--bot {
  margin-top: 0.15rem;
}
.sunny-chat__bubble--bot {
  align-self: flex-start;
  background: #eff6ff;
  color: #0f172a;
  border-bottom-left-radius: 0.3rem;
  border: 1px solid #dbeafe;
}
.sunny-chat__bubble--user {
  align-self: flex-end;
  background: #e2e8f0;
  color: #0f172a;
  border-bottom-right-radius: 0.3rem;
  border: 1px solid #cbd5e1;
}
.sunny-chat__bubble time {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  opacity: 0.7;
}
.sunny-chat__bubble a {
  color: #0f172a;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.sunny-chat__bubble--bot a {
  color: #0f172a;
  font-weight: 600;
}
.sunny-chat__bubble--user a {
  color: #0f172a;
}
.sunny-chat__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.65rem 0.85rem;
  background: #eff6ff;
  border-radius: 999px;
  border: 1px solid #dbeafe;
}
.sunny-chat__typing span {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 999px;
  background: #60a5fa;
  animation: sunnyChatDot 1s infinite ease-in-out;
}
.sunny-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.sunny-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sunnyChatDot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.sunny-chat__composer {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.sunny-chat__composer input {
  flex: 1;
  min-width: 0;
  min-height: 2.55rem;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.92rem;
}
.sunny-chat__composer input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.sunny-chat__send {
  width: 2.55rem;
  height: 2.55rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sunny-chat__send:hover { filter: brightness(1.06); }
.sunny-chat__send:disabled { opacity: 0.55; cursor: wait; }

@media (max-width: 480px) {
  .sunny-chat__panel {
    width: calc(100vw - 1rem);
    height: min(82vh, 40rem);
  }
  .sunny-chat__fab-label { display: none; }
  .sunny-chat__fab {
    width: 3.35rem;
    height: 3.35rem;
    padding: 0;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sunny-chat__panel,
  .sunny-chat__fab,
  .sunny-chat__typing span {
    animation: none !important;
    transition: none !important;
  }
}
