/* Visual language borrowed from the Browser Profiles design system: semantic
 * tokens, thin borders, moderate radii, compact table density, indigo accent.
 * Only the language — no components or business code are copied.
 *
 * Deviation, on purpose: Vela Sans is not shipped here. Bundling the font would
 * mean adding font-src to the CSP, and the security headers are out of scope
 * for this change, so the system stack is used with the same size/weight scale.
 */

:root {
  --app-bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-quiet: #94a3b8;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --focus: #818cf8;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-panel: 0 1px 2px rgb(15 23 42 / 0.04), 0 1px 3px rgb(15 23 42 / 0.06);
  --font-sans: "Vela Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --app-bg: #070b14;
    --surface: #111827;
    --surface-muted: #0b1220;
    --surface-subtle: #1e293b;
    --border: #263449;
    --border-strong: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-quiet: #64748b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: #1e1b4b;
    --accent-border: #3730a3;
    --success: #00c670;
    --success-soft: #052e1d;
    --warning: #fde68a;
    --warning-soft: #2a1f05;
    --danger: #f87171;
    --danger-soft: #2a0f12;
    --shadow-panel: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 auto;
  max-width: 78rem;
  padding: 20px 12px 64px;
  color: var(--text-primary);
  background: var(--app-bg);
}

h1 { font-size: 21px; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }

.lead { color: var(--text-secondary); max-width: 52rem; margin: 0; }
.hint { color: var(--text-muted); font-size: 11.5px; margin: 6px 0; }

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
  padding: 14px 16px 16px;
  margin-top: 12px;
}

header { padding: 4px 2px 8px; }
footer { color: var(--text-muted); font-size: 11.5px; margin-top: 24px; padding: 0 2px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
label { color: var(--text-secondary); font-size: 12px; }

/* ------------------------------- controls ------------------------------ */

button, select, input[type="text"], textarea, input[type="file"] {
  font: inherit;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 7px 11px;
  min-height: 32px;
}

button { cursor: pointer; color: var(--text-secondary); font-weight: 500; }
button:hover { background: var(--surface-muted); }
button[disabled] { opacity: 0.5; cursor: progress; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: var(--accent-hover); }
button.danger { border-color: var(--danger); color: var(--danger); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

input[type="text"] { flex: 1 1 22rem; min-width: 10rem; background: var(--surface-muted); }
input[type="text"]:focus { background: var(--surface); }
textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 11.5px;
  resize: vertical;
  background: var(--surface-muted);
}
input[type="file"] { padding: 5px 8px; background: var(--surface-muted); }

/* ------------------------------- summary ------------------------------- */

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }

.sum {
  flex: 1 1 200px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 12px;
  padding: 9px 12px;
  background: var(--surface-muted);
}
.sum b { display: block; font-size: 22px; font-weight: 650; line-height: 1.15; }
.sum span { color: var(--text-muted); font-size: 11.5px; }
.sum p { margin: 4px 0 0; font-size: 12px; color: var(--text-secondary); word-break: break-word; }
.sum-leak { border-left-color: var(--danger); background: var(--danger-soft); }
.sum-leak b { color: var(--danger); }
.sum-warn { border-left-color: var(--warning); background: var(--warning-soft); }
.sum-quiet { border-left-color: var(--border-strong); }

/* -------------------------------- network ------------------------------ */

