/* Spacing 4/8/12/16/24. Type 12/14/18, mono at 13. Radius 6px, 4px on tags. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --bg-2: #f3f4f6;
  --line: #e4e6ea;
  --line-2: #d2d6dc;
  --text: #1b1f24;
  --muted: #5f6873;
  --faint: #687079;
  --accent: #1f5fae;
  --ring: rgba(31, 95, 174, .25);
  --hover: #f7f8fa;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --live: #1f9d55;
  --live-glow: rgba(31, 157, 85, .45);
  --label-bg: #fdeeee;
  --label-bg-hover: #fadcdc;
  --label-line: #d77a7a;
  --label-fg: #a3201d;
  --del-bg: #ffeef0;
  --del-hl: #ffc9cc;
  --del-fg: #b42318;
  --add-bg: #e8f7ec;
  --add-hl: #b4ecc3;
  --add-fg: #1a7f37;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --w: 1200px;
  --pad: 24px;
  --r: 6px;
  color-scheme: light;
}
/* Dark theme: system, or the toggle's pick (<html data-theme>). Keep both
   blocks identical. Text colors meet WCAG AA on every surface. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131518;
    --surface: #1a1d21;
    --bg-2: #202328;
    --line: #2a2e34;
    --line-2: #383d44;
    --text: #dcdfe3;
    --muted: #9aa1aa;
    --faint: #8a919a;
    --accent: #84aee6;
    --ring: rgba(132, 174, 230, .3);
    --hover: #1e2125;
    --shadow: none;
    --live: #3fb950;
    --live-glow: rgba(63, 185, 80, .45);
    --label-bg: #3a1f21;
    --label-bg-hover: #4a2427;
    --label-line: #a64545;
    --label-fg: #f3a5a5;
    --del-bg: #2e1a1d;
    --del-hl: #5c2a2f;
    --del-fg: #f3a5a5;
    --add-bg: #14261b;
    --add-hl: #1f4d2d;
    --add-fg: #7ee2a0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131518;
  --surface: #1a1d21;
  --bg-2: #202328;
  --line: #2a2e34;
  --line-2: #383d44;
  --text: #dcdfe3;
  --muted: #9aa1aa;
  --faint: #8a919a;
  --accent: #84aee6;
  --ring: rgba(132, 174, 230, .3);
  --hover: #1e2125;
  --shadow: none;
  --live: #3fb950;
  --live-glow: rgba(63, 185, 80, .45);
  --label-bg: #3a1f21;
  --label-bg-hover: #4a2427;
  --label-line: #a64545;
  --label-fg: #f3a5a5;
  --del-bg: #2e1a1d;
  --del-hl: #5c2a2f;
  --del-fg: #f3a5a5;
  --add-bg: #14261b;
  --add-hl: #1f4d2d;
  --add-fg: #7ee2a0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
code, kbd, .mono { font-family: var(--mono); font-size: 13px; }
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Controls: one height, radius and focus ring for input, buttons, toggles. */
button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font: 500 13px var(--sans);
  cursor: pointer;
  box-shadow: var(--shadow);
}
button:hover { background: var(--hover); border-color: var(--faint); }
/* Square icon button (theme toggle). Shows the theme it switches to. */
button.icon { width: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--muted); }
button.icon:hover { color: var(--text); }
button.icon .sun, button.icon[data-mode="dark"] .moon { display: none; }
button.icon[data-mode="dark"] .sun { display: block; }
/* Theme toggle sits at the right edge, mirroring the home link on the left. */
.top #theme { margin-left: auto; }
/* Admin shortcut (top bar, admins only): pushed right, next to the theme. */
.top .admin-link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--muted);
  font: 500 13px var(--sans);
  white-space: nowrap;
}
.top .admin-link:hover { text-decoration: none; color: var(--text); background: var(--hover); border-color: var(--faint); }
.top .admin-link + #theme { margin-left: 8px; }
button.link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--accent);
  font: inherit;
}
button.link:hover { text-decoration: underline; text-underline-offset: 2px; }
/* Destructive actions (delete a target). */
button.danger { color: var(--del-fg); border-color: var(--label-line); }
button.danger:hover { background: var(--label-bg-hover); border-color: var(--label-line); }
button.link.danger { margin-left: auto; border: 0; color: var(--del-fg); }
button.link.danger:hover { background: none; }

/* Top bar: shares the content column via padding, so edges align. */
.top {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 24px;
  align-items: center;
  height: 56px;
  padding: 0 max(var(--pad), calc((100% - var(--w)) / 2 + var(--pad)));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.home { color: var(--muted); white-space: nowrap; }
.home:hover { color: var(--text); text-decoration: none; }
.search { position: relative; flex: 1; display: flex; gap: 8px; max-width: 760px; }
.search input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font: 13px var(--mono);
  box-shadow: var(--shadow);
}
.search input::placeholder { color: var(--faint); }
.search input:hover { border-color: var(--faint); }
.search input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.search .field { position: relative; flex: 1; min-width: 0; display: flex; }
.search .hint { position: absolute; right: 8px; top: 7px; pointer-events: none; }
.search input:focus ~ .hint, .search input:not(:placeholder-shown) ~ .hint { display: none; }

