:root {
  --ink: #0a0d10;
  --ink-soft: #12171c;
  --ink-line: #26313a;
  --paper: #f6f3ec;
  --paper-card: #ffffff;
  --graphite: #1c2126;
  --graphite-soft: #4b535a;
  --paper-line: #e2ddd0;
  --brass: #c9a45c;
  --brass-dim: #a3823f;
  --teal: #4fd1c5;
  --teal-dim: #2f8f86;
  --danger: #c1584a;

  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--graphite);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

p { margin: 0; }

a { color: inherit; }

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

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(246, 243, 236, 0.65);
  margin: 0 0 1rem;
}
.eyebrow-dark { color: var(--brass-dim); }

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--brass);
  color: #1a1206;
}
.btn-primary:hover { background: #d8b26c; }
.btn-ghost {
  background: transparent;
  border-color: rgba(246, 243, 236, 0.35);
  color: var(--paper);
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-block { width: 100%; margin-top: 0.5rem; }
.btn-nav-cta {
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1.3rem;
  font-size: 0.85rem;
}
.btn-nav-cta:hover { background: var(--brass); color: #1a1206; }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  padding: 1.1rem 0;
  transition: background 0.3s var(--ease), padding 0.3s var(--ease), border-color 0.3s var(--ease);
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(10, 13, 16, 0.78);
  backdrop-filter: blur(14px);
  padding: 0.7rem 0;
  border-color: rgba(246, 243, 236, 0.08);
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.06em;
  color: var(--paper);
  text-decoration: none;
}
.wordmark.small { color: var(--ink); font-size: 1.05rem; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}
.nav-links a {
  color: rgba(246, 243, 236, 0.85);
  text-decoration: none;
  font-size: 0.92rem;
}
.nav-links a:hover { color: var(--teal); }
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px; height: 1.5px;
  background: var(--paper);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  background: radial-gradient(ellipse at 70% 20%, #171d23 0%, var(--ink) 60%);
  overflow: hidden;
  display: flex;
  align-items: center;
}
#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hero-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,13,16,0.1) 0%, rgba(10,13,16,0.55) 78%, var(--ink) 100%);
  pointer-events: none;
}
.hero-content {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8rem 1.5rem 6rem;
  width: 100%;
}
.hero h1 {
  color: var(--paper);
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: 1.02;
  font-weight: 400;
  max-width: 14ch;
}
.hero-sub {
  color: rgba(246, 243, 236, 0.72);
  font-size: 1.1rem;
  max-width: 46ch;
  margin: 1.75rem 0 2.5rem;
}
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.scroll-cue {
  position: absolute;
  bottom: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: rgba(246, 243, 236, 0.55);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  animation: float 2.6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}

/* ---------- Values ---------- */
.values {
  max-width: 1180px;
  margin: 0 auto;
  padding: 7rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}
.value-col h2 {
  font-size: 2rem;
  margin: 0 0 1rem;
}
.value-col p {
  color: var(--graphite-soft);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 40ch;
}

/* ---------- How it works ---------- */
.how {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem 7rem;
}
.how h2 { font-size: 2rem; margin: 0.6rem 0 3rem; }
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
}
.step {
  border-top: 1px solid var(--paper-line);
  padding-top: 1.5rem;
}
.step-num {
  font-family: var(--font-mono);
  color: var(--teal-dim);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}
.step h3 {
  font-size: 1.15rem;
  margin: 0.6rem 0 0.5rem;
}
.step p {
  color: var(--graphite-soft);
  font-size: 0.94rem;
  line-height: 1.55;
}

