:root {
  --bg: #0d0d0d;
  --bg-2: #141414;
  --bg-3: #1a1a1a;
  --text: #e8e2d6;
  --text-dim: #a89f8d;
  --text-faint: #6b6357;
  --accent: #d8c9a8;
  --accent-strong: #e8d6ae;
  --line: rgba(216, 201, 168, 0.18);
  --line-strong: rgba(216, 201, 168, 0.32);
  --bubble-user: #2a241a;
  --bubble-bot: #1a1a1a;
  --serif: 'Cormorant Garamond', Garamond, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --header-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  overflow: hidden;
}

/* ───── chat layout ───── */
.chat-body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
}

.chat-header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  background: rgba(13,13,13,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
  z-index: 10;
}
.chat-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-h);
  padding: 0 18px;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a2f22, #1a1a1a);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  position: relative;
  flex: 0 0 auto;
}
.avatar-dot {
  position: absolute;
  right: -2px; bottom: -2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #6fbf73;
  border: 2px solid var(--bg);
}
.chat-titles { line-height: 1.2; }
.chat-title {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.chat-status {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 2px;
}

.chat-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.chat-stream::-webkit-scrollbar { width: 6px; }
.chat-stream::-webkit-scrollbar-thumb { background: rgba(216,201,168,0.15); border-radius: 3px; }

.loading {
  align-self: center;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.2em;
  padding: 30px 0;
}

/* ───── bubbles ───── */
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: fade-in 0.18s ease-out;
}
.msg.user {
  align-self: flex-end;
  background: var(--bubble-user);
  border: 1px solid rgba(216,201,168,0.12);
  border-bottom-right-radius: 6px;
  color: var(--text);
}
.msg.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  border: 1px solid rgba(216,201,168,0.08);
  border-bottom-left-radius: 6px;
  color: var(--text);
}
.msg.bot.error { color: #e08a8a; }
.msg.typing {
  align-self: flex-start;
  background: var(--bubble-bot);
  border-bottom-left-radius: 6px;
  padding: 14px 16px;
}
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: bob 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bob {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ───── composer ───── */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(13,13,13,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.composer-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;          /* 16px prevents iOS zoom on focus */
  font-weight: 300;
  padding: 10px 16px;
  resize: none;
  max-height: 140px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.2s;
}
.composer-input:focus { border-color: rgba(216,201,168,0.4); }
.composer-input::placeholder { color: var(--text-dim); }

.composer-send {
  width: 44px; height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #1a1410;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}
.composer-send:hover { transform: scale(1.05); }
.composer-send:disabled { opacity: 0.35; cursor: default; transform: none; }
.composer-send svg { display: block; }

/* ────────────────────────────────────────────────────────────────────── */
/* ───── HERO / SIGNUP ─────────────────────────────────────────────────── */
/* ────────────────────────────────────────────────────────────────────── */

.hero {
  position: fixed; inset: 0;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  z-index: 100;
}

.hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 55% at 20% 20%, rgba(216, 201, 168, 0.10), transparent 70%),
    radial-gradient(80% 60% at 80% 90%, rgba(180, 130, 90, 0.10), transparent 65%),
    radial-gradient(120% 100% at 50% 50%, #0d0d0d, #060606 80%);
  pointer-events: none;
}

.hero-grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.95  0 0 0 0 0.85  0 0 0 0.05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.55;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: 540px;
  margin: 0 auto;
  padding: clamp(48px, 10vh, 96px) 28px clamp(40px, 8vh, 80px);
  padding-top: calc(clamp(48px, 10vh, 96px) + var(--safe-top));
  padding-bottom: calc(clamp(40px, 8vh, 80px) + var(--safe-bottom));
}

.hero-mark {
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.4em;
  color: var(--accent);
  text-align: center;
  margin-bottom: 36px;
  opacity: 0.85;
}

.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(48px, 13vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  text-align: center;
  margin: 0 0 26px;
  color: var(--text);
}
.hero-title-italic {
  font-style: italic;
  font-weight: 400;
  color: var(--accent-strong);
}

.hero-tagline {
  font-family: var(--serif);
  font-size: clamp(18px, 4.2vw, 22px);
  font-weight: 400;
  line-height: 1.45;
  text-align: center;
  margin: 0 auto 44px;
  max-width: 380px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

/* ───── signup form ───── */
.signup {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.signup-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: block;
  position: relative;
}
.field-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
  padding-left: 2px;
}
.field-input {
  width: 100%;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: 0;
  border-bottom: 1px solid var(--line-strong);
  border-top: none;
  border-left: none;
  border-right: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 300;
  padding: 10px 0 12px;
  outline: none;
  transition: border-color 0.2s, color 0.2s;
}
.field-input::placeholder { color: var(--text-faint); font-weight: 300; }
.field-input:focus {
  border-bottom-color: var(--accent);
}
.field-input:invalid:not(:placeholder-shown) {
  border-bottom-color: rgba(224, 138, 138, 0.6);
}

.signup-cta {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: #15110b;
  border: none;
  border-radius: 100px;
  padding: 16px 28px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  box-shadow: 0 0 0 0 rgba(216,201,168,0.3);
}
.signup-cta:hover {
  background: var(--accent-strong);
  box-shadow: 0 0 32px 0 rgba(216,201,168,0.18);
}
.signup-cta:active { transform: scale(0.985); }
.signup-cta:disabled {
  opacity: 0.55;
  cursor: default;
  background: var(--accent);
  box-shadow: none;
}
.signup-cta-text { line-height: 1; }
.signup-cta.is-loading .signup-cta-arrow { display: none; }
.signup-cta-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,0.18);
  border-top-color: #15110b;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.signup-cta.is-loading .signup-cta-spinner { display: inline-block; }

