/* The course editor: a full screen over the board. Colours, type, spacing and motion come from the tokens in base.css. */
:root {
  --ce-chat-w: 440px;
  --ce-read: 720px;        /* reading measure for the draft */
  --you-ink: #1B33A0;
  --s10: 40px;
}

.ce {
  position: fixed; inset: 0; z-index: 45;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh; height: 100dvh;
  background: var(--ground);
}
.ce h1, .ce h2, .ce h3, .ce h4 { letter-spacing: -0.01em; }
.ce ul, .ce ol, .ce dl, .ce dd { margin: 0; padding: 0; }
.ce ul, .ce ol { list-style: none; }
.ce a { color: var(--you-ink); text-underline-offset: 2px; }
.ce a.btn { color: var(--ink); text-decoration: none; }

/* small uppercase label */
.ce-k {
  display: block; margin: 0;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.ce-note { font-size: var(--fs-sm); line-height: 1.5; letter-spacing: 0.01em; color: var(--muted); }
.ce-fine { font-size: var(--fs-xs); letter-spacing: 0.02em; color: var(--muted); }
.ce-err { font-size: var(--fs-sm); font-weight: 500; color: var(--bad); }

/* ---------- top bar ---------- */
.ce-top {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--bar-h); padding: var(--s2) var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.ce-back { --od-icon-size: 16px; flex: none; }
.ce-eyebrow { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ce-top h1 { font-size: var(--fs-lg); }
.ce-status {
  padding: var(--s1) var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r2);
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-2); background: var(--surface-2);
}
.ce-status[data-state="ready"] { border-color: var(--ok); color: var(--ok); background: var(--ok-tint); }
.ce-status[data-state="dirty"] { border-color: var(--ready); color: var(--ready-ink); background: var(--ready-tint); }
.ce-viewseg { display: none; }

