/* ============================================================
   Reverie — design system v1
   Ported from Claude Design's ReverieWorld bundle (2026-05-20).
   Tokens originate in reverie-system.jsx; CSS custom properties
   below are the source-of-truth for the engineering build.
   ============================================================ */

/* ─── Fonts ──────────────────────────────────────────────────
   Newsreader: variable optical-sizing serif for Nora's prose.
   Manrope:    quiet sans for UI chrome, buttons, meta.
   Loaded from Google Fonts. Italic variants pulled because
   the wordmark + epigraph + headline rely on italic. */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;1,6..72,400;1,6..72,500&display=swap');

/* ─── Palettes (parchment / dim) ─────────────────────────────
   OKLCH for hue-stable rendering across light + dim modes.
   Single accent (terracotta) carries between palettes; lightness
   and chroma flip to stay readable against each ground. */
:root {
  /* Type */
  --rv-serif: 'Newsreader', 'Source Serif Pro', ui-serif, Georgia, serif;
  --rv-sans:  'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --rv-mono:  ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing (4-base) */
  --rv-s-1: 4px;
  --rv-s-2: 8px;
  --rv-s-3: 12px;
  --rv-s-4: 16px;
  --rv-s-5: 24px;
  --rv-s-6: 32px;
  --rv-s-7: 48px;
  --rv-s-8: 64px;
  --rv-s-9: 96px;
  --rv-s-10: 128px;

  /* Radii */
  --rv-r-sm: 4px;
  --rv-r-md: 8px;
  --rv-r-lg: 14px;
  --rv-r-xl: 22px;
  --rv-r-pill: 999px;

  /* Motion */
  --rv-ease-soft:       cubic-bezier(0.16, 1, 0.3, 1);
  --rv-ease-in-out:     cubic-bezier(0.4, 0, 0.2, 1);
  --rv-ease-scene:      cubic-bezier(0.7, 0, 0.3, 1);
  --rv-dur-fast:        200ms;
  --rv-dur-base:        360ms;
  --rv-dur-slow:        720ms;
  --rv-dur-scene:       1200ms;

  /* Light "parchment" palette */
  --rv-bg:        oklch(96.5% 0.012 70);
  --rv-bg-elev:   oklch(94.0% 0.014 68);
  --rv-bg-sink:   oklch(91.5% 0.018 65);
  --rv-ink-1:     oklch(22% 0.025 40);
  --rv-ink-2:     oklch(40% 0.022 42);
  --rv-ink-3:     oklch(58% 0.018 45);
  --rv-ink-4:     oklch(72% 0.015 50);
  --rv-hairline:  oklch(86% 0.018 60);
  --rv-accent:    oklch(55% 0.12 35);
  --rv-accent-ink: oklch(96% 0.012 70);
  --rv-shadow-soft: 0 1px 2px rgba(40,28,18,0.05), 0 12px 32px -10px rgba(40,28,18,0.12);
  --rv-shadow-lift: 0 1px 2px rgba(40,28,18,0.06), 0 28px 60px -16px rgba(40,28,18,0.28);

  /* Soft warmth backdrop — a lamp in the corner */
  --rv-glow: radial-gradient(ellipse 70% 50% at 80% 10%, oklch(92% 0.03 60 / 0.7), transparent 60%);
}

/* Dim "night" palette — flips on user preference */
@media (prefers-color-scheme: dark) {
  :root {
    --rv-bg:        oklch(15.5% 0.014 36);
    --rv-bg-elev:   oklch(19% 0.016 36);
    --rv-bg-sink:   oklch(12% 0.012 35);
    --rv-ink-1:     oklch(92% 0.012 72);
    --rv-ink-2:     oklch(78% 0.015 70);
    --rv-ink-3:     oklch(60% 0.015 68);
    --rv-ink-4:     oklch(45% 0.015 60);
    --rv-hairline:  oklch(28% 0.018 40);
    --rv-accent:    oklch(72% 0.11 38);
    --rv-accent-ink: oklch(15% 0.014 36);
    --rv-shadow-soft: 0 1px 2px rgba(0,0,0,0.5), 0 14px 36px -10px rgba(0,0,0,0.6);
    --rv-shadow-lift: 0 2px 4px rgba(0,0,0,0.55), 0 36px 90px -20px rgba(0,0,0,0.75);
    --rv-glow: radial-gradient(ellipse 70% 50% at 80% 10%, oklch(28% 0.04 38 / 0.6), transparent 60%);
  }
}

