/* Agent workspace prototype. Light only. Values borrowed from PDL tokens
   (pdl-design-tokens/semantic.css) so it sits next to Poe without a build. */

:root {
  --surface-1: #f6f6f8;
  --surface-2: #fbfbfc;
  --surface-3: #ffffff;
  --fg: #0d0d0d;
  --fg-muted: #5d5e63;
  --fg-subtle: #6e6f74;
  --fg-faint: #a2a3a8;
  --border: rgb(0 0 0 / 0.07);
  --border-emphasis: rgb(0 0 0 / 0.23);
  --fill-hover: rgb(0 0 0 / 0.04);
  --fill-active: rgb(0 0 0 / 0.08);
  --accent: #5d5cde;
  --accent-emphasis: #413fa9;
  --accent-faint: #e7e9f6;
  --on-accent: #ffffff;
  --error: #d00e49;

  /* three agents, three marker colours; only on avatars, marks, and notes */
  --hue-accent: #5d5cde;
  --hue-accent-faint: #e7e9f6;
  --hue-ochre: #a8690f;
  --hue-ochre-faint: #f7ecd8;
  --hue-teal: #15786b;
  --hue-teal-faint: #dcf0ec;
  --hue-rose: #a8366f;
  --hue-rose-faint: #f7e1ec;
  --hue-user: #3a3a3f;
  --hue-user-faint: #e6e6ea;

  /* proofreading marks */
  --ink-del: #b3261e;
  --ink-del-faint: rgb(179 38 30 / 0.08);

  --sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Palatino", "Charter", "Georgia", serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --radius: 8px;
  --sidebar-w: 256px;
  --chat-w: 380px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--fg);
  background: var(--surface-3);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}
textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--chat-w);
  height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 6px;
  color: var(--fg);
}
.sidebar .brand svg { width: 22px; height: 22px; }
.sidebar .brand b { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.ws {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 8px 10px; padding: 8px 10px;
  border-radius: var(--radius);
  text-align: left; width: calc(100% - 16px);
}
.ws:hover { background: var(--fill-hover); }
.ws .ws-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws .ws-sub { font-size: 12px; color: var(--fg-subtle); display: block; font-weight: 400; }
.ws .chev { color: var(--fg-faint); }

.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg-subtle); padding: 10px 16px 4px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-label .mini { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--fg-subtle); padding: 2px 6px; border-radius: 6px; }
.nav-label .mini:hover { background: var(--fill-hover); color: var(--fg); }
.tree { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px; }
.row {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px; border-radius: 6px;
  text-align: left; color: var(--fg-muted);
  min-height: 30px;
}
.row:hover { background: var(--fill-hover); color: var(--fg); }
.row.active { background: var(--fill-active); color: var(--fg); }
.row .ico { width: 16px; height: 16px; color: var(--fg-faint); flex: none; }
.row.active .ico, .row:hover .ico { color: var(--fg-subtle); }
.row .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .tail { display: flex; align-items: center; gap: 6px; flex: none; }
.row.depth-1 { padding-left: 28px; }
.row .caret { width: 12px; height: 12px; color: var(--fg-faint); transition: transform 150ms var(--ease); flex: none; margin-left: -2px; }
.row.open .caret { transform: rotate(90deg); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hue-ochre); }

.agents-nav { padding: 0 8px 4px; border-top: 1px solid var(--border); }
.agents-nav .row .name { display: flex; flex-direction: column; line-height: 1.2; }
.agents-nav .row .name small { font-size: 11px; color: var(--fg-subtle); }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--fg-muted); }
.me b { font-weight: 500; color: var(--fg); }

