:root {
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --bg-code: #f1f4f8;
  --text: #1c2430;
  --muted: #5d6b7c;
  --border: #dde3ea;
  --accent: #0b6bcb;
  --accent-soft: #e6f0fb;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --note: #0b6bcb;
  --note-bg: #e6f0fb;
  --ok: #17703a;
  --ok-bg: #e4f5ea;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06);
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --bg-soft: #161d27; --bg-code: #1a2330; --text: #e3e9f0; --muted: #93a1b3; --border: #2a3441;
    --accent: #5aa7f2; --accent-soft: #14283f; --warn: #f0b95a; --warn-bg: #3a2a0c; --note: #5aa7f2; --note-bg: #14283f;
    --ok: #62c985; --ok-bg: #123221; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --bg-soft: #161d27; --bg-code: #1a2330; --text: #e3e9f0; --muted: #93a1b3; --border: #2a3441;
  --accent: #5aa7f2; --accent-soft: #14283f; --warn: #f0b95a; --warn-bg: #3a2a0c; --note: #5aa7f2; --note-bg: #14283f;
  --ok: #62c985; --ok-bg: #123221; --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--sans); }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 8px; z-index: 100; }
.muted { color: var(--muted); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-mark { color: var(--accent); font-size: 20px; }
.nav-toggle, .theme-toggle { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text); width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.nav-toggle { display: none; }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-soft); color: var(--text); font: inherit; font-size: 14px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--bg); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.search-results a { display: block; padding: 10px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.active { background: var(--accent-soft); }
.search-results .r-title { font-weight: 600; }
.search-results .r-sub { font-size: 13px; color: var(--muted); }
.search-results .none { padding: 12px 14px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1400px; margin: 0 auto; }
.sidebar { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow: auto; padding: 20px 12px 20px 16px; border-right: 1px solid var(--border); font-size: 14px; }
.nav-section { margin-bottom: 20px; }
.nav-heading { display: block; font-weight: 650; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.nav-heading:hover { color: var(--accent); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar li a:hover { background: var(--bg-soft); }
.sidebar li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .empty { color: var(--muted); padding: 5px 8px; }
.content { padding: 28px 40px 80px; min-width: 0; }
.toc { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow: auto; padding: 28px 16px; font-size: 13px; }
.toc-title { font-weight: 650; text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 3px 0 3px 12px; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc .d3 a { padding-left: 24px; }

/* prose */
.prose { max-width: 820px; }
.prose h1, .content > h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 12px; }
.prose h2 { font-size: 22px; margin: 40px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.prose h3 { font-size: 17px; margin: 28px 0 8px; }
.prose h2 .anchor, .prose h3 .anchor { margin-left: 8px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--bg-code); padding: .1em .35em; border-radius: 4px; }
.prose pre { background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow: auto; font-size: 13px; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.table-wrap { overflow-x: auto; margin: 16px 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border: 1px solid var(--border); vertical-align: top; }
.prose th { background: var(--bg-soft); }
.prose blockquote { margin: 16px 0; padding: 4px 16px; border-left: 4px solid var(--border); color: var(--muted); }
.callout { border-left-width: 4px; border-radius: 0 8px 8px 0; color: var(--text); }
.callout-note { border-color: var(--note); background: var(--note-bg); }
.callout-warning, .callout-open { border-color: var(--warn); background: var(--warn-bg); }
.callout-finding, .callout-tip { border-color: var(--ok); background: var(--ok-bg); }
.callout-title { display: inline-block; margin-right: 4px; text-transform: uppercase; font-size: 12px; letter-spacing: .06em; }
.lead { font-size: 18px; color: var(--muted); }

/* control labels on the Pilot risk pages */
.lbl { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 7px; border-radius: 4px; margin-right: 4px; vertical-align: 1px; }
.lbl-today { background: var(--ok-bg); color: var(--ok); }
.lbl-confirm { background: var(--note-bg); color: var(--note); }
.lbl-pilot { background: #efe6fb; color: #6b3fb0; }
.lbl-gap { background: var(--warn-bg); color: var(--warn); }
.lbl-note, .lbl-wrike, .lbl-wpp, .lbl-joint { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lbl-pilot { background: #2b1f45; color: #c3a5f0; } }
:root[data-theme="dark"] .lbl-pilot { background: #2b1f45; color: #c3a5f0; }
.prose ul li { margin: 4px 0; }
.prose p > em:only-child { color: var(--muted); }
.crumb { font-size: 14px; margin-bottom: 4px; }
.crumb a { text-decoration: none; }

/* meta, tags, cards */
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 24px; font-size: 14px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-soft); border: 1px solid var(--border); }
.pill-findings-ready { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill-in-progress, .pill-open { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill-reference { background: var(--note-bg); color: var(--note); border-color: transparent; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 4px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted); text-decoration: none; }
.tag:hover { color: var(--accent); border-color: var(--accent); }
.cards { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--bg); box-shadow: var(--shadow); }
.card-title { font-weight: 650; font-size: 17px; text-decoration: none; }
.card-title:hover { text-decoration: underline; }
.card-meta { display: flex; gap: 10px; align-items: center; font-size: 13px; margin: 8px 0; }
.card p { margin: 6px 0 10px; color: var(--muted); font-size: 14px; }
.hero { margin-bottom: 8px; }
.section-title { margin-top: 36px; }
.plain { padding-left: 20px; }

/* calendar request builder widget */
.tool { border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--bg-soft); margin: 20px 0; }
.tool textarea { width: 100%; min-height: 140px; font: 12px/1.4 var(--mono); padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.tool .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 10px 0; }
.tool label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.tool input[type=text], .tool select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: 13px var(--mono); }
.tool button { height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-size: 14px; cursor: pointer; }
.tool button.secondary { background: none; color: var(--accent); }
.tool .call { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); padding: 10px 12px; margin: 10px 0; }
.tool .call h4 { margin: 0 0 6px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tool .call pre { margin: 6px 0 0; max-height: 260px; }
.tool .err { color: var(--warn); }

/* wide pages (trackers, registers): no side TOC, full-width tables */
.wide .shell { grid-template-columns: 260px minmax(0, 1fr); }
.wide .toc { display: none; }
.wide .prose { max-width: none; }
.wide .prose table { font-size: 13px; }
.prose td > code { white-space: nowrap; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; z-index: 15; inset: 56px 0 0 0; height: auto; background: var(--bg); border-right: 0; }
  body.nav-open .sidebar { display: block; }
  .content { padding: 20px 16px 60px; }
  .brand { font-size: 15px; }
}

/* ---- Smart Context: risk references, overlay, quick-view dialog, titles toggle ---- */
a.risk-ref { color: var(--accent); text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; border-radius: 3px; }
a.risk-ref:hover, a.risk-ref:focus-visible { text-decoration-style: solid; background: var(--accent-soft); outline: none; }
a.risk-ref .rt { display: none; }
.show-risk-titles a.risk-ref { display: block; padding: 1px 0; }
.show-risk-titles a.risk-ref .rt { display: inline; }
.show-risk-titles a.risk-ref .rt::before { content: " "; }
.show-risk-titles .rsep { display: none; }
.show-risk-titles td:has(a.risk-ref) { min-width: 230px; }

.risk-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 -6px; font-size: 12.5px; color: var(--muted); }
.risk-toggle-btn { font: inherit; font-size: 12.5px; padding: 3px 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.risk-toggle-btn:first-of-type { border-radius: 6px 0 0 6px; }
.risk-toggle-btn:last-of-type { border-radius: 0 6px 6px 0; margin-left: -1px; }
.risk-toggle-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.risk-toggle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sc-badge { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.sc-pop { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 16px); padding: 12px 14px 14px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(10, 20, 35, .22); font-size: 13.5px; line-height: 1.45; }
.sc-pop[hidden] { display: none; }
.sc-title { font-weight: 700; font-size: 15px; margin: 4px 0 2px; }
.sc-key { color: var(--muted); }
.sc-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.sc-actions { display: grid; gap: 8px; margin-top: 12px; }
.sc-btn { display: block; width: 100%; text-align: left; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); color: var(--text); text-decoration: none; cursor: pointer; }
.sc-btn:hover, .sc-btn:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.sc-btn-main { display: block; font-weight: 600; color: var(--accent); }
.sc-btn-sub { display: block; font-size: 12px; color: var(--muted); }

.sc-dialog { padding: 0; width: min(1040px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); box-shadow: 0 16px 48px rgba(10, 20, 35, .35); }
.sc-dialog[open] { display: flex; flex-direction: column; }
.sc-dialog::backdrop { background: rgba(10, 16, 24, .55); }
.sc-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px 10px; border-bottom: 1px solid var(--border); }
.sc-dialog-title { margin: 2px 0 0; font-size: 19px; border: 0; padding: 0; }
.sc-close { font-size: 24px; line-height: 1; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); color: var(--text); cursor: pointer; }
.sc-close:hover, .sc-close:focus-visible { border-color: var(--accent); outline: none; }
.sc-dialog-body { flex: 1; overflow: auto; padding: 6px 20px 14px; max-width: none; }
.sc-dialog-body table { font-size: 13px; }
.sc-dialog-foot { padding: 10px 18px; border-top: 1px solid var(--border); text-align: right; font-size: 13.5px; }
html.sc-lock { overflow: hidden; }

/* Smart Context: capability (CD) references and dialog details */
a.cap-ref { color: var(--accent); text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; border-radius: 3px; }
a.cap-ref:hover, a.cap-ref:focus-visible { text-decoration-style: solid; background: var(--accent-soft); outline: none; }
.cd-id { font-family: var(--mono); font-size: 12px; font-weight: 700; white-space: nowrap; scroll-margin-top: 90px; }
tr:has(.cd-id:target) td { background: var(--accent-soft); }
.sc-dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 14px 0 6px; }
.sc-dl dt { font-weight: 600; color: var(--muted); }
.sc-dl dd { margin: 0; }
.sc-risk-list { margin: 0; padding-left: 18px; }
@media (max-width: 560px) { .sc-dl { grid-template-columns: 1fr; gap: 2px; } .sc-dl dd { margin-bottom: 8px; } }