main { max-width: var(--w); margin: 0 auto; padding: 24px var(--pad) 48px; }
h1 { font-size: 18px; font-weight: 600; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 14px; font-weight: 600; margin: 0; }
h1.mono { font-size: 18px; }

/* Surface: every block of content sits in one of these. */
.panel {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 44px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  font-size: 12px;
}
.panel-foot:has(> button[hidden]) { display: none; }
.panel-body > table tr:last-child td, .results li:last-child { border-bottom: 0; }
.empty-state { padding: 24px 16px; color: var(--muted); text-align: center; }

.meta { color: var(--muted); overflow-wrap: anywhere; }
/* Items move to the next line whole; long ones still wrap inside. */
.meta > span:not(.sep), .meta > a, .meta > button { display: inline-block; max-width: 100%; }
.sep { margin: 0 8px; color: var(--line-2); }

/* Message box, optional bold title line. */
.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--muted);
}
.ask-out { margin: 0; padding: 12px 16px; font: 13px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.notice strong { display: block; margin-bottom: 2px; color: var(--text); font-weight: 600; }

/* Tags: module names, "vhost". Neutral, small. */
.tag {
  display: inline-block;
  margin: 0 4px 0 0;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--muted);
  font: 12px/18px var(--sans);
  white-space: nowrap;
  vertical-align: 1px;
}
.more-tags { color: var(--faint); font-size: 12px; }

/* Segmented control: tinted track, selected option raised. */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
}
.seg button {
  height: 24px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
}
.seg button:hover { background: none; color: var(--text); }
.seg button[aria-pressed="true"] { border-color: var(--line-2); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button:focus-visible { outline-offset: 0; }

/* Panel header controls, e.g. [Live] [All | With facts]. */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Live dot: a halo grows and fades every 2.4 s. Reduced motion: static. */
.live-dot {
  position: relative;
  isolation: isolate;
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 10px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 6px 1px var(--live-glow);
  vertical-align: 1px;
  animation: live-breathe 2.4s ease-in-out infinite;
}
.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1; /* halo behind the dot, so the dot stays solid */
  border-radius: 50%;
  background: var(--live-glow);
  animation: live-halo 2.4s cubic-bezier(.2, .6, .4, 1) infinite;
}
.live-dot[hidden] { display: none; }
@keyframes live-halo {
  0% { transform: scale(1); opacity: .9; }
  70%, 100% { transform: scale(3); opacity: 0; }
}
@keyframes live-breathe { 50% { opacity: .75; } }
@media (prefers-reduced-motion: reduce) {
  .live-dot, .live-dot::after { animation: none; }
  .live-dot::after { transform: scale(1.8); opacity: .35; }
}

/* Home: query syntax as a compact reference, two pairs per row on desktop. */
.syntax {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
  gap: 0 24px;
  margin: 0;
  padding: 8px 16px;
  font: 13px/1.5 var(--mono);
}
.syntax dt, .syntax dd { padding: 4px 0; }
.syntax dt { color: var(--muted); }
.syntax dd { margin: 0; overflow-wrap: anywhere; }

/* Data tables. */
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
th {
  height: 36px;
  background: var(--bg-2);
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}
.list { table-layout: fixed; }
.list td { font-size: 13px; height: 41px; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--hover); }
.list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .name a { margin-right: 8px; }
/* Labels sit inline after the name and wrap instead of being clipped. */
.list .name { white-space: normal; overflow-wrap: anywhere; }
.list .name .labels { margin-left: 0; }
.list .ip { width: 160px; color: var(--muted); }
.list .mods { width: 300px; white-space: nowrap; overflow: hidden; }
.list th.num { width: 112px; }
.list .date { width: 120px; }
.list tr.empty .name a { color: var(--muted); }
.none { color: var(--faint); font-size: 12px; }
.num { text-align: right; }
.date { color: var(--muted); white-space: nowrap; }
.list td.date { text-align: right; }
.list th.date { text-align: right; }

