/* support-chat.css — Chatchee（青・角丸 / ORGANIC MORPH トグル）
   Cache-Control: no-cache。通常はファイル名を変えない。 */

.support-chat {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  z-index: 9980;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  pointer-events: none;
}

.support-chat > * {
  pointer-events: auto;
}

.support-chat__toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-paper);
  cursor: pointer;
}

.support-chat.is-open .support-chat__toggle,
.support-chat.is-leaving .support-chat__toggle,
.support-chat__toggle[hidden] {
  display: none;
}

.support-chat__toggle:focus-visible {
  outline: 2px solid var(--color-chat);
  outline-offset: 4px;
  border-radius: 50%;
}

.support-chat__morph {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--color-chat) 78%, var(--color-ink)),
    var(--color-chat) 55%,
    color-mix(in srgb, var(--color-chat) 72%, var(--color-paper))
  );
  animation: support-chat-morph 5s ease-in-out infinite;
}

.support-chat__toggle-icon {
  position: relative;
  z-index: 1;
  width: 2.25rem;
  height: 2.25rem;
  filter: brightness(0) invert(1);
  pointer-events: none;
}

.support-chat__panel {
  display: flex;
  flex-direction: column;
  width: min(22rem, calc(100vw - 1.5rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: min(32rem, calc(100dvh - 1.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--color-chat) 45%, transparent);
  border-radius: 1.5rem;
  background: color-mix(
    in srgb,
    color-mix(in srgb, var(--color-ink) 78%, var(--color-chat)) 82%,
    transparent
  );
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 12px 40px color-mix(in srgb, var(--color-ink) 55%, transparent),
    0 0 24px color-mix(in srgb, var(--color-chat) 22%, transparent);
  transform-origin: calc(100% - 2.25rem) calc(100% - 2.25rem);
}

.support-chat__panel[hidden] {
  display: none !important;
}

.support-chat__panel.is-enter {
  animation: support-chat-pop 0.52s cubic-bezier(0.22, 1.4, 0.36, 1) both;
}

.support-chat__panel.is-leave {
  animation: support-chat-fold 0.28s ease-in both;
}

.support-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid color-mix(in srgb, var(--color-chat) 35%, transparent);
  background: color-mix(in srgb, var(--color-ink) 38%, transparent);
}

.support-chat__title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.support-chat__title-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

.support-chat__title-logo {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  height: 1.5rem;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.support-chat__close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-paper);
  cursor: pointer;
}

.support-chat__close:hover .support-chat__close-icon {
  opacity: 0.72;
}

.support-chat__close:focus-visible {
  outline: 2px solid var(--color-chat);
  outline-offset: 3px;
}

.support-chat__close-icon {
  display: block;
  width: 1.75rem;
  height: auto;
  filter: brightness(0) invert(1);
}

.support-chat__log {
  position: relative;
  flex: 1 1 auto;
  min-height: 10rem;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.support-chat__turn {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  align-self: stretch;
  max-width: 100%;
}

.support-chat__avatar {
  width: 1.5rem;
  height: auto;
  flex-shrink: 0;
  margin-bottom: 0.1rem;
}

.support-chat__msg {
  max-width: 95%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.support-chat__msg--bot {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--paper-a18);
  border-radius: 1.125rem 1.125rem 1.125rem 0.35rem;
  background: var(--paper-a10);
  color: color-mix(in srgb, var(--color-paper) 92%, transparent);
}

.support-chat__msg--user {
  align-self: flex-end;
  border: 1px solid color-mix(in srgb, var(--color-chat) 40%, transparent);
  border-radius: 1.125rem 1.125rem 0.35rem 1.125rem;
  background: color-mix(
    in srgb,
    color-mix(in srgb, var(--color-chat) 42%, var(--color-ink)) 82%,
    transparent
  );
  color: var(--color-paper);
}

.support-chat__msg--thinking {
  min-width: 3.5rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}

.support-chat__thinking {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  height: 0.75rem;
}

.support-chat__thinking span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 9999px;
  background: var(--paper-a22);
  animation: support-chat-think 1.1s ease-in-out infinite;
}

.support-chat__thinking span:nth-child(2) {
  animation-delay: 0.16s;
}

.support-chat__thinking span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes support-chat-think {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-0.28rem);
    opacity: 1;
  }
}

.support-chat__msg--status {
  align-self: center;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--color-paper) 55%, transparent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.support-chat__msg-text {
  white-space: pre-wrap;
}

.support-chat__quote {
  margin-top: 0.55rem;
  white-space: normal;
}

.support-chat__quote-head {
  margin: 0;
  font-weight: 700;
}

.support-chat__quote-area {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: color-mix(in srgb, var(--color-paper) 62%, transparent);
}

.support-chat__quote-box {
  margin-top: 0.55rem;
  padding: 0.55rem;
  border: 1px solid color-mix(in srgb, var(--color-chat) 45%, transparent);
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--color-chat) 18%, transparent);
}

.support-chat__quote-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
  font-weight: 700;
}

.support-chat__quote-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

.support-chat__quote-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.support-chat__quote-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--color-chat) 40%, transparent);
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--color-ink) 28%, transparent);
}

