/* Rho Docs: the Rho Console's visual language for an internal document library.
   Layout: a fixed sidebar (never moves), a sticky top bar, and a white reading surface. */
@font-face { font-family: "Inter"; src: url("/static/fonts/Inter-variable.ttf") format("truetype"); font-weight: 100 900; font-display: block; }
@font-face { font-family: "JetBrains Mono"; src: url("/static/fonts/JetBrainsMono-variable.ttf") format("truetype"); font-weight: 100 800; font-display: block; }
@font-face { font-family: "Gelasio"; src: url("/static/fonts/gelasio-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "Gelasio"; src: url("/static/fonts/gelasio-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: block; }

:root {
  --side-w: 264px; --top-h: 56px;
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #f6f8fb; --surface-3: #eef1f6;
  --border: #e2e6ed; --border-2: #eef0f4;
  --ink: #131922; --ink-2: #3d434b; --ink-3: #5d636b; --ink-4: #8a9098;
  --accent: #2b55d6; --accent-2: #1d3fa8; --accent-soft: #e9eefc;
  --good: #1f9d5c; --good-ink: #1f7a4d; --good-soft: #e3f5eb;
  --warn: #c47a12; --warn-ink: #8a4b08; --warn-soft: #fdf3e4;
  --danger: #c0392b; --danger-soft: #fbe9e7;
  --radius: 10px; --radius-lg: 14px; --radius-sm: 8px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, -apple-system, "Segoe UI", Arial, sans-serif;
  --serif: Gelasio, Georgia, serif;
}
* { box-sizing: border-box; }
/* A permanent scrollbar gutter: short and long pages have the same width, so nothing shifts sideways. */
html { scrollbar-gutter: stable; overflow-y: scroll; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--surface); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
body { -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
.mono { font-family: var(--mono); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.kicker a { color: var(--ink-3); } .kicker a:hover { color: var(--accent); }
.muted { color: var(--ink-3); }
.warn-text { color: var(--warn-ink); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: 11px var(--mono); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; background: var(--surface); color: var(--ink-3); }

/* ---------- Sidebar: fixed to the viewport ---------- */
.side { position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); z-index: 30; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--border); }
.side-top { flex: none; height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: 16px; }
.brand:hover { color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.badge-internal { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--good-ink); display: flex; align-items: center; gap: 6px; }
.badge-internal::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.search-btn { flex: none; margin: 12px 12px 4px; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-3); font: 14px var(--sans); cursor: pointer; text-align: left; }
.search-btn span { flex: 1; }
.search-btn:hover { border-color: #c9cfd9; color: var(--ink-2); }
.side-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 8px 12px; scrollbar-width: thin; }
.nav-group { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.nav-group + .nav-group { border-top: 1px solid var(--border-2); }
.nav-h { padding: 6px 10px 4px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); }
.side-nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 30px; padding: 4px 10px; border-radius: 7px; color: var(--ink-2); font-size: 13.5px; line-height: 1.3; }
.side-nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.side-nav .n { font-family: var(--mono); font-size: 11.5px; color: var(--ink-4); font-weight: 400; }
.side-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; text-transform: uppercase; flex-shrink: 0; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.who-n { font-size: 13.5px; font-weight: 500; text-transform: capitalize; }
.who-e { font-family: var(--mono); font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2); flex: none; }
.iconbtn:hover { border-color: #c9cfd9; color: var(--ink); }

/* ---------- Page: offset by the sidebar; the top bar sticks ---------- */
.page { margin-left: var(--side-w); min-height: 100vh; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 32px; background: #fff; border-bottom: 1px solid var(--border); }
.menu-btn { display: none; }
.crumbs { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--ink-3); } .crumbs a:hover { color: var(--accent); }
.crumbs strong { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--ink-4); margin: 0 8px; }
.stamp { flex: none; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.stamp b { color: var(--ink-2); font-weight: 500; }
.main { padding-bottom: 72px; }

/* ---------- Generic page structure ---------- */
.container { max-width: 1180px; padding: 32px 40px 0; }
.container.narrow { max-width: 900px; }
.page-head { display: flex; flex-wrap: wrap; gap: 16px 24px; justify-content: space-between; align-items: flex-end; padding-bottom: 24px; border-bottom: 1px solid var(--border-2); margin-bottom: 8px; }
.page-head-text { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.page-title { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.lede-text { margin: 0; color: var(--ink-2); font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section { margin-top: 32px; }
.section-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; margin-bottom: 12px; }
.section-h h2 { margin: 0; font-size: 17px; font-weight: 650; }
.section-h a, .section-h .muted { font-size: 13px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.panel.pad { padding: 16px 20px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 32px; }
.jump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.jump a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--ink-2); font-size: 13px; }
.jump a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.plain-list { margin: 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }

/* Buttons and chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: 500 13.5px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c4cad4; color: var(--ink); text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.big { height: 46px; font-size: 15px; font-weight: 600; width: 100%; }
.btn.danger { color: var(--danger); }
.chip { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; border-radius: 5px; padding: 2px 6px; white-space: nowrap; line-height: 1.5; }
.chip.shareable, .chip.published { background: var(--accent-soft); color: var(--accent-2); }
.chip.internal { background: var(--warn-soft); color: var(--warn-ink); }
.chip.draft, .chip.prepared { background: #eef0f4; color: var(--ink-2); }
.chip.approved { background: var(--good-soft); color: var(--good-ink); }
.chip.in-review { background: #efeafd; color: #4a35a8; }
.chip.superseded { background: var(--danger-soft); color: #8e2a1f; }
.chip.share-open { background: var(--good-soft); color: var(--good-ink); }
.chip.share-nda { background: #fdecd8; color: #8a4b08; }
.chip.share-internal { background: #eef0f4; color: var(--ink-2); }
.chips { white-space: nowrap; } .chips .chip + .chip { margin-left: 4px; }

/* Stats and cards */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); }
.stat-v { font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.stat-d { font-size: 12.5px; color: var(--ink-3); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); background: var(--surface); }
.card:hover { border-color: #c4cad4; color: var(--ink); text-decoration: none; box-shadow: 0 2px 10px rgba(19,25,34,.05); }
.card h3 { margin: 2px 0 0; font-size: 15px; font-weight: 600; }
.card p { margin: 0; font-size: 13px; color: var(--ink-3); }

/* Packets */
.packet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.packet-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.packet-top { display: flex; gap: 12px; align-items: flex-start; }
.packet-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.packet-card h3 { margin: 2px 0 0; font-size: 16px; font-weight: 650; line-height: 1.3; }
.packet-card h3 a { color: var(--ink); }
.packet-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); flex: 1; }
.packet-meta { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); }
.packet-actions { display: flex; gap: 8px; }
.highlight { margin-top: 20px; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid #cfdaf7; background: #f3f6fe; border-radius: var(--radius-lg); }
.highlight-text { flex: 1; min-width: 0; font-size: 14px; }
.highlight-title { font-size: 16px; font-weight: 650; color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 18px; font-size: 13px; color: var(--ink-2); }
.legend .chip { margin-right: 4px; }
.phase { margin-top: 8px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.phase + .phase { margin-top: 16px; }
.phase.nda { background: #fffaf3; border-color: #f0d9b8; }
.phase-h { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: var(--ink); }
.step-no { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 650; font-size: 15px; flex: none; }
.packet-items { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--ink-2); border-top: 1px solid var(--border-2); padding-top: 10px; }
.packet-items .mono { font-size: 11px; color: var(--accent); margin-right: 4px; }
.share-banner { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding: 11px 16px; border-radius: var(--radius); font-size: 14px; border: 1px solid; }
.share-banner.open { background: #f1faf5; border-color: #bfe3cf; color: var(--good-ink); }
.share-banner.nda { background: #fff6ea; border-color: #f0d3a8; color: var(--warn-ink); }
.step-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border-2); }
.filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 10px; margin: 20px 0 8px; }
.filters select.input { padding: 0 8px; }
.deliv { display: flex; flex-direction: column; gap: 4px; }
.deliv-item { font-size: 13px; color: var(--ink-2); }

/* Tables */
.table-scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: 11px 16px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: #fafbfd; }
table.list .w-ver { width: 90px; } table.list .w-date { width: 120px; } table.list .w-chips { width: 190px; } table.list .w-dl { width: 120px; }
table.list .num, table.list th.num { width: 44px; color: var(--ink-4); font-family: var(--mono); font-size: 12px; }
table.list td.mono { font-size: 12.5px; }
table.list td.dl { text-align: right; } table.list td.dl form { display: inline; }
.row-title { color: var(--ink); font-weight: 500; display: inline; }
a.row-title:hover { color: var(--accent); }
.row-id { font-family: var(--mono); font-size: 11.5px; color: var(--accent); margin-right: 8px; font-weight: 400; }
.row-sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Document reader ---------- */
.reader { padding: 32px 40px 0; }
.doc-head { max-width: 1120px; padding-bottom: 18px; border-bottom: 1px solid var(--border-2); }
.doc-kicker { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.doc-kicker a { color: var(--ink-3); } .doc-kicker a:hover { color: var(--accent); }
.doc-kicker .sep { margin: 0 8px; color: var(--ink-4); }
.doc-title { margin: 8px 0 14px; font-family: var(--serif); font-weight: 400; font-size: 36px; line-height: 1.2; letter-spacing: -.005em; color: var(--ink); max-width: 28em; }
.doc-bar { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: space-between; align-items: center; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; color: var(--ink-3); }
.doc-meta .chip + .chip { margin-left: -8px; }
.doc-meta b { color: var(--ink); font-weight: 500; }
.doc-tools { display: flex; flex-wrap: wrap; gap: 8px; }
select.ver { height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font: 12.5px var(--mono); padding: 0 8px; color: var(--ink); cursor: pointer; }
.banner { margin-top: 16px; max-width: 1120px; border: 1px solid #f0d3a8; background: var(--warn-soft); color: var(--warn-ink); border-radius: var(--radius); padding: 11px 16px; font-size: 14px; }
.reader-body { display: grid; grid-template-columns: minmax(0, 740px) 250px; gap: 64px; margin-top: 28px; }
.rail { position: sticky; top: calc(var(--top-h) + 24px); align-self: start; max-height: calc(100vh - var(--top-h) - 48px); overflow-y: auto; display: flex; flex-direction: column; gap: 18px; font-size: 13px; scrollbar-width: thin; }
.rail-h { font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); margin-bottom: 8px; }
.toc { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--ink-3); line-height: 1.4; }
.toc li a:hover { color: var(--ink); text-decoration: none; }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.rail-box { border-top: 1px solid var(--border-2); padding-top: 14px; }
details.rail-box summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; margin-bottom: 0; }
details.rail-box summary::-webkit-details-marker { display: none; }
details.rail-box summary::after { content: "+"; font-family: var(--mono); color: var(--ink-4); }
details.rail-box[open] summary::after { content: "−"; }
details.rail-box[open] summary { margin-bottom: 10px; }
.facts { margin: 0; display: grid; grid-template-columns: 76px 1fr; gap: 7px 10px; }
.facts dt { color: var(--ink-4); } .facts dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.facts .small { font-size: 11.5px; }
ol.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
ol.hist li { padding-left: 14px; position: relative; color: var(--ink-2); }
ol.hist li::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: #c7ccd6; }
ol.hist li.cur::before { background: var(--accent); }
ol.hist li div { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }

