:root {
  --bg: #ffffff;
  --bg-soft: #f5f7fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #0f172a;
  --muted: #5b6577;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --ok: #16a34a;
  --ok-soft: #e7f7ec;
  --warn: #d97706;
  --warn-soft: #fff4e0;
  --err: #dc2626;
  --err-soft: #fdecec;
  --key: #f1f4f9;
  --key-border: #d4dbe7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-soft: #131a24;
    --surface: #161d29;
    --border: #263042;
    --text: #e6edf3;
    --muted: #94a0b4;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-soft: #1b2a4a;
    --ok: #3fbf6a;
    --ok-soft: #12291c;
    --warn: #f0a33a;
    --warn-soft: #2e2212;
    --err: #f2665f;
    --err-soft: #331617;
    --key: #1d2533;
    --key-border: #303b50;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .6em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 750; }
h3 { font-size: 1.1rem; font-weight: 700; }
img, svg, video, canvas { max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; padding-top: 40px; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; }
.section { margin-top: 56px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; }
.lang-switch { display: flex; gap: 2px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.lang-switch a { padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.lang-switch a:hover { text-decoration: none; color: var(--text); }
.lang-switch a[aria-current] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tool-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.tool-nav::-webkit-scrollbar { display: none; }
.tool-nav a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: .9rem; font-weight: 600; white-space: nowrap; }
.tool-nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.tool-nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }

/* Hero */
.hero { padding: 48px 0 32px; text-align: center; }
.hero .lead { max-width: 640px; margin: 0 auto; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 0; }
.tool-hero { padding: 8px 0 20px; }
.tool-hero h1 { margin-bottom: .3em; }
.crumbs { font-size: .85rem; color: var(--muted); padding-top: 20px; }
.crumbs span { margin: 0 4px; opacity: .6; }
.crumbs a { color: var(--muted); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s; }
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.card-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.card-title { font-weight: 750; font-size: 1.05rem; }
.card-text { color: var(--muted); font-size: .92rem; line-height: 1.5; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.feature svg { color: var(--accent); }
.feature h3 { margin: 8px 0 4px; }
.feature p { margin: 0; color: var(--muted); }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; font-weight: 650; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; border-radius: 12px; }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); max-width: 100%; min-width: 0; }
.field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.field input[type=range] { accent-color: var(--accent); }
.field output { font-family: var(--mono); color: var(--text); min-width: 4.5em; }

