:root {
  --bg: #0c0e12;
  --ink: #f4efe4;
  --muted: #a7adba;
  --faint: #8b91a1;
  --line: rgba(244, 239, 228, 0.14);
  --gold: #ffc14d;
  --gold-ink: #241804;
  --mint: #8ef0cf;
  --note: #ffe08a;
  --panel: #141820;
  --field: #0e1116;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -15%, rgba(255, 193, 77, 0.16), transparent 55%),
    radial-gradient(ellipse 45% 40% at 100% 100%, rgba(142, 240, 207, 0.08), transparent 50%),
    radial-gradient(rgba(244, 239, 228, 0.045) 1px, transparent 1px);
  background-size: auto, auto, 22px 22px;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--gold);
  color: var(--gold-ink);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

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

.home {
  width: min(40rem, calc(100% - 2rem));
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: clamp(2rem, 7vh, 4.25rem);
}

.brand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem 1rem;
  align-items: center;
}

.mark { display: block; }

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.5rem, 8vw, 4.35rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.wordmark em,
.mini-brand em {
  font-style: italic;
  color: var(--gold);
}

.lede {
  margin: 1.35rem 0 1.5rem;
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 38rem;
}

.ask label {
  display: block;
  margin-bottom: 0.55rem;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  min-height: 8.5rem;
  resize: vertical;
  padding: 1rem 1.05rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 1.2rem;
  line-height: 1.45;
}

textarea::placeholder { color: var(--faint); }

textarea:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 193, 77, 0.16);
}

textarea.shake { animation: shake 0.32s linear; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.meta-row {
  display: flex;
  justify-content: flex-end;
  margin: 0.35rem 0 0;
}

.counter {
  color: var(--faint);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.counter.is-full { color: var(--gold); }

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.85rem;
}

.examples-label {
  color: var(--faint);
  font-size: 0.85rem;
}

.examples button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.88rem;
}

.examples button:hover { border-color: var(--gold); }

.generate {
  width: 100%;
  margin-top: 1rem;
  height: 3.35rem;
  border: 0;
  border-radius: 14px;
  background: var(--gold);
  color: var(--gold-ink);
  font-weight: 700;
  font-size: 1.05rem;
}

.generate:hover { background: #ffcf70; }

.generate:active { transform: translateY(1px); }

.result {
  margin-top: 1.25rem;
  padding: 1rem 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 24, 32, 0.9);
  animation: rise 0.35s ease;
}

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

.result h2 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.link-row {
  display: flex;
  gap: 0.5rem;
}

.share-url {
  flex: 1;
  min-width: 0;
  height: 3rem;
  padding: 0 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  font-family: var(--mono);
  font-size: 16px;
}

.copy,
.preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1rem;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
}

.copy {
  min-width: 6.5rem;
  border: 0;
  background: var(--gold);
  color: var(--gold-ink);
}

.copy:hover { background: #ffcf70; }

.preview {
  width: 100%;
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
}

.preview:hover { border-color: var(--mint); color: var(--mint); }

.fine,
.noscript {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.noscript {
  margin-top: 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  background: #2a2118;
}

.site-footer {
  margin-top: auto;
  padding: 1.6rem 0 1.2rem;
}

.site-footer p {
  margin: 0;
  color: var(--faint);
  font-size: 0.82rem;
}

.stage {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(0.85rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(0.4rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.2;
}

.mini-brand img { display: block; }

.skip {
  color: var(--mint);
  font-weight: 700;
  text-underline-offset: 3px;
}

.play {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: 0;
  width: min(42rem, 100%);
  margin: 0 auto;
}

.caption-slot {
  min-height: 3.4rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}

.caption {
  margin: 0;
  max-width: 100%;
  padding: 0.65rem 0.95rem;
  border-radius: 3px 14px 14px 14px;
  background: var(--note);
  color: var(--gold-ink);
  font-weight: 700;
  font-size: clamp(1.12rem, 2.6vw, 1.4rem);
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
  transform: rotate(-1.15deg);
}

.caption:empty { visibility: hidden; }

.chat {
  width: 100%;
  flex: 1 1 auto;
  min-height: 18rem;
  max-height: min(36rem, calc(100dvh - 11rem));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.chat-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.presence {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(142, 240, 207, 0.12);
}

.thread {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.15rem;
  scrollbar-color: #3a4150 transparent;
}

.empty {
  margin: auto;
  max-width: 14rem;
  text-align: center;
  color: var(--faint);
}

.bubble {
  align-self: flex-end;
  max-width: min(85%, 28rem);
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 16px 16px 5px 16px;
  background: #2a2418;
  border: 1px solid rgba(255, 193, 77, 0.35);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise 0.25s ease;
}

.composer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.75rem;
  padding: 0.5rem 0.5rem 0.5rem 0.95rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--field);
  pointer-events: none;
}

.composer.is-active {
  border-color: rgba(255, 193, 77, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 193, 77, 0.12);
}

.field {
  flex: 1;
  min-height: 1.7rem;
  max-height: 7.5rem;
  overflow: auto;
  padding: 0.45rem 0;
  font-size: 1.05rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.placeholder { color: var(--faint); }

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -0.12em;
  background: var(--gold);
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.send {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--mint);
  color: #10241c;
}

.send.is-pressed { transform: scale(0.9); }

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  width: 28px;
  height: 28px;
  pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45));
  transform: translate(-80px, -80px);
}

.cursor-glyph {
  display: block;
  transform-origin: 4px 2px;
  transition: transform 140ms ease;
}

.cursor.is-clicking .cursor-glyph { transform: scale(0.82); }

.stage .site-footer {
  width: min(42rem, 100%);
  margin: 0.4rem auto 0;
  padding: 0.7rem 0 0.35rem;
  text-align: center;
}

@media (max-width: 560px) {
  .home { padding-top: 1.35rem; }

  .brand { gap: 0.7rem; }

  .mark { width: 48px; height: 48px; }

  .wordmark { font-size: clamp(2.15rem, 10vw, 3.4rem); }

  .lede {
    margin: 1rem 0 1.1rem;
    font-size: 1rem;
  }

  textarea { min-height: 6.25rem; }

  .link-row { flex-direction: column; }

  .copy { width: 100%; }

  .chat { border-radius: 18px; max-height: none; }
}

@media (max-height: 700px) {
  .home { padding-top: 1rem; }
  .lede { margin: 0.75rem 0 0.9rem; }
  textarea { min-height: 5.25rem; }
  .chat { min-height: 14rem; }
}

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