@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  color-scheme: dark;
  --ink: #f8edf4;
  --muted: #a995a2;
  --bg: #100a0f;
  --panel: rgba(31, 19, 28, 0.9);
  --panel-strong: #24151f;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ec6ca8;
  --accent-strong: #b93676;
  --violet: #916ee4;
  --success: #65d7a0;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(145, 110, 228, 0.18), transparent 32rem),
    radial-gradient(circle at 86% 90%, rgba(236, 108, 168, 0.16), transparent 30rem),
    var(--bg);
  font-family: 'DM Sans', system-ui, sans-serif;
}

button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.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;
}

.age-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 5, 9, 0.78);
  backdrop-filter: blur(18px);
}

.age-gate.hidden { display: none; }

.age-card {
  width: min(100%, 520px);
  padding: clamp(28px, 6vw, 52px);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(47, 27, 42, 0.98), rgba(23, 13, 21, 0.98));
  box-shadow: var(--shadow);
}

.age-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 24px;
  color: white;
  font-size: 1.35rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--accent-strong));
  box-shadow: 0 12px 38px rgba(185, 54, 118, 0.36);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.age-card h1 {
  margin: 0;
  font: 700 clamp(2.2rem, 7vw, 3.5rem)/1 'Playfair Display', serif;
}

.age-card > p:not(.eyebrow) {
  max-width: 410px;
  margin: 20px auto 30px;
  color: var(--muted);
  line-height: 1.7;
}

.age-actions { display: grid; gap: 10px; }

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover { transform: translateY(-1px); }
.button-primary { background: linear-gradient(135deg, var(--accent-strong), var(--violet)); }
.button-ghost { color: var(--muted); border-color: var(--line); background: transparent; }

.app {
  width: min(100%, 1120px);
  height: 100dvh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.topbar,
.chat-shell {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 78px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  border-radius: 22px;
}

.identity { display: flex; gap: 12px; align-items: center; min-width: 0; }

.avatar {
  position: relative;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font: 700 1.65rem/1 'Playfair Display', serif;
  background: linear-gradient(145deg, var(--violet), var(--accent-strong));
}

.avatar::before {
  content: '';
  position: absolute;
  width: 28px;
  height: 9px;
  top: -6px;
  border: 2px solid rgba(248, 237, 244, 0.76);
  border-radius: 50%;
}

.name-row { display: flex; align-items: center; gap: 8px; }
.name-row h1 { margin: 0; font: 700 1.35rem/1.1 'Playfair Display', serif; }
.identity p { margin: 5px 0 0; color: var(--muted); font-size: 0.85rem; }

.status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(101, 215, 160, 0.12);
}

.adult-badge {
  padding: 3px 6px;
  color: #ffc9df;
  font-size: 0.62rem;
  font-weight: 700;
  border: 1px solid rgba(236, 108, 168, 0.34);
  border-radius: 6px;
}

.toolbar { display: flex; gap: 8px; }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.icon-button:hover { border-color: rgba(236, 108, 168, 0.5); background: rgba(236, 108, 168, 0.09); }

.chat-shell {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr auto;
  border-radius: 24px;
}

.chat-log {
  min-height: 0;
  overflow-y: auto;
  padding: clamp(18px, 4vw, 38px);
  scroll-behavior: smooth;
}

.empty-state { margin: 30vh auto 0; color: var(--muted); text-align: center; }

.message {
  position: relative;
  width: fit-content;
  max-width: min(78%, 720px);
  margin: 0 0 22px;
  padding: 16px 18px 13px;
  border: 1px solid var(--line);
  border-radius: 19px;
  animation: arrive 220ms ease both;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.assistant {
  margin-right: auto;
  border-bottom-left-radius: 5px;
  background: linear-gradient(145deg, rgba(63, 34, 54, 0.96), rgba(42, 25, 38, 0.96));
}

.message.user {
  margin-left: auto;
  border-bottom-right-radius: 5px;
  background: linear-gradient(145deg, rgba(84, 52, 123, 0.86), rgba(55, 39, 87, 0.92));
}

.message-label { display: block; margin-bottom: 6px; color: var(--accent); font-size: 0.72rem; font-weight: 700; }
.message.user .message-label { color: #cdbdf6; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.58; }
.message time { display: block; margin-top: 8px; color: var(--muted); font-size: 0.66rem; text-align: right; }
.message.pending .message-text { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.45; } }

.composer-wrap {
  padding: 14px 18px 12px;
  border-top: 1px solid var(--line);
  background: rgba(18, 10, 16, 0.9);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  width: 100%;
  min-height: 52px;
  max-height: 150px;
  padding: 14px 16px;
  resize: none;
  overflow-y: auto;
  color: var(--ink);
  outline: none;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  line-height: 1.45;
}

.composer textarea:focus { border-color: rgba(236, 108, 168, 0.58); box-shadow: 0 0 0 3px rgba(236, 108, 168, 0.08); }
.composer textarea::placeholder { color: #7f6d78; }

.send-button {
  min-height: 52px;
  padding: 0 20px;
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent-strong), var(--violet));
  cursor: pointer;
}

.send-button:disabled { cursor: not-allowed; filter: grayscale(0.45); opacity: 0.55; }
.send-button.busy span:last-child { animation: pulse 900ms ease-in-out infinite; }
.composer-note { margin: 9px 4px 0; color: #796874; font-size: 0.68rem; text-align: center; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 24px;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #2f1c2a;
  box-shadow: var(--shadow);
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 20px; }

@media (max-width: 640px) {
  .app { padding: 0; gap: 0; }
  .topbar, .chat-shell { border-radius: 0; border-left: 0; border-right: 0; }
  .topbar { min-height: 72px; border-top: 0; }
  .chat-shell { border-bottom: 0; }
  .identity p { font-size: 0.75rem; }
  .toolbar { gap: 5px; }
  .icon-button { width: 39px; height: 39px; }
  .message { max-width: 91%; }
  .chat-log { padding: 18px 14px; }
  .composer-wrap { padding: 10px 10px 8px; }
  .send-button { width: 52px; padding: 0; }
  .send-button span:first-child { display: none; }
  .composer-note { font-size: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