/* editable text: looks like text, behaves like a button */
.ce-edit {
  display: inline; padding: 0; border: 0; background: transparent; text-align: left;
  font: inherit; color: inherit; cursor: text;
  text-decoration: underline dotted transparent; text-underline-offset: 4px;
  transition: text-decoration-color var(--t-fast) var(--ease-out);
}
.ce-edit { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.ce-edit:focus-visible { text-decoration-color: var(--you); }
.ce-tabs { max-width: 100%; overflow-x: auto; justify-self: start; }
@media (hover: hover) { .ce-edit:hover { text-decoration-color: var(--ink); } }

/* ---------- step rail ---------- */
.ce-steps { background: var(--surface); border-bottom: 1px solid var(--line); padding: var(--s2) var(--s4); }
.ce-rail { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s2); }
.ce-step {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s2); align-items: center;
  width: 100%; min-height: 52px; padding: var(--s2) var(--s3); text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface); color: var(--ink);
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.ce-step-mark {
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; grid-row: span 2;
  border: 1px solid var(--line-strong); border-radius: 50%;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; --od-icon-size: 14px;
}
.ce-step-n { display: block; font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ce-step-label { display: block; font-size: var(--fs-md); font-weight: 600; line-height: 1.3; }
.ce-step.is-done .ce-step-mark { background: var(--agent-tint); border-color: var(--agent); color: var(--agent-ink); }
.ce-step[aria-current="step"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.ce-step[aria-current="step"] .ce-step-n { color: var(--quiet-muted); }
.ce-step[aria-current="step"] .ce-step-mark { background: #fff; border-color: #fff; color: var(--ink); }
.ce-step:disabled { background: var(--surface-2); border-style: dashed; color: var(--muted); cursor: not-allowed; }
@media (hover: hover) { .ce-step:not(:disabled):not([aria-current="step"]):hover { border-color: var(--ink); } }

/* ---------- two panes ---------- */
.ce-main { display: grid; grid-template-columns: minmax(360px, var(--ce-chat-w)) minmax(0, 1fr); min-height: 0; }
.ce-chat {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line);
}
.ce-draft { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }

/* step brief */
.ce-brief { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ce-brief > summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4); cursor: pointer; list-style: none;
}
.ce-brief > summary::-webkit-details-marker { display: none; }
.ce-brief-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-body); }
.ce-brief-hint { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; flex: none; }
.ce-brief-list { display: grid; gap: var(--s3); padding: 0 var(--s4) var(--s4); }
.ce-brief-list dt { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ce-brief-list dd { font-size: var(--fs-md); line-height: 1.5; color: var(--ink-2); }

/* thread */
.ce-thread { display: flex; flex-direction: column; gap: var(--s5); padding: var(--s5) var(--s4); }
.ce-msg { display: grid; gap: var(--s1); animation: ceIn var(--t-med) var(--ease-out); }
.ce-who { display: flex; align-items: center; gap: var(--s2); font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; }
.ce-who::before { content: ""; width: 8px; height: 8px; flex: none; }
.ce-msg-agent .ce-who { color: var(--agent-ink); }
.ce-msg-agent .ce-who::before { border-radius: 50%; background: var(--agent); }
.ce-msg-you .ce-who { color: var(--you-ink); }
.ce-msg-you .ce-who::before { background: var(--you); }
.ce-body { display: grid; gap: var(--s2); font-size: var(--fs-body); line-height: 1.55; overflow-wrap: anywhere; }
.ce-msg-you .ce-body { padding: var(--s3); border-radius: var(--r2); background: var(--you-tint); }
.ce-body .ce-why { font-size: var(--fs-md); color: var(--ink-2); }
.ce-jump { justify-self: start; margin-top: var(--s1); }
.ce-divider {
  display: flex; align-items: center; gap: var(--s3);
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.ce-divider::before, .ce-divider::after { content: ""; flex: 1 1 0; height: 1px; background: var(--line); }

/* what the agent pulled in */
.ce-activity { padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); animation: ceIn var(--t-med) var(--ease-out); }
.ce-act-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--s2); }
.ce-act-line { display: flex; align-items: flex-start; gap: var(--s2); padding: 2px 0; font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.5; color: var(--muted); }
.ce-act-mark { display: flex; align-items: center; justify-content: center; width: 16px; height: 20px; flex: none; --od-icon-size: 14px; }
.ce-act-mark::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--line-strong); }
.ce-act-line.is-done { color: var(--ink-2); }
.ce-act-line.is-done .ce-act-mark { color: var(--agent); }
.ce-act-line.is-done .ce-act-mark::before { content: none; }
.ce-act-kind { flex: none; min-width: 52px; color: var(--agent-ink); }

/* question card */
.ce-q { display: grid; gap: var(--s3); padding: var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r3); background: var(--surface); animation: ceIn var(--t-med) var(--ease-out); }
.ce-q fieldset { display: grid; gap: var(--s2); margin: 0; padding: 0; border: 0; min-width: 0; }
.ce-q legend { padding: 0; margin-bottom: var(--s2); font-weight: 600; font-size: var(--fs-body); line-height: 1.45; }
.ce-opt {
  display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); min-height: 44px;
  border: 1px solid var(--line); border-radius: var(--r2); font-size: var(--fs-md); line-height: 1.5; cursor: pointer;
}
.ce-opt input { width: 16px; height: 16px; margin: 3px 0 0; flex: none; accent-color: var(--you); }
.ce-opt:has(input:checked) { border-color: var(--you); background: var(--you-tint); }
.ce-opt-idk { border-style: dashed; }
.ce-q.is-answered { background: var(--surface-2); }
.ce-q.is-answered .ce-opt { cursor: default; }
.ce-q label.ce-k { margin-bottom: var(--s1); }
.ce-input, .ce-form-input {
  display: block; width: 100%; padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface); color: var(--ink);
  font-size: var(--fs-body); line-height: 1.5; resize: vertical;
}
textarea.ce-input, textarea.ce-form-input { min-height: 44px; }
.ce-input:disabled { background: var(--surface-2); color: var(--ink-2); }

.ce-typing { padding: 0 var(--s4) var(--s2); font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--agent-ink); }

/* where the step stands */
.ce-strip { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); background: var(--surface-2); }
.ce-strip p { flex: 1 1 0; min-width: 0; font-size: var(--fs-md); line-height: 1.45; color: var(--ink-2); }
.ce-strip .btn { --od-icon-size: 16px; }
.ce-composer { display: grid; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); border-top: 1px solid var(--line); }