/* avatars */
.av {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  flex: none; font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--hue); background: var(--hue-faint);
}
.av svg { width: 62%; height: 62%; display: block; }
.av.lg { width: 36px; height: 36px; font-size: 13px; }
.av.sm { width: 18px; height: 18px; font-size: 8px; }
.av.xs { width: 14px; height: 14px; }
.hue-accent { --hue: var(--hue-accent); --hue-faint: var(--hue-accent-faint); }
.hue-ochre { --hue: var(--hue-ochre); --hue-faint: var(--hue-ochre-faint); }
.hue-teal { --hue: var(--hue-teal); --hue-faint: var(--hue-teal-faint); }
.hue-rose { --hue: var(--hue-rose); --hue-faint: var(--hue-rose-faint); }
.hue-user { --hue: var(--hue-user); --hue-faint: var(--hue-user-faint); }

/* ---------- document ---------- */
.doc { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface-3); }
.doc-bar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--fg-subtle); min-width: 0; }
.crumbs .sep { color: var(--fg-faint); }
.crumbs .here { color: var(--fg); font-weight: 500; }
.crumbs button:hover { color: var(--fg); }
.doc-bar .spacer { flex: 1; }
.last-edit { display: flex; align-items: center; gap: 6px; color: var(--fg-subtle); font-size: 13px; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  font-weight: 500; font-size: 13px; white-space: nowrap;
  color: var(--fg); transition: background 150ms var(--ease), color 150ms var(--ease);
}
.btn svg { width: 15px; height: 15px; }
.btn.ghost { color: var(--fg-muted); }
.btn.ghost:hover { background: var(--fill-hover); color: var(--fg); }
.btn.ghost.on { background: var(--fill-active); color: var(--fg); }
.btn.outline { border: 1px solid var(--border-emphasis); }
.btn.outline:hover { background: var(--fill-hover); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-emphasis); }
.btn.review { background: var(--hue-ochre-faint); color: var(--hue-ochre); }
.btn.review:hover { filter: brightness(0.97); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.xs { height: 22px; padding: 0 7px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--error); }
.btn.danger:hover { background: rgb(208 14 73 / 0.06); }
.btn:disabled { opacity: 0.45; cursor: default; }

.doc-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.page {
  --gutter: 44px; --margin: 260px;
  max-width: calc(620px + var(--gutter) + var(--margin));
  margin: 0 auto; padding: 44px 24px 120px;
  font-family: var(--serif); font-size: 17.5px; line-height: 1.65;
  color: var(--fg);
}
.page .banner {
  margin: 0 0 24px var(--gutter);
  max-width: 620px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 12px;
  border-radius: 10px;
  background: var(--hue-ochre-faint);
  font-family: var(--sans); font-size: 13px; color: var(--fg);
}
.page .banner .t { flex: 1; }
.page .banner b { font-weight: 600; }
.page .banner.done { background: var(--surface-1); color: var(--fg-muted); }
.lines { display: grid; grid-template-columns: var(--gutter) minmax(0, 620px) var(--margin); }
.line { display: contents; }
.line .num {
  font-family: var(--sans); font-size: 11px; color: transparent;
  text-align: right; padding-right: 14px; user-select: none;
  line-height: inherit; padding-top: 2px;
}
.lines:hover .num, .line.flash .num { color: var(--fg-faint); }
.line .txt { min-height: 1.65em; white-space: pre-wrap; overflow-wrap: anywhere; position: relative; padding-right: 8px; }
.line .side { position: relative; }
.line.h1 .txt { font-size: 26px; line-height: 1.3; letter-spacing: -0.01em; margin: 0 0 22px; font-weight: 500; }
.line.h1 .num { padding-top: 10px; }
.line.flash .txt { background: var(--accent-faint); border-radius: 4px; transition: background 600ms var(--ease); }
.line.hl .txt { background: var(--surface-1); border-radius: 4px; }
::selection { background: var(--accent-faint); }
.line.hunk-first .txt { margin-top: 2px; }

