/* Keyboard test: the board, the key caps, rollover groups and the key log.
   Every rule is scoped under .kbt; colours come from the site's tokens. */
.kbt-bar { justify-content: space-between; align-items: end; }
.kbt-field { display: grid; gap: 4px; min-width: 0; }
.kbt-label { font-size: 14px; font-weight: 500; }
.kbt-th { flex: 1 1 200px; max-width: 300px; }
.kbt-th-row { display: flex; justify-content: space-between; gap: 8px; }
.kbt-th output { color: var(--muted); }

/* The board: a quarter-key grid (--q, set by the script to fit the box). */
.kbt-wrap { position: relative; overflow-x: auto; padding: 2px; }
.kbt-board { width: max-content; margin: 0 auto; padding: 10px; border: 2px solid var(--line-strong); border-radius: var(--radius); background: var(--sunk); outline: none; }
.kbt-board.is-capturing { border-color: var(--accent); }
.kbt-board:focus-visible { box-shadow: 0 0 0 4px var(--accent-soft); }
.kbt-keys { --q: 9px; display: grid; }
.kbt .kbt-key { position: relative; width: auto; min-width: 0; height: auto; margin: calc(var(--q) * .22); padding: 0 1px;
  font-size: calc(clamp(8px, calc(var(--q) * 1.12), 13px) * var(--fit, 1)); line-height: 1.05; white-space: pre-line; overflow: hidden; }
.kbt .kbt-key.is-optional:not(.is-tested):not(.is-down) { border-style: dashed; border-bottom-width: 1px; color: var(--muted); }
.kbt .kbt-key.is-down { transform: translateY(1px); }
.kbt .kbt-key.is-fail.is-down { background: var(--crit); border-color: var(--crit); color: var(--panel); }
.kbt .kbt-key[data-n]::after { content: attr(data-n); position: absolute; top: 1px; right: 2px; font-size: 9px; font-weight: 700; line-height: 1; }
.kbt-resume { position: absolute; inset: 0; margin: auto; width: fit-content; height: fit-content; max-width: calc(100% - 24px);
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--panel) 55%, transparent); }
.kbt-status { margin: -6px 0 0; color: var(--muted); font-size: 14px; text-align: center; }

.kbt-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.kbt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kbt .kbt-chip { width: auto; height: 2.3em; padding: 0 .7em; }

/* Rollover groups, key repeat and the log sit in quiet wells, so the test
   stays the one bordered panel. */
.kbt-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.kbt-panel { display: grid; gap: 10px; align-content: start; min-width: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--sunk); }
.kbt-panel h2 { font-size: 18px; }
.kbt-panel .readout .v { font-size: clamp(26px, 4vw, 34px); }
.kbt-groups { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.kbt-group { display: grid; gap: 6px; }
.kbt-group-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 10px; font-size: 15px; }
.kbt-group-keys { display: flex; flex-wrap: wrap; gap: 4px; }
.kbt-group-keys .keycap { width: auto; min-width: 2.4em; height: 2.2em; font-size: 11px; }
.kbt-rep { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

.kbt-logscroll { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.kbt-log { width: 100%; border-collapse: collapse; font: 400 13px/1.4 var(--f-mono); font-variant-numeric: tabular-nums; }
.kbt-log th { position: sticky; top: 0; padding: 7px 10px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--muted); font: 600 12px/1.3 var(--f-body); text-align: left; white-space: nowrap; }
.kbt-log td { padding: 4px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
.kbt-log tr:first-child td { border-top: 0; }
.kbt-log tr.is-up td { color: var(--muted); }
.kbt-log tr.is-chatter td { color: var(--crit); font-weight: 600; }
.kbt .readout.is-fail .v { color: var(--crit); }
