:root {
  --bg: #faf9f7;
  --ink: #2a2a28;
  --muted: #6b6b66;
  --line: #e4e1da;
  --card: #ffffff;
  --accent: #5b6b58;
  --accent-ink: #ffffff;
  --user-bubble: #eef0ea;
  --assistant-bubble: #ffffff;
  --error: #a4453a;
  --badge-linked-bg: #e6ecdf;   --badge-linked-ink: #3c4b39;   --badge-linked-line: #c9d5c1;
  --badge-neutral-bg: #f0efec;  --badge-neutral-ink: #55554f;  --badge-neutral-line: #e4e1da;
  --badge-unclear-bg: #f6efdc;  --badge-unclear-ink: #6b5a2a;  --badge-unclear-line: #e7dbb6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

/* Dark theme: follows the OS by default, or whatever the toggle set (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1c1a;
    --ink: #e6e4df;
    --muted: #9a9a93;
    --line: #34362f;
    --card: #242622;
    --accent: #8fa58a;
    --accent-ink: #14170f;
    --user-bubble: #2c3129;
    --assistant-bubble: #242622;
    --error: #e08a7c;
    --badge-linked-bg: #2f3b2c;  --badge-linked-ink: #c4d6bd;  --badge-linked-line: #48583f;
    --badge-neutral-bg: #2b2c29; --badge-neutral-ink: #c2c1bb; --badge-neutral-line: #3d3e39;
    --badge-unclear-bg: #3a3323; --badge-unclear-ink: #e0cf9f; --badge-unclear-line: #5a4f2f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1b1c1a;
  --ink: #e6e4df;
  --muted: #9a9a93;
  --line: #34362f;
  --card: #242622;
  --accent: #8fa58a;
  --accent-ink: #14170f;
  --user-bubble: #2c3129;
  --assistant-bubble: #242622;
  --error: #e08a7c;
  --badge-linked-bg: #2f3b2c;  --badge-linked-ink: #c4d6bd;  --badge-linked-line: #48583f;
  --badge-neutral-bg: #2b2c29; --badge-neutral-ink: #c2c1bb; --badge-neutral-line: #3d3e39;
  --badge-unclear-bg: #3a3323; --badge-unclear-ink: #e0cf9f; --badge-unclear-line: #5a4f2f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

input, textarea, button { font-family: inherit; }
input, textarea { background: var(--card); color: var(--ink); }

/* Theme toggle button (lives in the nav on chat pages, floats top-right elsewhere) */
.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1;
}

.theme-toggle:hover { color: var(--ink); background: var(--user-bubble); }

.theme-toggle.floating {
  position: fixed;
  top: 12px;
  right: 12px;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); font-size: 0.9rem; }

/* --- Passcode gates --- */
body.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-card h1 { font-size: 1.2rem; margin: 0 0 4px; }

.gate-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
}

.gate-card button {
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  cursor: pointer;
}

.gate-card button:hover { opacity: 0.9; }

/* --- Chat page --- */
body.chat {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

header {
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--line);
}

header h1 { font-size: 1.15rem; margin: 0 0 6px; }
header .muted { line-height: 1.5; }
header a { color: var(--accent); }

/* Mode switcher (Conversation <-> Trait check) */
.modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.modes a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  background: var(--card);
}

.modes a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.modes a.end {
  border: none;
  background: none;
  color: var(--muted);
  padding-right: 0;
}

/* The right-hand controls travel together, so a narrow screen wraps the whole group
   rather than orphaning one link on its own row. */
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.modes a:not(.active):not(.end):hover { background: var(--user-bubble); }

/* --- Trait check page --- */
#results {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--assistant-bubble);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  line-height: 1.5;
}

.card.pending { color: var(--muted); font-style: italic; }
.card.error-card { color: var(--error); }

.card .quote {
  background: var(--user-bubble);
  border-radius: 10px;
  padding: 10px 12px;
  white-space: pre-wrap;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }

