/* Online HID testers (keyboardtester/, mousetester/, gamepadtester/) - builds on style.css tokens */

.ht-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.ht-tabs a, .ht-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--bg); color: var(--text-2); font-weight: 600; font-size: .9rem;
  text-decoration: none; cursor: pointer; font-family: inherit;
}
.ht-tabs a:hover, .ht-tab:hover { border-color: var(--border-2); color: var(--text); }
.ht-tabs a[aria-current="page"], .ht-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ht-tab.off { opacity: .55; }
.ht-tabs svg { flex: none; }

.ht-tool {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg);
  padding: 18px; margin-bottom: 40px; box-shadow: var(--shadow);
}
.ht-tool:fullscreen { overflow: auto; padding: 32px; border-radius: 0; }
.ht-hint { color: var(--text-2); font-size: .92rem; margin: 0 0 14px; }

.ht-bar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin-bottom: 16px; }
.ht-tile {
  display: flex; flex-direction: column; justify-content: center; min-width: 110px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft);
}
.ht-tile b { font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.ht-tile span { font: 600 1.05rem/1.3 var(--font-mono); color: var(--text); white-space: nowrap; }
.ht-tile.wide { flex: 1 1 200px; }
.ht-tile span.txt { font: 500 .9rem/1.4 var(--font-body); white-space: normal; }
.mono { font-family: var(--font-mono); }
.ht-tile.bad { border-color: #e9b4ae; background: #fdecea; }
.ht-tile.bad span { color: #b42318; }
.ht-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; align-items: center; }
.ht-note { font-size: .82rem; color: var(--text-3); }

.ht-h span[id], .gp-h span[id] { margin-left: .5em; }
.ht-h, .gp-h { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); font-weight: 600; margin: 18px 0 8px; }
.ht-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ht-chip {
  display: inline-block; padding: 4px 10px; border: 1px solid var(--border-2); border-radius: 6px;
  background: var(--bg); font-size: .82rem; color: var(--text-2); position: relative;
}
.ht-chip.held { background: var(--accent); border-color: var(--accent-d); color: #fff; }
.ht-chip.ok { background: #dff3e7; border-color: #1e7848; color: #14532d; }
.ht-chip.chat { box-shadow: inset 0 0 0 2px #d4351c; }

.ht-log {
  margin: 0; height: 150px; overflow: auto; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-soft); font: .76rem/1.5 var(--font-mono); color: var(--text-2);
  white-space: pre;
}

/* ---- keyboard ---- */
.ht-kb-wrap { overflow-x: auto; padding-bottom: 4px; }
.ht-kb { position: relative; aspect-ratio: 22.5 / 6.25; min-width: 760px; container-type: inline-size; }
.ht-key { position: absolute; padding: 2px; box-sizing: border-box; }
.ht-key .cap {
  display: flex; align-items: center; justify-content: center; height: 100%; padding: 0 2px;
  border: 1px solid var(--border-2); border-radius: 5px; background: var(--bg);
  box-shadow: 0 1px 0 var(--border-2); color: var(--text-2);
  font: 600 1.05cqw/1.1 var(--font-body); text-align: center; overflow: hidden; white-space: nowrap;
  transition: background-color .08s, color .08s;
}
/* Inter's arrows are tiny at this size - the system symbol font draws them clearly */
.ht-key.arrow .cap { font-family: 'Segoe UI Symbol', 'Segoe UI', system-ui, sans-serif; font-size: 1.5cqw; font-weight: 400; }
.ht-key.join-b { padding-bottom: 0; }
.ht-key.join-b .cap { border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; }
.ht-key.join-t { padding-top: 0; }
.ht-key.join-t .cap { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.ht-key.ok .cap { background: #dff3e7; border-color: #1e7848; color: #14532d; }
.ht-key.held .cap { background: var(--accent); border-color: var(--accent-d); color: #fff; }
.ht-key.chat .cap { box-shadow: inset 0 0 0 2px #d4351c; }
.ht-key[data-n]::after, .ht-chip[data-n]::after {
  content: attr(data-n); position: absolute; top: -4px; right: -4px; padding: 0 4px; border-radius: 6px;
  background: #d4351c; color: #fff; font: 700 10px/15px var(--font-body);
}

/* ---- mouse ---- */
.ht-ms-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.ht-area {
  display: grid; place-items: center; min-height: 340px; padding: 20px; border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg); background: var(--bg-soft); color: var(--text-3); text-align: center;
  cursor: crosshair; user-select: none; -webkit-user-select: none; touch-action: none;
}
.ht-area.measuring { border-color: var(--accent); background: #eef2fd; }
.ht-area p { margin: 0; max-width: 34ch; }
.ms-svg { width: 100%; max-width: 200px; display: block; margin: 0 auto; }
.ms-body { fill: var(--surface-2); stroke: var(--border-2); stroke-width: 2; }
.ms-part { fill: var(--bg); stroke: var(--border-2); stroke-width: 2; transition: fill .08s; }
.ms-part.ok { fill: #dff3e7; stroke: #1e7848; }
.ms-part.on { fill: var(--accent); stroke: var(--accent-d); }
.ms-t { font: 600 11px var(--font-body); fill: var(--text-3); text-anchor: middle; pointer-events: none; }
.ht-table { width: 100%; border-collapse: collapse; font-size: .84rem; margin-top: 10px; }
.ht-table th { white-space: nowrap; }
.ht-table td:not(:first-child) { white-space: nowrap; }
.ht-table th, .ht-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.ht-table th { color: var(--text-3); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.ht-table td.bad, .bad { color: #b42318; font-weight: 600; }
.ht-rate { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.ht-rate i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ht-dpi { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ht-dpi input {
  width: 90px; padding: 7px 10px; border: 1px solid var(--border-2); border-radius: var(--radius);
  font: inherit; background: var(--bg); color: var(--text);
}
.ht-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.ht-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--bg-soft); }
.ht-box h3 { font-size: .95rem; margin: 0 0 8px; }
.ht-box p { font-size: .86rem; color: var(--text-2); margin: 8px 0 0; }

/* ---- gamepad ---- */
.gp-empty { padding: 48px 20px; text-align: center; color: var(--text-2); border: 2px dashed var(--border-2); border-radius: var(--radius-lg); background: var(--bg-soft); }
.gp-empty svg { color: var(--text-3); margin-bottom: 10px; }
.gp-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.gp-name { font-size: 1rem; word-break: break-word; }
.gp-sub { font-size: .82rem; }
.gp-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gp-std { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; }
.gp-svg { width: 100%; max-width: 440px; display: block; margin: 0 auto; }
.gp-body { fill: var(--surface-2); stroke: var(--border-2); stroke-width: 2; }
.gp-part { fill: var(--bg); stroke: var(--border-2); stroke-width: 2; transition: fill .06s; }
.gp-part.ok { fill: #dff3e7; stroke: #1e7848; }
.gp-part.on { fill: var(--accent); stroke: var(--accent-d); }
.gp-fill { fill: var(--accent); opacity: .55; pointer-events: none; }
.gp-dot { fill: var(--ink-2); pointer-events: none; }
.gp-t { font: 700 10px var(--font-body); fill: var(--text-3); text-anchor: middle; pointer-events: none; }
.gp-sticks { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.gp-stick { margin: 0; text-align: center; }
.gp-stick canvas { width: 180px; height: 180px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.gp-stick figcaption { font-size: .8rem; color: var(--text-2); line-height: 1.45; max-width: 200px; }
.gp-stick figcaption b { display: block; color: var(--text); }
.gp-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.gp-btn {
  position: relative; overflow: hidden; padding: 6px 8px; border: 1px solid var(--border-2); border-radius: 6px;
  background: var(--bg); font-size: .78rem; color: var(--text-2); min-height: 44px;
}
.gp-btn b { display: block; font: 700 .9rem var(--font-mono); color: var(--text); }
.gp-btn span { position: relative; z-index: 1; }
.gp-btn i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--accent); }
.gp-btn.ok { background: #dff3e7; border-color: #1e7848; }
.gp-btn.on { background: var(--accent); border-color: var(--accent-d); color: #fff; }
.gp-btn.on b { color: #fff; }
.gp-btn.on i { background: #fff; }
.gp-axes .mono { font-family: var(--font-mono); font-size: .82rem; white-space: nowrap; }
.gp-barcell { width: 40%; }
.gp-bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); }
.gp-bar::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border-2); }
.gp-bar i { position: absolute; top: 0; height: 100%; background: var(--accent); border-radius: 5px; }
.gp-bar i.full { background: #1e7848; }

/* ---- related testers + desktop app ---- */
.ht-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 14px; }
.ht-related a {
  display: block; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg); text-decoration: none; color: var(--text);
}
.ht-related a:hover { border-color: var(--border-2); }
.ht-related b { display: block; margin-bottom: 4px; }
.ht-related span { font-size: .88rem; color: var(--text-2); }

@media (max-width: 860px) {
  .ht-ms-grid, .gp-std, .ht-cols { grid-template-columns: 1fr; }
  .ht-actions { margin-left: 0; }
}