/* ---------- Rendered Markdown ---------- */
.prose { font-size: 16px; line-height: 1.72; color: var(--ink-2); min-width: 0; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin: 4px 0; } .prose li > p { margin: 0; } .prose li > ul, .prose li > ol { margin: 4px 0 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose h2 { font-family: var(--serif); font-weight: 400; font-size: 25px; line-height: 1.3; color: var(--ink); margin: 48px 0 14px; scroll-margin-top: calc(var(--top-h) + 20px); }
.prose h3 { font-size: 17.5px; font-weight: 650; color: var(--ink); margin: 32px 0 10px; line-height: 1.35; scroll-margin-top: calc(var(--top-h) + 20px); }
.prose h4 { font-size: 15.5px; font-weight: 650; color: var(--ink); margin: 24px 0 8px; scroll-margin-top: calc(var(--top-h) + 20px); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.prose a { text-decoration: underline; text-decoration-color: #b9c6ee; text-underline-offset: 2px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose a.xref { color: var(--ink-2); text-decoration: underline dotted var(--ink-4); cursor: help; }
.prose code { font-family: var(--mono); font-size: .84em; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 5px; color: var(--ink); overflow-wrap: anywhere; }
.prose pre { background: #0f1520; color: #e6e9ef; border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 0 0 18px; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; }
.prose p.lede { font-size: 15px; line-height: 1.65; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.prose p.caption { font-size: 13px; color: var(--ink-3); margin-top: -6px; }
.prose p.caption em { font-style: normal; }
/* Callouts, as in the PDFs */
.prose blockquote { margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); font-size: 15px; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose blockquote.callout.note { border-color: #cfdaf7; background: #f3f6fe; }
.prose blockquote.callout.warn { border-color: #f0d3a8; background: var(--warn-soft); }
.prose blockquote.callout.warn strong:first-child { color: var(--warn-ink); }
.prose blockquote.callout.internal { border-style: dashed; border-color: #e3b26a; background: #fffaf1; }
/* Maturity tags */
.prose strong.tag { display: inline-block; font: 600 10.5px var(--mono); letter-spacing: .05em; text-transform: uppercase; border-radius: 5px; padding: 1px 6px; vertical-align: 1px; }
.prose strong.tag-built { background: var(--good-soft); color: var(--good-ink); }
.prose strong.tag-thin { background: #e8f3ec; color: #3d7a57; }
.prose strong.tag-shaped { background: #efeafd; color: #4a35a8; }
.prose strong.tag-planned { background: var(--warn-soft); color: var(--warn-ink); }
.prose strong.tag-vision { background: #eef0f4; color: var(--ink-3); }
/* Tables: scroll inside their own box, never widen the page */
.prose .table-wrap { margin: 18px 0 24px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.prose th { text-align: left; vertical-align: bottom; font: 500 10.5px var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); }
.prose td { padding: 9px 12px; border-bottom: 1px solid var(--border-2); vertical-align: top; min-width: 96px; }
.prose td:first-child { min-width: 64px; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: #fbfcfd; }
.prose td code { font-size: 12px; }
/* Figures */
.prose img { display: block; border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0 10px; height: auto; }
.prose figure.diagram { margin: 18px 0 10px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.prose pre.mermaid { background: none; color: var(--ink); text-align: center; margin: 0; padding: 0; }
.img-missing { display: flex; flex-direction: column; gap: 4px; padding: 26px 20px; margin: 8px 0 10px; border: 1px dashed #c7ccd6; border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); font-size: 13.5px; text-align: center; }
/* Internal notes and Sources */
.prose .blank-note { display: none; }
.prose .internal-note { border: 1px dashed #e3b26a; background: #fffaf1; border-radius: var(--radius); padding: 2px 18px 6px; margin: 28px 0; font-size: 14.5px; }
.prose .internal-label { font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--warn-ink); margin-top: 12px; margin-bottom: 6px; }
.prose .sources { margin-top: 48px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--ink-3); }
.prose .sources h2 { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); margin: 16px 0 8px; }
.prose .sources ul { padding-left: 18px; }
.prose .sources code { font-size: 11.5px; }
.prose.compact { font-size: 14.5px; }
.prose.compact h2 { font-family: var(--sans); font-size: 15px; font-weight: 650; margin: 22px 0 8px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input { height: 40px; border: 1px solid #cdd2db; border-radius: var(--radius-sm); padding: 0 12px; font: 15px var(--sans); color: var(--ink); background: #fff; width: 100%; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input.code { font-family: var(--mono); font-size: 24px; letter-spacing: .5em; text-align: center; height: 56px; }
.add-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.add-form .grow2 { flex: 2 1 240px; } .add-form .grow1 { flex: 1 1 160px; } .add-form select { width: 140px; }
.add-form .btn { height: 40px; }
.notice { font-size: 13.5px; border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 16px; }
.notice.err { background: var(--danger-soft); color: #8e2a1f; margin-top: 0; }
.notice.ok { background: var(--good-soft); color: var(--good-ink); }

/* ---------- Sign-in ---------- */
.auth-body { background: var(--bg); }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth-inner { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.auth-brand { display: flex; align-items: center; justify-content: space-between; }
.auth-brand .b { display: flex; align-items: center; gap: 12px; }
.auth-brand img { border-radius: 10px; display: block; }
.auth-brand .t { display: flex; flex-direction: column; } .auth-brand .t strong { font-size: 19px; font-weight: 650; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 8px 28px rgba(19,25,34,.06); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.auth-h { display: flex; flex-direction: column; gap: 6px; }
.auth-h h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.auth-h p { margin: 0; color: var(--ink-2); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-links { display: flex; justify-content: space-between; font-size: 13px; }
.auth-foot { display: flex; gap: 10px; align-items: flex-start; border-top: 1px solid var(--border-2); padding-top: 16px; font-size: 12.5px; color: var(--ink-2); }
.auth-foot svg { color: var(--ink-3); flex: none; margin-top: 1px; }
.auth-note { margin: 0; text-align: center; font-size: 12px; color: var(--ink-3); }

/* ---------- Search ---------- */
.searchform { display: flex; gap: 10px; margin-top: 20px; } .searchform .input { flex: 1; height: 42px; } .searchform .btn { height: 42px; }
.result-count { margin: 14px 0 0; font-size: 13px; }
.results { display: flex; flex-direction: column; margin-top: 8px; }
.result { padding: 16px 0; border-bottom: 1px solid var(--border-2); display: flex; flex-direction: column; gap: 4px; }
.result-h { font-size: 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.result-h > a { font-weight: 600; }
.result-sec { display: flex; flex-direction: column; padding: 8px 12px; margin: 0 -12px; border-radius: var(--radius-sm); color: var(--ink-2); }
.result-sec:hover { background: var(--surface-2); color: var(--ink-2); text-decoration: none; }
.sec-h { font-size: 13px; font-weight: 600; color: var(--ink); } .sec-t { font-size: 13.5px; line-height: 1.55; }
mark { background: #fff0b3; color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- ⌘K palette ---------- */
.pal-back { position: fixed; inset: 0; background: rgba(19,25,34,.36); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.pal { width: 100%; max-width: 680px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(19,25,34,.28); display: flex; flex-direction: column; max-height: 72vh; overflow: hidden; }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--ink-3); }
.pal-in input { flex: 1; height: 54px; border: 0; outline: none; font: 16.5px var(--sans); color: var(--ink); background: transparent; }
.pal-in input::-webkit-search-cancel-button { display: none; }
.pal-list { overflow-y: auto; padding: 6px; }
.pal-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 9px; color: var(--ink); cursor: pointer; }
.pal-item:hover { text-decoration: none; color: var(--ink); background: var(--surface-2); }
.pal-item[aria-selected="true"] { background: var(--accent-soft); }
.pal-item .t { font-weight: 600; font-size: 14.5px; } .pal-item .t .mono { font-weight: 400; font-size: 11.5px; color: var(--ink-3); margin-left: 8px; }
.pal-item .s { font-size: 12.5px; color: var(--accent-2); } .pal-item .x { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pal-empty { padding: 22px 16px; color: var(--ink-3); font-size: 14px; }
.pal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--border); font: 11px var(--mono); color: var(--ink-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .reader-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rail { position: static; max-height: none; order: -1; margin-bottom: 24px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
  .rail .toc-box { display: none; }
  .rail-box:first-of-type { border-top: 0; padding-top: 0; }
}
@media (max-width: 1000px) {
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open .side { transform: none; box-shadow: 0 0 40px rgba(19,25,34,.25); }
  .page { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; gap: 10px; }
  .stamp { display: none; }
  .container, .reader { padding: 24px 18px 0; }
  .doc-title { font-size: 28px; }
  .page-title { font-size: 25px; }
  .prose { font-size: 15.5px; }
}
@media print {
  .side, .rail, .topbar, .doc-tools, .actions { display: none !important; }
  .page { margin: 0; } .reader-body { display: block; }
}
.step-nav .btn { white-space: normal; height: auto; min-height: 36px; padding: 8px 12px; text-align: left; line-height: 1.35; }
@media (max-width: 860px) { .step-nav { flex-direction: column; } .share-banner { align-items: flex-start; } .legend { flex-direction: column; } }
