/* ============================================================
   Quiet ledger (design 1a) — loaded after styles.css.
   A reduction pass on the record view: less chrome, same tokens.
   ============================================================ */

/* Section labels: small grey eyebrows. Teal is kept for links and the one primary action. */
.section-label, .rec-side .section-label, .rec-side .block-toggle { font-size: 0.6875rem; color: var(--mute); }
.rec-side .block-toggle:hover { color: var(--ink); }

/* Record header */
.rec-head { align-items: flex-end; padding: 30px 56px 22px; }
.evidence.established, .evidence.probable { color: var(--mute); }
.rec-actions { align-items: center; gap: 16px; }
.rec-actions .copy-btn.btn { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent-strong); font-weight: 400; }
.rec-actions .copy-btn.btn:hover { background: none; color: var(--ink); text-decoration: underline; }
#edit-toggle { background: var(--bg); border: 1px solid var(--ink); color: var(--ink); font-weight: 500; }
#edit-toggle:hover { background: var(--paper); }
.detail.curating #edit-toggle { background: var(--btn-fill); border-color: var(--btn-fill); color: #fff; font-weight: 600; }

/* Definition: up to three lines, then an expand control (quiet-ledger.js). Replaces the sticky context bar. */
.detail .definition { font-size: 1.0625rem; max-width: 64ch; }
.definition.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.def-expand { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  font: 400 0.7812rem var(--font-sans); color: var(--accent-strong); cursor: pointer; }
.def-expand:hover { color: var(--ink); text-decoration: underline; }
.def-expand svg { width: 13px; height: 13px; transition: transform .2s var(--ease); }
.def-expand[aria-expanded="true"] svg { transform: rotate(180deg); }
.def-expand-row { margin: -4px 0 12px; }
.rec-context, .rec-read:has(.right-col.open) .rec-context { display: none !important; }
.rec-read:has(.right-col.open) { padding-top: 30px; }

/* Story spine: no step numbers, no column rules, underline for the open category. */
.story { gap: 0 32px; }
.story-step, .story-step:first-child, .story-step:last-child { padding: 0; border-left: 0; }
.story-step.active { background: none; margin-top: 0; padding-top: 0; }
.story-num { display: none; }
.story-title { font-size: 0.7812rem; }
.story .box { font-size: 0.7812rem; padding: 0 0 3px; border-bottom: 2px solid transparent; }
.story .box.active { border-bottom-color: var(--accent); }

/* Deep dive: a section under a hairline, not a card. Wide screens only — below
   1024px it is a drawer over the record (styles.css) and keeps its own frame. */
@media (min-width: 1025px) {
  .right-col.open { margin-top: 36px; padding-top: 18px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
  .right-panel { padding: 0; }
  .right-panel > h2 { margin: 0 0 6px; padding: 8px 0; background: var(--bg); border: 0; border-radius: 0;
    font: 400 1.375rem/1.2 var(--font-sans); letter-spacing: -.01em; }
}
.right-panel > h2 .panel-ord { display: none; }
.right-panel > h2 .panel-aspect { font-size: 0.8125rem; }
.right-panel > h2 .close-btn, .right-panel > h2 .edit-items-btn { border: 0; background: none; padding: 0 0 0 8px; font-size: 0.7812rem; }
.right-panel > h2 .edit-items-btn { color: var(--accent-strong); }
.right-panel > h2 .close-btn:hover, .right-panel > h2 .edit-items-btn:hover { background: none; color: var(--ink); text-decoration: underline; }
.data-table td { padding: 11px 16px 11px 0; }
.data-table th { padding: 0 16px 8px 0; }
/* Likelihood in tables: dot + word instead of a filled badge. */
.data-table .badge { background: none !important; padding: 0; color: var(--ink); font-weight: 400; letter-spacing: 0;
  text-transform: none; font-size: 0.8125rem; display: inline-flex; align-items: center; gap: 8px; }
.data-table .badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--mute-soft); }
.data-table .badge-common::before { background: var(--success); }
.data-table .badge-moderate::before { background: var(--warning); }

