/* Hardware Test Online family — shared design tokens and components.
 * Used by every page on hardwaretestonline.com.
 *
 * /monitor-test/ used to opt out, on the grounds that a calibration tool wants
 * colour-uninflected chrome. It doesn't any more: the patterns are judged full screen,
 * where no chrome is on the panel at all, so the landing view may as well match its
 * siblings. Keep test surfaces themselves painted from raw values, never tokens.
 *
 * Theme: the light palette is the base on :root. Dark is redefined twice — once behind
 * prefers-color-scheme for viewers who never chose, once behind [data-theme="dark"] so the
 * toggle wins either way. Components only ever read tokens, never a raw color.
 */
*, *::before, *::after { box-sizing: border-box; }

/* Self-hosted IBM Plex, latin subset (OFL). `optional` rather than `swap`: a font that
 * arrives late is skipped for that page view instead of reflowing the text under the reader,
 * which is what drove layout shift on the text-heavy pages. Every page preloads the two
 * files used above the fold, so on a normal connection they make the 100 ms window.
 * Paths are root-relative so the same rule works from any page depth. */
@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: optional;
  src: url(/fonts/ibm-plex-sans-var.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: optional;
  src: url(/fonts/ibm-plex-mono-400.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: optional;
  src: url(/fonts/ibm-plex-mono-600.woff2) format("woff2");
}

:root {
  --bg: #f3f5fa;
  --panel: #ffffff;
  --panel-2: #eaeef6;
  --line: #d8dee9;
  --text: #10141d;
  --muted: #596174;
  --dim: #626a7c;
  --accent: #0f766e;
  --accent-2: #4f46e5;
  --on-accent: #ffffff;
  --good: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 20, 29, .06);
  --radius: 10px;
  --font: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c11;
    --panel: #11141c;
    --panel-2: #171b25;
    --line: #242a3a;
    --text: #e7eaf3;
    --muted: #8a92a6;
    --dim: #7d8599;
    --accent: #5eead4;
    --accent-2: #818cf8;
    --on-accent: #06110f;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0c11;
  --panel: #11141c;
  --panel-2: #171b25;
  --line: #242a3a;
  --text: #e7eaf3;
  --muted: #8a92a6;
  --dim: #7d8599;
  --accent: #5eead4;
  --accent-2: #818cf8;
  --on-accent: #06110f;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

main { padding: 0 clamp(12px, 3vw, 28px) 48px; max-width: 1500px; margin: 0 auto; }

:where(button, select, input, a):focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ---------- header ---------- */
.bar {
  display: flex; flex-wrap: wrap; gap: 16px 24px;
  align-items: flex-end; justify-content: space-between;
  padding: 20px clamp(12px, 3vw, 28px) 18px;
  max-width: 1500px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  margin: 0; font-family: var(--mono); font-weight: 600;
  font-size: clamp(1.25rem, 2.4vw, 1.7rem); letter-spacing: -0.03em;
}
.logo { width: clamp(1.4rem, 2.6vw, 1.9rem); height: clamp(1.4rem, 2.6vw, 1.9rem); flex-shrink: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.ctl { display: flex; flex-direction: column; gap: 4px; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; }
.ctl select {
  font: inherit; font-size: 0.85rem; text-transform: none; letter-spacing: 0;
  color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; box-shadow: var(--shadow);
  max-width: 16rem; text-overflow: ellipsis;
}
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.sw {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 0.8rem; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 11px 6px 9px; user-select: none;
  box-shadow: var(--shadow);
}
.sw:has(input:checked) {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 35%, transparent);
}
.sw:has(input:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.sw input { accent-color: var(--accent); margin: 0; }
.btns { display: flex; gap: 6px; }
.btn {
  font: inherit; font-size: 0.82rem; color: var(--text); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.icon { padding: 7px 10px; }
.btn.ok { color: var(--good); border-color: var(--good); }
.btn.primary {
  color: var(--on-accent); background: var(--accent); border-color: var(--accent);
  font-size: 0.95rem; font-weight: 600; padding: 10px 20px;
}
.btn.primary:hover { filter: brightness(1.06); }
.mini {
  font: inherit; font-size: 0.7rem; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 7px; margin-left: 8px;
}
.mini:hover { color: var(--text); border-color: var(--accent); }

/* ---------- cross-tool nav ---------- */
.tool-nav {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  padding: 0 clamp(12px, 3vw, 28px) 12px;
  max-width: 1500px; margin: 0 auto;
}
.tool-nav a {
  font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
  text-decoration: none; padding: 4px 1px; border-bottom: 1px solid transparent;
}
.tool-nav a:hover, .tool-nav a:focus-visible { color: var(--accent); border-bottom-color: var(--accent); }
.tool-nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.stat .k { font-family: var(--mono); font-size: 1.25rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .v { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat.alert { border-color: color-mix(in oklab, var(--bad) 50%, var(--line)); }
.stat.alert .k { color: var(--bad); }
.bar-track { margin-top: 8px; height: 4px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

/* ---------- readout: a big current-value card beside a grid of state chips ---------- */
.readout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
@media (max-width: 820px) { .readout { grid-template-columns: 1fr; } }

.now, .flags {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.now { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.now-value {
  font-family: var(--mono); font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 600;
  min-width: 3.9em; padding: 10px 14px; text-align: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--accent); overflow: hidden; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.now-value .unit { font-size: 0.36em; color: var(--muted); font-weight: 400; margin-left: 0.4em; }
.now-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: 8px 18px; flex: 1; min-width: 0; }
.now-meta > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.now-meta span { font-size: 0.64rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; }
.now-meta code { font-family: var(--mono); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 6px; }
.flag {
  font-family: var(--mono); font-size: 0.72rem; text-align: center;
  padding: 6px 4px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted);
}
.flag.on { color: var(--on-accent); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.flag.on.is-warn { background: var(--warn); border-color: var(--warn); color: #17110a; }
.flag.on.is-bad { background: var(--bad); border-color: var(--bad); color: #190808; }

h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
h2.mt { margin-top: 18px; }

.hint { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 12px 0 0; }

/* ---------- scroll cue ---------- */
.scroll-cue {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin: 6px auto 0;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); background: var(--panel); box-shadow: var(--shadow);
  transition: color .15s, border-color .15s, transform .15s;
}
.scroll-cue:hover, .scroll-cue:focus-visible { color: var(--accent); border-color: var(--accent); transform: translateY(2px); }
.scroll-cue svg { width: 15px; height: 15px; }
@media (prefers-reduced-motion: reduce) { .scroll-cue { transition: none; } }

/* ---------- panels / log table ---------- */
.panels { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
@media (max-width: 920px) { .panels { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; min-width: 0; box-shadow: var(--shadow);
}
.panel .sub { margin: -4px 0 10px; font-size: 0.78rem; color: var(--muted); }
.log-wrap { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.log { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.76rem; font-variant-numeric: tabular-nums; }
table.log th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600;
  color: var(--muted); background: var(--panel-2); padding: 6px 9px; border-bottom: 1px solid var(--line);
}
table.log td { padding: 4px 9px; border-bottom: 1px solid color-mix(in oklab, var(--line) 55%, transparent); }
table.log tr.empty td { color: var(--dim); font-family: var(--font); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; }
.chips li {
  font-family: var(--mono); font-size: 0.72rem; padding: 3px 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.chips li.none, .chips li.wait { border-style: dashed; color: var(--dim); }

/* ---------- content sections (FAQ / troubleshooting) ---------- */
.content-section {
  max-width: 720px; margin: 20px auto 0;
  color: var(--muted); font-size: 0.92rem; line-height: 1.65;
}
.content-section p { margin: 0 0 12px; }
.content-section p:last-child { margin-bottom: 0; }
.content-section h2 {
  font-family: var(--mono); font-weight: 600; text-transform: none; letter-spacing: -0.01em;
  font-size: 1.05rem; color: var(--text); margin: 0 0 14px; text-wrap: balance;
}

.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 14px; box-shadow: var(--shadow);
}
.faq-item summary {
  cursor: pointer; list-style: none; padding: 12px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--font); font-weight: 600; font-size: 0.9rem; color: var(--text);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; flex-shrink: 0; font-family: var(--mono); font-weight: 400;
  color: var(--muted); transition: transform .15s;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 6px; }
.faq-item p { padding-bottom: 14px; }

.troubleshoot-list {
  margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 10px;
}
.troubleshoot-list li::marker { font-family: var(--mono); font-weight: 600; color: var(--accent); }
.troubleshoot-list strong { color: var(--text); }

.content-section code {
  font-family: var(--mono); color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}

/* Reference tables in the explainer prose: "what your reading means", typical limits. */
.ref-table {
  width: 100%; margin: 0 0 14px; border-collapse: collapse; font-size: 0.86rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.ref-table th {
  text-align: left; font-weight: 600; color: var(--text); background: var(--panel-2);
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.ref-table td {
  padding: 7px 12px; vertical-align: top;
  border-bottom: 1px solid color-mix(in oklab, var(--line) 55%, transparent);
}
.ref-table tr:last-child td { border-bottom: 0; }
.ref-table td:first-child { color: var(--text); font-family: var(--mono); font-size: 0.8rem; white-space: nowrap; }
@media (max-width: 560px) { .ref-table td:first-child { white-space: normal; } }

@media (prefers-reduced-motion: reduce) {
  .faq-item summary::after { transition: none; }
  .bar-fill { transition: none; }
}

/* ---------- footer: every check, linked from every page ----------
 * The .tool-nav strip only carries the four headline tools. This is where the companion
 * pages (chatter, ghosting, monitor ghosting) get a link from every other page, so a visitor
 * — or a crawler — landing on one of them can reach the rest without going via the FAQ. */
.site-footer {
  max-width: 1500px; margin: 0 auto; padding: 24px clamp(12px, 3vw, 28px) 40px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem;
}
.site-footer h2 {
  margin: 0 0 12px; font-family: var(--mono); font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim);
}
.site-footer ul {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 24px;
}
.site-footer li { display: flex; flex-direction: column; gap: 1px; }
.site-footer li a { color: var(--text); text-decoration: none; font-weight: 600; }
.site-footer li a:hover, .site-footer li a:focus-visible { color: var(--accent); text-decoration: underline; }
.site-footer li a[aria-current="page"] { color: var(--accent); }
.site-footer li span { font-size: 0.78rem; color: var(--dim); }
.site-footer p { margin: 20px 0 0; font-size: 0.78rem; color: var(--dim); }
