.cw-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  color: #f8f0df;
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.cw-chat * {
  box-sizing: border-box;
}

.cw-chat-launcher {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-left: auto;
  border: 1px solid rgba(230, 194, 110, 0.72);
  border-radius: 50%;
  background: linear-gradient(145deg, #e4bd61, #b78025);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34), 0 0 22px rgba(228, 189, 97, 0.22);
  color: #17120a;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.cw-chat-launcher:hover,
.cw-chat-launcher:focus-visible {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 15px 38px rgba(0, 0, 0, 0.4), 0 0 28px rgba(228, 189, 97, 0.34);
}

.cw-chat-launcher svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.cw-chat-panel {
  width: min(380px, calc(100vw - 32px));
  max-height: min(650px, calc(100vh - 40px));
  overflow: hidden;
  border: 1px solid rgba(220, 183, 99, 0.38);
  border-radius: 22px;
  background: rgba(20, 17, 12, 0.98);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
}

.cw-chat[data-open="false"] .cw-chat-panel,
.cw-chat[data-open="true"] .cw-chat-launcher {
  display: none;
}

.cw-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 17px;
  border-bottom: 1px solid rgba(220, 183, 99, 0.2);
  background: linear-gradient(120deg, rgba(219, 177, 83, 0.16), rgba(255, 255, 255, 0.02));
}

.cw-chat-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(230, 194, 110, 0.56);
  border-radius: 12px;
  color: #e6c26e;
  font-family: Georgia, serif;
  font-size: 1.05rem;
}

.cw-chat-heading {
  min-width: 0;
  flex: 1;
}

.cw-chat-heading strong,
.cw-chat-heading span {
  display: block;
}

.cw-chat-heading strong {
  color: #fff8e9;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.cw-chat-heading span {
  margin-top: 3px;
  color: #bfb4a0;
  font-size: 0.72rem;
}

.cw-chat-close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #dfd4c0;
  cursor: pointer;
  font-size: 1.25rem;
}

.cw-chat-close:hover,
.cw-chat-close:focus-visible {
  background: rgba(230, 194, 110, 0.12);
  color: #f0cf80;
}

.cw-chat-messages {
  display: flex;
  min-height: 170px;
  max-height: 275px;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
}

.cw-chat-message {
  width: fit-content;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 15px 15px 15px 4px;
  background: #2b261e;
  color: #f4ead7;
  font-size: 0.82rem;
  line-height: 1.65;
  white-space: pre-line;
}

.cw-chat-message.user {
  align-self: flex-end;
  border-radius: 15px 15px 4px 15px;
  background: linear-gradient(135deg, #d8ad50, #b77c20);
  color: #160f05;
}

.cw-chat-message a {
  color: #f2cf7c;
  font-weight: 700;
}

.cw-chat-quick {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 16px 13px;
  scrollbar-width: thin;
}

.cw-chat-quick button {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid rgba(224, 186, 98, 0.38);
  border-radius: 999px;
  background: rgba(224, 186, 98, 0.06);
  color: #ead7ad;
  cursor: pointer;
  font-size: 0.74rem;
}

.cw-chat-quick button:hover,
.cw-chat-quick button:focus-visible {
  border-color: #dcb45b;
  color: #f3d48d;
}

.cw-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 14px 8px;
  border-top: 1px solid rgba(220, 183, 99, 0.2);
}

.cw-chat-form input {
  min-width: 0;
  height: 42px;
  padding: 0 13px;
  border: 1px solid rgba(230, 194, 110, 0.28);
  border-radius: 12px;
  outline: 0;
  background: #0f0d0a;
  color: #fff8e9;
  font: inherit;
  font-size: 0.82rem;
}

.cw-chat-form input:focus {
  border-color: #dbb45c;
  box-shadow: 0 0 0 3px rgba(219, 180, 92, 0.12);
}

.cw-chat-send {
  min-width: 64px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #e4bd61, #b78025);
  color: #171006;
  cursor: pointer;
  font-weight: 800;
}

.cw-chat-note {
  margin: 0;
  padding: 0 15px 12px;
  color: #918777;
  font-size: 0.63rem;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .cw-chat {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .cw-chat-panel {
    width: calc(100vw - 24px);
    max-height: min(620px, calc(100dvh - 24px));
    border-radius: 19px;
  }

  .cw-chat-messages {
    max-height: min(260px, 38dvh);
  }

  .cw-chat-launcher {
    width: 54px;
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cw-chat-launcher {
    transition: none;
  }
}
