/* Shared by the documentation page and the admin page. */
body.page { overflow: auto; height: auto; min-height: 100%; }
body.page .top { position: sticky; top: 0; z-index: 20; }
a.chip { text-decoration: none; }
.snap-host .lbl { transition: none; }

/* ---------- trap reference ---------- */
.doc-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.doc-side {
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--bg2); padding: 14px 12px 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.side-h { font: 600 10.5px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin: 10px 4px 0; display: flex; justify-content: space-between; }
.side-h span { font-family: var(--mono); color: var(--accent); letter-spacing: 0; }
.doc-side .risk-filter { margin: 0; }
.side-toggles { display: grid; gap: 5px; font-size: 13px; color: #cfd4df; padding: 4px; }
.side-toggles label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.side-toggles input { accent-color: var(--accent); }
.cats { display: grid; gap: 2px; }
.cats button {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; text-align: left;
  border: 1px solid transparent; border-left: 3px solid transparent; background: none; padding: 6px 8px; border-radius: 8px; font-size: 13px;
}
.cats button:hover { background: var(--panel); }
.cats button.on { background: var(--panel2); border-color: var(--line2); border-left-color: var(--fam, var(--accent)); }
.cats b { font: 600 13px var(--display); }
.cats small { font: 11px var(--mono); color: var(--dim); }
.idx { display: grid; gap: 1px; }
.idx a { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 7px; text-decoration: none; color: #cfd4df; font-size: 12.5px; }
.idx a span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idx a:hover { background: var(--panel); }
.idx a.cur { background: rgba(62, 230, 176, .1); color: var(--text); }
.side-open { display: none; }

.doc { min-width: 0; max-width: 1040px; margin: 0 auto; padding: 26px 28px 60px; width: 100%; }
.doc .kicker { font: 600 11px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.doc-cover h1 { font: 700 38px/1.05 var(--display); letter-spacing: -.03em; margin: 8px 0 10px; }
.lede { font-size: 16px; color: #cfd4df; max-width: 720px; margin: 0 0 16px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.legend li { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 12.5px; color: var(--muted); }
.legend li b { display: block; font: 600 12px var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.legend li:last-child b { color: var(--bad); }
.showing { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.showing b { color: var(--text); }
.clear { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; text-decoration: underline; padding: 0 0 0 6px; }
.none { color: var(--muted); padding: 40px 0; text-align: center; }
.doc-fam[hidden], .trap[hidden] { display: none; }
.doc-fam { margin-top: 34px; }
.fam-head { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; border-bottom: 2px solid var(--fam); padding-bottom: 12px; margin-bottom: 16px; }
.fam-head .fi { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--panel2); border: 1px solid var(--line2); }
.fam-head h2 { font: 700 26px/1.1 var(--display); margin: 0; letter-spacing: -.02em; }
.fam-head p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.fam-head small { color: var(--dim); font: 12px var(--mono); }
.trap { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px 18px; margin-bottom: 14px; }
.trap { scroll-margin-top: 70px; }
.trap > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trap h3 { font: 700 19px/1.2 var(--display); margin: 0; }
.trap .code { font-size: 12px; padding: 2px 7px; }
.trap .play { margin-left: auto; color: var(--accent); text-decoration: none; font: 600 12px var(--mono); }
.trap .what { color: #dfe3ec; margin: 10px 0 12px; font-size: 14.5px; }
.facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.facts .fact { margin: 0; }
.board { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 12px; }
.board li { min-width: 0; }
.facts.one { grid-template-columns: minmax(0, 1fr); }
.pending { color: var(--amber); font-size: 12.5px; margin: 10px 0 0; }
.no-pics .frame { display: none; }
.no-pics .board { gap: 8px 14px; }
.board li b { display: block; font: 600 10.5px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 7px 0 2px; }
.board li:last-child b { color: var(--bad); }
.board li p { margin: 0; font-size: 13px; line-height: 1.45; color: #cfd4df; }
.frame { aspect-ratio: 16 / 10; border-radius: 9px; overflow: hidden; background: linear-gradient(110deg, #10141d 30%, #171c27 50%, #10141d 70%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; border: 1px solid var(--line); }
.frame img { width: 100%; height: 100%; display: block; object-fit: cover; }
.frame:has(img), .no-art .frame, .no-gl .frame { animation: none; }
.no-art .frame, .no-gl .frame { display: none; }
@keyframes shimmer { to { background-position: -200% 0; } }
.doc-foot { margin-top: 40px; color: var(--dim); font-size: 12px; text-align: center; }
.pdf-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 12px;
  background: #161b26; border: 1px solid var(--line2); border-radius: 12px; padding: 10px 14px; box-shadow: 0 16px 40px rgba(0,0,0,.6); font-size: 13px; }
.pdf-bar[hidden] { display: none; }
.pdf-bar i { width: 180px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.pdf-bar i b { display: block; height: 100%; width: 0; background: var(--accent); }
@media (max-width: 900px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-side { display: none; position: fixed; top: 56px; left: 0; bottom: 0; width: min(320px, 88vw); z-index: 30; box-shadow: 20px 0 50px rgba(0,0,0,.6); height: auto; }
  body.side-on .doc-side { display: flex; }
  .side-open { display: inline-block; }
  .doc { padding: 20px 16px 60px; }
  .board, .facts { grid-template-columns: minmax(0, 1fr); }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-cover h1 { font-size: 30px; }
  .fam-head { grid-template-columns: 44px 1fr; } .fam-head small { display: none; }
  body.page .top .brand-sub { display: none; }
}

/* ---------- print (the PDF export) ----------
   Text first: each trap is its definition, what the trap checks and an example,
   with one picture (the moment it is caught). The step-by-step flow is left out. */
@media print {
  @page { size: A4; margin: 14mm 13mm 15mm; }
  :root { color-scheme: light; }
  html, body.page { background: #fff !important; color: #14171f !important; height: auto; font-size: 10.5pt; }
  .no-print, .toasts, .snap-host { display: none !important; }
  .doc-layout { display: block; }
  .doc { max-width: none; padding: 0; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .doc-cover { break-after: page; padding-top: 60mm; }
  .doc .kicker { color: #0a7a5a; font-size: 9pt; }
  .doc-cover h1 { font-size: 40pt; color: #0c0f15; margin: 4mm 0 5mm; }
  .lede { color: #2a2f3a !important; font-size: 13pt; max-width: 150mm; }
  .legend { display: none; }
  .doc-foot { color: #6b7385; font-size: 8.5pt; text-align: left; margin-top: 10mm; }

  .doc-fam { break-before: page; margin: 0; }
  .doc-fam[hidden], .trap[hidden] { display: none !important; }
  .fam-head { grid-template-columns: 12mm 1fr auto; gap: 4mm; border-bottom: 1.2pt solid var(--fam); padding-bottom: 3mm; margin-bottom: 5mm; }
  .fam-head .fi { width: 12mm; height: 12mm; font-size: 16pt; background: #f3f5f9; border-color: #d5dae4; border-radius: 3mm; }
  .fam-head h2 { font-size: 20pt; color: #0c0f15; }
  .fam-head p { color: #3a4254 !important; font-size: 10pt; }
  .fam-head small { color: #6b7385; }

  .trap {
    break-inside: avoid; background: #fff !important; border: 0; border-top: .6pt solid #d5dae4; border-radius: 0;
    padding: 4.5mm 0 5mm; margin: 0;
    display: grid; grid-template-columns: minmax(0, 1fr) 58mm; column-gap: 6mm; align-items: start;
  }
  .trap > header { grid-column: 1 / -1; gap: 3mm; margin-bottom: 1.5mm; }
  .trap h3 { font-size: 13.5pt; color: #0c0f15; }
  .trap .code { font-size: 9pt; background: none !important; }
  .trap .what { grid-column: 1; color: #14171f !important; font-size: 10.5pt; line-height: 1.5; margin: 1mm 0 2.5mm; }
  .facts { grid-column: 1; grid-template-columns: minmax(0, 1fr); gap: 1.5mm; }
  .fact { background: none !important; border: 0 !important; border-left: 1.6pt solid #d5dae4 !important; border-radius: 0; padding: 0 0 0 3mm; }
  .fact b { font-size: 7.5pt; margin-bottom: .5mm; }
  .fact p { color: #2a2f3a !important; font-size: 10pt; line-height: 1.45; }
  .fact.signal { border-left-color: #0b6a94 !important; } .fact.signal b { color: #0b6a94; }
  .fact.example { border-left-color: #b97400 !important; } .fact.example b { color: #9a5b00; }
  .code.H, .risk-pill.H { color: #c0263a; } .code.M, .risk-pill.M { color: #9a5b00; } .code.L, .risk-pill.L { color: #0b6a94; }
  .risk-pill { font-size: 8pt; }
  .new-tag { background: #0f9d76; color: #fff; }

  /* One picture: the last frame. No captions, no flow. */
  .board { grid-column: 2; grid-row: 2 / span 2; display: block; margin: 1mm 0 0; }
  .board li { display: none; }
  .board li:last-child { display: block; }
  .board li b, .board li p { display: none; }
  .frame, .no-pics .frame { display: block; animation: none; border: .6pt solid #d5dae4; border-radius: 2mm; background: #f3f5f9; }
  .frame:not(:has(img)) { display: none; }
  .no-art .board, .no-gl .board { display: none; }
}

/* ---------- admin ---------- */
.adm { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }
.adm h1 { font: 700 30px/1.1 var(--display); letter-spacing: -.02em; margin: 6px 0 6px; }
.adm h2 { font: 700 18px var(--display); margin: 28px 0 10px; }
.adm .sub { color: var(--muted); margin: 0 0 18px; max-width: 720px; }
.adm .kicker { font: 600 11px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.gate { max-width: 460px; margin: 12vh auto; text-align: center; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; padding: 28px; }
.gate h1 { font-size: 24px; }
.gate .err { color: var(--bad); font-size: 13px; }
.adm-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.adm-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; color: var(--text); display: block; text-align: left; }
.adm-card:hover { border-color: var(--accent); }
.adm-card strong { display: block; font: 600 15px var(--display); }
.adm-card small { color: var(--muted); }
.adm textarea, .adm input[type=text], .adm select {
  width: 100%; background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; color: var(--text); font: inherit; padding: 9px 11px; }
.adm textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
.adm textarea.mono { font: 12.5px/1.5 var(--mono); min-height: 130px; }
.adm textarea:focus, .adm input:focus, .adm select:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row .grow { flex: 1; }
.note { color: var(--muted); font-size: 12.5px; }
.note.bad { color: var(--bad); } .note.good { color: var(--good); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: none; border: 1px solid rgba(255,90,106,.5); color: var(--bad); }
.draft { background: var(--bg2); border: 1px solid var(--line2); border-radius: 14px; padding: 16px; margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; }
.draft.err { border-color: rgba(255,90,106,.6); }
.draft .f { margin-bottom: 9px; }
.draft .f label { display: block; font: 600 10.5px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
.draft .f textarea { min-height: 0; }
.draft .three { display: grid; grid-template-columns: 110px 1fr 130px; gap: 8px; }
.draft .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pv { position: sticky; top: 76px; align-self: start; }
.pv-frames { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pv-frames .frame { animation: none; }
.pv-msg { font-size: 12.5px; margin: 8px 0; min-height: 18px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font: 600 10.5px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding: 8px; border-bottom: 1px solid var(--line2); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .acts { text-align: right; white-space: nowrap; }
.tbl .acts button, .tbl .acts a { margin-left: 6px; }
.status { font: 600 11px var(--mono); padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; }
.status.published { color: var(--good); } .status.draft { color: var(--amber); }
.who { color: var(--muted); font-size: 13px; }
@media (max-width: 980px) { .draft { grid-template-columns: 1fr; } .pv { position: static; } .adm-cards { grid-template-columns: 1fr; } }

/* ---------- submit a trap ---------- */
.sub-form { background: var(--bg2); border: 1px solid var(--line2); border-radius: 14px; padding: 18px; max-width: 860px; }
.sub-form .f { margin-bottom: 12px; }
.sub-form .f label { display: block; font: 600 10.5px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.sub-form .f small { display: block; margin-top: 3px; }
.sub-form .three { display: grid; grid-template-columns: 200px 1fr 150px; gap: 10px; }
.sub-form textarea { min-height: 0; }
@media (max-width: 760px) { .sub-form .three { grid-template-columns: 1fr; } }

/* ---------- live-trap agent ---------- */
.agent-box { background: var(--bg2); border: 1px solid var(--line2); border-radius: 14px; padding: 16px 18px; }
.agent-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.agent-stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.agent-stats b { display: block; font: 600 15px var(--display); }
.agent-stats b.ok { color: var(--good); } .agent-stats b.off { color: var(--amber); }
.agent-stats small { color: var(--muted); font-size: 12px; }
.agent-log { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; color: #cfd4df; display: grid; gap: 4px; }
.agent-log span { color: var(--dim); font: 11px var(--mono); margin-right: 8px; }
@media (max-width: 760px) { .agent-stats { grid-template-columns: 1fr 1fr; } }