/* ---------- draft head ---------- */
.ce-draft-head { display: grid; gap: var(--s3); padding: var(--s3) var(--s6); background: var(--surface); border-bottom: 1px solid var(--line); }
.ce-legend { font-size: var(--fs-sm); color: var(--ink-2); }
.ce-pendbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px dashed var(--agent); border-radius: var(--r2); background: var(--agent-tint); }
.ce-pendbar p { flex: 1 1 200px; font-size: var(--fs-md); font-weight: 500; color: var(--agent-ink); }

/* provenance marks: shape + label, never colour alone */
.ce-prov {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 24px; padding: 0 var(--s2);
  border: 1px solid transparent; border-radius: var(--r1);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; --od-icon-size: 12px;
}
.ce-prov-you { background: var(--you-tint); color: var(--you-ink); }
.ce-prov-proposed { background: var(--agent-tint); color: var(--agent-ink); border: 1px dashed var(--agent); }
.ce-prov-tested { background: var(--ok-tint); color: var(--ok); }
.ce-prov-source { background: var(--surface-2); color: var(--ink-2); border-color: var(--line-strong); }
.ce-prov-gap { background: var(--bad-tint); color: var(--bad); }

/* ---------- draft body ---------- */
.ce-draft-body { padding: var(--s6) var(--s6) var(--s10); }
.ce-draft-body:focus { outline: none; }
.ce-doc { display: grid; gap: var(--s8); max-width: var(--ce-read); margin: 0 auto; }
.ce-sec { display: grid; gap: var(--s4); padding: var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3); scroll-margin-top: var(--s4); }
.ce-sec-head { display: grid; gap: var(--s1); }
.ce-sec h2 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
.ce-sec-sub { font-size: var(--fs-md); color: var(--muted); }
.ce-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); margin-top: var(--s2); font-family: var(--font-body); font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; }
.ce-sub .ce-note { font-weight: 400; }
.ce-list { display: grid; gap: var(--s2); }
.ce-item { padding: var(--s2) 0; border-bottom: 1px solid var(--line); --od-gap: 12px; }
.ce-item:last-child { border-bottom: 0; }
.ce-item-text { font-size: var(--fs-body); line-height: 1.5; overflow-wrap: anywhere; }
.ce-empty { padding: var(--s4); border: 1px dashed var(--line-strong); border-radius: var(--r2); font-size: var(--fs-md); color: var(--muted); }
.ce-x {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none;
  border: 1px solid transparent; border-radius: var(--r2); background: transparent; color: var(--ink-2); --od-icon-size: 16px;
}
.ce-x:disabled { color: var(--line-strong); cursor: not-allowed; }
@media (hover: hover) { .ce-x:not(:disabled):hover { border-color: var(--ink); color: var(--ink); } }

