:root {
  --bg: #0f0f12;
  --surface: #1a1a22;
  --surface-2: #242430;
  --bubble-fan: #2a2a38;
  --bubble-you: #6b2d8b;
  --bubble-you-text: #fff;
  --text: #f2f2f7;
  --muted: #9a9aab;
  --accent: #c77dff;
  --accent-2: #9b59b6;
  --danger: #e85d75;
  --ok: #3dd68c;
  --warn: #f5c542;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

.topbar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid #2e2e3a;
  padding-top: var(--safe-t);
  z-index: 10;
}

.topbar-inner { padding: 10px 12px 12px; }

.staff-banner {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
}

.staff-banner-training {
  border: 1px solid rgba(123, 92, 255, 0.35);
  background: linear-gradient(135deg, rgba(123, 92, 255, 0.12), rgba(224, 86, 160, 0.08));
}

.training-mode-tag {
  color: #c4b5fd;
  font-weight: 600;
}

.fan-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b5cff, #e056a0);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.fan-meta { flex: 1; min-width: 0; }
.fan-meta h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}
.status {
  font-size: 12px;
  color: var(--ok);
}

.btn-end {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-end:hover { background: rgba(232, 93, 117, 0.12); }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.day-chip {
  align-self: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 999px;
  margin: 4px 0 8px;
}

.msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg.fan {
  align-self: flex-start;
  background: var(--bubble-fan);
  border-bottom-left-radius: 6px;
}

.msg.you {
  align-self: flex-end;
  background: var(--bubble-you);
  color: var(--bubble-you-text);
  border-bottom-right-radius: 6px;
}

.msg .meta {
  display: block;
  font-size: 10px;
  opacity: 0.65;
  margin-top: 4px;
}

.typing {
  align-self: flex-start;
  background: var(--bubble-fan);
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid #2e2e3a;
  padding: 10px 12px calc(10px + var(--safe-b));
}

#chatForm {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 20px;
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.35;
  max-height: 120px;
  font-family: inherit;
}

.btn-send {
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 11px 16px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.results {
  position: absolute;
  inset: 0;
  background: var(--bg);
  overflow-y: auto;
  z-index: 20;
  padding: calc(12px + var(--safe-t)) 14px calc(24px + var(--safe-b));
}
.results.hidden { display: none; }

.results-inner { max-width: 520px; margin: 0 auto; }
.results h2 { margin: 0 0 6px; font-size: 22px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.scorecard {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid #2e2e3a;
}
.scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.score-pill {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.score-pill .label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.score-pill .val {
  font-size: 22px;
  font-weight: 700;
}
.score-pill .val small { font-size: 12px; font-weight: 500; color: var(--muted); }

.coaching { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.45; }
.coaching li { margin-bottom: 8px; }
.disclaimer {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.transcript-block {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  border: 1px solid #2e2e3a;
  margin-bottom: 16px;
}
.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.transcript-head h3 { margin: 0; font-size: 15px; }

.btn-copy, .btn-restart {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-copy {
  background: var(--accent-2);
  color: #fff;
}
.btn-restart {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  padding: 14px;
  font-size: 15px;
}
.btn-restart:hover { background: #303040; }
.btn-restart:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.results-inner .hint {
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  margin: 0 0 20px;
}

.transcript {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  color: #d8d8e4;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--bg);
  padding: 10px;
  border-radius: 10px;
}

.copy-status {
  min-height: 1.2em;
  font-size: 12px;
  color: var(--ok);
  margin: 6px 0 0;
}

@media (min-width: 540px) {
  #app {
    border-left: 1px solid #2e2e3a;
    border-right: 1px solid #2e2e3a;
  }
}


/* Name gate (first-load overlay) */
.name-gate {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 18, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-t)) 16px calc(24px + var(--safe-b));
}
.name-gate.hidden { display: none; }

.name-gate-inner {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid #2e2e3a;
  border-radius: 16px;
  padding: 22px 18px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.name-gate-inner h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 650;
}

.name-gate-text {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

#nameForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#nameInput {
  width: 100%;
  border: 1px solid #3a3a4a;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
}
#nameInput:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.35);
}
#nameInput.name-input-invalid {
  border-color: var(--danger);
}

.name-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.3;
}
.name-error.hidden { display: none; }

.btn-name-start {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  background: var(--accent-2);
  color: #fff;
}
.btn-name-start:hover { filter: brightness(1.08); }

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


/* OnlyFans-style locked PPV purchase system card */
.msg.purchase {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  padding: 4px 0;
  border-radius: 0;
  white-space: normal;
}

.msg.purchase .meta {
  margin-top: 6px;
  padding-left: 2px;
}

.purchase-card {
  background: #242526;
  border-radius: 12px;
  padding: 14px 14px 12px;
  color: #e4e6eb;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid #3a3b3c;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.purchase-line {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #e4e6eb;
}

.purchase-price {
  color: #6ec1ff;
  font-weight: 700;
}

.purchase-divider {
  border: none;
  border-top: 1px solid #3a3b3c;
  margin: 12px 0 10px;
}

.purchase-creator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.purchase-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7b5cff, #e056a0);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.purchase-creator-name {
  font-size: 13px;
  font-weight: 500;
  color: #e4e6eb;
}
