:root {
  --ink: #111;
  --muted: #666;
  --line: #e5e5e5;
  --paper: #fafafa;
  --blue: #111;
  --match: #f0f0f0;
  --match-border: #111;
  --context: #f7f7f7;
  --amber: #666;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: white;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; min-width: 320px; }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
button { border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; background: white; color: var(--ink); font-size: .82rem; white-space: nowrap; }
button:hover { background: var(--context); border-color: #b5b5b5; }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 2px solid #111; outline-offset: 3px; }
input, select { min-width: 0; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
.app-header { display: flex; align-items: center; gap: 16px; padding: 16px 24px; min-height: 74px; border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 13px; flex: none; }
.brand-mark { font: 26px var(--mono); letter-spacing: -7px; padding-right: 7px; }
.brand h1 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.035em; }
.active-capture { padding-left: 18px; margin-left: 2px; border-left: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.dataset-controls { display: flex; gap: 12px; margin-left: auto; min-width: 0; }
.dataset-controls label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: .67rem; }
.dataset-controls select { border: 1px solid var(--line); border-radius: 6px; background: white; padding: 6px 24px 6px 9px; max-width: 275px; font-size: .82rem; color: var(--ink); }
.statistics-launch { background: white; }
main { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(340px, 1fr); flex: 1; min-height: 0; overflow: hidden; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: white; }
.semantic-pane { border-right: 1px solid var(--line); }
.pane-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 20px 22px 16px; min-height: 74px; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -.025em; }
.eyebrow { font: .65rem var(--mono); letter-spacing: .06em; color: var(--muted); }
.count { font: .7rem var(--mono); color: var(--muted); margin-left: auto; }
.pane-tools { display: flex; gap: 7px; padding: 0 22px 12px; }
.search-label { flex: 1; min-width: 0; }
.search-label input { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); padding: 8px 10px; font-size: .84rem; color: var(--ink); }
.search-label input::placeholder { color: #767676; }
.scope-option, .source-context { display: flex; align-items: center; gap: 7px; padding: 0 22px 13px; min-height: 32px; font-size: .73rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.scope-option input { accent-color: #111; margin: 0; }
.source-context { justify-content: space-between; }
.legend { display: flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 7px; height: 7px; background: #111; border-radius: 1px; }
.legend .ancestor-dot { background: transparent; border: 1px dashed #777; margin-left: 8px; }
.tree { flex: 1; min-height: 0; overflow: auto; padding: 12px 12px 28px; scroll-padding: 30px; }
.tree-row { position: relative; display: flex; align-items: flex-start; gap: 6px; min-height: 34px; padding: 7px 8px 7px calc(8px + var(--depth) * 16px); border: 1px solid transparent; border-radius: 5px; font-size: .87rem; cursor: pointer; overflow-wrap: anywhere; line-height: 1.4; }
.tree-row:hover { background: #f7f7f7; }
.tree-row.match { background: var(--match); border-color: #c5c5c5; }
.tree-row.context { background: var(--context); }
.tree-row.via { border: 1px dashed #777; background: #fafafa; }
.tree-row.preview { border-color: #888; background: #f4f4f4; }
.tree-row.selected { background: #111; border-color: #111; color: white; }
.tree-row.selected .row-id, .tree-row.selected .node-kind, .tree-row.selected .expander,
.tree-row.selected .dom-tag, .tree-row.selected .dom-text, .tree-row.selected .dom-identity { color: #eee; border-color: #777; }
.expander { border: 0; background: transparent; padding: 0; width: 15px; flex: none; line-height: 19px; color: #777; font: 13px/19px var(--mono); }
.node-kind { font: .6rem var(--mono); flex: none; color: #777; border: 1px solid #ddd; padding: 1px 3px; border-radius: 3px; margin-top: 2px; }
.node-kind.group { color: #444; }
.row-label { min-width: 0; flex: 1; }
.row-id { font: .64rem var(--mono); color: #777; flex: none; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.dom-tree .tree-row { font: .76rem/1.5 var(--mono); white-space: nowrap; min-width: max-content; padding-right: 14px; }
.dom-tree .row-label { flex: none; display: flex; gap: 8px; }
.dom-tag { color: #222; }
.dom-identity { color: #555; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.dom-text { color: #777; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.dom-tree .row-id { margin-left: 8px; max-width: none; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; flex: none; background: #fafafa; }
.view-switch button { border: 0; background: transparent; border-radius: 4px; font-size: .76rem; padding: 5px 9px; color: var(--muted); }
.view-switch button[aria-pressed=true] { background: #111; color: white; }
.keyboard-help { border-top: 1px solid var(--line); padding: 10px 22px; color: var(--muted); font-size: .73rem; }
.keyboard-help p { padding-top: 8px; }
.pane-caption { font-size: .73rem; color: var(--muted); padding: 12px 0; }
.selection-detail { border-top: 1px solid var(--line); background: #fafafa; flex: none; padding: 14px 24px; max-height: 28vh; overflow: auto; }
.selection-top { display: flex; align-items: center; gap: 14px; }
.selection-top #match-count { font-size: .73rem; color: var(--muted); }
.selection-top button { margin-left: auto; font-size: .73rem; padding: 4px 8px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 8px; min-width: 0; }
.detail-grid > * { min-width: 0; }
h3 { font-size: .91rem; font-weight: 600; }
.detail-grid p { font-size: .78rem; color: var(--muted); line-height: 1.55; margin-top: 5px; }
.detail-grid code { display: block; font: .73rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; }
#source-detail summary { font-size: .78rem; }
#source-attributes { font-family: var(--mono); }
.selection-navigation { font-size: .73rem; line-height: 1.5; color: var(--muted); margin-top: 8px; }
.screenshot-panel { flex: 1; min-height: 0; overflow: auto; background: #fafafa; padding: 20px; }
.screenshot-panel > p:first-child { font-size: .75rem; margin-bottom: 12px; color: var(--muted); }
.screenshot-stage { position: relative; width: 100%; background: white; border: 1px solid var(--line); }
.screenshot-stage img { width: 100%; display: block; }
.screenshot-stage #overlays { position: absolute; inset: 0; pointer-events: none; }
.bound { position: absolute; background: #00000012; border: 2px solid #111; pointer-events: auto; border-radius: 2px; min-width: 0; min-height: 0; padding: 0; }
.bound:hover, .bound:focus-visible { background: #00000025; border-color: #111; }
.error { padding: 12px 24px; background: #f3f3f3; border-bottom: 1px solid #111; color: #111; }
.empty { padding: 30px 20px; color: var(--muted); font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.statistics-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.statistics-heading p { color: var(--muted); font-size: .83rem; margin-top: 6px; }
#statistics-dialog { width: min(940px, calc(100vw - 32px)); max-height: 88dvh; border: 1px solid var(--line); border-radius: 12px; padding: 26px; color: var(--ink); box-shadow: 0 20px 80px #00000022; }
#statistics-dialog::backdrop { background: #00000066; }
.statistics-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.statistics-card { padding: 15px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.statistics-card > span { font-size: .77rem; color: var(--muted); }
.statistics-card > strong { display: block; font-size: 1.65rem; font-weight: 600; margin: 6px 0; font-variant-numeric: tabular-nums; }
.statistics-card p, .statistics-explanation, .statistics-caveat, .statistics-method { font-size: .81rem; line-height: 1.6; color: var(--muted); }
.statistics-caveat { margin: 16px 0 22px; }
.statistics-explanation { margin: 8px 0 12px; }
.statistics-table-wrap { overflow-x: auto; }
.statistics-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.statistics-table th, .statistics-table td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; vertical-align: top; }
.statistics-table th:first-child, .statistics-table td:first-child { text-align: left; }
.statistics-table th { font-weight: 500; }
.statistics-table thead { background: var(--paper); }
.statistics-method { margin: 16px 0 24px; }
.statistics-method summary { color: var(--ink); }
.statistics-method li { margin-bottom: 7px; }
.statistics-target-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.targets-table td:first-child { width: 55%; }
.targets-table code { display: block; color: var(--muted); font-size: .72rem; margin-top: 4px; }
.statistics-target-link { border: 0; background: transparent; padding: 0; color: var(--ink); text-align: left; line-height: 1.4; }
.statistics-target-link:hover { text-decoration: underline; background: transparent; }
@media (max-width: 1100px) {
  .app-header { gap: 12px; padding: 14px 18px; flex-wrap: wrap; }
  .dataset-controls select { max-width: 210px; }
  .pane-heading { padding: 16px 14px; }
  .pane-tools { padding-inline: 14px; }
  .scope-option, .source-context { padding-inline: 14px; }
  .legend { display: none; }
  .row-id { display: none; }
  .dom-tree .row-id { display: block; }
}
@media (max-width: 720px) {
  body { height: auto; min-height: 100dvh; }
  .app-header { padding: 14px; gap: 12px; }
  .active-capture { margin-left: auto; font-size: .8rem; }
  .dataset-controls { order: 2; width: 100%; margin: 0; }
  .dataset-controls label { flex: 1; }
  .dataset-controls select { max-width: 100%; width: 100%; }
  main { display: flex; flex-direction: column; flex: none; }
  .pane { height: 55vh; min-height: 320px; }
  .semantic-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .pane-heading { gap: 7px; min-height: 70px; }
  .pane-tools { gap: 5px; }
  .pane-tools button { padding: 7px; font-size: .75rem; }
  .view-switch button { font-size: .71rem; padding-inline: 7px; }
  .selection-detail { padding: 14px; max-height: none; }
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .selection-top { flex-wrap: wrap; gap: 8px; }
  #statistics-dialog { padding: 18px; }
  .statistics-summary { grid-template-columns: 1fr; }
  .statistics-card { padding: 10px 14px; }
  .statistics-card > strong { font-size: 1.35rem; }
  .statistics-target-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .tree-row { transition: background-color .1s, border-color .1s; }
}
