:root {
  --bg: #f6f8fb;
  --bg-soft: rgba(255, 255, 255, 0.9);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius-xl: 28px;
  --radius-lg: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(37, 99, 235, 0.06), transparent 35%),
    radial-gradient(circle at 85% 20%, rgba(14, 165, 233, 0.06), transparent 32%),
    linear-gradient(180deg, #f7f9fc 0%, #f3f6fb 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
textarea {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.page-shell {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
}

/* ---------- Animated gradient-mesh background ---------- */
.mesh-blob,
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.mesh-blob {
  position: fixed;
  inset: auto;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  z-index: -3;
  will-change: transform;
}

.mesh-blob.b1 {
  width: 48vw;
  height: 48vw;
  top: -14vw;
  left: -10vw;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.5), transparent 70%);
  animation: float1 22s ease-in-out infinite;
}

.mesh-blob.b2 {
  width: 42vw;
  height: 42vw;
  top: -8vw;
  right: -12vw;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.45), transparent 70%);
  animation: float2 26s ease-in-out infinite;
}

.mesh-blob.b3 {
  width: 52vw;
  height: 52vw;
  bottom: -22vw;
  left: 30vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35), transparent 70%);
  animation: float3 30s ease-in-out infinite;
}

.noise {
  z-index: -2;
  opacity: 0.025;
  background-image:
    linear-gradient(transparent 0, rgba(15, 23, 42, 0.2) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='%230f172a' fill-opacity='.14'%3E%3Ccircle cx='12' cy='14' r='1'/%3E%3Ccircle cx='48' cy='88' r='1'/%3E%3Ccircle cx='102' cy='41' r='1'/%3E%3Ccircle cx='129' cy='112' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vw, 3vw) scale(1.08); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-3vw, 4vw) scale(1.06); }
}

@keyframes float3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-4vw, -3vw) scale(1.1); }
}

/* ---------- Layout ---------- */
.topbar,
.chat-app {
  width: min(820px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "Sora", sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: 1.05rem;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.4);
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.topbar-meta span {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.chat-app {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: calc(100vh - 34px);
}

.chat-window {
  padding: 6px 0 170px;
}

.intro-card,
.message-body,
.composer,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.intro-card {
  padding: 28px;
  border-radius: var(--radius-xl);
  margin-bottom: 18px;
  background: var(--panel-strong);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent));
}

h1,
h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
}

h2 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.intro-card p:last-child {
  margin: 8px 0 0;
  max-width: 56ch;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------- Chat thread ---------- */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--accent);
  font-family: "Sora", sans-serif;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.message-user .message-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

.message-body {
  padding: 16px 18px;
  border-radius: 22px;
  background: var(--panel-strong);
}

.message-ai .message-body {
  border-top-left-radius: 6px;
}

.message-user {
  grid-template-columns: minmax(0, 1fr) 44px;
}

.message-user .message-body {
  order: -1;
  border-top-left-radius: 22px;
  border-top-right-radius: 6px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 233, 0.05));
  border-color: rgba(37, 99, 235, 0.14);
}

.message-body p {
  margin: 0;
  line-height: 1.72;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.message-meta strong {
  font-size: 0.95rem;
}

.message-meta span,
.step-note,
.quote-card cite,
.composer-hint {
  color: var(--muted);
}

.message-meta span {
  font-size: 0.78rem;
}

.message-steps {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.step-card {
  padding: 13px 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  transition: border-color 220ms ease, transform 220ms ease, background 220ms ease;
  animation: stepIn 320ms ease both;
}

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

.step-card.active {
  border-color: rgba(37, 99, 235, 0.4);
  background: var(--accent-soft);
  transform: translateX(3px);
}

.step-card.done {
  border-color: rgba(14, 165, 233, 0.22);
  background: rgba(14, 165, 233, 0.04);
}

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

.step-head strong {
  font-size: 0.92rem;
}

.step-head span {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.step-card.active .step-head span {
  color: var(--accent);
  font-weight: 600;
}

.step-card.done .step-head span {
  color: #0ea5e9;
}

.step-note {
  font-size: 0.88rem;
  line-height: 1.6;
}

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 12px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing span:nth-child(3) {
  animation-delay: 0.28s;
}

/* ---------- Composer ---------- */
.composer {
  position: sticky;
  bottom: 14px;
  z-index: 3;
  padding: 14px;
  margin-bottom: 14px;
  border-radius: 24px;
  background: var(--panel-strong);
}

textarea {
  width: 100%;
  min-height: 56px;
  max-height: 180px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fafc;
  padding: 16px 18px;
  color: var(--text);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

textarea::placeholder {
  color: var(--muted-soft);
}

textarea:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  background: #fff;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
}

.composer-hint {
  font-size: 0.82rem;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  background: var(--accent);
  color: #fff;
  font-family: "Sora", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease, background 180ms ease;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
}

button:hover {
  transform: translateY(-1px);
  background: #1d4fd8;
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

.secondary-btn {
  background: var(--panel-strong);
  color: var(--accent);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.secondary-btn:hover {
  background: #f1f5fb;
  color: var(--accent);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 28px;
  border-radius: 26px;
  background: var(--panel-strong);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  background: #f1f5fb;
  color: var(--text);
  box-shadow: none;
  font-size: 1.2rem;
  line-height: 1;
  min-height: 0;
}

.modal-close:hover {
  background: #e2e8f3;
  transform: none;
}

.modal-copy {
  max-width: 90%;
  margin-bottom: 22px;
}

.modal-copy h2 {
  margin-top: 4px;
}

.modal-copy p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.prank-stage {
  display: grid;
  gap: 16px;
}

.prank-answer {
  margin: 0;
  text-align: center;
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.1;
}

.prank-stage .gif-tile {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  place-items: center;
}

.prank-stage .gif-tile img {
  max-height: 280px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  margin: 0 auto;
}

.prank-stage .gif-tile p {
  margin: 10px 0 0;
  color: var(--muted-soft);
  font-size: 0.82rem;
  text-align: center;
}

.prank-stage .quote-card {
  padding: 16px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid var(--line);
  box-shadow: none;
}

.quote-card blockquote {
  margin: 0 0 10px;
  line-height: 1.6;
  font-size: 1.02rem;
  font-style: italic;
  color: var(--text);
}

.quote-card cite {
  font-style: normal;
  font-weight: 600;
  font-size: 0.86rem;
}

.shuffle-row {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

/* ---------- A11y ---------- */
.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;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar {
    flex-direction: row;
    align-items: center;
  }

  .topbar-meta .pill-secondary {
    display: none;
  }

  .chat-window {
    padding-bottom: 180px;
  }

  .message {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
  }

  .message-user {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 0.85rem;
  }

  .intro-card,
  .composer,
  .message-body,
  .modal-card {
    border-radius: 22px;
  }

  .composer {
    padding: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .composer-hint {
    display: none;
  }

  .composer-actions {
    justify-content: flex-end;
  }

  .modal {
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    padding: 24px 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .prank-stage .gif-tile img {
    max-height: 200px;
  }
}

@media (max-width: 420px) {
  .brand {
    font-size: 0.98rem;
  }

  h1 {
    font-size: 2rem;
  }

  .topbar-meta {
    font-size: 0.76rem;
  }
}