.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-linked { background: var(--badge-linked-bg); color: var(--badge-linked-ink); border-color: var(--badge-linked-line); }
.badge-not_linked { background: var(--badge-neutral-bg); color: var(--badge-neutral-ink); border-color: var(--badge-neutral-line); }
.badge-unclear { background: var(--badge-unclear-bg); color: var(--badge-unclear-ink); border-color: var(--badge-unclear-line); }

.card .headline { font-weight: 600; margin: 0 0 8px; }
.card .body-text { margin: 0 0 8px; white-space: pre-wrap; }

.card .aside {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.card .aside-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.card .disclaimer { margin: 10px 0 0; font-size: 0.8rem; }

.check-form textarea { min-height: 96px; }

/* A trait-check thread: description, assessment, follow-ups, optional wrap-up */
.thread .quote.follow {
  margin-top: 14px;
  margin-left: 24px;
  border-left: 3px solid var(--line);
  border-radius: 0 10px 10px 0;
}

.thread .assessment { margin-top: 12px; }
.thread .assessment.pending { color: var(--muted); font-style: italic; }
.thread .assessment.error-card { color: var(--error); }
.thread .assessment > .aside-label { margin-bottom: 8px; }

.thread-summary {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--badge-linked-line);
  background: var(--user-bubble);
  border-radius: 12px;
}

.thread-summary > .aside-label { margin-bottom: 8px; }
.thread-summary .aside { border-top-color: var(--line); }

.thread.done { border-color: var(--badge-linked-line); }

.thread-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.thread-actions textarea {
  resize: none;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
}

.thread-actions button {
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.thread-actions .followup { border: none; background: var(--accent); color: var(--accent-ink); }
.thread-actions .wrapup { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.thread-actions .wrapup:hover { background: var(--user-bubble); }
.thread-actions button:disabled, .thread-actions textarea:disabled { opacity: 0.6; cursor: default; }

.thread-actions.two { grid-template-columns: 1fr auto; }

@media (max-width: 480px) {
  .thread-actions { grid-template-columns: 1fr 1fr; }
  .thread-actions textarea { grid-column: 1 / -1; }
}

.banner {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--user-bubble);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.banner strong { display: block; margin-bottom: 2px; }
.banner .muted { margin: 0; }

#log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  border: 1px solid var(--line);
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
}

.msg.typing { color: var(--muted); font-style: italic; }

/* The text box gets its own row and the buttons sit under it. Three buttons sharing a line
   with the textarea left barely any room to type, and this is a tool where people write
   several sentences about their own life -- the writing space is the important part. */
#composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 12px 0 20px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--bg);
}

#input {
  grid-column: 1 / -1;
  resize: vertical;
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  line-height: 1.45;
  font-family: inherit;
}

/* Send sits on the left of its row, the two quieter actions are pushed to the right. */
#send {
  grid-column: 1;
  justify-self: start;
  padding: 9px 22px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  cursor: pointer;
}

#send:disabled { opacity: 0.6; cursor: default; }

/* Both are things you reach for occasionally; neither should compete with Send. */
#summary, #new-conversation {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
}

#summary { grid-column: 2; color: var(--ink); }
#new-conversation { grid-column: 3; color: var(--muted); }

#summary:hover { background: var(--user-bubble); }
#new-conversation:hover { background: var(--user-bubble); color: var(--ink); }
#summary:disabled, #new-conversation:disabled { opacity: 0.6; cursor: default; }