/* Sidebar: white, hairline rows, no boxed ledger or chips. */
.rec-body { grid-template-columns: 1fr 320px; }
.rec-side { background: var(--bg); padding: 28px; }
.xref-ledger { background: none; border: 0; border-radius: 0; }
.xref-ledger .xr { padding: 6px 0; }
.xref-ledger .xr:hover { background: none; }
.detail .synonyms span, .chips > span { padding: 0; border: 0; background: none; font-size: 0.8125rem; }
.detail .synonyms span:not(:last-child)::after { content: ' \00b7'; color: var(--mute-soft); }
.chips:not(.synonyms) > span:not(:last-child)::after { content: ' \00b7'; color: var(--mute-soft); }
.chips.synonyms { gap: 4px 6px; }
.tissue-chip { background: none !important; border: 0 !important; color: var(--ink); }
.ref-links { flex-direction: column; gap: 6px; }
.ref-link { border: 0; padding: 0; }
.ref-link:hover { background: none; text-decoration: underline; }

/* Curate mode: one amber rule and one status line. */
.detail.curating .rec-body, [data-theme="dark"] .detail.curating .rec-body { box-shadow: none; background: none; }
.detail.curating .rec-head { border-bottom: 2px solid var(--warning); }
.edit-banner, [data-theme="dark"] .edit-banner { margin: 0; padding: 9px 56px; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; background: none; color: var(--mute); font-size: 0.7812rem; }
.edit-banner::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); flex: none; }
.edit-banner strong { color: var(--ink); }

/* Rail: legend and autoimmune filter removed (#ai-only stays in the DOM; trees.js binds to it). */
.rail-legend { display: none; }
.node-row.selected { border-radius: 0 4px 4px 0; }

/* Header: Cross-references as a text link. */
header #matrix-link.hbtn { border: 0; background: none; padding: 0 4px; color: rgba(255,255,255,.85); font-size: 0.8125rem; }
header #matrix-link.hbtn:hover { color: #fff; text-decoration: underline; background: none; }

/* Version line now lives in the settings menu. */
.menu #onto-meta { padding: 4px 8px 6px; font-size: 0.6875rem; color: var(--mute); line-height: 1.5; }
.menu #onto-meta b { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }

@media (max-width: 1200px) {
  .edit-banner { padding-left: 32px; padding-right: 32px; }
  .rec-read:has(.right-col.open) { padding-top: 24px; }
}

/* ------------------------------------------------------------ mobile (≤640px)
   Mobile mockups 2a–2d. The record stacks in one column, the rail is a drawer
   carrying Cross-references and Submit for review, the deep dive is a
   full-width drawer with a framed title bar, and curate mode puts Save and
   Cancel in a bar pinned to the bottom. Tap targets are 44px. */