/* proofreading marks */
.txt del { text-decoration: line-through; text-decoration-color: var(--ink-del); text-decoration-thickness: 1.2px; color: var(--ink-del); background: var(--ink-del-faint); border-radius: 2px; }
.txt ins { text-decoration: underline; text-decoration-color: var(--hue-ochre); text-decoration-thickness: 1.5px; text-underline-offset: 3px; background: var(--hue-ochre-faint); border-radius: 2px; }
.line.del-line .txt { color: var(--ink-del); text-decoration: line-through; text-decoration-color: var(--ink-del); background: var(--ink-del-faint); border-radius: 2px; }
.line.ins-line .txt { background: var(--hue-ochre-faint); border-radius: 2px; text-decoration: underline; text-decoration-color: var(--hue-ochre); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.line.acc .txt { background: none; }

/* margin: hunk controls and notes */
.mark {
  position: absolute; left: 18px; top: 2px;
  display: flex; align-items: center; gap: 4px;
  font-family: var(--sans); font-size: 12px; line-height: 1.3;
  white-space: nowrap;
}
.mark .who { color: var(--fg-subtle); margin-right: 2px; }
.mark .btn { height: 24px; padding: 0 8px; }
.mark .accept { color: var(--fg); }
.mark .accept:hover { background: var(--fill-hover); }
.mark .reject { color: var(--fg-muted); }
.mark .reject:hover { background: var(--fill-hover); color: var(--fg); }
.mark .state { color: var(--fg-subtle); display: inline-flex; align-items: center; gap: 4px; }
.mark .state svg { width: 12px; height: 12px; }

.note {
  position: absolute; left: 18px; top: 0; width: 230px;
  font-family: var(--sans); font-size: 12.5px; line-height: 1.45;
  color: var(--fg-muted);
  padding: 8px 10px 9px; border-radius: 8px;
  background: var(--surface-3);
  border-left: 2px solid var(--hue);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  z-index: 1;
}
.note.new { animation: notein 220ms var(--ease); }
@keyframes notein { from { opacity: 0; transform: translateY(4px); } }
.note .nh { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--fg); font-weight: 500; }
.note .nh time { color: var(--fg-faint); font-weight: 400; margin-left: auto; font-size: 11px; }

/* editing */
.editor {
  width: 100%; min-height: 60vh; resize: none; border: 0; outline: none;
  background: transparent; font: inherit; line-height: inherit; color: inherit;
  padding: 0; margin-left: var(--gutter); max-width: 620px; display: block;
}
.edit-hint { margin: 0 0 16px var(--gutter); font-family: var(--sans); font-size: 12.5px; color: var(--fg-subtle); }

/* floating quote button */
.float-quote {
  position: fixed; z-index: 30; transform: translate(-50%, -100%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: 8px;
  background: var(--fg); color: var(--surface-3); font-size: 12.5px; font-weight: 500;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.18);
  animation: notein 150ms var(--ease);
}
.float-quote svg { width: 13px; height: 13px; }