/* Results: one entry per target inside the panel, matched facts beneath. */
.query {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--text);
  font-size: 12px;
}
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.results li:hover { background: var(--hover); }
.r-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.r-head > a { font-weight: 600; overflow-wrap: anywhere; }
.r-head .tag { margin: 0; }
.r-meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.r-meta .mono { font-size: 12px; }
.r-meta .sep { margin: 0 6px; }
.hit {
  margin-top: 4px;
  font: 12px/1.6 var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit-k { color: var(--muted); }

/* Detail page. */
.head { padding: 16px; }
.head h1 { margin-bottom: 4px; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; }
.group-by { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

details.module summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-height: 40px;
  padding: 8px 16px;
  background: var(--bg-2);
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
details.module[open] summary { border-bottom: 1px solid var(--line); }
details.module summary:hover { color: var(--text); }
details.module summary::-webkit-details-marker { display: none; }
details.module summary::before { content: "\25BE"; color: var(--faint); width: 8px; }
details.module:not([open]) summary::before { content: "\25B8"; }
details.module summary h2 { font: 600 13px var(--mono); color: var(--text); }
details.module summary a { margin-left: auto; }

.facts { table-layout: fixed; }
.facts td { font: 13px/1.5 var(--mono); padding-top: 6px; padding-bottom: 6px; vertical-align: baseline; }
.facts tr:last-child td { border-bottom: 0; }
.facts tr:hover td { background: var(--hover); }
.facts .port { width: 112px; color: var(--muted); }
.facts .port.rep { color: transparent; }
.facts tr:hover .port.rep { color: var(--muted); }
.facts .key { width: 28%; overflow-wrap: anywhere; }
.facts.by-port .key { width: 36%; }
.facts .key a { color: var(--muted); }
.facts .val { overflow-wrap: anywhere; }
.facts .val a { color: var(--text); }
.facts .key a:hover, .facts .val a:hover { color: var(--accent); }
/* Label tags <[ label ]. clip-path drops borders, so the element is the line
   color, ::after the fill inset 1px, ::before the eyelet. */
.labels { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; vertical-align: 1px; }
h1 .labels { vertical-align: 3px; }
.label {
  position: relative;
  isolation: isolate;
  display: inline-block;
  padding: 0 6px 0 14px;
  border-radius: 0 4px 4px 0;
  background: var(--label-line);
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%);
  font: 12px/20px var(--sans);
  white-space: nowrap;
}
.label::after {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 0 3px 3px 0;
  background: var(--label-bg);
  clip-path: polygon(7px 0, 100% 0, 100% 100%, 7px 100%, 0.6px 50%);
}
.label::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 6px;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--label-line);
}
a.label, .facts .val a.label { color: var(--label-fg); }
a.label:hover, .facts .val a.label:hover { color: var(--label-fg); text-decoration: none; }
a.label:hover::after { background: var(--label-bg-hover); }
a.label:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; clip-path: none; }

/* "+N" pivot badge: N other targets share this value; click to list them. */
.pivot {
  display: inline-block;
  margin-left: 8px;
  padding: 0 5px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--bg-2);
  color: var(--muted);
  font: 11px/16px var(--mono);
  vertical-align: 1px;
  white-space: nowrap;
}
.facts .val a.pivot { color: var(--muted); }
.facts .val a.pivot:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Compare: two scans side by side, removed on the left in red, added on the
   right in green. The +/- gutter is a pseudo-element, so copying skips it. */
.cmp-form, .cmp-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cmp-form .input { width: 220px; height: 32px; }
.cmp-inline { margin-left: 4px; }
.cmp-inline .input { width: 180px; }
.cmp-inline button { height: 28px; }
.input[aria-invalid="true"] { border-color: var(--del-fg); }
.meta > form { display: inline-flex; max-width: 100%; }
.diff-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.stat-add { color: var(--add-fg); font-weight: 600; }
.stat-del { color: var(--del-fg); font-weight: 600; }
.diff { table-layout: fixed; }
.diff th { height: auto; padding: 10px 16px; font-weight: 400; white-space: normal; vertical-align: top; color: var(--text); }
.diff th + th, .diff td + td { border-left: 1px solid var(--line); }
.side-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.side-name .tag { margin: 0; }
.side .meta { margin-top: 2px; font-weight: 400; }
.diff tbody td { padding: 2px 12px 2px 28px; position: relative; font: 12px/1.6 var(--mono); overflow-wrap: anywhere; vertical-align: top; }
.diff tbody td { border-bottom: 0; }
.diff .d-scope { color: var(--muted); }
.diff .d-key { color: var(--muted); font-weight: 600; }
.diff td.del { background: var(--del-bg); }
.diff td.add { background: var(--add-bg); }
.diff td.del::before, .diff td.add::before { position: absolute; left: 10px; font-weight: 700; }
.diff td.del::before { content: "\2212" / "removed"; color: var(--del-fg); }
.diff td.add::before { content: "+" / "added"; color: var(--add-fg); }
.diff td.empty { background: var(--bg-2); }
.diff mark { color: inherit; border-radius: 2px; }
.diff td.del mark { background: var(--del-hl); }
.diff td.add mark { background: var(--add-hl); }
.diff tr.gap td { padding: 4px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-2); font-family: var(--sans); font-size: 12px; text-align: center; }
.diff td.empty-state { padding: 24px 16px; font-family: var(--sans); font-size: 14px; }