.support-chat__quote-item-name {
  min-width: 0;
  font-weight: 700;
}

.support-chat__quote-item-amount {
  flex-shrink: 0;
  font-family: var(--font-oxanium);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.support-chat__quote-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--color-chat) 55%, transparent);
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--color-chat) 42%, transparent);
  font-weight: 700;
}

.support-chat__quote-total-amount {
  font-family: var(--font-oxanium);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.support-chat__quote-note {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: color-mix(in srgb, var(--color-paper) 62%, transparent);
}

.support-chat__choices + .support-chat__quote-note {
  margin-top: 0.55rem;
}

.support-chat__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
  white-space: normal;
}

.support-chat__choices--stack {
  flex-direction: column;
}

.support-chat__choices--grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.support-chat__choices + .support-chat__choices {
  margin-top: 0.35rem;
}

.support-chat__choices.is-spent {
  opacity: 0.45;
  pointer-events: none;
}

.support-chat__choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--color-chat) 45%, transparent);
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--color-chat) 28%, transparent);
  color: var(--color-paper);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.support-chat__choices--stack .support-chat__choice {
  width: 100%;
}

.support-chat__choices--grid .support-chat__choice {
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.15rem;
  text-align: center;
  border-radius: 0.65rem;
}

.support-chat__choice:hover:not(:disabled) {
  border-color: var(--color-chat);
  background: color-mix(in srgb, var(--color-chat) 48%, transparent);
}

.support-chat__choice:disabled {
  cursor: default;
}

.support-chat__choice-meta {
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  color: color-mix(in srgb, var(--color-paper) 62%, transparent);
}

.support-chat__choice--cta {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  background: var(--grad-ticket-cta);
  color: var(--color-ink);
  font-size: 0.875rem;
  line-height: 1.2;
}

.support-chat__choice-icon {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  object-fit: contain;
}

.support-chat__choice-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.15rem;
  min-width: 0;
}

.support-chat__choice--cta .support-chat__choice-label {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0.72;
}

.support-chat__choice--cta .support-chat__choice-meta {
  color: inherit;
  font-size: 0.875rem;
  font-weight: 700;
}

.support-chat__choice-arrow {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

.support-chat__choice--cta:hover,
.support-chat__choice--cta:hover:not(:disabled) {
  border: 0;
  background: var(--grad-ticket-cta-hover);
  color: var(--color-ink);
}

.support-chat__choice--cta:focus-visible {
  outline: 2px solid var(--color-neon);
  outline-offset: 3px;
}

.support-chat__form {
  padding: 0.65rem 0.75rem 0.85rem;
  border-top: 1px solid color-mix(in srgb, var(--color-chat) 35%, transparent);
  background: color-mix(in srgb, var(--color-ink) 38%, transparent);
}

.support-chat__composer {
  position: relative;
}

.support-chat__note {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: color-mix(in srgb, var(--color-paper) 50%, transparent);
}

.support-chat__input {
  width: 100%;
  min-height: 2.75rem;
  max-height: 6rem;
  resize: none;
  padding: 0.45rem 2.75rem 0.45rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--color-chat) 40%, transparent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--color-chat) 14%, transparent);
  color: var(--color-paper);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.45;
}

.support-chat__input:focus {
  outline: none;
  border-color: var(--color-chat);
}

.support-chat__send {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-paper);
  transform: translateY(-50%);
  cursor: pointer;
}

.support-chat__send:hover:not(:disabled) {
  opacity: 0.75;
}

.support-chat__send:focus-visible {
  outline: 2px solid var(--color-chat);
  outline-offset: 3px;
}

.support-chat__send-icon {
  width: 1.5rem;
  height: 1.5rem;
  filter: brightness(0) invert(1);
}

.support-chat__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes support-chat-pop {
  0% {
    opacity: 0;
    transform: translate(18%, 22%) scale(0.16);
  }
  58% {
    opacity: 1;
    transform: translate(-1.5%, -2%) scale(1.08, 0.92);
  }
  78% {
    transform: translate(0.6%, 1%) scale(0.96, 1.05);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes support-chat-fold {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  36% {
    transform: scale(1.05, 0.9);
  }
  100% {
    opacity: 0;
    transform: translate(16%, 22%) scale(0.18);
  }
}

@keyframes support-chat-morph {
  0%,
  100% {
    border-radius: 28% 72% 66% 34% / 40% 34% 66% 60%;
    rotate: 0deg;
  }
  40% {
    border-radius: 70% 30% 32% 68% / 58% 70% 30% 42%;
    rotate: 35deg;
  }
  72% {
    border-radius: 44% 56% 73% 27% / 30% 52% 48% 70%;
    rotate: -20deg;
  }
}

@media (min-width: 1024px) {
  .support-chat {
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .support-chat__morph {
    animation: none;
    border-radius: 44% 56% 73% 27% / 30% 52% 48% 70%;
  }

  .support-chat__panel.is-enter,
  .support-chat__panel.is-leave {
    animation: none;
  }

  .support-chat__thinking span {
    animation: none;
    opacity: 0.7;
  }
}