/* a proposed change, waiting for a decision */
.ce-prop { display: grid; gap: var(--s2); padding: var(--s3); border: 1px dashed var(--agent); border-radius: var(--r2); background: #F3FAF9; animation: ceIn var(--t-med) var(--ease-out); }
.ce-prop-kind { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--agent-ink); }
.ce-prop-text { font-size: var(--fs-body); font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.ce-prop-why { font-size: var(--fs-md); line-height: 1.5; color: var(--ink-2); }
.ce-prop-why .ce-k { display: inline; margin-right: var(--s1); }
.ce-btn-accept { background: var(--agent-tint); border-color: var(--agent); color: var(--agent-ink); }
@media (hover: hover) { .ce-btn-accept:hover { background: var(--agent); color: #fff; } }

/* sources */
.ce-source { display: grid; gap: var(--s3); padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.ce-source:last-child { border-bottom: 0; }
.ce-source-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.ce-source.is-ignored .ce-source-title { text-decoration: line-through; color: var(--muted); }
.ce-read { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: var(--s1) var(--s3); font-size: var(--fs-md); line-height: 1.5; }
.ce-read dt { padding-top: 2px; }
.ce-chip { display: inline-flex; align-items: center; gap: var(--s1); min-height: 28px; padding: 0 var(--s2) 0 var(--s3); border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); font-size: var(--fs-sm); font-weight: 500; }
.ce-chip-plain { padding-right: var(--s3); }
.ce-chip .ce-x { width: 24px; height: 24px; --od-icon-size: 12px; }
.ce-cover { display: grid; gap: var(--s2); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.ce-cover:last-child { border-bottom: 0; }
.ce-level { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 var(--s2); border-radius: var(--r1); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; --od-icon-size: 12px; }
.ce-level-ok { background: var(--ok-tint); color: var(--ok); }
.ce-level-thin { background: var(--ready-tint); color: var(--ready-ink); }
.ce-level-gap { background: var(--bad-tint); color: var(--bad); }

/* arc options */
.ce-arcs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.ce-arc { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface); }
.ce-arc h4 { font-size: var(--fs-lg); }
.ce-arc-thread { font-size: var(--fs-md); font-weight: 500; line-height: 1.45; }
.ce-fit { align-self: flex-start; padding: 0 var(--s2); border-radius: var(--r1); background: var(--ink); color: #fff; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; line-height: 22px; }
.ce-arc ul { display: grid; gap: var(--s1); margin: var(--s2) 0; flex: 1 1 auto; align-content: start; }
.ce-arc .check { align-items: flex-start; min-height: 28px; line-height: 1.4; cursor: pointer; }
.ce-arc .check input { margin-top: 2px; flex: none; }
.ce-yourarc { display: grid; gap: var(--s3); padding: var(--s4); border: 2px solid var(--ink); border-radius: var(--r2); }
.ce-yourarc ol { display: grid; gap: var(--s1); padding-left: var(--s5); list-style: decimal; font-size: var(--fs-md); }

/* framework map */
.ce-map { padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); }
.ce-map svg { display: block; width: 100%; height: auto; }
.ce-map .n-box { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.ce-map .n-box.is-hi { fill: var(--agent-tint); stroke: var(--agent); stroke-width: 2.5; }
.ce-map .n-num { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); letter-spacing: 0.06em; }
.ce-map .n-text { font-family: var(--font-body); font-size: 14px; font-weight: 600; fill: var(--ink); }
.ce-map .e-line { fill: none; stroke: var(--ink-2); stroke-width: 1.5; }
.ce-map .e-loop { stroke-dasharray: 5 4; }
.ce-map .e-head { fill: var(--ink-2); }

.ce-part { display: grid; gap: var(--s3); padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.ce-part:last-child { border-bottom: 0; }
.ce-num { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; border: 1px solid var(--ink); border-radius: 50%; font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 500; }
.ce-part-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.4; }
.ce-indent { display: grid; gap: var(--s2); padding-left: var(--s10); }
.ce-sel { display: inline-grid; gap: 2px; }
.ce-sel select, .ce-form-input select, select.ce-form-input {
  min-height: 36px; padding: 0 var(--s2); border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface); color: var(--ink); font-size: var(--fs-md);
}
.ce-conn { display: grid; gap: 2px; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-md); line-height: 1.5; }
.ce-conn:last-child { border-bottom: 0; }
.ce-conn-ends { font-weight: 600; }

/* epitomes and lessons */
.ce-epi { display: grid; gap: var(--s4); padding: var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r2); }
.ce-epi h3 { font-size: var(--fs-lg); }
.ce-dl { display: grid; gap: var(--s3); }
.ce-dl > div { display: grid; gap: var(--s1); }
.ce-dl dd { font-size: var(--fs-body); line-height: 1.5; }
.ce-lessons { display: grid; }
.ce-lesson { padding: var(--s3) 0; border-top: 1px solid var(--line); }
.ce-lesson-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.4; }
.ce-lesson .check { min-height: 36px; align-self: end; }
.ce-min { align-self: end; }
.ce-moves { display: flex; flex-direction: column; gap: 2px; flex: none; }