.signup-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: #e08a8a;
  text-align: center;
  letter-spacing: 0.01em;
}

.signup-fineprint {
  margin: 18px auto 0;
  max-width: 360px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-faint);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ───── divider + meta ───── */
.hero-divider {
  margin: 56px auto 32px;
  height: 1px;
  width: 60%;
  max-width: 240px;
  background: linear-gradient(to right, transparent, var(--line-strong), transparent);
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}
.hero-meta-num {
  font-family: var(--serif);
  font-size: clamp(28px, 7vw, 36px);
  font-weight: 500;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 8px;
}
.hero-meta-label {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-faint);
  line-height: 1.4;
}

/* ───── splash ───── */
.splash-body {
  height: 100dvh;
  display: grid;
  place-items: center;
}
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.splash-spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(216,201,168,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.splash-text {
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-dim);
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 380px) {
  .hero-meta-num { font-size: 24px; }
  .hero-meta-label { font-size: 9px; letter-spacing: 0.18em; }
}

.chat-footer {
  position: fixed;
  bottom: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(216,201,168,0.42);
  pointer-events: none;
  z-index: 5;
  flex-wrap: wrap;
  padding: 0 14px;
}
.chat-footer a {
  color: rgba(216,201,168,0.55);
  text-decoration: none;
  pointer-events: auto;
  transition: color 0.2s;
}
.chat-footer a:hover { color: var(--accent); }
.chat-footer span { color: rgba(216,201,168,0.25); }
body.chatting .chat-footer { display: none; }
@media (max-width: 480px) {
  .chat-footer { font-size: 9px; gap: 6px; bottom: 10px; }
}

/* ── AI badge in header ─────────────────────────────────────── */
.ai-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 500;
  text-transform: uppercase;
  color: rgba(216,201,168,0.7);
  border: 1px solid rgba(216,201,168,0.3);
  border-radius: 999px;
  vertical-align: 2px;
  cursor: help;
}

/* ── Signup consent checkbox ────────────────────────────────── */
.signup-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  font-size: 12px;
  line-height: 1.55;
  color: rgba(232,226,214,0.72);
  cursor: pointer;
}
.signup-consent input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.signup-consent strong { color: var(--text); font-weight: 500; }
.signup-consent a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ── Account menu ───────────────────────────────────────────── */
.chat-header-inner { position: relative; }
.acct-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(216,201,168,0.18);
  color: rgba(216,201,168,0.7);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.acct-btn:hover { color: var(--accent); border-color: rgba(216,201,168,0.4); }
.acct-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 14px;
  z-index: 50;
  min-width: 200px;
  background: #18130c;
  border: 1px solid rgba(216,201,168,0.14);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.acct-menu button {
  text-align: left;
  background: transparent;
  border: 0;
  color: rgba(232,226,214,0.85);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--sans);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s;
}
.acct-menu button:hover { background: rgba(216,201,168,0.08); color: var(--text); }
.acct-menu .acct-danger { color: #e08580; }
.acct-menu .acct-danger:hover { background: rgba(224,133,128,0.08); color: #f0a0a0; }
