/* --- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --warn: #b45309;
  --good: #15803d;
  --hover: #f3f4f6;

  --dep-BM: #2563eb;
  --dep-IM: #0891b2;
  --dep-Fin: #16a34a;
  --dep-PAM: #7c3aed;
  --dep-HR: #ea580c;
  --dep-MK: #db2777;
  --dep-EMI: #6b7280;
  --dep-default: #94a3b8;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue",
               "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
em.muted { font-style: italic; }

/* --- Header / tabs ------------------------------------------------------- */
header {
  background: white; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 22px 28px 0;
}
h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.subtitle { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 2px; }
.tabs button {
  border: 0; background: none; padding: 10px 16px; font-size: 14px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  font-family: inherit; line-height: 1.2;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 500;
}

/* --- Main / tabs --------------------------------------------------------- */
main { max-width: 1280px; margin: 0 auto; padding: 24px 28px 80px; }
.tab { display: none; }
.tab.active { display: block; }

/* --- Cards / sections ---------------------------------------------------- */
.cards {
  display: grid; gap: 12px; margin-bottom: 28px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
}
.card .num { font-size: 22px; font-weight: 600; line-height: 1.1; }
.card .lbl {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px;
}
.section { margin-bottom: 32px; }
.section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); margin: 0 0 10px;
}

