:root {
  --bg: #f7f7f5; --panel: #ffffff; --ink: #1a1a1a; --muted: #5c5c58; --faint: #8a8a85;
  --line: #d9d9d4; --line-soft: #e8e8e3; --accent: #2f5d8a; --accent-soft: #e9eff5; --accent-ink: #ffffff;
  --ok: #3f7d5a; --warn: #a5772a; --bad: #a33d3d; --off: #9a9a95;
  --paper: #4a6d8c; --textbook: #7b6a8c; --video: #5c8a6a; --web: #8c7a4a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
             font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }

header.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 18px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
header.top h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
header.top h1 a { color: inherit; text-decoration: none; }
header.top .crumb { color: var(--muted); font-size: 14px; }
header.top .crumb a { color: var(--muted); text-decoration: none; }
header.top .crumb a:hover { text-decoration: underline; }
header.top .links { margin-left: auto; font-size: 14px; }
header.top .links a { margin-left: 14px; color: var(--muted); text-decoration: none; }
header.top .links a:hover { color: var(--accent); }

h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); font-family: var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.live { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

button { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 3px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
button:hover { border-color: #b9b9b4; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.quiet { border-color: transparent; background: none; color: var(--muted); padding: 4px 8px; }
button.quiet:hover { color: var(--ink); background: var(--accent-soft); border-color: transparent; }
button.danger { color: var(--bad); }
a.btn { text-decoration: none; display: inline-block; font-size: 14px; padding: 7px 14px; border-radius: 3px; border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.note { font-size: 13px; color: var(--muted); }
.note.bad { color: var(--bad); }

.box { background: var(--panel); border: 1px solid var(--line); padding: 16px 18px; min-width: 0; }
.box + .box { margin-top: 18px; }
.boxhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.boxhead .tag { font-family: var(--mono); font-size: 11.5px; color: var(--faint); white-space: nowrap; }

input[type=text], textarea, select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--ink); font: inherit; }
textarea { min-height: 60px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
label.field { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
label.field:first-child { margin-top: 0; }

.chip { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); padding: 1px 7px; color: var(--muted); background: #fbfbfa; white-space: nowrap; border-left-width: 3px; }
.chip.paper { border-left-color: var(--paper); } .chip.textbook { border-left-color: var(--textbook); } .chip.video { border-left-color: var(--video); } .chip.web { border-left-color: var(--web); }
.ic { display: inline-block; font-family: var(--mono); font-size: 10.5px; color: #fff; padding: 2px 0; width: 40px; text-align: center; letter-spacing: 0.04em; flex: none; }
.ic.pdf { background: var(--paper); } .ic.mp4 { background: var(--video); } .ic.web { background: var(--web); }

dialog { border: 1px solid var(--line); border-radius: 4px; padding: 0; width: min(460px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(20, 20, 18, 0.35); }
dialog form { padding: 18px 20px 16px; }
dialog h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
dialog .actions .spacer { flex: 1; }

footer { margin-top: 40px; font-size: 13px; color: var(--faint); border-top: 1px solid var(--line); padding-top: 14px; }
footer code { font-family: var(--mono); font-size: 12px; }

@media (max-width: 900px) {
  .wrap { padding: 20px 16px 48px; }
  header.top .links { margin-left: 0; }
}

/* --- header nav (Console / Projects on every page) ------------------------ */
header.top .links a.here { color: var(--ink); font-weight: 600; }

/* --- numeric citation markers: [1] [2], source name on hover/focus -------- */
.cite { position: relative; display: inline-block; font-family: var(--mono); font-size: 10.5px;
        line-height: 1.5; color: var(--accent); text-decoration: none; padding: 0 2px; margin-left: 1px;
        border-radius: 2px; vertical-align: super; cursor: pointer; }
.cite:hover, .cite:focus-visible { background: var(--accent-soft); outline: 1px solid var(--accent); outline-offset: 0; }
.cite .tip { position: absolute; bottom: calc(100% + 7px); left: 0; z-index: 40;
             width: max-content; max-width: 260px; padding: 7px 9px; border-radius: 3px;
             background: #2a2a28; color: #f3f3f1; text-align: left; white-space: normal;
             font: 400 12px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
             opacity: 0; visibility: hidden; transition: opacity 0.12s ease; pointer-events: none; }
.cite .tip b { display: block; font-weight: 600; }
.cite .tip i { display: block; font-style: normal; color: #b6b6b1; font-family: var(--mono); font-size: 11px; margin-top: 2px; }
.cite .tip::after { content: ""; position: absolute; top: 100%; left: 8px; border: 5px solid transparent; border-top-color: #2a2a28; }
.cite.flip .tip { left: auto; right: 0; }
.cite.flip .tip::after { left: auto; right: 8px; }
.cite:hover .tip, .cite:focus .tip, .cite:focus-visible .tip { opacity: 1; visibility: visible; }
.cites { display: inline; }

/* --- source rows shared by the project page ------------------------------- */
.srcrow { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; align-items: baseline;
          padding: 8px 0; border-top: 1px solid var(--line-soft); }
.srcrow:first-child { border-top: 0; }
.srcrow .num { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.srcrow .t { font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srcrow .t a { color: inherit; text-decoration: none; }
.srcrow .t a:hover { color: var(--accent); text-decoration: underline; }
.srcrow .by { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }
.srcrow .x { border: 0; background: none; color: var(--faint); font-size: 16px; line-height: 1; padding: 0 3px; }
.srcrow .x:hover { color: var(--bad); }

/* --- source kinds beyond the original four -------------------------------- */
:root { --guideline: #8a5c4a; --podcast: #4a6a8c; }
.chip.guideline { border-left-color: var(--guideline); }
.chip.podcast { border-left-color: var(--podcast); }

/* --- accepted / rejected source groups ------------------------------------ */
/* An accepted source sits in the normal row; a rejected one is deliberately
   quieter — present and readable, but plainly set aside. */
.srcrow .open { font-family: var(--mono); font-size: 10.5px; color: var(--muted); text-decoration: none;
                border: 1px solid var(--line); padding: 0 5px; white-space: nowrap; }
.srcrow .open:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.srcrow .media { font-family: var(--mono); font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.srcrow button.use { font-size: 11.5px; padding: 2px 8px; white-space: nowrap; }

 /* A run brings back 30+ sources on purpose. All of them stay listed; a long
   list just gets its own scroll so the panel does not run away down the page. */
.srclist.scroll { max-height: 430px; overflow-y: auto; padding-right: 4px;
                  border-bottom: 1px solid var(--line-soft); }
.notused { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.notused > summary { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.05em;
                     text-transform: uppercase; color: var(--faint); cursor: pointer; list-style: none; }
.notused > summary::-webkit-details-marker { display: none; }
.notused > summary::before { content: "▸ "; }
.notused[open] > summary::before { content: "▾ "; }
.notused > summary:hover { color: var(--muted); }
.srcrow { grid-template-columns: 26px minmax(0, 1fr) auto auto auto; }
.srcrow.off { grid-template-columns: minmax(0, 1fr) auto auto; opacity: 0.72; }
.srcrow.off .t { color: var(--muted); }
.srcrow.off .why { grid-column: 1 / -1; font-size: 12px; color: var(--faint); margin-top: -4px; }

/* --- cross-check strip ---------------------------------------------------- */
/* Counting, not fact-checking: the wording says so, and so does the tooltip. */
.xcheck { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
          border-top: 1px solid var(--line-soft); margin-top: 12px; padding-top: 10px;
          font-size: 12.5px; color: var(--muted); }
.xcheck b { font-weight: 600; color: var(--ink); }
.xcheck .hostchip { font-family: var(--mono); font-size: 11px; color: var(--muted);
                    border: 1px solid var(--line-soft); background: #fbfbfa; padding: 1px 6px; }
.xcheck .hostchip i { font-style: normal; color: var(--faint); }
.corrob { font-family: var(--mono); font-size: 10.5px; color: var(--ok); border: 1px solid #cadcd1;
          background: #f2f7f4; padding: 0 5px; margin-left: 6px; white-space: nowrap; vertical-align: 1px; }
.corrob.thin { color: var(--warn); border-color: #e3d3b3; background: #faf5ea; }
.corrob.lib { color: var(--faint); border-color: var(--line-soft); background: #fbfbfa; }
.offlist.scroll { max-height: 340px; overflow-y: auto; padding-right: 4px; }

/* --- practice items pulled from the procedure library --------------------- */
.ann.lib { opacity: 0.85; }
.ann.lib .kind { color: var(--faint); border-style: dashed; }
.libnote { font-family: var(--mono); font-size: 11px; color: var(--faint); margin: 10px 0 2px;
           border-top: 1px solid var(--line-soft); padding-top: 8px; }