/* Confirm step for starting over: the visible transcript vanishes, so it says what doesn't. */
.confirm-bar {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: var(--user-bubble);
  border: 1px solid var(--accent);
  border-radius: 10px;
}
.confirm-bar .body-text { margin: 0 0 10px; font-size: 0.92rem; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions button {
  padding: 7px 14px; border-radius: 8px; font-size: 0.9rem; cursor: pointer;
  border: 1px solid var(--line);
}
#confirm-new { border: none; background: var(--accent); color: var(--accent-ink); }
#cancel-new { background: var(--card); color: var(--ink); }
#cancel-new:hover { background: var(--bg); }

@media (max-width: 560px) {
  /* Send takes the full width, the two quieter actions share the row beneath it. */
  #composer { grid-template-columns: 1fr 1fr; }
  #send { grid-column: 1 / -1; justify-self: stretch; }
  #summary { grid-column: 1; }
  #new-conversation { grid-column: 2; }
  #summary, #new-conversation { white-space: normal; padding: 9px 10px; }
}

/* --- Admin page --- */
body.admin {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.session {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--card);
}

.session summary { cursor: pointer; font-weight: 600; }

.evidence { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.evidence .meta { font-size: 0.75rem; color: var(--muted); margin-right: 4px; }

.chip {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--user-bubble);
}

.chip-pattern { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.transcript { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

.transcript .msg { white-space: normal; }
.msg .meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 2px; }
.msg .body { white-space: pre-wrap; }

@media (max-width: 480px) {
  .msg { max-width: 95%; }
}

/* --- Overview page --- */
#overview { flex: 1; padding: 16px 0 32px; display: flex; flex-direction: column; gap: 22px; }

.domain-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.domain-head h2 { font-size: 1.05rem; margin: 0; }
.domain .rule { margin: 4px 0 12px; }
.domain .card + .card { margin-top: 10px; }

.criterion-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.criterion .code {
  display: inline-block; font-weight: 700; font-size: 0.85rem; padding: 2px 8px; margin-right: 8px;
  border-radius: 6px; background: var(--user-bubble); border: 1px solid var(--line);
}
.criterion .name { font-weight: 600; }
.criterion .description { color: var(--ink); }
.criterion.status-none .description { color: var(--muted); }
.criterion.status-pattern { border-color: var(--badge-linked-line); }

.evidence-list { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.evidence-list .aside-label { margin-bottom: 6px; }

.evidence-item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; background: var(--bg); }
.evidence-item summary { cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; list-style: none; }
.evidence-item summary::-webkit-details-marker { display: none; }
.evidence-item summary::before { content: "\25B8"; color: var(--muted); margin-right: 6px; }
.evidence-item[open] summary::before { content: "\25BE"; }
.evidence-item .note { flex: 1; }
.evidence-item .source { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
.evidence-item .quote { margin: 10px 0 0; }
.evidence-item .reply { margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--line); color: var(--muted); font-size: 0.92rem; white-space: pre-wrap; }
.evidence-item a { color: var(--accent); }

.card.empty { text-align: center; }

/* --- Folding threads (trait check + where it fits) --- */
.fold-controls { display: flex; align-items: center; gap: 8px; padding: 12px 0 0; }
.fold-controls .muted { margin-right: auto; }
.fold-controls button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; font-size: 0.8rem; padding: 5px 10px; cursor: pointer;
}
.fold-controls button:hover { color: var(--ink); background: var(--user-bubble); }

.thread-head {
  display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
  margin: -4px -6px 0; padding: 4px 6px; border-radius: 8px;
}
.thread-head:hover { background: var(--user-bubble); }
.thread-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thread-head .chevron::before { content: "\25BE"; color: var(--muted); font-size: 0.9rem; }
.thread.collapsed .thread-head .chevron::before { content: "\25B8"; }
.thread-head .excerpt {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 0.95rem;
}
.thread.collapsed .thread-head .excerpt { color: var(--ink); }
.thread:not(.collapsed) .thread-head .excerpt { color: var(--muted); font-size: 0.85rem; }
.thread-head .head-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.thread-head .turns { font-size: 0.78rem; white-space: nowrap; }
.chip.mini { font-size: 0.72rem; padding: 2px 7px; }

.thread .thread-head + .thread-body { margin-top: 10px; }
.thread.collapsed .thread-body, .thread.collapsed .thread-actions { display: none; }

@media (max-width: 480px) {
  .thread-head { flex-wrap: wrap; }
  .thread-head .excerpt { flex-basis: calc(100% - 24px); }
  .thread-head .head-meta { margin-left: 24px; justify-content: flex-start; }
}

/* Attribution chips (autism / ADHD overlap / interaction) */
.chip.attr-overlap { background: var(--badge-unclear-bg); color: var(--badge-unclear-ink); border-color: var(--badge-unclear-line); }
.chip.attr-interaction { background: var(--badge-linked-bg); color: var(--badge-linked-ink); border-color: var(--badge-linked-line); }
.evidence-item .attr-note { margin: 8px 0 0; }
#cooccurrence .criterion .name { font-weight: 500; }

/* --- Overview: two conditions --- */
.jump { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.jump a { color: var(--accent); }
.condition { display: flex; flex-direction: column; gap: 18px; }
.condition-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; border-top: 2px solid var(--line); }
.condition-head h2 { font-size: 1.2rem; margin: 10px 0 0; flex-basis: 100%; }
.condition + .condition { margin-top: 10px; }
.domain-head h3 { font-size: 1rem; margin: 0; }
.chip.muted-chip { background: var(--card); color: var(--muted); }
.criterion.compact { padding: 10px 14px; }
.criterion.compact .criterion-head { margin-bottom: 4px; }
.criterion.compact .description { font-size: 0.92rem; margin: 4px 0 0; }
.criterion.compact .more summary { cursor: pointer; font-size: 0.85rem; list-style: none; }
.criterion.compact .more summary::before { content: "\25B8 "; }
.criterion.compact .more[open] summary::before { content: "\25BE "; }
.criterion.compact .more .description { margin-top: 6px; }
.criterion.compact .more .aside-label { display: inline; margin-right: 4px; }
.criterion.compact .evidence-list { margin-top: 8px; padding-top: 8px; }
.pair { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pair .plus { font-weight: 600; }
.code.cond-adhd { background: var(--badge-unclear-bg); border-color: var(--badge-unclear-line); color: var(--badge-unclear-ink); }
.tag-notes { margin: 6px 0 8px; padding-left: 18px; }
.tag-notes li { margin: 2px 0; }
.clinician .card { opacity: 0.9; }

/* --- Welcome / landing page --- */
body.welcome { padding-bottom: 40px; }
.welcome header { border-bottom: none; }
.welcome .lead { font-size: 1.05rem; line-height: 1.6; margin: 0; max-width: 60ch; }
.modes a.active-link { color: var(--ink); font-weight: 600; }

#welcome { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 0; }
#welcome h2 { font-size: 1rem; margin: 0 0 8px; }
#welcome .body-text, #welcome .lead { white-space: normal; }
#welcome .card .body-text + .body-text { margin-top: 10px; }
#welcome .modes-list + .body-text { margin-top: 12px; }
#welcome .card .body-text:last-child { margin-bottom: 0; }

.modes-list { margin: 0; }
.modes-list dt { font-weight: 600; margin-top: 10px; }
.modes-list dt:first-child { margin-top: 0; }
.modes-list dd { margin: 2px 0 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }

.card.cta { border-color: var(--accent); }
.openers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.openers button {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}
.openers button:hover { background: var(--user-bubble); border-color: var(--accent); }
.openers button.no-idea { color: var(--muted); font-style: italic; }
.skip { margin: 12px 0 0; }
.skip a, .start-link { color: var(--accent); }
.start-link { font-size: 1rem; font-weight: 600; }

/* --- Save as PDF (Overview) --- */
/* The Overview is already the organized version of someone's own material, so the export is
   the page itself rather than a separate document: print rules plus the browser's own
   Save-as-PDF. Nothing new to keep in sync, and it travels to an appointment on paper. */
.page-actions { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; }
.page-actions .muted { font-size: 0.85rem; margin: 0; max-width: 56ch; }
#print-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; font-size: 0.85rem; padding: 6px 14px; cursor: pointer;
  flex-shrink: 0;
}
#print-btn:hover { background: var(--user-bubble); border-color: var(--accent); }
.print-only { display: none; }

@media print {
  /* Print the light palette whatever the toggle says -- dark mode on paper is a solid
     block of toner, and a shared copy shouldn't depend on the reader's screen setting. */
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #ffffff; --ink: #1a1a1a; --muted: #4a4a4a; --line: #c9c9c9;
    --card: #ffffff; --accent: #333333; --accent-ink: #ffffff;
    --user-bubble: #f4f4f2; --assistant-bubble: #ffffff;
    --badge-linked-bg: #ffffff;  --badge-linked-ink: #1a1a1a;  --badge-linked-line: #8a8a8a;
    --badge-neutral-bg: #ffffff; --badge-neutral-ink: #4a4a4a; --badge-neutral-line: #c9c9c9;
    --badge-unclear-bg: #ffffff; --badge-unclear-ink: #1a1a1a; --badge-unclear-line: #8a8a8a;
    color-scheme: light;
  }

  @page { margin: 16mm 14mm; }

  body, body.chat, body.overview {
    background: #fff; color: var(--ink);
    height: auto; max-width: none; padding: 0; margin: 0;
    display: block; overflow: visible;
    font-size: 10.5pt;
  }

  /* Navigation, controls, and the resume code: none of it means anything on paper, and the
     resume code plus the access code would reopen the whole session for whoever holds the
     printout. */
  /* The era chip is content on paper, not a control -- it just happens to be a button
     so it can be clicked to open the editor on screen. */
  .modes, .jump, .page-actions, .theme-toggle, .banner,
  button:not(.era-chip):not(.setting-chip) { display: none !important; }

  header { border-bottom: 1px solid var(--line); padding-top: 0; }
  .print-only { display: block; }
  .printed-on { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }

  main, #overview { overflow: visible; display: block; }
  a { color: inherit; text-decoration: none; }

  .card, .criterion, .condition-head, .domain-head { break-inside: avoid; }
  .evidence-item, .evidence-list { break-inside: avoid; }
  .condition { break-before: page; }
  .condition:first-of-type { break-before: auto; }
  h2, h3 { break-after: avoid; }

  .card { box-shadow: none; border: 1px solid var(--line); }
  .criterion.status-none { opacity: 0.75; }

  /* Opened by the print handler, so drop the disclosure arrow and let each item read as a
     heading with its story underneath. */
  .evidence-item > summary { list-style: none; font-weight: 600; }
  .evidence-item > summary::-webkit-details-marker { display: none; }
  .evidence-item .quote { border-left: 2px solid var(--line); }
}

