:root {
  color-scheme: light;
  --chatbot-width: min(360px, 90vw);
  --chatbot-height: min(520px, 80vh);
  --chatbot-bg: #ffffff;
  --chatbot-border: #e2e8f0;
  --chatbot-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #0f172a;
  --text-secondary: #64748b;
  font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.chatbot-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 999;
}

.chatbot-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(37, 99, 235, 0.45);
}

.chatbot-launcher:active {
  transform: translateY(0);
}

.chatbot-launcher svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.chatbot-container {
  position: fixed;
  top: 16px;
  right: 16px;
  width: var(--chatbot-width);
  height: var(--chatbot-height);
  background: var(--chatbot-bg);
  border-radius: 20px;
  border: 1px solid var(--chatbot-border);
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.35s ease;
  z-index: 998;
}

.chatbot-container.is-open {
  transform: translateX(0);
}

.chatbot-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--chatbot-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(37, 99, 235, 0.08);
  backdrop-filter: blur(8px);
}

.chatbot-header__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chatbot-status span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.chatbot-close {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.chatbot-close:hover {
  background: rgba(15, 23, 42, 0.08);
}

.chatbot-close svg {
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
}

.chatbot-messages {
  flex: 1;
  padding: 18px 18px 12px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.6) 0%, rgba(255, 255, 255, 0.9) 100%);
}

.chatbot-message {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
}

.chatbot-message.bot {
  align-items: flex-start;
}

.chatbot-message.user {
  justify-content: flex-end;
}

.chatbot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}

.chatbot-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  white-space: pre-wrap;
}

.chatbot-message.user .chatbot-bubble {
  background: var(--primary);
  color: #fff;
  border: none;
  border-top-right-radius: 6px;
}

.chatbot-message.bot .chatbot-bubble {
  border-top-left-radius: 6px;
}

.chatbot-footer {
  border-top: 1px solid var(--chatbot-border);
  padding: 14px 16px;
  background: rgba(248, 250, 252, 0.9);
}

.chatbot-form {
  display: flex;
  gap: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.chatbot-input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 80px;
  max-height: 260px;
  resize: vertical;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.chatbot-submit {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chatbot-submit:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.chatbot-submit:active {
  transform: translateY(0);
}

.chatbot-submit svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.chatbot-typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.chatbot-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing 1.2s infinite ease-in-out;
}

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

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

@keyframes typing {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .chatbot-container {
    top: auto;
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 85vh;
    border-radius: 18px 18px 0 0;
  }

  .chatbot-launcher {
    bottom: 18px;
    right: 18px;
  }
}