/* ─── Reset + base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--rv-bg);
  color: var(--rv-ink-1);
  font-family: var(--rv-serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--rv-accent); }

/* The lamp-in-the-corner glow lives as a fixed full-screen
   pseudo-element so it doesn't affect layout. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--rv-glow);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

/* ─── Wordmark (typographic, no logomark) ────────────────── */
.rv-wordmark {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--rv-ink-2);
  text-transform: lowercase;
  font-variant-ligatures: common-ligatures;
  display: inline-flex;
  align-items: baseline;
  gap: 0.18em;
  text-decoration: none;
}
.rv-wordmark__dot {
  display: inline-block;
  width: 0.18em;
  height: 0.18em;
  border-radius: 50%;
  background: var(--rv-accent);
  transform: translateY(-0.05em);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.rv-btn {
  appearance: none;
  border: 0;
  background: var(--rv-ink-1);
  color: var(--rv-bg);
  font-family: var(--rv-sans);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.02em;
  padding: 18px 38px;
  border-radius: var(--rv-r-pill);
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  transition: transform var(--rv-dur-fast) var(--rv-ease-soft),
              background var(--rv-dur-base);
  text-decoration: none;
}
.rv-btn:hover { transform: translateY(-1px); }
.rv-btn:active { transform: translateY(0); }
.rv-btn[disabled] { opacity: 0.4; cursor: default; transform: none; }
.rv-btn__arrow {
  font-family: var(--rv-serif);
  font-style: italic;
  opacity: 0.7;
  font-size: 14px;
}
.rv-btn--ghost {
  background: transparent;
  color: var(--rv-ink-1);
  border: 1px solid var(--rv-hairline);
}
.rv-btn--sm { padding: 10px 18px; font-size: 14px; }

/* ─── Hairline rule ──────────────────────────────────────── */
.rv-hairline { height: 1px; background: var(--rv-hairline); flex: 1; }

/* ─── Forms ──────────────────────────────────────────────── */
.rv-field { display: block; margin-bottom: var(--rv-s-5); }
.rv-input,
.rv-textarea {
  width: 100%;
  font-family: var(--rv-serif);
  font-size: 19px;
  line-height: 1.5;
  color: var(--rv-ink-1);
  background: var(--rv-bg-elev);
  border: 1px solid var(--rv-hairline);
  border-radius: var(--rv-r-lg);
  padding: 14px 16px;
  outline: none;
  transition: border-color var(--rv-dur-fast) var(--rv-ease-soft);
}
.rv-input:focus, .rv-textarea:focus { border-color: var(--rv-accent); }
.rv-textarea { min-height: 140px; resize: vertical; }

.rv-chips { display: flex; flex-wrap: wrap; gap: var(--rv-s-2); margin-top: var(--rv-s-3); }
.rv-chip {
  font-family: var(--rv-sans);
  font-size: 13px;
  color: var(--rv-ink-3);
  background: transparent;
  border: 1px solid var(--rv-hairline);
  border-radius: var(--rv-r-pill);
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--rv-dur-fast) var(--rv-ease-soft), color var(--rv-dur-fast);
}
.rv-chip:hover { background: var(--rv-bg-elev); color: var(--rv-ink-1); }

