:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --text: #15201e;
  --muted: #5b6b68;
  --line: #dde4e2;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d5efec;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 4px 16px rgba(16, 24, 22, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1514;
    --surface: #17201e;
    --surface-2: #1e2a28;
    --text: #e7efed;
    --muted: #9db0ac;
    --line: #2a3835;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #123f3a;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
img, video, canvas { max-width: 100%; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 16px; }
.site-nav { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--accent); }

/* typography */
h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; margin: 28px 0 8px; letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 36px 0 12px; }
h3 { font-size: 18px; margin: 24px 0 8px; }
.lead { color: var(--muted); font-size: 18px; margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* tool card */
.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 12px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 14px 24px; font-size: 18px; }

label { font-weight: 600; font-size: 14px; }
select, input[type="text"], input[type="number"], textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: grid; gap: 6px; flex: 1 1 220px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; }

/* status */
.status { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--line); }
.status.ok { border-left-color: var(--ok); }
.status.warn { border-left-color: var(--warn); }
.status.bad { border-left-color: var(--bad); }
.status strong { display: block; }

/* level meter */
.meter { position: relative; height: 28px; background: var(--surface-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #22c55e 0%, #22c55e 60%, #eab308 80%, #ef4444 100%); transition: width .06s linear; }
.meter-peak { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); left: 0; }
.big-number { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat small { display: block; color: var(--muted); font-size: 13px; }
.stat b { font-variant-numeric: tabular-nums; }

.video-box { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; }
.video-box video { width: 100%; height: 100%; object-fit: contain; }
.video-box .placeholder { color: #9aa; padding: 20px; text-align: center; }
.mirror { transform: scaleX(-1); }

.wave { width: 100%; height: 90px; display: block; background: var(--surface-2); border-radius: 10px; }

/* dropzone */
.drop {
  display: block;
  font-size: 16px;
  font-weight: 400;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.file-list { display: grid; gap: 12px; margin-top: 16px; }
.file-item { display: grid; grid-template-columns: 84px 1fr; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.file-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.file-item .meta-list { font-size: 14px; margin: 6px 0; padding-left: 18px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }
.tag.bad { background: var(--bad); color: #fff; }
.tag.ok { background: var(--ok); color: #fff; }

/* results */
.result { font-size: 20px; font-weight: 600; background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; word-break: break-word; }
.result-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.result-table td { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.result-table td:last-child { text-align: right; font-weight: 700; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 9px 14px; font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* tool cards */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; }
.tool-card:hover { border-color: var(--accent); }
.tool-card strong { display: block; }
.tool-card small { color: var(--muted); display: block; line-height: 1.4; margin-top: 2px; }
.tool-card.big { padding: 18px; }
.tool-icon { font-size: 26px; line-height: 1; }

/* article and faq */
.article p, .article li { max-width: 72ch; }
.faq-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq-item summary { cursor: pointer; font-weight: 600; }
.faq-item div { color: var(--muted); margin-top: 8px; }

.ad { margin: 20px 0; min-height: 90px; text-align: center; }

.site-footer { margin-top: 56px; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.footer-links a { color: var(--muted); }

.copy-ok { color: var(--ok); font-size: 14px; }
.hidden { display: none !important; }

@media (max-width: 560px) {
  .tool { padding: 16px; }
  .file-item { grid-template-columns: 1fr; }
  .file-item img { width: 100%; height: 140px; }
  .file-item img:not([src]) { display: none !important; }
  .seg { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; flex: none; min-height: 44px; }
}

/* keyboard */
.kb-wrap { overflow-x: auto; padding-bottom: 4px; }
.kb { display: flex; gap: clamp(6px, 1.5vw, 14px); user-select: none; -webkit-user-select: none; }
.kb-block { display: flex; flex-direction: column; gap: clamp(2px, 0.6vw, 5px); min-width: 0; }
.kb-main { flex: 15 1 0; }
.kb-nav { flex: 3 1 0; }
.kb-row { display: flex; gap: clamp(2px, 0.6vw, 5px); }
.kb-key, .kb-gap { height: clamp(26px, 5vw, 40px); min-width: 0; }
.kb-key {
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: clamp(4px, 0.8vw, 7px); font-size: clamp(8px, 1.4vw, 12px); font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; transition: background .08s;
}
.kb-key.ok { background: #16a34a; border-color: #15803d; color: #fff; }
.kb-key.chatter { background: #ea580c; border-color: #c2410c; color: #fff; }
.kb-key.down { background: #2563eb; border-color: #1d4ed8; color: #fff; transform: translateY(1px); }

/* screen test */
.screen-fs { position: fixed; inset: 0; z-index: 1000; cursor: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--line); cursor: pointer; }

/* user list */
.user-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.user-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.user-list li:last-child { border-bottom: 0; }
.user-list a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; min-width: 0; }
.user-list li > span { white-space: nowrap; flex: none; }

/* ---- touch, accessibility & responsive polish ---- */
.faq-item summary { padding: 10px 0; min-height: 44px; display: flex; align-items: center; gap: 8px; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '+'; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: var(--accent); font-weight: 700; flex: none; }
.faq-item[open] summary::before { content: '–'; }
.faq-item { padding: 2px 0; }
.faq-item div { margin: 0 0 12px 30px; }

input[type="range"] { width: 100%; height: 32px; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check { min-height: 44px; cursor: pointer; }
.btn, select, input[type="text"], input[type="number"] { min-height: 44px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible { outline-offset: 3px; }
.drop:focus-within { border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* safe areas (iPhone notch / home bar) */
.wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.site-footer { padding-bottom: max(40px, env(safe-area-inset-bottom)); }

/* phones: single-row scrollable nav instead of a tall wrapped block */
@media (max-width: 700px) {
  .header-inner { gap: 6px 16px; }
  .site-nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { white-space: nowrap; padding: 8px 2px; }
  h1 { margin-top: 20px; }
  .lead { font-size: 17px; }
  .btn.big { width: 100%; justify-content: center; }
  .row > .btn { flex: 1 1 auto; justify-content: center; }
  .big-number { font-size: 34px; }
}

/* tablets & desktops: roomier tool card */
@media (min-width: 900px) {
  .tool { padding: 28px; }
  .wrap { max-width: 960px; }
}

/* print: just the content */
@media print {
  .site-header, .site-footer, .ad, .related, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

@media (max-width: 640px) { .kb-nav { display: none; } .kb-main { flex: 1 1 auto; } }
.row > .field { align-self: flex-start; }

/* toast */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 2000; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.btn.share::before { content: '↗'; font-weight: 700; }

:root{--accent:#0f766e;--accent-soft:#d5efec;--accent-ink:#ffffff}
@media (prefers-color-scheme: dark){:root{--accent:#2dd4bf;--accent-soft:#123f3a;--accent-ink:#062b27}}
.mouse-pad { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; background: var(--surface-2); user-select: none; -webkit-user-select: none; cursor: crosshair; display: grid; gap: 10px; touch-action: none; }
.mouse-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.mouse-btn { display: grid; place-items: center; gap: 2px; min-height: 70px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; transition: background .08s; }
.mouse-btn b { font-variant-numeric: tabular-nums; }
.mouse-btn.ok { background: #16a34a; border-color: #15803d; color: #fff; }
.mouse-btn.down { background: #2563eb; color: #fff; }
.mouse-btn.chatter { background: #dc2626; border-color: #b91c1c; color: #fff; }
.cps-area { display: grid; place-items: center; min-height: 240px; width: 100%; border-radius: var(--radius); border: 2px solid var(--accent); background: var(--accent-soft); color: var(--text); font: inherit; font-size: clamp(20px, 5vw, 40px); font-weight: 700; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.cps-area:active { transform: scale(.995); }
.cps-area.done { opacity: .7; }
.gp-stick { width: 160px; height: 160px; display: block; margin: 6px auto; }
.gp-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.gp-btn { position: relative; overflow: hidden; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 14px; font-weight: 600; }
.gp-btn i { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--accent); }
.gp-btn.ok { border-color: #16a34a; }
.gp-btn.down { background: var(--accent-soft); }
.rr-track { position: relative; height: 64px; border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.rr-ufo { position: absolute; top: 12px; left: 0; font-size: 36px; line-height: 1; will-change: transform; }