/* --- Department bars ----------------------------------------------------- */
.dept-bar { display: flex; align-items: center; gap: 12px; }
.dept-bar .name { width: 220px; font-size: 13px; }
.dept-bar .bar {
  flex: 1; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.dept-bar .bar > span { display: block; height: 100%; }
.dept-bar .count {
  width: 32px; text-align: right; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dept-topics {
  font-size: 12px; color: var(--muted); margin: 2px 0 14px 232px;
}

/* --- Tags / pills -------------------------------------------------------- */
.tag, .kw {
  display: inline-block; background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 1px 8px; margin: 2px 3px 2px 0; font-size: 11px; color: var(--text);
}
.kw .c { color: var(--muted); margin-left: 4px; }
.kw .zh, .name .zh, .trends-row .name .zh, .fac-list-item .zh {
  margin-left: 5px; color: var(--muted); font-size: 11px;
}
.dept-pill {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 10.5px; font-weight: 500; border: 1px solid currentColor;
  vertical-align: 1px; letter-spacing: 0.02em;
}

/* --- Controls ------------------------------------------------------------ */
.controls, .net-controls {
  display: flex; gap: 14px; align-items: center; margin-bottom: 14px;
  flex-wrap: wrap;
}
.controls input[type="search"], .controls select, .controls input[type="number"],
.net-controls select, .net-controls button {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 13px; background: white;
}
.controls input[type="search"] { min-width: 280px; }
.controls label, .net-controls label {
  font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.net-controls button {
  cursor: pointer; background: white;
}
.net-controls button:hover { background: var(--hover); }

/* --- Pair / faculty / paper rows ----------------------------------------- */
.pair-row {
  background: white; border: 1px solid var(--border); border-radius: 6px;
  padding: 11px 14px; margin-bottom: 8px;
  transition: border-color 0.1s;
}
.pair-row.clickable { cursor: pointer; }
.pair-row.clickable:hover { border-color: var(--accent); }
.pair-row .top {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.pair-row .names { font-weight: 500; }
.pair-row .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.pair-row .kws { font-size: 12px; }
.pair-row .sim {
  display: inline-block; padding: 2px 9px;
  background: var(--accent); color: white; border-radius: 12px;
  font-size: 11.5px; font-variant-numeric: tabular-nums; font-weight: 500;
}

.coauth-warn { color: var(--warn); }
.cross-dept-flag { color: var(--good); font-weight: 500; }

/* --- Tables -------------------------------------------------------------- */
table.kw-table { width: 100%; border-collapse: collapse; font-size: 13px; background: white;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
table.kw-table th, table.kw-table td { text-align: left; padding: 8px 14px; }
table.kw-table th {
  font-weight: 500; color: var(--muted); font-size: 12px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.04em;
}
table.kw-table tr { border-bottom: 1px solid var(--border); cursor: pointer; }
table.kw-table tr:last-child { border-bottom: 0; }
table.kw-table tr:hover { background: var(--hover); }
table.kw-table td.num { font-variant-numeric: tabular-nums; color: var(--muted); width: 80px; }

/* --- Network ------------------------------------------------------------- */
#cy {
  width: 100%; height: 720px; background: white;
  border: 1px solid var(--border); border-radius: 6px;
}

/* --- Drawer -------------------------------------------------------------- */
#drawer {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: 480px; max-width: 92vw;
  background: white; box-shadow: -6px 0 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease-out; transform: translateX(0);
  overflow-y: auto; z-index: 100;
}
#drawer.hidden { transform: translateX(100%); pointer-events: none; }
.drawer-inner { padding: 28px 28px 60px; }
#drawer-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: 0; font-size: 28px; line-height: 1;
  cursor: pointer; color: var(--muted); width: 32px; height: 32px;
}
#drawer-close:hover { color: var(--text); }

.fac-name { font-size: 19px; font-weight: 600; margin: 0; }
.fac-name .cn { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 16px; }
.fac-meta { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }

.kw-list { margin: 4px 0 8px; }

.paper-item {
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.paper-item:last-child { border-bottom: 0; }
.paper-item .title { color: var(--text); line-height: 1.4; }
.paper-item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.subtle-link { color: var(--accent); cursor: pointer; }
.subtle-link:hover { text-decoration: underline; }

.fac-list-item {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 10px; cursor: pointer;
  align-items: flex-start;
}
.fac-list-item:last-child { border-bottom: 0; }
.fac-list-item:hover { background: var(--hover); }
.fac-list-item .right {
  color: var(--muted); font-size: 12px; text-align: right;
  white-space: nowrap; flex-shrink: 0;
}
/* In Discovery's narrow columns, drop horizontal gap further still. */
.subtopic-card .fac-list-item { padding: 6px 8px; gap: 6px; }
.subtopic-card .fac-list-item .right { font-size: 11px; }

.year-row {
  display: flex; gap: 16px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.year-row:last-child { border-bottom: 0; }
.year-row .y {
  font-weight: 600; min-width: 50px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.year-row .ks { flex: 1; font-size: 13px; }

#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(247, 248, 250, 0.85); color: var(--muted);
  font-size: 15px; z-index: 200; pointer-events: none;
  transition: opacity 0.2s;
}
#loading.hidden { opacity: 0; }

/* Header right side: settings button */
.header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.settings-btn {
  background: white; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 16px; cursor: pointer; color: var(--muted);
  font-family: inherit;
}
.settings-btn:hover { color: var(--text); border-color: #cbd5e1; }
.settings-btn.active { color: var(--accent); border-color: var(--accent); }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 300;
  transition: opacity 0.15s;
}
.modal.hidden { opacity: 0; pointer-events: none; }
.modal-card {
  background: white; border-radius: 10px; padding: 28px 32px;
  width: 460px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  position: relative;
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: none; border: 0;
  font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted);
  width: 30px; height: 30px;
}
.modal-close:hover { color: var(--text); }
.btn-primary, .btn-secondary {
  border: 1px solid var(--accent); padding: 7px 16px; border-radius: 6px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: white; color: var(--muted); border-color: var(--border); }
.btn-secondary:hover { color: var(--text); border-color: #94a3b8; }

/* Discovery tab */
.discovery-input { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.discovery-input input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 14px;
}
.discovery-input input:focus { outline: 0; border-color: var(--accent); }
.discovery-examples { font-size: 12px; color: var(--muted); margin: -8px 0 16px; }
.discovery-examples a { color: var(--accent); cursor: pointer; margin-right: 8px; }
.discovery-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.subtopic-card {
  background: white; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 18px; margin-bottom: 14px;
}
.subtopic-card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.subtopic-card .explanation {
  color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.5;
}
.subtopic-card .matched-kws { margin: 6px 0 12px; }
.subtopic-card .matched-kws .kw {
  background: var(--accent-soft); border-color: #bfdbfe; color: #1e3a8a;
}
.subtopic-card .no-match { color: var(--muted); font-size: 12px; font-style: italic; }
.subtopic-card .fac-list-item { padding: 6px 8px; }

/* Trends tab */
.trends-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .trends-grid { grid-template-columns: 1fr; } }
.trends-col h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.trends-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.trends-row:last-child { border-bottom: 0; }
.trends-row .name { flex: 1; }
.trends-row .count {
  color: var(--muted); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right;
}
.trends-row .ratio { color: var(--good); font-weight: 500; min-width: 60px; text-align: right; }
.trends-row .bar {
  width: 100px; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.trends-row .bar > span { display: block; height: 100%; background: var(--accent); }

/* Cluster tab */
.cluster-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .cluster-layout { grid-template-columns: 1fr; }
}
.cluster-sidebar {
  max-height: 720px;
  overflow-y: auto;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px;
  background: white;
  padding: 6px;
}
.cluster-sidebar-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted, #475569);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  margin-bottom: 4px;
}
.cluster-card {
  display: flex; align-items: flex-start; gap: 8px;
  width: 100%;
  padding: 7px 9px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font: inherit; text-align: left; cursor: pointer;
}
.cluster-card:hover    { background: #f1f5f9; }
.cluster-card.selected { background: #e0f2fe; border-color: #7dd3fc; }
.cluster-card .dot {
  flex: 0 0 10px; width: 10px; height: 10px;
  border-radius: 50%; margin-top: 4px;
}
.cluster-card .body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.cluster-card .lbl  { font-size: 13px; line-height: 1.3; color: #0f172a;
                      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cluster-card .meta { font-size: 11px; color: var(--muted, #64748b); }
.cluster-card .tops { font-size: 11px; line-height: 1.3;
                      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#cy-clusters {
  width: 100%; height: 720px; background: white;
  border: 1px solid var(--border); border-radius: 6px;
}

/* Discovery — side-by-side columns. Use --n CSS var so the grid adapts to
   however many subtopics the user requested. */
.discovery-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(var(--n, 4), minmax(260px, 1fr));
}
@media (max-width: 1100px) {
  .discovery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .discovery-grid { grid-template-columns: 1fr; }
}
.discovery-grid .subtopic-card { margin-bottom: 0; }

/* Blacklist tab */
.bl-chip { cursor: default; }
.bl-chip .x {
  display: inline-block; margin-left: 6px; color: var(--muted);
  cursor: pointer; font-weight: 600;
}
.bl-chip:hover .x { color: var(--warn); }

/* Edit Papers tab */
.paper-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: white; margin-bottom: 6px;
  transition: opacity 0.12s;
}
.paper-row.removed { opacity: 0.45; background: #fef2f2; border-color: #fecaca; }
.paper-keep {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; flex-shrink: 0; min-width: 80px; padding-top: 2px;
}
.paper-keep .trust {
  font-size: 10.5px; padding: 1px 6px; border-radius: 9px;
  border: 1px solid currentColor; font-variant-numeric: tabular-nums;
  text-align: center; line-height: 1.2;
}
.trust-good { color: var(--good); }
.trust-mid  { color: #b45309; }
.trust-bad  { color: #b91c1c; background: #fef2f2; }

.paper-body { flex: 1; min-width: 0; }
.paper-body .title { font-size: 13.5px; line-height: 1.4; }
.paper-body .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Slightly-tightened range slider readouts */
input[type="range"] { vertical-align: middle; max-width: 140px; }

/* --- Discovery-Collab ------------------------------------------------------ */
.collab-picker-controls {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 10px;
}
.collab-picker-controls input,
.collab-picker-controls select {
  padding: 6px 10px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 6px; font-size: 13px; background: white;
}
.collab-picker {
  max-height: 380px; overflow-y: auto;
  border: 1px solid var(--border, #cbd5e1); border-radius: 8px;
  background: white;
  padding: 8px;
}
.collab-picker-group { margin-bottom: 8px; }
.collab-picker-group:last-child { margin-bottom: 0; }
.collab-picker-group-h {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; margin-bottom: 4px;
  font-size: 12px; color: var(--muted, #475569);
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.collab-picker-rows {
  display: grid; gap: 2px;
  grid-template-columns: 1fr;
}
@media (min-width: 800px) {
  .collab-picker-rows { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1200px) {
  .collab-picker-rows { grid-template-columns: 1fr 1fr 1fr; }
}
.collab-picker-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) minmax(0, auto) auto;
  align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  font: inherit; text-align: left; cursor: pointer;
  width: 100%; min-width: 0;
}
.collab-picker-row:hover { background: #f1f5f9; }
.collab-picker-row.checked {
  background: #e0f2fe;
  border-color: #7dd3fc;
}
.collab-picker-row .check {
  text-align: center; color: #0369a1; font-weight: 600;
  font-size: 14px;
}
.collab-picker-row .name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.collab-picker-row .cn {
  font-size: 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.collab-picker-row .papers {
  font-size: 11px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.collab-chips { display: flex; flex-wrap: wrap; gap: 6px;
                margin: 10px 0 14px; min-height: 24px; }
.collab-chip  { display: inline-flex; align-items: center; gap: 6px;
                padding: 4px 10px; border-radius: 14px;
                background: var(--bg-soft, #f1f5f9);
                border: 1px solid var(--border, #cbd5e1);
                font-size: 13px; }
.collab-chip button { background: transparent; border: 0; cursor: pointer;
                      color: var(--muted, #64748b); font-size: 14px;
                      padding: 0 2px; line-height: 1; }
.collab-chip button:hover { color: var(--warn, #b91c1c); }

/* Color the keyword-union chips by how many of the selected faculty have
 * this keyword (1 = light, 2 = mid, ≥3 = strong). The .c badge sits inside
 * the chip and shows "Nx · totalPapers". */
.collab-kw.shared-1 { background: #f8fafc; border-color: #e2e8f0; color: #475569; }
.collab-kw.shared-2 { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.collab-kw.shared-3 { background: #c7d2fe; border-color: #6366f1; color: #312e81;
                      font-weight: 600; }
.collab-kw .c { margin-left: 6px; font-size: 11px; opacity: 0.75;
                font-variant-numeric: tabular-nums; }

.collab-grid { display: grid; gap: 14px;
               grid-template-columns: 1fr; }
@media (min-width: 1200px) {
  .collab-grid { grid-template-columns: 1fr 1fr; }
}
.collab-topic-card {
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  padding: 14px 16px;
  background: white;
  page-break-inside: avoid;
  break-inside: avoid;
}
.collab-topic-card h3 { margin: 0 0 6px; font-size: 15px; line-height: 1.35; }
.collab-topic-card .explanation { margin: 0 0 4px; font-size: 13px;
                                  color: var(--muted, #475569); line-height: 1.45; }
.collab-subs { margin: 4px 0 0 18px; padding: 0; font-size: 13px; }
.collab-subs li { margin: 4px 0; line-height: 1.4; }

/* Per-(topic, faculty) embedding similarity badge. Three buckets, colored
 * by strength so the user can scan a card and see which contributors are
 * actually pulling weight semantically vs being shoehorned in. */
.sim-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  border-radius: 9px; font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid currentColor;
}
.sim-badge.sim-strong { color: #166534; background: #dcfce7; }
.sim-badge.sim-mid    { color: #1e40af; background: #dbeafe; }
.sim-badge.sim-weak   { color: #b91c1c; background: #fef2f2; }

/* The LLM is supposed to include every selected faculty in every topic's
 * contributors. When it skips someone, we still render the topic but flag
 * it visibly so the user knows to re-run if they care. */
.collab-topic-card.has-missing { border-color: #fcd34d; background: #fffbeb; }
.collab-missing {
  margin-top: 10px; padding: 6px 10px; border-radius: 5px;
  background: #fef3c7; color: #92400e; font-size: 12px;
  border: 1px solid #fde68a;
}

/* --- Print + PDF export ---------------------------------------------------- *
 * .print-only is the header injected into Discovery / Discover-Emb result
 * containers. Hidden on screen; the @media print rule below makes it visible
 * for the browser print path. The PDF path renders the cloned wrapper
 * directly so it sets visibility inline (see app.js exportResultsToPdf). */
.print-only { display: none; }
.print-header { margin: 0 0 14px; padding-bottom: 6px; border-bottom: 1px solid #aaa; }
.print-header h2 { margin: 0 0 4px; font-size: 18px; }
.print-header .meta { font-size: 12px; color: #555; }

@media print {
  /* Reset background so dark themes don't bleed onto paper. */
  body { background: white !important; color: black !important; }
  /* Hide chrome that has no business on paper. */
  header, .tabs, #drawer, #loading, .modal,
  .discovery-input, .controls, .discovery-examples,
  #discovery-status, #dembStatus, #collabStatus,
  .collab-chip button,
  .collab-picker-section,
  #settings-btn { display: none !important; }
  /* Only the active tab's content survives. */
  .tab:not(.active) { display: none !important; }
  /* The print-only header now appears at the top of the active result. */
  .print-only { display: block !important; }
  main { padding: 0 !important; max-width: none !important; margin: 0 !important; }
  /* Stack subtopic cards instead of side-by-side grid so they fit page width. */
  .discovery-grid { display: block !important; grid-template-columns: unset !important; }
  .subtopic-card { page-break-inside: avoid; break-inside: avoid;
                   box-shadow: none !important; margin-bottom: 12px; }
  /* Strip link colors so anchors don't print as blue noise. */
  a { color: black !important; text-decoration: none !important; }
  /* Keep keyword chips legible without colored backgrounds. */
  .kw { background: white !important; border: 1px solid #888 !important; }
}