/* ─── Page shells ────────────────────────────────────────── */
.rv-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ─── Landing ────────────────────────────────────────────── */
.rv-landing { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.rv-landing__head {
  padding: 28px 28px 0;
  display: flex;
  justify-content: center;
}
.rv-landing__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 28px 64px;
}
.rv-eyebrow {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rv-ink-3);
  margin: 0 0 28px;
}
.rv-headline {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 38px;
  line-height: 1.12;
  letter-spacing: -0.012em;
  color: var(--rv-ink-1);
  margin: 0;
  max-width: 320px;
  text-wrap: balance;
}
.rv-headline em.rv-accent { font-style: italic; color: var(--rv-accent); }
.rv-cta-block { margin-top: 44px; }
.rv-trial-note {
  margin-top: 18px;
  font-family: var(--rv-sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--rv-ink-3);
}
.rv-landing__foot {
  padding: 14px 28px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rv-stamp {
  font-family: var(--rv-sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rv-ink-4);
}
.rv-tagline {
  font-family: var(--rv-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--rv-ink-4);
}

@media (min-width: 720px) {
  .rv-landing__head { padding: 36px 56px; justify-content: flex-start; }
  .rv-landing__main { padding: 0 64px 80px; }
  .rv-eyebrow { font-size: 16px; margin-bottom: 40px; }
  .rv-headline { font-size: 64px; max-width: 760px; }
  .rv-cta-block { margin-top: 56px; }
  .rv-landing__foot { padding: 20px 56px 28px; }
}

/* ─── Input flow ─────────────────────────────────────────── */
.rv-flow-wrap {
  max-width: 36rem;
  width: 100%;
  margin: 0 auto;
  padding: var(--rv-s-7) var(--rv-s-5);
  flex: 1;
}
.rv-flow-head {
  display: flex;
  justify-content: center;
  margin-bottom: var(--rv-s-7);
}
.rv-step { display: none; }
.rv-step.is-active { display: block; animation: rv-fade-in 480ms var(--rv-ease-soft); }
@keyframes rv-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rv-step__meta {
  font-family: var(--rv-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rv-ink-4);
  margin: 0 0 var(--rv-s-3);
}
.rv-step__title {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: -0.005em;
  margin: 0 0 var(--rv-s-5);
  color: var(--rv-ink-1);
}
.rv-step__nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--rv-s-6);
  gap: var(--rv-s-3);
}
.rv-back {
  font-family: var(--rv-sans);
  font-size: 14px;
  color: var(--rv-ink-3);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 8px 12px;
}
.rv-back:hover { color: var(--rv-ink-1); }

/* ─── Scene runtime ──────────────────────────────────────── */
.rv-scene-shell {
  max-width: 38rem;
  margin: 0 auto;
  padding: var(--rv-s-7) var(--rv-s-5) 200px;
}
.rv-scene-marker {
  display: flex;
  align-items: center;
  gap: var(--rv-s-3);
  margin-bottom: var(--rv-s-6);
}
.rv-scene-marker__label {
  font-family: var(--rv-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rv-ink-4);
}
.rv-scene-marker__slug {
  font-family: var(--rv-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--rv-ink-3);
}

.rv-turn { margin: 0 0 var(--rv-s-5); }
.rv-turn-nora {
  font-family: var(--rv-serif);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.55;
  letter-spacing: -0.003em;
  color: var(--rv-ink-1);
  font-variation-settings: 'opsz' 18;
  text-wrap: pretty;
  white-space: pre-wrap;
}
.rv-turn-nora p { margin: 0 0 1em; }
.rv-turn-nora p:last-child { margin-bottom: 0; }

.rv-turn-user {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--rv-ink-3);
  padding-left: 1.5em;
  border-left: 1px solid var(--rv-hairline);
  margin: 4px 0;
  white-space: pre-wrap;
}

.rv-cursor {
  display: inline-block;
  width: 0.4em;
  height: 1em;
  background: var(--rv-accent);
  margin-left: 2px;
  transform: translateY(0.15em);
  animation: rv-blink 900ms steps(2, end) infinite;
}
@keyframes rv-blink {
  50% { opacity: 0; }
}

@media (min-width: 720px) {
  .rv-turn-nora { font-size: 20px; font-variation-settings: 'opsz' 20; }
  .rv-turn-user { font-size: 16px; }
}