.net {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 10px 0 14px;
}
.net-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--surface-muted);
}
.net-cell {
  flex: 1 1 160px;
  padding: 8px 12px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.net-cell:last-child { border-right: 0; }
.net-cell i {
  display: block;
  font-style: normal;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-quiet);
  margin-bottom: 2px;
}
.net-cell b { font-size: 12.5px; font-weight: 550; word-break: break-all; }
.net-rtc {
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* -------------------------------- filters ------------------------------ */

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.filters button {
  border-radius: 999px;
  padding: 5px 12px;
  min-height: 28px;
  font-size: 11.5px;
}
.filters button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

/* -------------------------------- tables ------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
th {
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-muted);
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-muted); }

.surface-name { font-weight: 600; font-size: 12px; color: var(--text-primary); }
.surface-id { display: block; color: var(--text-quiet); font-size: 10.5px; }

.st { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11.5px; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex: none; }
.st-leak { color: var(--danger); }
.st-partial, .st-mismatch { color: var(--warning); }
.st-applied { color: var(--success); }
.st-inconclusive { color: var(--warning); }
.st-unproven, .st-inactive, .st-not_applicable { color: var(--text-muted); }
.reason { display: block; color: var(--text-muted); font-size: 10.5px; margin-top: 2px; max-width: 24ch; }

.val { word-break: break-word; overflow-wrap: anywhere; }
.val.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mono { font-family: var(--font-mono); font-size: 11px; }
.absent { color: var(--text-quiet); font-style: italic; }
.more {
  display: block;
  margin-top: 3px;
  padding: 0;
  min-height: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 500;
}
.more:hover { background: none; text-decoration: underline; }

.ctx-toggle {
  padding: 3px 9px;
  min-height: 24px;
  font-size: 10.5px;
  border-radius: 999px;
  white-space: nowrap;
}
.ctx-toggle[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.ctx-row > td { background: var(--surface-muted); padding: 0 8px 10px; }
.ctx-row table { font-size: 10.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.ctx-row th { background: var(--surface-subtle); }

details { margin: 10px 0 0; }
summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-secondary);
  padding: 7px 0;
}
summary:hover { color: var(--text-primary); }
details .table-wrap { margin-top: 6px; }

code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-subtle);
  padding: 1px 5px;
  border-radius: 5px;
}
pre {
  font-family: var(--font-mono);
  background: var(--surface-subtle);
  padding: 8px;
  overflow-x: auto;
  border-radius: 8px;
  margin: 4px 0;
  font-size: 10.5px;
}

ul { padding-left: 18px; margin: 6px 0; }
li { margin: 3px 0; }
ul#progress { color: var(--text-muted); font-size: 11.5px; }
ul#limits { color: var(--text-secondary); font-size: 11.5px; }

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  padding: 9px 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin: 10px 0;
}

.error {
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: 9px 12px;
  margin-top: 10px;
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The probe's same-origin iframe: present but out of the way. */
.leak-probe-frame { width: 1px; height: 1px; opacity: 0; position: absolute; left: -9999px; border: 0; }

/* Independent CSS path for the fixed matchMedia v1 matrix. The probe reads
   these values from computed style; script never writes them. */
:root {
  --lc-media-dark: 0;
  --lc-media-reducedMotion: 0;
  --lc-media-forcedColors: 0;
  --lc-media-coarsePointer: 0;
  --lc-media-p3Gamut: 0;
  --lc-media-dynamicRange: 0;
}
@media (prefers-color-scheme: dark) { :root { --lc-media-dark: 1; } }
@media (prefers-reduced-motion: reduce) { :root { --lc-media-reducedMotion: 1; } }
@media (forced-colors: active) { :root { --lc-media-forcedColors: 1; } }
@media (any-pointer: coarse) { :root { --lc-media-coarsePointer: 1; } }
@media (color-gamut: p3) { :root { --lc-media-p3Gamut: 1; } }
@media (dynamic-range: high) { :root { --lc-media-dynamicRange: 1; } }
.leak-domrect-sentinel {
  position: fixed; left: -10000px; top: -10000px; width: 123.25px; height: 47.5px;
  transform: translate(0.125px, 0.375px); visibility: hidden; pointer-events: none;
}

/* ------------------------------ responsive ----------------------------- */

@media (max-width: 760px) {
  body { padding: 14px 10px 48px; }
  section { padding: 12px; border-radius: 12px; }
  .net-cell { flex: 1 1 100%; border-right: 0; border-bottom: 1px solid var(--border); }
  .net-cell:last-child { border-bottom: 0; }

  /* The main table becomes surface cards: the value and its status stay
     visible without scrolling to a far-right column. Direct-child selectors
     only — the nested context table must keep a normal table layout. */
  table.cards,
  table.cards > tbody,
  table.cards > tbody > tr,
  table.cards > tbody > tr > td { display: block; width: 100%; }
  table.cards > thead { display: none; }
  table.cards > tbody > tr.surface-row {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: var(--surface);
  }
  table.cards > tbody > tr > td { border-bottom: 0; padding: 3px 0; }
  table.cards > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 9.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-quiet);
  }
  table.cards > tbody > tr > td[data-label="Поверхность"]::before { display: none; }
  .reason { max-width: none; }

  /* `display: block` above would otherwise defeat the hidden attribute and
     leave an empty strip where a collapsed context row sits. */
  table.cards > tbody > tr[hidden] { display: none; }

  /* The status label must stay fully readable inside a card, so it wraps
     instead of being clipped; the dot stays on its first line. */
  .st { white-space: normal; align-items: flex-start; }
  .st::before { margin-top: 5px; }

  table.cards > tbody > tr.ctx-row { border: 0; margin: 0 0 8px; padding: 0; }
  .ctx-row > td { padding: 0; }
  .ctx-row .table-wrap { overflow-x: auto; }
  .ctx-row table { min-width: 520px; }
}
