:root {
  --ink: #100e0c;
  --ink-2: #171513;
  --ink-3: #211e1b;
  --line: #322d28;
  --paper: #f6f2ec;
  --muted: #a29a90;
  --muted-2: #6f6760;
  --orange: #f26522;
  --orange-dim: #b7481400;
  --ok: #7fb069;
  --radius: 4px;
  --display: "Archivo", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: var(--orange); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  border-right: 1px solid var(--line);
  padding: 32px 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 30px;
  background: var(--ink-2);
}

.mark {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.mark span { color: var(--orange); }
.mark-sub {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* ---------- Signature: the 75% Equation meter ---------- */

.meter { display: flex; flex-direction: column; gap: 20px; }

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.meter-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper);
}
.meter-count b { color: var(--orange); font-weight: 500; }

.pillar { display: flex; flex-direction: column; gap: 7px; }

.pillar-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.pillar.live .pillar-label { color: var(--paper); }
.pillar.done .pillar-label { color: var(--muted); }

.ticks { display: flex; gap: 4px; }
.tick {
  height: 22px;
  flex: 1;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 1px;
  transition: background 240ms ease, border-color 240ms ease;
}
.tick.filled { background: var(--orange); border-color: var(--orange); }
.tick.current {
  border-color: var(--orange);
  background: transparent;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.rail-note {
  margin-top: auto;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted-2);
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

/* ---------- Main column ---------- */

.main {
  padding: 40px 40px 0;
  display: flex;
  flex-direction: column;
  max-width: 780px;
  width: 100%;
  min-height: 100vh;
}

.screen { display: none; flex-direction: column; flex: 1; min-height: 0; }
.screen.active { display: flex; }

/* ---------- Gate ---------- */

.gate { justify-content: center; padding-bottom: 80px; }
.gate h1 {
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin: 16px 0 18px;
  font-weight: 800;
  max-width: 15ch;
}
.gate p {
  font-size: 16px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 54ch;
  margin: 0 0 12px;
}

.field { margin-top: 26px; max-width: 400px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

input[type="text"], textarea {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 13px 14px;
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
}
input[type="text"]:focus, textarea:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  border-color: transparent;
}
input[type="text"]::placeholder, textarea::placeholder { color: #5a534c; }

.btn {
  appearance: none;
  border: 1px solid var(--orange);
  background: var(--orange);
  color: #180b03;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.01em;
  padding: 13px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 140ms ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn.ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line);
}
.btn.ghost:hover { border-color: var(--muted); filter: none; }

.error {
  margin-top: 14px;
  font-size: 13.5px;
  color: #ff9d7a;
  font-family: var(--mono);
  min-height: 18px;
}

/* ---------- Chat ---------- */

.log {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 26px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.turn { display: flex; flex-direction: column; gap: 8px; max-width: 62ch; }
.turn .who {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.turn.bot .who { color: var(--orange); }
.turn .msg { font-size: 16.5px; line-height: 1.62; white-space: pre-wrap; }
.turn.you { align-self: flex-end; align-items: flex-end; }
.turn.you .msg {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: 15.5px;
  color: #ded6cc;
}

.thinking {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted-2);
  letter-spacing: 0.08em;
}
.thinking::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

.composer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--ink) 74%, transparent);
  padding: 14px 0 26px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea { min-height: 54px; max-height: 200px; }
.hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #554e47;
  padding-bottom: 30px;
  text-align: right;
}

/* ---------- Blueprint ---------- */

.doc-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}
.doc-bar .spacer { flex: 1; }

.doc {
  padding-bottom: 90px;
  max-width: 68ch;
  font-size: 16px;
  line-height: 1.68;
}
.doc h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 30px;
  font-weight: 800;
}
.doc h2 {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 42px 0 12px;
  font-weight: 500;
}
.doc h3 {
  font-size: 17px;
  margin: 26px 0 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.doc p { margin: 0 0 14px; color: #e2dbd2; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 20px; color: #e2dbd2; }
.doc li { margin-bottom: 7px; }
.doc strong { color: var(--paper); font-weight: 700; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }
.doc blockquote {
  margin: 0 0 16px;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--orange);
  color: var(--paper);
  font-size: 17px;
}
.doc code {
  font-family: var(--mono);
  font-size: 13.5px;
  background: var(--ink-2);
  padding: 2px 5px;
  border-radius: 2px;
}

.caret {
  display: inline-block;
  width: 8px;
  height: 17px;
  background: var(--orange);
  vertical-align: -2px;
  animation: pulse 1s ease-in-out infinite;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: column;
    gap: 20px;
    padding: 20px 20px 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail-note { display: none; }
  .pillar-label { font-size: 9.5px; }
  .tick { height: 14px; }
  .main { padding: 24px 20px 0; }
  .turn { max-width: 100%; }
}

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

/* ---------- Print ---------- */

@media print {
  .rail, .doc-bar, .composer, .hint { display: none !important; }
  html, body { background: #fff; color: #111; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .doc { max-width: none; font-size: 11pt; }
  .doc h2 { color: #b7481a; }
  .doc p, .doc li, .doc ul, .doc ol { color: #222; }
  .doc strong { color: #000; }
  .caret { display: none; }
}

/* Version badge on the rail */
.badge {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orange);
  border: 1px solid var(--orange);
  border-radius: 2px;
  padding: 3px 8px;
}

/* Rail navigation between surfaces */
.nav { display: flex; flex-direction: column; gap: 6px; }
.navbtn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-left: 2px solid var(--line);
  color: var(--muted-2);
  font-family: var(--display);
  font-size: 14px;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.navbtn:hover { color: var(--paper); }
.navbtn.on { color: var(--paper); border-left-color: var(--orange); font-weight: 700; }

/* Ask surface */
.ask-head { padding-bottom: 22px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.ask-title {
  font-size: clamp(24px, 3.4vw, 34px);
  letter-spacing: -0.03em;
  font-weight: 800;
  margin: 12px 0 10px;
  line-height: 1.1;
}
.ask-sub { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0; max-width: 58ch; }
.ask-sub b { color: var(--orange); font-weight: 500; }

.turn .msg .doc-inline h3 { font-size: 16px; margin: 14px 0 6px; }
.turn.bot .msg ul, .turn.bot .msg ol { padding-left: 20px; margin: 8px 0; }
.turn.bot .msg li { margin-bottom: 5px; }
.turn.bot .msg p { margin: 0 0 10px; }
.turn.bot .msg p:last-child { margin-bottom: 0; }
.turn.bot .msg a { color: var(--orange); }

@media (max-width: 860px) {
  .nav { flex-direction: row; gap: 4px; }
  .navbtn { flex: 1; text-align: center; border-left: 0; border-bottom: 2px solid var(--line); padding: 8px 6px; font-size: 13px; }
  .navbtn.on { border-left: 0; border-bottom-color: var(--orange); }
}
