/* Alex · Intaglio Note */
:root {
  color-scheme: light;
  --paper: #ecede4;        /* currency paper ground */
  --paper-hi: #f6f7f1;     /* issued answer sheet */
  --paper-lo: #e2e4d8;     /* evidence rail */
  --rule: #c3c7b6;         /* hairlines */
  --ink: #15181a;
  --ink-soft: #4a5048;
  --face: #1f3a2e;         /* intaglio face green */
  --face-hi: #2b4d3d;
  --back: #3f6b52;         /* back green, labels */
  --on-face: #eef1e8;
  --evidence: #7f5300;     /* reserved: citations and tool calls only */
  --evidence-tint: #f1e6cf;
  --fibre-red: #a8231b;    /* state: errors, serials */
  --fibre-blue: #2b4c9a;   /* state: links */
  --ok: #2f7a4b;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Public Sans", system-ui, "Segoe UI", sans-serif;
  --engraved: "Cinzel", "Times New Roman", serif;

  --profile-w: clamp(280px, 22vw, 340px);
  --evidence-w: clamp(300px, 25vw, 390px);
  --band-h: 72px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  display: grid;
  grid-template-rows: var(--band-h) minmax(0, 1fr);
  caret-color: var(--face);
  scrollbar-color: var(--rule) transparent;
}
::selection { background: rgba(63, 107, 82, .22); color: var(--ink); }
:focus-visible { outline: 2px solid var(--face); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
a { color: var(--fibre-blue); text-underline-offset: 3px; }

/* ── Band ─────────────────────────────────────────────── */
.band {
  position: relative;
  overflow: hidden;
  background: var(--face);
  color: var(--on-face);
  display: grid;
  grid-template-columns: var(--profile-w) minmax(0, 1fr) var(--evidence-w);
  align-items: center;
}
.band > * { position: relative; padding: 0 24px; }
.band .guilloche { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; opacity: .2; pointer-events: none; }
.wordmark { font: 600 30px/1 var(--engraved); letter-spacing: .14em; margin: 0; }
.wordmark small { display: block; margin-top: 6px; font: 600 12px/1 var(--sans); letter-spacing: .16em; color: #c9d4c6; }
.sources { display: flex; gap: 22px; justify-content: center; font-size: 13px; color: #dfe6dc; white-space: nowrap; overflow: hidden; }
.sources span { display: inline-flex; align-items: center; gap: 7px; }
.sources b { color: #fff; font-weight: 600; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: #8fd6a6; box-shadow: 0 0 0 2px rgba(143, 214, 166, .25); }
.pip.down { background: #f08a80; box-shadow: 0 0 0 2px rgba(240, 138, 128, .25); }
.session { text-align: right; font: 600 13px var(--sans); letter-spacing: .16em; color: #e2cf93; }

/* ── Work areas ───────────────────────────────────────── */
.work {
  display: grid;
  grid-template-columns: var(--profile-w) minmax(0, 1fr) var(--evidence-w);
  min-height: 0;
}
.pane-title {
  font: 600 12px/1 var(--sans);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--back);
  margin: 0 0 12px;
}

/* Profile */
.profile { border-right: 1px solid var(--rule); overflow-y: auto; padding: 22px 24px 28px; }
.personas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 26px; }
.personas button {
  border: 1px solid var(--rule);
  background: var(--paper-hi);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 2px;
  transition: background-color .15s, border-color .15s;
}
.personas button:hover { border-color: var(--back); }
.personas button[aria-pressed="true"] { background: var(--face); border-color: var(--face); color: var(--on-face); }
.profile-head { display: flex; justify-content: space-between; align-items: baseline; }
.text-btn { background: none; border: 0; padding: 2px 0; color: var(--back); font-size: 12.5px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--face); }
.field { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 2px 10px; border-top: 1px solid var(--rule); padding: 9px 0; }
.field:last-of-type { border-bottom: 1px solid var(--rule); }
.field code { grid-row: span 2; font: 600 12px/1.75 var(--sans); color: var(--back); letter-spacing: .04em; }
.field label { font-size: 12px; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%;
  font: 14px/1.4 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px dashed transparent;
  padding: 1px 0 3px;
  resize: none;
  field-sizing: content;
}
.field input:hover, .field textarea:hover, .field select:hover { border-bottom-color: var(--rule); }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-bottom: 1px solid var(--face); }
.field ::placeholder { color: #5f6559; font-style: italic; }
.field select:invalid, .field select.unknown { color: #5f6559; font-style: italic; }
.profile .hint { font-size: 12.5px; color: var(--ink-soft); margin: 14px 0 0; }

/* Conversation */
.conversation { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.log { overflow-y: auto; padding: 28px clamp(20px, 3vw, 44px) 20px; display: flex; flex-direction: column; gap: 22px; scroll-behavior: smooth; }

.welcome { margin: auto 0; max-width: 62ch; }
.welcome h2 { font: 600 30px/1.2 var(--serif); margin: 0 0 10px; text-wrap: balance; }
.welcome p { font: 17px/1.55 var(--serif); color: var(--ink-soft); margin: 0 0 22px; }
.starters { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.starters button {
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 12px 2px;
  font: 16px/1.4 var(--serif);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.starters button::after { content: "Ask"; font: 600 12px var(--sans); color: var(--back); letter-spacing: .06em; white-space: nowrap; }
.starters button:hover { background: var(--paper-hi); }

.question {
  align-self: flex-end;
  max-width: min(70%, 640px);
  background: var(--face);
  color: var(--on-face);
  padding: 12px 16px;
  font-size: 16px;
  white-space: pre-wrap;
  border-radius: 2px;
}

.note {
  position: relative;
  background: var(--paper-hi);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 18px clamp(18px, 2.4vw, 30px) 22px;
  max-width: 920px;
  box-shadow: 0 1px 2px rgba(21, 24, 26, .06), 0 8px 24px -16px rgba(21, 24, 26, .25);
  transition: border-color .2s;
}
.note.selected { border-color: var(--back); }
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 10px; margin-bottom: 14px; }
.serial { font: 600 12px var(--sans); letter-spacing: .16em; color: var(--fibre-red); }
.note-meta { font-size: 12.5px; color: var(--ink-soft); }
.mark-btn { background: none; border: 0; padding: 0; line-height: 0; border-radius: 50%; }
.mark-btn svg { width: 44px; height: 44px; }

.prose { font: 17px/1.6 var(--serif); max-width: 72ch; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; text-wrap: balance; margin: 1.4em 0 .45em; }
.prose h1, .prose h2 { font-size: 23px; }
.prose h3 { font-size: 20px; }
.prose h4 { font-size: 17px; }
.prose p, .prose ul, .prose ol { margin: 0 0 .8em; }
.prose li { margin-bottom: .3em; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 1.2em 0; }
.prose strong { font-weight: 600; }
.prose blockquote { margin: 0 0 .8em; padding-left: 14px; border-left: 1px solid var(--back); color: var(--ink-soft); }
.prose table { border-collapse: collapse; margin: .4em 0 1em; font: 14px/1.4 var(--sans); width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--back); border-bottom-color: var(--back); }
.prose code { font: 13px var(--sans); }
.prose em:last-child { color: var(--ink-soft); }

.cite {
  display: inline-block;
  font: 600 13.5px/1.3 var(--sans);
  letter-spacing: .03em;
  color: var(--evidence);
  background: none;
  border: 0;
  border-bottom: 1.5px solid currentColor;
  padding: 0 1px;
  margin: 0 1px;
  vertical-align: 1px;
}
.cite:hover, .cite.lit { background: var(--evidence-tint); }

.pending { display: flex; gap: 18px; align-items: center; }
.pending svg { width: 72px; height: 72px; flex: none; }
.pending p { margin: 0; font: 16px/1.5 var(--serif); color: var(--ink-soft); }
.pending b { font: 600 13px var(--sans); color: var(--ink); letter-spacing: .04em; }

.note.failed { border-color: var(--fibre-red); }
.note.failed .prose { color: var(--fibre-red); font-family: var(--sans); font-size: 15px; }
.retry { margin-top: 10px; }

.inline-evidence { display: none; }

/* Composer */
.composer { border-top: 1px solid var(--rule); background: var(--paper); padding: 14px clamp(20px, 3vw, 44px) 18px; }
.composer form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; max-width: 920px; }
.composer textarea {
  width: 100%;
  font: 16px/1.45 var(--sans);
  color: var(--ink);
  background: var(--paper-hi);
  border: 1.5px solid var(--face);
  border-radius: 2px;
  padding: 11px 14px;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  field-sizing: content;
}
.composer textarea::placeholder { color: #5b6156; }
.composer textarea:focus { outline: none; box-shadow: 0 0 0 3px rgba(31, 58, 46, .18); }
.actions { display: flex; gap: 8px; }
.primary {
  background: var(--face);
  color: var(--on-face);
  border: 1.5px solid var(--face);
  border-radius: 2px;
  padding: 11px 20px;
  font-weight: 700;
  letter-spacing: .02em;
  min-height: 48px;
}
.primary:hover { background: var(--face-hi); }
.primary:disabled { opacity: .55; cursor: progress; }
.secondary { background: transparent; color: var(--face); border: 1.5px solid var(--rule); border-radius: 2px; padding: 11px 14px; font-weight: 600; min-height: 48px; }
.secondary:hover { border-color: var(--face); }
.composer .fine { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }

/* Evidence rail */
.evidence { border-left: 1px solid var(--rule); background: var(--paper-lo); overflow-y: auto; padding: 22px 24px 28px; }
.provenance { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 16px; align-items: center; margin-bottom: 20px; }
.provenance svg { width: 104px; height: 104px; }
.provenance p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.provenance p b { display: block; font-size: 15px; color: var(--ink); margin-bottom: 2px; }
.ev-section { margin-top: 22px; }
.ev-item { border-top: 1px solid var(--rule); padding: 10px 0; transition: opacity .2s, background-color .2s; }
.ev-item:last-child { border-bottom: 1px solid var(--rule); }
.ev-item .id { font: 600 12px var(--sans); color: var(--evidence); letter-spacing: .03em; }
.ev-item .what { font-size: 14.5px; }
.ev-item .when { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.ev-item details summary { cursor: pointer; font-size: 12px; color: var(--back); margin-top: 4px; list-style-position: inside; }
.ev-item pre { margin: 6px 0 0; font: 11.5px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; background: var(--paper-hi); border: 1px solid var(--rule); padding: 8px; }
.ev-item.err .id { color: var(--fibre-red); }
.ev-rule { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px; }
.evidence.focusing .ev-item { opacity: .38; }
.evidence.focusing .ev-item.lit { opacity: 1; background: var(--evidence-tint); }
.ev-meta { margin-top: 22px; font-size: 12px; color: var(--ink-soft); display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.ev-meta dt { color: var(--back); font-weight: 600; }
.ev-meta dd { margin: 0; }
.tool-list .ev-item .id { color: var(--back); } /* evidence ink is for an answer's own evidence */
.inline-evidence .ev-item.lit { background: var(--evidence-tint); }
#evidence-title:focus { outline: none; }
.tool-list .ev-item p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.muted { color: var(--ink-soft); font-size: 13px; }

/* ── Motion: the rosette engraves while Alex works ───── */
.engrave path, .engrave circle { stroke-dasharray: 1; stroke-dashoffset: 1; animation: engrave 2.4s cubic-bezier(.22, 1, .36, 1) infinite alternate; }
.engrave g:nth-child(2) path, .engrave g:nth-child(2) circle { animation-delay: .6s; }
.settle path, .settle circle { stroke-dasharray: 1; stroke-dashoffset: 1; animation: engrave 1.1s cubic-bezier(.22, 1, .36, 1) forwards; }
@keyframes engrave { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .engrave path, .engrave circle, .settle path, .settle circle { animation: none; stroke-dashoffset: 0; }
  .log { scroll-behavior: auto; }
}

/* ── Narrower screens ─────────────────────────────────── */
@media (max-width: 1180px) {
  .band, .work { grid-template-columns: var(--profile-w) minmax(0, 1fr); }
  .session { display: none; }
  .evidence { display: none; }
  .inline-evidence { display: block; margin-top: 16px; border-top: 1px solid var(--rule); padding-top: 10px; }
  .inline-evidence summary { cursor: pointer; font: 600 12px var(--sans); color: var(--evidence); letter-spacing: .06em; text-transform: uppercase; }
}
@media (max-width: 760px) {
  /* Phone: plain document flow, so nothing stretches to the window height or grows past it. */
  html, body { height: auto; }
  body { display: block; min-height: 100%; overflow-x: hidden; }
  .work, .conversation { display: block; }
  .band { grid-template-columns: minmax(0, 1fr); padding: 14px 0; gap: 8px; }
  .starters button { white-space: normal; }
  .starters button::after { content: none; }
  .band > * { padding: 0 16px; }
  .wordmark { font-size: 24px; }
  .sources { justify-content: flex-start; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; white-space: normal; }
  .profile { border-right: 0; border-bottom: 1px solid var(--rule); padding: 16px; max-height: none; }
  .profile-fields { display: none; }
  .profile.open .profile-fields { display: block; }
  .log { padding: 18px 16px; overflow: visible; }
  .question { max-width: 92%; }
  .composer { position: sticky; bottom: 0; padding: 12px 16px; }
  .composer form { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .composer .fine { display: none; }
  .actions { justify-content: flex-end; }
  .primary, .secondary { min-height: 44px; padding: 8px 14px; }
  .serial { letter-spacing: .08em; }
}
@media (min-width: 761px) { .profile-toggle { display: none; } }