/* Composer (input dock at bottom) */
.rv-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--rv-s-5) var(--rv-s-4) var(--rv-s-4);
  background: linear-gradient(to top, var(--rv-bg) 78%, color-mix(in oklch, var(--rv-bg) 80%, transparent));
  display: flex;
  justify-content: center;
  z-index: 2;
}
.rv-composer__inner {
  max-width: 38rem;
  width: 100%;
  display: flex;
  gap: var(--rv-s-3);
  align-items: flex-end;
}
.rv-composer textarea {
  flex: 1;
  font-family: var(--rv-serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.5;
  color: var(--rv-ink-1);
  background: var(--rv-bg-elev);
  border: 1px solid var(--rv-hairline);
  border-radius: var(--rv-r-xl);
  padding: 12px 18px;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  outline: none;
  transition: border-color var(--rv-dur-fast) var(--rv-ease-soft);
}
.rv-composer textarea::placeholder { color: var(--rv-ink-4); font-style: italic; }
.rv-composer textarea:focus { border-color: var(--rv-accent); }
.rv-send {
  font-family: var(--rv-sans);
  font-weight: 500;
  font-size: 14px;
  padding: 14px 22px;
  border: 0;
  border-radius: var(--rv-r-pill);
  background: var(--rv-ink-1);
  color: var(--rv-bg);
  cursor: pointer;
  min-height: 48px;
  transition: transform var(--rv-dur-fast) var(--rv-ease-soft);
}
.rv-send:hover { transform: translateY(-1px); }
.rv-send[disabled] { opacity: 0.4; cursor: default; transform: none; }

/* Scene-ending visual effect */
.rv-scene-shell.is-ending {
  filter: blur(0.4px);
  opacity: 0.92;
  transition: filter var(--rv-dur-scene) var(--rv-ease-scene),
              opacity var(--rv-dur-scene) var(--rv-ease-scene);
}

/* ─── Subscribe modal ─────────────────────────────────────── */
.rv-modal-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(30% 0.02 30 / 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--rv-s-4);
  z-index: 10;
  opacity: 0;
  transition: opacity var(--rv-dur-base) var(--rv-ease-soft);
}
@media (prefers-color-scheme: dark) {
  .rv-modal-backdrop { background: oklch(8% 0.01 35 / 0.55); }
}
.rv-modal-backdrop.is-open { opacity: 1; }
.rv-modal-backdrop[hidden] { display: none; }

.rv-modal {
  width: 100%;
  max-width: 480px;
  background: var(--rv-bg-elev);
  color: var(--rv-ink-1);
  border: 1px solid var(--rv-hairline);
  border-radius: var(--rv-r-xl);
  box-shadow: var(--rv-shadow-lift);
  overflow: hidden;
  font-family: var(--rv-sans);
  transform: translateY(8px);
  transition: transform var(--rv-dur-base) var(--rv-ease-soft);
}
.rv-modal-backdrop.is-open .rv-modal { transform: translateY(0); }

.rv-modal__head {
  padding: 26px 26px 0;
}
.rv-modal__epigraph {
  text-align: center;
  margin-bottom: 18px;
  font-family: var(--rv-sans);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--rv-ink-3);
}
.rv-modal__title {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: var(--rv-ink-1);
  margin: 0;
  text-align: center;
  text-wrap: balance;
}
.rv-modal__body {
  margin: 14px 0 0;
  text-align: center;
  font-family: var(--rv-serif);
  font-size: 15px;
  line-height: 1.55;
  color: var(--rv-ink-2);
  text-wrap: pretty;
}

.rv-modal__choices {
  padding: 22px 26px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rv-choice {
  appearance: none;
  text-align: left;
  padding: 18px 20px;
  background: transparent;
  border: 1px solid var(--rv-hairline);
  border-radius: var(--rv-r-lg);
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--rv-sans);
  color: var(--rv-ink-1);
  transition: background var(--rv-dur-fast), border-color var(--rv-dur-fast);
  min-height: 64px;
}
.rv-choice:hover { background: var(--rv-bg-sink); }
.rv-choice--selected {
  background: var(--rv-bg-elev);
  border-color: var(--rv-ink-2);
}
.rv-choice__left { display: flex; flex-direction: column; gap: 4px; }
.rv-choice__label { font-size: 14px; font-weight: 500; letter-spacing: 0.02em; }
.rv-choice__note { font-family: var(--rv-serif); font-style: italic; font-size: 13px; color: var(--rv-ink-3); }
.rv-choice__right { display: flex; align-items: baseline; gap: 4px; }
.rv-choice__price { font-family: var(--rv-serif); font-weight: 400; font-size: 24px; color: var(--rv-ink-1); letter-spacing: -0.01em; }
.rv-choice__cadence { font-size: 12px; color: var(--rv-ink-3); letter-spacing: 0.04em; }