/* checks */
.ce-check { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.ce-check:last-child { border-bottom: 0; }
.ce-check-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.4; }
.ce-check .ce-level { min-width: 64px; justify-content: center; margin-top: 2px; }
.ce-meter { height: 12px; border: 1px solid var(--ink); border-radius: 6px; background: var(--surface); overflow: hidden; }
.ce-meter span { display: block; height: 100%; background: var(--agent); transform-origin: 0 50%; transition: transform var(--t-med) var(--ease-out); }
.ce-meter.is-over span { background: var(--bad); }
.ce-pre {
  margin: 0; padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r2); background: var(--quiet-bg); color: var(--quiet-ink);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* change log */
.ce-logrow { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.ce-logrow:last-child { border-bottom: 0; }
.ce-rev { flex: none; min-width: 48px; font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--muted); padding-top: 2px; }
.ce-logrow.is-version .ce-log-text { font-weight: 600; }
.ce-log-text { font-size: var(--fs-md); line-height: 1.5; overflow-wrap: anywhere; }

/* dialogs */
.ce-dialog-wide { width: min(680px, calc(100vw - 32px)); max-height: min(86vh, 860px); overflow-y: auto; }
.ce-prose { display: grid; gap: var(--s3); }
.ce-prose p, .ce-prose li, .ce-prose dd { font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2); max-width: 65ch; }
.ce-prose h3 { font-size: var(--fs-body); margin-top: var(--s2); letter-spacing: 0; }
.ce-prose ol { margin: 0; padding-left: var(--s6); list-style: decimal; }
.ce-compare { display: grid; }
.ce-compare > div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--line); }
.ce-compare dt { font-weight: 600; }
.ce-field { display: grid; gap: var(--s1); }
.ce-field .check { min-height: 36px; }
#ceCostList { display: grid; gap: var(--s1); margin: var(--s2) 0 0; padding-left: 20px; list-style: disc; font-size: var(--fs-md); line-height: 1.5; color: var(--ink-2); }

@keyframes ceIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .ce-arcs { grid-template-columns: minmax(0, 1fr); }
  .ce-rail { display: flex; overflow-x: auto; scrollbar-width: none; }
  .ce-rail::-webkit-scrollbar { display: none; }
  .ce-rail > li { flex: none; width: 200px; }
}
@media (max-width: 900px) {
  .ce-main { grid-template-columns: minmax(0, 1fr); }
  .ce-viewseg { display: inline-flex; }
  .ce[data-view="chat"] .ce-draft { display: none; }
  .ce[data-view="draft"] .ce-chat { display: none; }
  .ce-chat { border-right: 0; }
  .ce-top { flex-wrap: wrap; }
  .ce-top-title { flex: 1 1 60%; }
  .ce-draft-head, .ce-draft-body { padding-left: var(--s4); padding-right: var(--s4); }
  .ce-sec { padding: var(--s4); }
  .ce-indent { padding-left: 0; }
}
@media (max-width: 520px) {
  .ce-back span { display: none; }
  .ce-status { order: 5; }
  .ce-read { grid-template-columns: minmax(0, 1fr); }
  .ce-compare > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ce-strip { flex-wrap: wrap; }
  .ce-strip p { flex-basis: 100%; }
}