.rail-links { display: none; }
@media (max-width: 640px) {
  header { gap: 2px; padding: 0 6px; position: relative; }
  .iconbtn { width: 44px; height: 44px; }
  #help-btn, header #matrix-link, #gh-slot .hbtn.primary { display: none; }
  #gh-slot .who { font-size: 0; gap: 0; }
  #gh-slot .avatar { width: 32px; height: 32px; font-size: 0.6875rem; margin-right: 6px; }
  /* The wordmark is the one item that gives way, so the bar never runs past the
     screen: signed in, at a larger text size, or before the condensed font
     loads, it truncates instead of pushing the settings button off the edge (#228). */
  .brand { flex: 0 1 auto; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; overflow: hidden; }
  .brand-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 1.25rem; line-height: 1; }
  .brand-sub { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 0.5625rem; line-height: 1; }

  /* Search collapses to an icon; tapping it opens the field across the bar (quiet-ledger.js). */
  .search-wrap { margin-left: auto; flex: none; width: 44px; height: 44px; min-width: 0; padding: 0;
    justify-content: center; background: none; cursor: pointer; }
  .search-wrap input { display: none; }
  header.search-open .search-wrap { position: absolute; top: 6px; left: 8px; right: 8px; z-index: 5; width: auto;
    max-width: none; padding: 0 12px; justify-content: flex-start; background: var(--bar);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); cursor: auto; }
  header.search-open .search-wrap input { display: block; font-size: 16px; }
  .dropdown { min-width: 0; }
  .menu { position: fixed; top: 56px; left: 8px; right: 8px; min-width: 0; max-height: calc(100vh - 64px); overflow: auto; }

  /* Rail drawer */
  .left-col { width: min(312px, 86vw) !important; min-width: 0 !important; }
  .left-col .tab { min-height: 36px; }
  .rail-links { display: flex; flex: none; flex-direction: column; padding: 8px 20px 20px; border-top: 1px solid var(--line); }
  .rail-links a, .rail-links button { min-height: 44px; display: flex; align-items: center; padding: 0; border: 0;
    background: none; font: 400 0.875rem var(--font-sans); color: var(--accent-strong); text-decoration: none; cursor: pointer; }
  body:not(:has(#gh-slot .hbtn.primary)) .rail-links .rl-submit { display: none; }

  /* Record: one scroll for the whole record. The head used to stay put while
     only the body scrolled under it, which on a phone left a third of the
     screen fixed and two scroll areas (#228). */
  .detail { overflow: auto; }
  .rec-body { flex: none; overflow: visible; }
  .rec-head { flex-direction: column; align-items: stretch; gap: 14px; padding: 22px 20px 18px; }
  .detail h1 { font-size: 2rem; line-height: 1.08; }
  .rec-actions { margin-left: 0; flex-direction: row-reverse; justify-content: flex-end; }
  #edit-toggle { min-height: 44px; padding: 0 18px; font-size: 0.875rem; }
  .rec-actions .copy-btn.btn { min-height: 44px; font-size: 0.875rem; }
  .rec-read { padding: 18px 20px; }
  .rec-side { padding: 20px; }
  .edit-banner { padding: 9px 20px; }
  .detail .definition { font-size: 1rem; }
  .def-expand { min-height: 32px; font-size: 0.8125rem; }

  /* Story: one tappable row per category */
  .story { gap: 0; }
  .story-step, .story-step:first-child, .story-step:last-child { padding: 10px 0 4px; border-bottom: 1px solid var(--line); }
  .story-title { font-size: 0.6875rem; color: var(--mute); }
  .story .box { min-height: 40px; align-items: center; padding: 0; border-bottom: 0; font-size: 0.9375rem; color: var(--ink); }
  .story .box .count { font-size: 0.8125rem; color: var(--mute); }
  .story .box::after { content: ''; flex: none; width: 7px; height: 7px; margin: 0 4px;
    border-top: 1.5px solid var(--mute-soft); border-right: 1.5px solid var(--mute-soft); transform: rotate(45deg); }

  /* Deep dive: full-width drawer, framed title bar */
  .right-col.open { width: 100vw; border-left: 0; }
  .right-panel { padding: 0 20px 20px; }
  .right-panel > h2 { margin: 0 -20px 14px; padding: 8px 8px 8px 20px; flex-wrap: wrap; row-gap: 2px; font-size: 1rem; font-weight: 400; }
  .right-panel > h2 .close-btn, .right-panel > h2 .edit-items-btn { min-height: 44px; padding: 0 12px; font-size: 0.875rem; }
  .right-panel .data-table, .right-panel .data-table tbody, .right-panel .data-table tr, .right-panel .data-table td { display: block; width: auto !important; }
  .right-panel .data-table thead { display: none; }
  .right-panel .data-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .right-panel .data-table td { padding: 2px 0 !important; border: 0; font-size: 0.875rem; }
  .right-panel .data-table td:first-child { font-size: 0.9375rem; font-weight: 500; }
  /* A stacked figure row names each value ("Year 2019"), since the header is gone. */
  .right-panel .epi-table td.num { text-align: left; }
  .right-panel .epi-table td[data-label]:not(:first-child)::before { content: attr(data-label) ' '; color: var(--mute); }

  /* Curate: Save and Cancel pinned to the bottom */
  .edit-actions { position: sticky; bottom: 0; z-index: 3; flex-direction: row-reverse; gap: 10px;
    margin: 16px -20px 0; padding: 12px 20px 16px; background: var(--bg); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px -4px rgba(15,40,64,.10); }
  .edit-actions .hbtn { flex: 1; min-height: 44px; justify-content: center; font-size: 0.875rem; }
  .edit-actions .hbtn.primary { flex: 2; }
  .detail input:not([type=checkbox]):not([type=radio]), .detail select, .detail textarea,
  .right-panel input:not([type=checkbox]):not([type=radio]), .right-panel select, .right-panel textarea { font-size: 16px; }
  .detail input:not([type=checkbox]):not([type=radio]), .detail select,
  .right-panel input:not([type=checkbox]):not([type=radio]), .right-panel select { min-height: 44px; }
}