/* --- Transcript --- */
/* The Overview is the sorted view; this is the record it was sorted from, and most of what
   someone says never gets tied to a criterion at all. */
body.transcript #transcript { display: flex; flex-direction: column; gap: 26px; padding-bottom: 60px; }
.chapter { display: flex; flex-direction: column; gap: 10px; }
.chapter .condition-head { margin-bottom: 4px; }
.chapter .msg { max-width: 76%; }

/* Arrived from an Overview example: hold the eye on the message it came from. */
.msg.targeted {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  scroll-margin-top: 80px;
}
.msg:focus { outline: none; }
.msg.targeted::after {
  content: "the example on your Overview came from here";
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 560px) {
  .chapter .msg { max-width: 92%; }
}

@media print {
  /* Bubbles floated left and right waste most of the page and read as chat UI rather than a
     record. On paper it becomes a script: who spoke, then what they said. */
  body.transcript #transcript { display: block; }
  .chapter { display: block; break-before: page; }
  .chapter:first-of-type { break-before: auto; }
  .chapter .msg, .transcript .msg {
    max-width: none; align-self: auto; break-inside: avoid;
    border: none; border-left: 2px solid var(--line); border-radius: 0;
    background: none; padding: 2px 0 2px 12px; margin: 0 0 10px;
  }
  .transcript .msg.user { border-left-color: var(--ink); font-weight: 500; }
  .msg.targeted { outline: none; }
  .msg.targeted::after { content: none; }
}