.rv-modal__cta {
  padding: 12px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.rv-btn--block { width: 100%; justify-content: center; }
.rv-let-go {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--rv-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--rv-ink-3);
  cursor: pointer;
  padding: 6px 14px;
}
.rv-let-go:hover { color: var(--rv-ink-1); }

.rv-modal__fineprint {
  border-top: 1px solid var(--rv-hairline);
  padding: 12px 28px;
  background: var(--rv-bg-sink);
  font-family: var(--rv-sans);
  font-size: 11px;
  color: var(--rv-ink-4);
  text-align: center;
  letter-spacing: 0.02em;
}

@media (min-width: 720px) {
  .rv-modal__head { padding: 32px 36px 0; }
  .rv-modal__title { font-size: 30px; }
  .rv-modal__body { font-size: 16px; }
  .rv-modal__choices { padding: 24px 36px 8px; }
  .rv-modal__cta { padding: 12px 36px 30px; }
}

/* ─── Library ────────────────────────────────────────────── */
.rv-library-list {
  display: flex;
  flex-direction: column;
  gap: var(--rv-s-3);
  margin-top: var(--rv-s-3);
}
.rv-library-card {
  display: block;
  text-decoration: none;
  color: var(--rv-ink-1);
  background: var(--rv-bg-elev);
  border: 1px solid var(--rv-hairline);
  border-radius: var(--rv-r-lg);
  padding: var(--rv-s-5) var(--rv-s-5);
  transition: transform var(--rv-dur-fast) var(--rv-ease-soft),
              border-color var(--rv-dur-fast),
              background var(--rv-dur-fast);
}
.rv-library-card:hover {
  transform: translateY(-1px);
  border-color: var(--rv-ink-3);
  background: var(--rv-bg);
}
.rv-library-card__head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-family: var(--rv-sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rv-ink-3);
  margin-bottom: var(--rv-s-2);
}
.rv-library-card__loc { font-weight: 500; color: var(--rv-ink-2); }
.rv-library-card__sep { opacity: 0.4; }
.rv-library-card__desc {
  font-family: var(--rv-serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.5;
  color: var(--rv-ink-2);
  margin-bottom: var(--rv-s-2);
}
.rv-library-card__meta {
  font-family: var(--rv-sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--rv-ink-4);
}

/* ─── Legal pages (privacy + terms) ──────────────────────── */
.rv-legal h1 { margin-bottom: var(--rv-s-7); }
.rv-legal h2 {
  font-family: var(--rv-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.005em;
  color: var(--rv-ink-1);
  margin: var(--rv-s-7) 0 var(--rv-s-3);
}
.rv-legal p, .rv-legal li {
  font-family: var(--rv-serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--rv-ink-2);
  text-wrap: pretty;
}
.rv-legal ul { padding-left: var(--rv-s-5); margin: var(--rv-s-3) 0; }
.rv-legal li { margin-bottom: var(--rv-s-2); }
.rv-legal strong { color: var(--rv-ink-1); font-weight: 500; }
.rv-legal__footer {
  margin-top: var(--rv-s-7);
  padding-top: var(--rv-s-4);
  border-top: 1px solid var(--rv-hairline);
  font-family: var(--rv-sans);
  font-size: 13px;
  font-style: italic;
  color: var(--rv-ink-4);
}

/* Wire privacy/terms links into the landing footer */
.rv-landing__foot-links {
  display: flex;
  gap: var(--rv-s-3);
  align-items: center;
}
.rv-landing__foot-links a {
  font-family: var(--rv-sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rv-ink-4);
  text-decoration: none;
}
.rv-landing__foot-links a:hover { color: var(--rv-ink-2); }
.rv-landing__foot-links span { color: var(--rv-ink-4); opacity: 0.4; }
