:root {
  color-scheme: dark;
  --bg: #141018;
  --surface: #201a28;
  --surface-strong: #2a2234;
  --surface-soft: #332a3f;
  --ink: #fff8f5;
  --muted: #b9aebf;
  --line: rgb(255 255 255 / 14%);
  --accent: #f0b36c;
  --rose: #db6f92;
  --teal: #52c7b8;
  --violet: #9a76ff;
  --danger: #ff8a8a;
  --shadow: 0 20px 70px rgb(0 0 0 / 36%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgb(240 179 108 / 14%), transparent 26rem),
    linear-gradient(145deg, #121018 0%, #1b1423 52%, #11171d 100%);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

pre {
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 6%);
}

.age-gate,
.home-screen {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 22px;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.gate-panel {
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(32 26 40 / 86%);
  box-shadow: var(--shadow);
}

.gate-panel h1,
.home-head h1 {
  margin: 8px 0 12px;
  font-size: clamp(32px, 8vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}

.gate-panel p,
.home-head p,
.modal p,
.flow-banner p,
.flow-banner small,
.drawer-head small,
.avatar-mini small {
  color: var(--muted);
  line-height: 1.6;
}

.notice-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgb(255 255 255 / 7%);
  font-size: 13px;
}

.btn,
.auth-btn,
.pill-btn,
.send-btn,
.voice-btn,
.icon-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  background: rgb(255 255 255 / 10%);
  border: 1px solid var(--line);
}

.btn.primary,
.send-btn,
.pill-btn {
  background: linear-gradient(135deg, var(--violet), var(--rose) 52%, var(--accent));
  color: white;
  border: 0;
}

.voice-btn {
  position: relative;
  width: 46px;
  min-width: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.voice-btn.active {
  color: var(--teal);
  border-color: rgb(82 199 184 / 58%);
  background: rgb(82 199 184 / 13%);
}

.voice-btn.voice-connecting::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 8px;
  border: 1px solid rgb(82 199 184 / 46%);
  animation: voice-pulse 1s ease-out infinite;
}

.voice-icon {
  position: relative;
  width: 18px;
  height: 24px;
  display: block;
}

.voice-capsule {
  position: absolute;
  left: 5px;
  top: 1px;
  width: 8px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.voice-stem {
  position: absolute;
  left: 8px;
  top: 17px;
  width: 2px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
}

.voice-stem::after {
  content: "";
  position: absolute;
  left: -5px;
  top: 5px;
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.voice-wave {
  height: 22px;
  display: none;
  align-items: center;
  gap: 3px;
}

.voice-wave i {
  width: 4px;
  height: 8px;
  border-radius: 6px;
  background: currentColor;
  animation: voice-wave 0.72s ease-in-out infinite;
}

.voice-wave i:nth-child(2) {
  animation-delay: 0.12s;
}

.voice-wave i:nth-child(3) {
  animation-delay: 0.24s;
}

.voice-btn.voice-recording .voice-icon {
  display: none;
}

.voice-btn.voice-recording .voice-wave {
  display: flex;
}

.voice-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgb(255 255 255 / 28%);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: voice-spin 0.8s linear infinite;
}

.voice-btn.voice-processing .voice-icon,
.voice-btn.voice-processing .voice-wave {
  display: none;
}

.voice-btn.voice-processing .voice-spinner {
  display: block;
}

.auth-btn.logged-in {
  color: var(--teal);
  border-color: rgb(82 199 184 / 48%);
  background: rgb(82 199 184 / 12%);
}

.btn.secondary {
  background: var(--surface-soft);
}

.btn.ghost {
  background: transparent;
}

.icon-btn {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
}

.icon-btn.compact {
  width: 36px;
  min-height: 36px;
  font-size: 22px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.avatar-card {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow);
}

.avatar-card img,
.material-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.avatar-card-shade,
.material-shade {
  position: absolute;
  inset: auto 0 0;
  height: 48%;
  background: linear-gradient(transparent, rgb(0 0 0 / 82%));
}

.avatar-card-body {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  gap: 8px;
  padding: 16px;
}

.avatar-card-body strong {
  font-size: 26px;
}

.avatar-card-body small,
.tag {
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 7px;
  border-radius: 8px;
  background: rgb(255 255 255 / 10%);
  font-size: 12px;
}

.chat-screen {
  min-height: 100vh;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px clamp(10px, 3vw, 22px) 168px;
}

.chat-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  background: rgb(20 16 24 / 88%);
  backdrop-filter: blur(16px);
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.chat-actions .auth-btn,
.chat-actions .pill-btn {
  min-height: 38px;
  padding: 8px 10px;
  white-space: nowrap;
}

.avatar-mini {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-mini img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
}

.avatar-mini strong,
.avatar-mini small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
}

.status-strip div,
.flow-banner {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 7%);
}