/* --- Editing an example on the Overview --- */
/* Era, retag and removal. The person is the authority on their own material; none of this
   asks the model anything. Folded away by default so the page stays a page. */
.chip.era-chip { background: var(--badge-unclear-bg); color: var(--badge-unclear-ink); border-color: var(--badge-unclear-line); }
.chip.era-chip.missing { background: var(--card); color: var(--muted); border-style: dashed; }
/* It's a button so it can open the editor, but it has to read as a chip. */
button.era-chip { cursor: pointer; font-family: inherit; line-height: inherit; }
button.era-chip:hover { border-color: var(--accent); color: var(--ink); }
button.era-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.era-chip.missing:hover { background: var(--user-bubble); }

/* The setting chip behaves the same way; kept visually quieter than the era chip so the two
   don't compete in the summary row. */
.chip.setting-chip { background: var(--card); color: var(--muted); }
.chip.setting-chip.missing { border-style: dashed; }
button.setting-chip { cursor: pointer; font-family: inherit; line-height: inherit; }
button.setting-chip:hover { border-color: var(--accent); color: var(--ink); background: var(--user-bubble); }
button.setting-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.evidence-item .era-note { margin: 8px 0 0; }
.evidence-item .item-links { display: flex; gap: 12px; align-items: center; margin: 8px 0 0; }
.linkish {
  color: var(--accent); font-size: 0.85rem; background: none; border: none;
  padding: 0; cursor: pointer; text-decoration: underline; font-family: inherit;
}
.linkish:hover { opacity: 0.8; }