/* ---------- Book ---------- */
.book {
  background: var(--ink);
  padding: 6rem 1.5rem;
}
.book-grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 3.5rem;
  align-items: start;
}
.book-copy h2 {
  color: var(--paper);
  font-size: 2.1rem;
  margin-bottom: 1rem;
}
.book-copy p {
  color: rgba(246, 243, 236, 0.65);
  max-width: 34ch;
  line-height: 1.6;
}
.book-form {
  background: var(--paper-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: grid;
  gap: 1.1rem;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}
label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--graphite);
}
input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.98rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  font-weight: 400;
  background: #fbfaf6;
  color: var(--graphite);
  transition: border-color 0.2s var(--ease);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  outline: none;
}
textarea { resize: vertical; }
.result-banner {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  display: none;
  white-space: pre-wrap;
}
.result-banner.show { display: block; }
.result-banner.ok { background: #eaf6f2; color: #1f6f5c; }
.result-banner.error { background: #faeceb; color: var(--danger); }

/* ---------- Status ---------- */
.status {
  max-width: 1180px;
  margin: 0 auto;
  padding: 6rem 1.5rem 8rem;
}
.status h2 { font-size: 2rem; margin: 0.6rem 0 2rem; }
.status-form {
  display: flex;
  gap: 0.8rem;
  max-width: 480px;
}
.status-form input {
  flex: 1;
  font-family: var(--font-mono);
}
.status-result {
  margin-top: 1.5rem;
  background: var(--ink-soft);
  color: #d7e6e3;
  padding: 1.2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  max-width: 480px;
  overflow-x: auto;
  min-height: 1.2em;
}

/* ---------- Footer ---------- */
.footer {
  background: var(--ink);
  color: rgba(246, 243, 236, 0.5);
  padding: 2.5rem 1.5rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: space-between;
  font-size: 0.85rem;
  border-top: 1px solid rgba(246, 243, 236, 0.08);
}
.footer .wordmark.small { color: var(--paper); }

/* ---------- Chat widget ---------- */
.chat-fab {
  position: fixed;
  bottom: 1.8rem;
  right: 1.8rem;
  z-index: 60;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--brass);
  color: #1a1206;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px -8px rgba(201, 164, 92, 0.6);
  transition: transform 0.25s var(--ease);
}
.chat-fab:hover { transform: scale(1.06); }

.chat-panel {
  position: fixed;
  bottom: 1.8rem;
  right: 1.8rem;
  z-index: 60;
  width: min(380px, calc(100vw - 2.4rem));
  height: min(560px, calc(100vh - 6rem));
  background: var(--ink-soft);
  border-radius: var(--radius-lg);
  border: 1px solid var(--ink-line);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 0.28s var(--ease);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--ink-line);
  color: var(--paper);
}
.chat-header strong { font-family: var(--font-display); font-size: 1.05rem; }
.chat-header p {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: rgba(246, 243, 236, 0.55);
  line-height: 1.4;
}
.chat-header button {
  background: none;
  border: none;
  color: rgba(246, 243, 236, 0.6);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-msg {
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  max-width: 85%;
}
.chat-msg.assistant {
  background: rgba(79, 209, 197, 0.12);
  color: #d7e6e3;
  align-self: flex-start;
  border: 1px solid rgba(79, 209, 197, 0.2);
}
.chat-msg.user {
  background: var(--brass);
  color: #1a1206;
  align-self: flex-end;
}
.chat-msg.error {
  background: rgba(193, 88, 74, 0.15);
  color: #f0b9b0;
  align-self: flex-start;
}
.chat-form {
  display: flex;
  gap: 0.6rem;
  padding: 0.9rem;
  border-top: 1px solid var(--ink-line);
}
.chat-form input {
  flex: 1;
  background: rgba(246, 243, 236, 0.06);
  border: 1px solid var(--ink-line);
  color: var(--paper);
}
.chat-form input::placeholder { color: rgba(246, 243, 236, 0.4); }
.chat-form button {
  width: 40px;
  border-radius: 50%;
  border: none;
  background: var(--brass);
  color: #1a1206;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-cue { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
  .values { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .book-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .chat-panel { right: 0.7rem; bottom: 0.7rem; }
  .chat-fab { right: 1.2rem; bottom: 1.2rem; }
}