/* folder view */
.folder { max-width: 680px; margin: 0 auto; padding: 44px 24px 120px; }
.folder h1 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
.folder .sub { color: var(--fg-subtle); margin: 0 0 24px; }
.frow {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 10px 10px; border-radius: 8px; text-align: left;
  border-top: 1px solid var(--border);
}
.frow:hover { background: var(--fill-hover); }
.frow > span:nth-child(2) { min-width: 0; }
.frow .roman { font-family: var(--serif); color: var(--fg-subtle); font-size: 15px; }
.frow .fname { font-weight: 500; }
.frow .prev { color: var(--fg-subtle); font-size: 13px; font-family: var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frow .meta { display: flex; align-items: center; gap: 8px; color: var(--fg-subtle); font-size: 12.5px; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 500; background: var(--hue-ochre-faint); color: var(--hue-ochre); }
.pill.neutral { background: var(--surface-1); color: var(--fg-subtle); }
.pill.teal { background: var(--hue-teal-faint); color: var(--hue-teal); }
.pill.accent { background: var(--hue-accent-faint); color: var(--hue-accent); }

/* markdown-ish prose for non-manuscript files */
.prose { font-family: var(--sans); font-size: 15px; line-height: 1.6; color: var(--fg); }
.prose .txt { font-family: var(--sans); font-size: 15px; }
.prose .line.h1 .txt { font-family: var(--serif); font-size: 26px; font-weight: 500; margin-bottom: 14px; }
.prose .line.h2 .txt { font-weight: 600; font-size: 15px; margin-top: 14px; }
.prose .line.li .txt { padding-left: 18px; }
.prose .line.li .txt::before { content: "•"; position: absolute; left: 4px; color: var(--fg-faint); }
.prose .line.ol .txt { padding-left: 22px; }
.prose .line.ol .txt b.n { position: absolute; left: 2px; color: var(--fg-subtle); font-weight: 500; }
.prose .txt strong { font-weight: 600; }
.prose .ref {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 6px; border-radius: 5px; margin: 0 1px;
  background: var(--surface-1); color: var(--fg); font-size: 13px; font-weight: 500;
  text-decoration: none; border: 1px solid var(--border);
}
.prose .ref:hover { background: var(--fill-active); }
.prose .ref svg { width: 11px; height: 11px; color: var(--fg-subtle); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--surface-3); }
.chat-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.chat-head .ctx { font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .ctx small { color: var(--fg-subtle); font-weight: 400; display: block; font-size: 12px; line-height: 1.2; }
.chat-head .stack { display: flex; }
.chat-head .stack .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface-3); }
.chat-head .stack .av:first-child { margin-left: 0; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg.user { flex-direction: row-reverse; }
.msg .bubble { font-size: 14px; line-height: 1.5; max-width: 86%; }
.msg.user .bubble { background: var(--surface-1); padding: 8px 12px; border-radius: 16px 16px 4px 16px; }
.msg.agent .bubble { padding-top: 2px; }
.msg .who { font-size: 12px; color: var(--fg-subtle); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.msg .who b { font-weight: 500; color: var(--fg); }
.msg .mention { color: var(--accent); font-weight: 500; }
.msg.hl .bubble { box-shadow: 0 0 0 2px var(--accent-faint); border-radius: 12px; }
.msg .ref-card {
  margin-top: 8px; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  width: 100%; text-align: left;
}
.msg .ref-card:hover { background: var(--fill-hover); }
.msg .ref-card .k { font-size: 12px; color: var(--fg-subtle); }
.msg .ref-card .v { font-weight: 500; font-size: 13px; }
.msg .ref-card svg { width: 14px; height: 14px; color: var(--fg-faint); margin-left: auto; }
.msg .ref-card .ico { width: 16px; height: 16px; margin-left: 0; color: var(--hue-ochre); }
.quote {
  font-family: var(--serif); font-size: 13.5px; line-height: 1.45; color: var(--fg-muted);
  border-left: 2px solid var(--border-emphasis); padding: 2px 10px; margin-bottom: 6px; white-space: pre-wrap;
}
.quote .qf { font-family: var(--sans); font-size: 11.5px; color: var(--fg-subtle); display: block; margin-bottom: 2px; }
.typing { display: inline-flex; gap: 3px; padding: 8px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--fg-faint); animation: ty 1.1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ty { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.composer-wrap { padding: 8px 12px 14px; flex: none; position: relative; }
.composer {
  border: 1px solid var(--border-emphasis); border-radius: 18px;
  padding: 8px 8px 8px 14px; background: var(--surface-3);
  transition: box-shadow 150ms var(--ease);
}
.composer:focus-within { box-shadow: 0 0 0 3px var(--accent-faint); }
.composer .qchip {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--fg-muted);
  padding: 6px 8px; margin: 0 0 6px; border-radius: 8px; background: var(--surface-1);
}
.composer .qchip .ico { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--fg-subtle); }
.composer .qchip .x svg { width: 14px; height: 14px; }
.composer .qchip .qt { flex: 1; min-width: 0; font-family: var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer .qchip .qf { font-weight: 500; color: var(--fg); font-family: var(--sans); }
.composer .qchip .x { color: var(--fg-subtle); padding: 0 2px; }
.composer .qchip .x:hover { color: var(--fg); }
.composer .crow { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent;
  font-size: 14px; line-height: 1.45; padding: 4px 0; max-height: 160px; min-height: 24px;
}
.composer textarea::placeholder { color: var(--fg-faint); }
.send {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); transition: background 150ms var(--ease), opacity 150ms var(--ease);
}
.send:hover { background: var(--accent-emphasis); }
.send:disabled { background: var(--surface-1); color: var(--fg-faint); cursor: default; }
.send svg { width: 15px; height: 15px; }
.hint { font-size: 11.5px; color: var(--fg-faint); padding: 6px 16px 0; }
.hint b { font-weight: 500; color: var(--fg-subtle); }

.mention-pop {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px);
  background: var(--surface-3); border-radius: 10px; padding: 4px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 2px 4px rgb(0 0 0 / 0.04), 0 4px 8px rgb(0 0 0 / 0.04), 0 8px 16px rgb(0 0 0 / 0.04);
  border: 1px solid var(--border);
}
.mention-pop .row { color: var(--fg); }
.mention-pop .row small { color: var(--fg-subtle); margin-left: auto; }