/* ---------- editing in place ---------- */
.ce-in {
  display: block; width: 100%; min-width: 0; padding: 2px 0; border: 0; border-bottom: 1px dotted transparent; border-radius: 0;
  background: transparent; color: inherit; font: inherit; line-height: 1.5; resize: none;
}
.ce-in::placeholder { color: var(--muted); font-weight: 400; }
.ce-in:focus-visible { outline: none; border-bottom: 1px solid var(--you); }
@media (hover: hover) { .ce-in:hover { border-bottom-color: var(--line-strong); } }
.ce-in-area { min-height: 52px; resize: vertical; field-sizing: content; }
.ce-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; }
.ce-select { min-height: 32px; padding: 0 var(--s2); border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface); color: var(--ink); font-size: var(--fs-sm); max-width: 100%; }
.ce-minutes { width: 68px; }
.ce-stack { display: grid; gap: var(--s1); min-width: 0; }
.ce-add { display: flex; align-items: center; gap: var(--s2); }
.ce-add .ce-input { flex: 1 1 0; min-width: 0; min-height: 32px; padding: var(--s1) var(--s3); font-size: var(--fs-md); }
.ce-pair { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: flex-start; }
.ce-pair .ce-field { min-width: 200px; }
.ce-hours { flex: none; width: 140px; }
.ce-tick { width: 18px; height: 18px; margin: 5px 0 0; flex: none; accent-color: var(--you); }
.ce-item.is-off .ce-in { text-decoration: line-through; color: var(--muted); }
.ce-x { font-size: var(--fs-body); line-height: 1; }
.ce-x-small { width: 22px; height: 20px; font-size: var(--fs-sm); }
.ce-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
button.ce-chip { cursor: pointer; color: var(--ink-2); }
button.ce-chip[aria-pressed="true"] { border-color: var(--you); background: var(--you-tint); color: var(--you-ink); font-weight: 600; }
.ce-source.ce-prop { padding: var(--s3); border-bottom: 1px dashed var(--agent); }
.ce-gap { color: var(--bad); }
.ce-arc ol { display: grid; gap: var(--s1); margin: var(--s2) 0; padding-left: var(--s5); list-style: decimal; font-size: var(--fs-md); flex: 1 1 auto; align-content: start; }
.ce-arc.is-chosen { border: 2px solid var(--ink); }
.ce-parts { display: grid; gap: var(--s1); }
.ce-partrow { padding: var(--s1) 0; }
.ce-epis { display: grid; gap: var(--s4); }
.ce-epi-title .ce-in { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; }
.ce-lesson .ce-stack > .ce-in { font-weight: 600; }
.ce-lesson-facts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.ce-min { display: inline-flex; align-items: center; gap: var(--s1); }
.ce-commit { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.ce-commit p { flex: 1 1 260px; }
.ce-fold { border-top: 1px solid var(--line); padding-top: var(--s3); }
.ce-fold > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-md); }
.ce-fold[open] > summary { margin-bottom: var(--s3); }
.ce-fold .ce-pre { max-height: 420px; overflow: auto; margin-top: var(--s2); }
.ce-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
/* the thread */
.ce-said { white-space: pre-wrap; }
.ce-msg-notice .ce-who { color: var(--bad); }
.ce-msg-notice .ce-who::before { background: var(--bad); }
.ce-act-line.is-failed { color: var(--bad); }
.ce-act-line.is-failed .ce-act-mark { color: var(--bad); }
button.ce-opt { width: 100%; background: var(--surface); color: var(--ink); text-align: left; font: inherit; font-size: var(--fs-md); }
button.ce-opt[aria-pressed="true"] { border-color: var(--you); background: var(--you-tint); }
button.ce-opt:disabled { cursor: default; }
@media (hover: hover) { button.ce-opt:not(:disabled):hover { border-color: var(--ink); } }
.ce-brief-list > div { display: grid; gap: 2px; }
.ce-typing[hidden] { display: none; }
/* where the step stands: the sentence gets its own line, the buttons sit under it */
.ce-strip { flex-wrap: wrap; justify-content: flex-end; gap: var(--s2) var(--s3); }
.ce-strip p { flex: 1 1 100%; }
.ce-strip .btn { flex: none; white-space: nowrap; }
/* no step brief: the thread is the first row */
.ce-chat { grid-template-rows: minmax(0, 1fr) auto auto auto; }
/* what the agent is doing, how long it has been, and a way to stop it */
.ce-typing { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4); border-top: 1px solid var(--line); background: var(--agent-tint); }
.ce-typing p { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--agent-ink); overflow-wrap: anywhere; }
.ce-pulse { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--agent); animation: cePulse 1.1s ease-in-out infinite; }
@keyframes cePulse { 50% { opacity: .25; transform: scale(.7); } }
.ce-act-line:not(.is-done) .ce-act-mark::before { border-color: var(--agent); animation: cePulse 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ce-pulse, .ce-act-line .ce-act-mark::before { animation: none; } }
/* panes never grow wider than the screen because of long content */
.ce, .ce-chat, .ce-draft { grid-template-columns: minmax(0, 1fr); }
.ce-main > section { min-width: 0; }
/* the agent's menu, above the message box */
.ce-composer-head { display: flex; align-items: center; gap: var(--s2); }
.ce-composer-head .menu > summary { min-height: 28px; padding: 0 var(--s2); font-size: var(--fs-sm); font-family: var(--font-mono); color: var(--agent-ink); }
.menu-pop.agentpop { left: auto; right: 0; width: 280px; display: grid; gap: var(--s2); }
.menu-pop.agentpop select { width: 100%; min-height: 32px; }
.menu-pop.agentpop .seg { display: flex; }
.menu-pop.agentpop .seg-btn { flex: 1 1 0; justify-content: center; white-space: nowrap; }
.ce-composer .hearing { margin: 0; padding: 0; }
/* push to talk: says what to hold, on its face */
.talk { justify-self: start; gap: var(--s2); min-height: 32px; font-size: var(--fs-sm); touch-action: none; user-select: none; }
.talk-icon { display: inline-flex; width: 16px; height: 16px; }
.talk-icon svg { width: 100%; height: 100%; }
.talk kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r1); background: var(--surface-2); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); }
.talk[aria-pressed="true"] { border-color: var(--bad); color: var(--bad); background: var(--bad-tint); }
/* under the message box: attach and talk */
.ce-composer-tools { display: flex; flex-wrap: wrap; gap: var(--s2); }
/* dropping a file anywhere on the editor */
.ce-drop { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(20, 24, 29, .45); pointer-events: none; }
/* ways of listening, one to a line */
.choices { display: grid; gap: var(--s1); }
.choice { display: grid; gap: 1px; padding: var(--s2) var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface); color: var(--ink); text-align: left; }
.choice b { font-size: var(--fs-sm); }
.choice small { font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
.choice[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.choice[aria-pressed="true"] small { color: var(--quiet-muted); }
/* the thread scrolls down only; long addresses wrap instead of pushing it sideways */
.ce-thread { overflow-x: hidden; }
.ce-thread > * { min-width: 0; max-width: 100%; }
.ce-activity, .ce-body { min-width: 0; overflow-wrap: anywhere; }
.ce-act-line > span:last-child { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.ce-draft-body { overflow-x: hidden; }
/* what a depth means */
.ce-means { color: var(--ink-2); }
.ce-depths { border-top: 0; padding-top: 0; }
.ce-depths .ce-read { grid-template-columns: 120px minmax(0, 1fr); margin-bottom: var(--s2); }
/* nothing in the draft may be wider than its pane */
.ce-doc, .ce-sec, .ce-list, .ce-epi, .ce-epis, .ce-source, .ce-part, .ce-stack, .ce-dl, .ce-lessons, .ce-yourarc, .ce-parts, .ce-cover, .ce-fold { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.ce-sec > *, .ce-epi > *, .ce-item > *, .ce-lesson > * { min-width: 0; }
.ce-select { max-width: 100%; min-width: 0; }

/* a source you can look at before deciding: what it is, where, and for a video its picture */
.ce-peek {
  display: inline-flex; align-items: center; gap: var(--s3); max-width: 100%; padding: 6px var(--s3) 6px 6px;
  border: 1px solid var(--line-strong); border-radius: var(--r2); background: var(--surface);
  color: var(--ink); text-decoration: none; justify-self: start;
}
.ce-peek:not(.is-video) { padding-left: var(--s3); }
.ce-peek:hover { border-color: var(--ink); }
.ce-thumb { position: relative; flex: none; width: 160px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.ce-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ce-thumb-play {
  position: absolute; inset: 0; margin: auto; width: 40px; height: 28px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 13px;
}
.ce-peek-text { display: grid; gap: 2px; min-width: 0; font-size: var(--fs-sm); line-height: 1.35; }
.ce-peek-text b { font-size: var(--fs-md); }
.ce-peek-text span { color: var(--muted); overflow-wrap: anywhere; }
.ce-peek-text .ce-peek-open { color: var(--you); text-decoration: underline; }
@media (max-width: 767px) { .ce-thumb { width: 112px; } }