.status-strip small,
.status-strip strong,
.flow-banner span,
.flow-banner strong,
.flow-banner small {
  display: block;
}

.status-strip small,
.flow-banner span {
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  margin-top: 4px;
  font-size: 18px;
}

.flow-banner {
  margin-bottom: 10px;
  display: grid;
  gap: 4px;
}

.flow-banner.active {
  border-color: rgb(240 179 108 / 54%);
  background: rgb(240 179 108 / 12%);
}

.thread-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
}

.thread-strip button {
  flex: 0 0 min(210px, 72vw);
  display: grid;
  gap: 3px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 7%);
  text-align: left;
}

.thread-strip button.active {
  border-color: rgb(82 199 184 / 72%);
  background: rgb(82 199 184 / 14%);
}

.thread-strip span {
  color: var(--muted);
  font-size: 11px;
}

.thread-strip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.messages {
  min-height: 42vh;
  max-height: 58vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0 96px;
  scroll-padding-bottom: 96px;
}

.message {
  width: fit-content;
  max-width: min(82%, 560px);
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.55;
  background: var(--surface-strong);
}

.message.assistant {
  border-top-left-radius: 3px;
}

.message.assistant.streaming {
  color: rgb(255 248 245 / 82%);
  background: rgb(42 34 52 / 82%);
}

.message.assistant.failed {
  color: var(--danger);
  border: 1px solid rgb(255 138 138 / 42%);
  background: rgb(255 138 138 / 10%);
}

.streaming-placeholder {
  display: inline-block;
  color: var(--muted);
  animation: typing-pulse 1.1s ease-in-out infinite;
}

.message.user {
  align-self: flex-end;
  color: white;
  background: #355f78;
  border-top-right-radius: 3px;
}

.message.system {
  align-self: center;
  max-width: 92%;
  color: var(--muted);
  background: rgb(255 255 255 / 7%);
  font-size: 13px;
}

.message-image {
  display: block;
  width: min(260px, 70vw);
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.message-image-btn {
  display: block;
  padding: 0;
  margin: 0 0 8px;
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.message-image-btn .message-image {
  margin-bottom: 0;
}

@keyframes typing-pulse {
  0%,
  100% {
    opacity: 0.36;
  }

  50% {
    opacity: 1;
  }
}

@keyframes voice-pulse {
  0% {
    opacity: 0.9;
    transform: scale(0.82);
  }

  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes voice-wave {
  0%,
  100% {
    height: 7px;
  }

  50% {
    height: 20px;
  }
}

@keyframes voice-spin {
  to {
    transform: rotate(360deg);
  }
}

.composer {
  position: sticky;
  bottom: 72px;
  z-index: 25;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(32 26 40 / 94%);
  box-shadow: 0 10px 36px rgb(0 0 0 / 24%);
}

.composer textarea {
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border: 0;
  outline: 0;
  border-radius: 8px;
  padding: 11px;
  color: var(--ink);
  background: rgb(255 255 255 / 10%);
}

.voice-panel {
  position: sticky;
  bottom: 146px;
  z-index: 26;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid rgb(82 199 184 / 36%);
  border-radius: 8px;
  background: rgb(22 41 47 / 94%);
  box-shadow: 0 10px 36px rgb(0 0 0 / 22%);
}

.voice-panel span,
.voice-panel strong {
  min-width: 0;
  display: block;
}

.voice-panel span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.voice-panel strong {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.voice-panel.failed {
  border-color: rgb(255 138 138 / 46%);
  background: rgb(76 32 38 / 94%);
}

.voice-cancel {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgb(255 255 255 / 9%);
  white-space: nowrap;
}

.image-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(0 0 0 / 78%);
  backdrop-filter: blur(10px);
}

.image-preview-shell {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  gap: 10px;
  align-content: center;
}

.image-preview-shell img {
  width: 100%;
  max-height: calc(100vh - 128px);
  object-fit: contain;
  border-radius: 8px;
  background: #050507;
  box-shadow: var(--shadow);
}

.image-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 38px;
  min-height: 38px;
  border-radius: 8px;
  background: rgb(0 0 0 / 56%);
  border: 1px solid rgb(255 255 255 / 26%);
  font-size: 24px;
  line-height: 1;
}

.image-preview-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
}

.image-preview-meta strong {
  color: var(--ink);
}

.image-preview-meta span {
  padding: 4px 7px;
  border-radius: 8px;
  color: var(--ink);
  background: rgb(255 255 255 / 12%);
  font-size: 12px;
}

.quick-tabs {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 24;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 20px));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(32 26 40 / 92%);
  backdrop-filter: blur(16px);
}