/* Previous scans list, under the target header. */
.head .history { margin: 12px -16px 0; border-top: 1px solid var(--line); }
.head .history:last-child { margin-bottom: -16px; }
.head .history + .admin-row { margin-top: 0; }
.head .history > p { padding: 12px 16px; }
.hist td { font-size: 13px; height: 36px; }
.hist tbody tr:last-child td { border-bottom: 0; }
.hist tr.cur td { background: var(--hover); }
.hist .acts { text-align: right; white-space: nowrap; }
.hist .acts .sep { margin: 0 6px; }

/* Admin tools. */
.input {
  height: 28px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font: 13px var(--mono);
}
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.head .admin-row { margin: 12px -16px -16px; background: var(--bg-2); }
.admin-row button, .rule-form button { height: 28px; }
.admin-err { color: var(--label-fg); font-size: 12px; }
/* Admin overview: one cell per count, separated by the panel's line color. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  background: var(--line);
}
.stat { display: flex; flex-direction: column; gap: 1px; padding: 12px 16px; background: var(--surface); }
.stat-n { font-size: 20px; font-weight: 600; line-height: 1.2; }
.stat-l { color: var(--muted); font-size: 12px; }
.stat-note { color: var(--faint); font-size: 11px; }
.own-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 2px 4px 2px 0;
  padding: 0 2px 0 6px;
  border: 1px solid var(--label-line);
  border-radius: 4px;
  background: var(--label-bg);
  color: var(--label-fg);
  font: 12px/20px var(--sans);
}
button.x {
  height: 18px;
  width: 18px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font-size: 14px;
  line-height: 18px;
}
button.x:hover { background: var(--label-bg-hover); }
.rule-btn {
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  color: var(--muted);
  font: 11px var(--sans);
  box-shadow: none;
  visibility: hidden;
}
.facts tr:hover .rule-btn, .rule-btn:focus-visible { visibility: visible; }
.rule-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 8px; font-family: var(--sans); }
.rule-form .input { width: 180px; }
.rule-form select.input { width: auto; font-family: var(--sans); }
.panel-note { padding: 12px 16px; color: var(--muted); font-size: 13px; }
.admin-form { display: grid; gap: 12px; max-width: 360px; padding: 16px; }
.field-row { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.admin-row .field-row { flex: 1 1 140px; }
.admin-row:has(.field-row) { align-items: flex-end; }
.admin-form .input { height: 32px; }
.admin-table td { font-size: 13px; }
.admin-table .val { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .list .mods { width: 200px; }
  .syntax { grid-template-columns: max-content minmax(0, 1fr); }
}
@media (max-width: 640px) {
  :root { --pad: 12px; }
  .top { gap: 12px; height: auto; padding-top: 8px; padding-bottom: 8px; }
  .search button, .search .hint { display: none; }
  .search button.ask { display: inline-block; }
  .search input { padding-right: 12px; }
  main { padding-top: 12px; }
  .hide-sm { display: none; }
  .panel-head, .panel-foot, .results li, .head, details.module summary { padding-left: 12px; padding-right: 12px; }
  th:first-child, td:first-child { padding-left: 12px; }
  th:last-child, td:last-child { padding-right: 12px; }
  .list th.num { width: 96px; }
  .list .date { width: 88px; }
  .syntax { gap: 0 16px; padding: 8px 12px; font-size: 12px; }
  .r-meta { margin-left: 0; flex-basis: 100%; }

  /* Facts stack: port + key on one line, value under it. */
  .facts, .facts tbody { display: block; }
  .facts tr { display: flex; flex-wrap: wrap; padding: 6px 12px; border-bottom: 1px solid var(--line); }
  .facts tr:last-child { border-bottom: 0; }
  .facts td { border: 0; padding: 0 8px 0 0 !important; width: auto !important; background: none !important; }
  .facts .port.rep { color: var(--muted); }
  .facts .val { flex-basis: 100%; }

  /* Diff halves stack: removed above added. */
  .diff, .diff thead, .diff tbody, .diff tr, .diff th, .diff td { display: block; }
  .diff th + th, .diff td + td { border-left: 0; }
  .diff th { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .diff td.empty, .diff td.dup { display: none; } /* unchanged: shown once */
  .cmp-form { width: 100%; }
  .cmp-form .input { flex: 1 1 100%; width: auto; }
  .cmp-form .icon { order: 3; }
  .cmp-form button[type="submit"] { order: 4; flex: 1; }
  .rule-btn { visibility: visible; } /* no hover on touch screens */
}
@media (max-width: 420px) {
  .syntax { grid-template-columns: 1fr; }
  .syntax dt { padding-bottom: 0; }
  .syntax dd { padding-top: 0; }
}