.item-editor {
  margin-top: 12px; padding: 14px; border: 1px solid var(--accent);
  border-radius: 10px; background: var(--user-bubble);
}
.item-editor .field + .field { margin-top: 14px; }
.item-editor .q { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.item-editor .hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 8px; }
.item-editor .choices { display: flex; flex-wrap: wrap; gap: 6px; }
.item-editor .choices button {
  font-size: 0.85rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; font-family: inherit;
}
.item-editor .choices button:hover { border-color: var(--accent); }
.item-editor .choices button[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
/* "Not sure" is a real answer, but it shouldn't look like the same kind of answer. */
.item-editor .choices button.soft[aria-pressed="true"] {
  background: var(--muted); border-color: var(--muted); color: var(--bg);
}
.item-editor input[type=text], .item-editor select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.92rem; font-family: inherit; background: var(--card); color: var(--ink);
}
.editor-actions {
  display: flex; gap: 8px; align-items: center; margin-top: 16px;
  padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.editor-actions .save {
  border: none; background: var(--accent); color: var(--accent-ink);
  padding: 8px 18px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.9rem;
}
.editor-actions .cancel {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.9rem;
}
.editor-actions .remove {
  margin-left: auto; color: var(--error); background: none; border: none;
  font-size: 0.85rem; cursor: pointer; font-family: inherit; text-decoration: underline;
}
.removal {
  margin-top: 12px; padding: 12px 14px; border: 1px solid var(--error);
  border-radius: 10px; font-size: 0.9rem;
}
.removal-actions { display: flex; gap: 8px; margin-top: 10px; }
.removal-actions button { padding: 7px 14px; border-radius: 8px; font-size: 0.88rem; cursor: pointer; font-family: inherit; }
.removal-actions .confirm-remove { border: none; background: var(--error); color: #fff; }
.removal-actions .cancel-remove { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.editor-status:empty { display: none; }
.editor-status { margin: 10px 0 0; }

@media print {
  /* The era chip is worth carrying to paper -- "at home, school years" next to an anecdote
     is most of what a clinician wants from it. The controls are not. */
  .item-editor, .edit-toggle { display: none !important; }
  .chip.era-chip.missing, .chip.setting-chip.missing { display: none; }
  .evidence-item .item-links { display: block; }
}