/* ---------- side panels (history, agents) ---------- */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 400px;
  background: var(--surface-2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 20;
  box-shadow: -8px 0 24px rgb(0 0 0 / 0.04);
  animation: slidein 180ms var(--ease);
}
@keyframes slidein { from { transform: translateX(12px); opacity: 0; } }
.panel-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--border); flex: none; }
.panel-head h2 { font-size: 14px; font-weight: 600; margin: 0; flex: 1; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 40px; }
.seg { display: inline-flex; background: var(--surface-1); border-radius: 8px; padding: 2px; }
.seg button { height: 24px; padding: 0 10px; border-radius: 6px; font-size: 12px; color: var(--fg-muted); font-weight: 500; }
.seg button.on { background: var(--surface-3); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.06); }

.cs { padding: 14px 0; border-bottom: 1px solid var(--border); }
.cs .cs-head { display: flex; align-items: flex-start; gap: 10px; }
.cs .cs-title { flex: 1; min-width: 0; }
.cs .cs-title b { font-weight: 500; }
.cs .cs-title .sum { color: var(--fg-muted); }
.cs .cs-title .when { color: var(--fg-subtle); font-size: 12px; display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.cs .status { font-size: 11.5px; font-weight: 500; padding: 2px 7px; border-radius: 10px; background: var(--surface-1); color: var(--fg-subtle); white-space: nowrap; }
.cs .status.pending { background: var(--hue-ochre-faint); color: var(--hue-ochre); }
.cs .status.reverted { background: var(--ink-del-faint); color: var(--ink-del); }
.cs .trigger {
  margin: 8px 0 0 34px; display: flex; align-items: center; gap: 6px; width: calc(100% - 34px);
  font-size: 12.5px; color: var(--fg-muted); padding: 4px 8px; border-radius: 6px; background: var(--surface-1);
  max-width: 100%; text-align: left;
}
.cs .trigger:hover { background: var(--fill-active); }
.cs .trigger svg { width: 12px; height: 12px; color: var(--fg-subtle); flex: none; }
.cs .trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs .files { margin: 10px 0 0 34px; display: flex; flex-direction: column; gap: 2px; }
.cs .f { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 6px; border-radius: 6px; margin-left: -6px; }
.cs .f .ico { width: 14px; height: 14px; color: var(--fg-faint); flex: none; }
.cs .f:hover { background: var(--fill-hover); }
.cs .f .fn { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs .f .fn:hover { text-decoration: underline; }
.cs .f .st { color: var(--fg-subtle); font-size: 12px; white-space: nowrap; }
.cs .f .st.rev { color: var(--ink-del); }
.cs .f .btn { opacity: 0; }
.cs .f:hover .btn, .cs .f .btn:focus-visible { opacity: 1; }
.cs .actions { margin: 10px 0 0 34px; display: flex; gap: 6px; }

.agent-tabs { display: flex; gap: 2px; padding: 2px; background: var(--surface-1); border-radius: 10px; margin: 2px 0 14px; }
.agent-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 6px; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--fg-muted); min-width: 0; white-space: nowrap; }
.agent-tabs button .av { display: none; }
.sheet .sub { font-variant-caps: all-small-caps; letter-spacing: 0.08em; }
.sheet .li { padding-left: 1.2em; text-indent: -1.2em; }
.agent-tabs button.on { background: var(--surface-3); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.06); }
.agent-tabs button:hover:not(.on) { color: var(--fg); }
.agent-card { padding: 4px 0 16px; }
.agent-card .ah .n small { display: block; }
.facts { display: grid; grid-template-columns: 64px 1fr; gap: 10px 12px; align-items: center; margin: 18px 0 0 0; font-size: 13px; }
.facts dt { color: var(--fg-subtle); }
.facts dd { margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
.facts .tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-1); font-weight: 500; font-size: 12px; }
.facts .via { color: var(--fg-subtle); font-size: 12.5px; }
.agent-card .ah { display: flex; align-items: center; gap: 10px; }
.agent-card .ah .n { flex: 1; min-width: 0; }
.agent-card .ah .n b { font-weight: 500; display: block; }
.agent-card .ah .n small { color: var(--fg-subtle); font-size: 12px; }
.agent-card .bio { color: var(--fg-muted); margin: 10px 0 0 46px; font-size: 13px; text-wrap: pretty; }
.agent-card select {
  width: 100%; height: 30px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--border-emphasis); background: var(--surface-3);
}
.agent-card select:disabled { color: var(--fg-muted); border-color: var(--border); background: var(--surface-1); }
.agent-card .stats { margin: 16px 0 0 0; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--fg-subtle); display: flex; gap: 12px; flex-wrap: wrap; }
.agent-card .stats b { color: var(--fg); font-weight: 500; }
.src { display: inline-flex; align-items: center; gap: 4px; }
.src svg { width: 11px; height: 11px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--fg); color: var(--surface-3); padding: 9px 14px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.16); z-index: 50;
  display: flex; align-items: center; gap: 12px; animation: notein 160ms var(--ease);
}
.toast button { color: var(--surface-3); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- proof view: the chapter set as book pages from design/typography.md ---------- */
.proof { padding: 36px 24px 120px; background: var(--surface-1); min-height: 100%; }
.proof .proof-head { max-width: 980px; margin: 0 auto 20px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--fg-muted); }
.proof .proof-head > span { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.proof .proof-head b { font-weight: 500; color: var(--fg); }
.proof .proof-head .spec { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; color: var(--fg-subtle); font-size: 12px; }
.proof .proof-head .spec span b { color: var(--fg-muted); font-weight: 500; }
.sheets { max-width: 980px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; }
.sheet {
  background: #fdfcfa; color: #1a1816;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.08);
  position: relative; overflow: hidden; flex: none;
}
.sheet .body { position: absolute; }
.sheet .pl { white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet .pl.hang { padding-left: var(--hang); text-indent: calc(-1 * var(--hang)); }
.sheet .ch { font-variant: normal; }
.sheet .ch.caps { font-variant-caps: all-small-caps; letter-spacing: 0.12em; text-align: center; }
.sheet .folio { position: absolute; bottom: 0; font-size: 0.7em; color: #8a8580; letter-spacing: 0.05em; }
.sheet.verso .folio { left: 0; }
.sheet.recto .folio { right: 0; }