.quick-tabs button {
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.quick-tabs button.active {
  color: white;
  background: linear-gradient(135deg, rgb(154 118 255 / 90%), rgb(240 179 108 / 86%));
}

.bottom-drawer {
  position: fixed;
  left: 50%;
  bottom: 70px;
  z-index: 23;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 20px));
  max-height: min(52vh, 520px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(32 26 40 / 96%);
  box-shadow: var(--shadow);
}

.toast-shell {
  position: fixed;
  top: 96px;
  left: 50%;
  z-index: 44;
  width: min(520px, calc(100% - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgb(240 179 108 / 48%);
  border-radius: 8px;
  background: rgb(32 26 40 / 96%);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.toast-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.toast-copy strong,
.toast-copy p {
  margin: 0;
}

.toast-copy p {
  color: var(--muted);
  line-height: 1.45;
}

.toast-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast-action {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

.toast-close {
  width: 34px;
  min-height: 34px;
  border-radius: 8px;
  color: var(--muted);
  background: rgb(255 255 255 / 8%);
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.drawer-head strong,
.drawer-head small {
  display: block;
}

.card-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scene-card {
  position: relative;
  min-height: 190px;
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  background:
    linear-gradient(145deg, rgb(154 118 255 / 20%), rgb(240 179 108 / 10%)),
    var(--surface-soft);
}

.scene-card.advanced {
  background:
    linear-gradient(145deg, rgb(219 111 146 / 22%), rgb(82 199 184 / 12%)),
    var(--surface-soft);
}

.scene-card.locked {
  opacity: 0.58;
}

.scene-card strong,
.scene-card small,
.scene-card em {
  display: block;
}

.scene-card small,
.scene-card em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.opener-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.opener-row span {
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 8px;
  color: var(--ink);
  background: rgb(255 255 255 / 10%);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.opener-chip {
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--ink);
  background: rgb(255 255 255 / 12%);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
}

.scene-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgb(255 255 255 / 14%);
  font-size: 12px;
}

.material-card {
  position: relative;
  overflow: hidden;
  min-height: 210px;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.material-card.locked img {
  filter: blur(5px) brightness(0.62);
}

.material-meta {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  gap: 3px;
  padding: 10px;
  text-align: left;
}

.material-meta small {
  color: var(--muted);
}

.empty {
  margin: 10px 0;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(0 0 0 / 58%);
}

.modal {
  width: min(440px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 8px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.invite-field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
}

.invite-field input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: rgb(255 255 255 / 9%);
}

@media (min-width: 900px) {
  .chat-screen {
    padding-bottom: 184px;
  }

  .messages {
    min-height: 48vh;
  }

  .card-grid,
  .media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .chat-screen {
    padding-left: 10px;
    padding-right: 10px;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-top {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chat-actions {
    grid-column: 1 / -1;
  }

  .status-strip strong {
    font-size: 15px;
  }

  .toast-shell {
    top: 124px;
  }

  .toast-card {
    grid-template-columns: 1fr;
  }

  .toast-controls {
    justify-content: flex-end;
  }

  .card-grid,
  .media-grid {
    grid-template-columns: 1fr 1fr;
  }

  .scene-card {
    min-height: 154px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .send-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .voice-panel {
    bottom: 192px;
  }
}
