/* Azorian beta — editorial light theme ported from the approved atelier mockup
   (2026-07-28-azorian-chat/final). Fraunces / Instrument Sans / Spline Sans Mono,
   terracotta accent. Layout adapted to a live chat: header + scrollable thread +
   bottom composer, stepper driven by `stage` NDJSON events (app.js). */

:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --ink: #1C1915;
  --ink-soft: #4A453D;
  --muted: #6F6A5F;
  --faint: #8A8375;
  --hairline: #E8E4DC;
  --hairline-soft: #F0EDE7;
  --accent: #B0521F;
  --accent-soft: #F6EBE2;
  --ok: #5A7A52;
  --shadow: 0 1px 2px rgba(28,25,21,.04), 0 4px 16px rgba(28,25,21,.03);
  --sans: "Instrument Sans", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "Spline Sans Mono", ui-monospace, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "ss01";
  height: 100dvh;
  display: flex; flex-direction: column;
}
::selection { background: var(--accent-soft); color: var(--ink); }
button, textarea, input { font-family: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---------- Header ---------- */
header {
  flex: none; z-index: 20;
  background: rgba(250,248,245,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.hdr-row {
  max-width: 1120px; margin: 0 auto;
  padding: 14px 32px 12px;
  display: flex; align-items: baseline; gap: 14px;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: .14em;
}
.wordmark span { color: var(--accent); }
.tag { font-size: 12px; color: var(--muted); letter-spacing: .01em; }

/* ---------- Stepper ---------- */
.stepper-band {
  max-width: 1120px; margin: 0 auto;
  padding: 10px 32px 12px;
}
ol.stepper {
  list-style: none;
  display: flex; align-items: flex-start;
}
ol.stepper li {
  display: flex; align-items: flex-start;
  flex: 1 1 0; min-width: 0;
}
ol.stepper li:last-child { flex: 0 0 auto; }
.step {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.step-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--faint);
  white-space: nowrap;
}
.step-num {
  font-family: var(--mono); font-size: 10.5px;
  width: 17px; height: 17px; flex: none;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.step.done .step-head { color: var(--muted); }
.step.done .step-num { border-color: var(--hairline); color: var(--ok); }
.step.current .step-head { color: var(--ink); font-weight: 600; }
.step.current .step-num {
  border-color: var(--accent); color: var(--accent); font-weight: 500;
}
.step-label { position: relative; padding-bottom: 3px; }
.step.current .step-label::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: var(--accent); border-radius: 1px;
}
.substatus {
  font-size: 11px; color: var(--muted);
  padding-left: 24px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.connector {
  flex: 1 1 auto; height: 1px; background: var(--hairline);
  margin: 8px 10px 0;
  min-width: 12px;
}
.check svg { display: block; }

/* condensed stepper (mobile) */
.stepper-mini { display: none; }

/* ---------- Thread ---------- */
main {
  flex: 1 1 auto; overflow-y: auto;
  padding: 36px 32px 40px;
}
main > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.msg { margin-bottom: 28px; }
.msg-meta {
  font-family: var(--mono);
  font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}
.bot .msg-meta { color: var(--accent); }
.bot .body {
  color: var(--ink-soft);
  white-space: pre-wrap; overflow-wrap: break-word;
}
.bot .body b, .bot .body strong { color: var(--ink); font-weight: 600; }
.bot .body code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.user { display: flex; flex-direction: column; align-items: flex-end; }
.user .bubble {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 16px;
  max-width: 46ch;
  box-shadow: var(--shadow);
  white-space: pre-wrap; overflow-wrap: break-word;
}

.msg.error {
  font-family: var(--mono); font-size: 12.5px;
  color: #8A2F1B;
  background: var(--accent-soft);
  border: 1px solid #E7CDBB;
  border-radius: 8px;
  padding: 10px 14px;
}

/* ---------- Status lines ---------- */
.status {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 12px;
  color: var(--faint);
  margin: 18px auto;
  padding-left: 2px;
}
.status .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--hairline); flex: none;
  outline: 3px solid var(--bg);
}
.status.past .dot { background: var(--ok); opacity: .5; }
.status.live { color: var(--ink-soft); }
.status.live .dot {
  background: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(176,82,31,.35); }
  50% { box-shadow: 0 0 0 5px rgba(176,82,31,0); }
}
.status.live em {
  font-style: normal;
  animation: fade 1.8s ease-in-out infinite;
}
@keyframes fade { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---------- Wait indicator (pre-first-event; atelier 2026-07-29, C+A composite) ---------- */
.wait { overflow: hidden; }
.wait .serif-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 24px;
  color: var(--ink-soft);
  min-height: 1.4em; /* reserve the line before its text lands (announced post-insert) */
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.wait .wait-row {
  display: flex; align-items: center; gap: 14px;
  max-width: 460px; margin-top: 14px;
}
.wait .track {
  flex: 1 1 auto; position: relative; height: 1px;
  background: var(--hairline);
}
.wait .track i {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--accent);
  transition: width .45s ease;
}
.wait .elapsed {
  flex: none;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.wait.leaving {
  opacity: 0; height: 0 !important; margin-bottom: 0;
  transition: opacity .3s ease, height .35s ease, margin-bottom .35s ease;
}
@media (prefers-reduced-motion: reduce) {
  .wait .track { display: none; } /* counter alone carries the signal (no stepping bar) */
}

/* ---------- Tables (bot markdown — coverage-card styling) ---------- */
.bot .body table {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 10px 0;
  white-space: normal;
}
.bot .body th {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 400;
  text-align: left;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--hairline-soft);
}
.bot .body td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: baseline;
  color: var(--ink-soft);
}
.bot .body tr:last-child td { border-bottom: none; }
.bot .body th.num { text-align: right; }
.bot .body td.num {
  font-family: var(--mono); font-size: 13px;
  text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.bot .body td.num.full { color: var(--ok); }
.bot .body td.num.low { color: var(--ink); font-weight: 600; }

/* ---------- Artifact card ---------- */
.artifact {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 20px;
  max-width: 460px;
}
.artifact .doc-ico {
  flex: none;
  width: 40px; height: 48px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--hairline-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.artifact .meta { flex: 1 1 auto; min-width: 200px; }
.artifact .name {
  font-family: var(--mono); font-size: 13px;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.artifact .sub {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px;
  font-size: 12px; color: var(--muted);
}
.badge {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .09em;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
}
.dl-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 44px;
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.dl-btn:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
@media (max-width: 520px) {
  .artifact .dl-btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- Composer ---------- */
.composer-wrap {
  flex: none; z-index: 20;
  background: var(--bg);
  padding: 12px 32px 16px;
}
.composer {
  max-width: 760px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px 8px 6px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.icon-btn {
  flex: none;
  min-width: 44px; min-height: 44px;
  border: none; background: none;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hairline-soft); color: var(--ink); }
.composer textarea {
  flex: 1 1 auto;
  border: none; background: none; resize: none;
  font-size: 16px; line-height: 1.5;
  color: var(--ink);
  padding: 8px 4px;
  max-height: 160px;
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--faint); }
.send-btn {
  flex: none;
  min-width: 44px; min-height: 44px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.send-btn:hover { background: #984517; }
.send-btn:disabled { opacity: .45; cursor: default; }
.send-btn:disabled:hover { background: var(--accent); }
.composer-hint {
  max-width: 760px; margin: 8px auto 0;
  font-size: 11px; color: var(--faint);
  text-align: center;
}

/* ---------- Token dialog ---------- */
dialog {
  margin: auto;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  width: min(340px, 90vw);
}
dialog::backdrop { background: rgba(28,25,21,.35); }
.dlg-title {
  font-family: var(--serif);
  font-weight: 600; font-size: 17px;
  margin-bottom: 4px;
}
.dlg-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
dialog input {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  margin-bottom: 12px;
  background: var(--bg);
  color: var(--ink);
}
dialog input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dlg-btn {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  transition: background .15s;
}
.dlg-btn:hover { background: var(--ink-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  ol.stepper { display: none; }
  .stepper-mini { display: block; }
  .stepper-mini .mini-line {
    display: flex; align-items: baseline; justify-content: space-between;
    font-size: 12.5px;
  }
  .stepper-mini .mini-step { font-weight: 600; }
  .stepper-mini .mini-step b {
    font-family: var(--mono); font-weight: 500; color: var(--accent);
    margin-right: 6px;
  }
  .stepper-mini .mini-sub {
    color: var(--muted); font-size: 11px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-left: 12px;
  }
  .progress {
    margin-top: 7px; height: 2px; border-radius: 1px;
    background: var(--hairline);
    overflow: hidden;
  }
  .progress i {
    display: block; height: 100%; width: 0;
    background: var(--accent); border-radius: 1px;
    transition: width .3s ease;
  }
}
@media (max-width: 640px) {
  .hdr-row { padding: 12px 18px 10px; flex-wrap: wrap; gap: 10px; }
  .tag { font-size: 11px; }
  .stepper-band { padding: 8px 18px 12px; }
  main { padding: 26px 18px 30px; }
  .bot .body table { font-size: 12.5px; }
  .bot .body th, .bot .body td { padding-left: 12px; padding-right: 12px; }
  .composer-wrap { padding: 10px 12px 14px; }
  .user .bubble { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