/* Tool shell */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tool-head .select { flex: 1 1 200px; max-width: 360px; }
.tool-status { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.tool-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.tool-status[data-state=live] .dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 1.6s infinite; }
.tool-status[data-state=live] { color: var(--text); }
.tool-status[data-state=error] .dot { background: var(--err); }
.tool-status[data-state=error] { color: var(--err); }
.tool-status[data-state=wait] .dot { background: var(--warn); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.tool-start { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tool-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tool-note { margin: 0; font-size: .88rem; color: var(--muted); }
.tool-subhead { margin: 8px 0 0; padding-top: 18px; border-top: 1px solid var(--border); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.stat-value { font-family: var(--mono); font-size: 1.15rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.verdict { border-radius: 12px; padding: 14px 16px; font-weight: 650; display: flex; gap: 10px; align-items: flex-start; }
.verdict[data-type=ok] { background: var(--ok-soft); color: var(--ok); }
.verdict[data-type=warn] { background: var(--warn-soft); color: var(--warn); }
.verdict[data-type=err] { background: var(--err-soft); color: var(--err); }
.verdict p { margin: 0; color: var(--text); font-weight: 400; }

.privacy-note { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin: 12px 0 0; }
.privacy-note svg { color: var(--ok); flex: none; }

/* Mic */
.meter { position: relative; height: 18px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--ok) 0%, var(--ok) 65%, var(--warn) 82%, var(--err) 100%); background-size: 100vw 100%; transition: width .05s linear; }
.meter-peak { position: absolute; top: 0; bottom: 0; width: 3px; left: 0; background: var(--text); opacity: .6; }
.wave { width: 100%; height: 140px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; display: block; }

/* Webcam */
.video-wrap { position: relative; aspect-ratio: 16 / 9; background: #0b0f17; border-radius: 14px; overflow: hidden; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-wrap.mirror video { transform: scaleX(-1); }
.video-placeholder { position: absolute; inset: 0; display: grid; place-items: center; }

/* Keyboard */
.kb-scroll { overflow-x: auto; padding-bottom: 4px; }
.kb { display: flex; gap: 14px; width: max-content; margin: 0 auto; user-select: none; }
.kb-block { display: flex; flex-direction: column; gap: 5px; }
.kb-row { display: flex; gap: 5px; min-height: 40px; }
.kb-gap { height: 12px; min-height: 12px; }
.key { --w: 1; flex: 0 0 calc(var(--w) * 40px + (var(--w) - 1) * 5px); height: 40px; border-radius: 7px; background: var(--key); border: 1px solid var(--key-border); border-bottom-width: 3px; display: grid; place-items: center; font-size: .72rem; font-weight: 600; color: var(--muted); transition: background .08s, color .08s, transform .05s; text-align: center; line-height: 1.1; padding: 0 3px; }
.key.spacer { visibility: hidden; }
.key.tested { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.key.down { background: var(--accent); border-color: var(--accent-hover); color: #fff; transform: translateY(2px); }

/* Mouse */
.click-zone { min-height: 200px; border: 2px dashed var(--border); border-radius: 14px; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; transition: background .1s, border-color .1s; }
.click-zone.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.mbtn { border: 1px solid var(--border); background: var(--bg-soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; transition: background .08s; }
.mbtn-name { font-size: .8rem; color: var(--muted); font-weight: 700; }
.mbtn-count { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; }
.mbtn-dbl { font-size: .78rem; font-weight: 700; color: var(--err); }
.mbtn.down { background: var(--accent); border-color: var(--accent); }
.mbtn.down * { color: #fff; }
.mbtn.tested:not(.down) { border-color: var(--ok); }

/* Gamepad */
.gp-empty { display: grid; place-items: center; text-align: center; padding: 36px 16px; color: var(--muted); border: 2px dashed var(--border); border-radius: 14px; }
.gp-empty p { margin: 8px 0 0; max-width: 420px; }
.gp-pad { display: flex; flex-direction: column; gap: 16px; }
.gp-pad + .gp-pad { border-top: 1px solid var(--border); padding-top: 18px; }
.gp-name { font-weight: 700; font-size: .95rem; word-break: break-word; }
.gp-name small { display: block; color: var(--muted); font-weight: 500; }
.gp-sticks { display: flex; gap: 20px; flex-wrap: wrap; }
.gp-stick { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gp-stick-area { position: relative; width: 130px; height: 130px; border-radius: 50%; background: var(--bg-soft); border: 1px solid var(--border); }
.gp-stick-area::before, .gp-stick-area::after { content: ""; position: absolute; background: var(--border); }
.gp-stick-area::before { left: 50%; top: 8px; bottom: 8px; width: 1px; }
.gp-stick-area::after { top: 50%; left: 8px; right: 8px; height: 1px; }
.gp-deadzone { position: absolute; left: 50%; top: 50%; border-radius: 50%; border: 1px dashed var(--warn); transform: translate(-50%, -50%); width: 20%; height: 20%; }
.gp-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--accent); left: 50%; top: 50%; z-index: 1; box-shadow: 0 0 0 4px var(--accent-soft); }
.gp-stick-val { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.gp-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.gp-btn { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 8px 6px; text-align: center; overflow: hidden; background: var(--bg-soft); }
.gp-btn-fill { position: absolute; inset: auto 0 0 0; height: 0; background: var(--accent); opacity: .9; }
.gp-btn span { position: relative; font-size: .78rem; font-weight: 700; }
.gp-btn small { position: relative; display: block; font-family: var(--mono); font-size: .7rem; color: var(--muted); }
.gp-btn.on span, .gp-btn.on small { color: #fff; }
.gp-btn.tested { border-color: var(--ok); }
.gp-axes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; font-family: var(--mono); font-size: .8rem; }
.gp-axis { display: flex; align-items: center; gap: 8px; }
.gp-axis-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--bg-soft); border: 1px solid var(--border); position: relative; }
.gp-axis-bar i { position: absolute; top: -1px; bottom: -1px; width: 4px; margin-left: -2px; background: var(--accent); border-radius: 2px; left: 50%; }

/* Monitor */
.hz-display { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 10px 0; }
.hz-value { font-size: clamp(3rem, 10vw, 5rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.hz-value small { font-size: .35em; margin-left: 6px; color: var(--muted); letter-spacing: 0; }
.hz-bar { position: relative; width: 100%; height: 30px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.hz-ball { position: absolute; top: 5px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); left: 0; will-change: transform; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.pixel-overlay { position: fixed; inset: 0; z-index: 100; cursor: none; }
.pixel-hint { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(0, 0, 0, .7); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: .9rem; transition: opacity .4s; text-align: center; max-width: calc(100% - 32px); }

/* Affiliate */
.affiliate { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; background: var(--bg-soft); }
.affiliate h2 { font-size: 1.15rem; margin-bottom: .3em; }
.affiliate p { margin: 0 0 10px; }
.affiliate ul { margin: 0 0 10px; padding: 0; list-style: none; display: flex; gap: 8px; flex-wrap: wrap; }
.affiliate li a { display: inline-block; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .9rem; }

/* Prose */
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose p, .prose li { color: var(--text); }
.prose ol, .prose ul { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .93rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-soft); }
.prose kbd { font-family: var(--mono); font-size: .85em; background: var(--key); border: 1px solid var(--key-border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }

/* FAQ */
.faq { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.faq-item { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.faq-item summary { cursor: pointer; padding: 14px 16px; font-weight: 650; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.3rem; line-height: 1; }
.faq-item[open] summary::after { content: "–"; }
.faq-a { padding: 0 16px 14px; color: var(--muted); }
.faq-a p { margin: 0 0 .6em; }

/* Footer */
.site-footer { margin-top: 80px; border-top: 1px solid var(--border); background: var(--bg-soft); padding: 40px 0 24px; font-size: .92rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin: 4px 0; }
.footer-grid li a { color: var(--muted); }
.footer-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.footer-bottom { margin-top: 28px; font-size: .82rem; }

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid > div:first-child { grid-column: 1 / -1; }
  .tool { padding: 14px; border-radius: 14px; }
  .hero { padding: 32px 0 24px; }
  .section { margin-top: 44px; }
  .btn-lg { padding: 12px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.license { white-space: pre-wrap; font-family: var(--mono); font-size: .75rem; color: var(--muted); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow-x: auto; }
.ad-label { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-bottom: 8px; }
