:root {
    --bg: #020617;
    --panel: rgba(15, 23, 42, 0.88);
    --border: rgba(148, 163, 184, 0.18);
    --text: #e5eefc;
    --muted: #94a3b8;
    --accent: #22d3ee;
    --accent-soft: rgba(34, 211, 238, 0.12);
    --active: #22c55e;
    --key-bg: linear-gradient(180deg, #1e293b 0%, #111827 100%);
    --shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
}

.tester-page {
    width: 100%;
    margin: 0;
    padding: 0;
}

.tester-page .hero {
    margin-bottom: 0;
}

.tester-workspace {
    width: 100%;
    max-width: 100%;
    margin-top: 0;
    padding-inline: clamp(18px, 3vw, 36px);
    padding-bottom: 16px;
    box-sizing: border-box;
    min-width: 0;
    overflow-x: hidden;
}

.panel-tester {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    margin-top: 0;
    padding: 12px;
    overflow: hidden;
}

.tester-block + .tester-block {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.tester-layout + .tester-mouse {
    margin-top: 72px;
    padding-top: 0;
    border-top: 0;
}

#mouseTester {
    margin-top: 15px;
    margin-bottom: 2px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.panel-header h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.03em;
}

.panel-header p,
.stat-sub {
    color: #cbd5e1;
    line-height: 1.6;
}

.stat-sub {
    display: block;
    margin-top: 8px;
    font-size: 12px;
}

.panel-header-legend {
    justify-content: space-between;
}

.panel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tester-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
}

.toolbar-chip {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(34, 211, 238, 0.18);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.12), rgba(15, 23, 42, 0.2));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.toolbar-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.toolbar-value {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.panel-actions-compact {
    flex-wrap: nowrap;
}

.panel-actions-compact .btn {
    height: 38px;
    padding: 0 14px;
    border-radius: 999px;
}

.panel-actions-compact .btn-primary {
    box-shadow: 0 8px 20px rgba(34, 211, 238, 0.16);
}

.log-box {
    width: 100%;
    min-height: 96px;
    height: 100px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(2, 6, 23, 0.6);
    color: #dbe7f5;
    padding: 16px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.7;
}

.log-box:focus {
    outline: 2px solid rgba(34, 211, 238, 0.24);
    outline-offset: 2px;
}

.legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: #cbd5e1;
    font-size: 12px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toggle-btn {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    cursor: pointer;
    min-height: 34px;
    padding: 0 12px;
    font-weight: 700;
    transition: 0.18s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.07);
}

.toggle-btn.active {
    background: var(--accent-soft);
    border-color: rgba(34, 211, 238, 0.32);
    color: #bef5ff;
}

.layout-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
}

.layout-switch-btn {
    width: 38px;
    min-width: 38px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    display: grid;
    place-items: center;
}

.layout-switch-btn svg {
    width: 16px;
    height: 16px;
}

.layout-switch-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.layout-switch-btn.active {
    border: 0;
    background: rgba(34, 211, 238, 0.14);
    color: #bef5ff;
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.2);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.dot-default {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.dot-tested {
    background: var(--accent);
}

.dot-active {
    background: var(--active);
}

.keyboard-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable both-edges;
}

.tester-layout {
    min-width: 0;
    overflow: hidden;
}

.tester-mouse {
    display: grid;
    justify-items: center;
    align-items: start;
}

.board {
    width: max-content;
    min-width: 100%;
    margin: 0 auto;
}

.keyboard-grid {
    display: inline-flex;
    min-width: max-content;
    width: max-content;
    gap: 16px;
    align-items: start;
}

.board-mac .keyboard-grid {
    gap: 12px;
}

.board.hidden {
    display: none;
}

.cluster {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
    width: max-content;
}

.cluster-numpad {
    display: grid;
    grid-template-columns: repeat(4, 52px);
    grid-auto-rows: 54px;
    gap: 8px;
    width: max-content;
}

.row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: max-content;
}

.key,
.mouse-key {
    min-width: 52px;
    height: 54px;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--key-bg);
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    user-select: none;
    transition: 0.1s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    flex: 0 0 auto;
}

.key.tested,
.mouse-key.tested {
    border-color: rgba(34, 211, 238, 0.46);
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.14);
}

.key.active,
.mouse-key.active {
    background: linear-gradient(180deg, #0f3d27 0%, #0a2e1d 100%);
    border-color: rgba(34, 197, 94, 0.55);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.18), 0 0 18px rgba(34, 197, 94, 0.16);
    transform: translateY(1px);
}

.spacer {
    min-width: 52px;
    height: 54px;
    opacity: 0;
    flex: 0 0 auto;
}

.key-half {
    min-width: 52px;
    height: 25px;
    padding: 0 8px;
    font-size: 11px;
}

.mac-inline-arrows {
    display: grid;
    grid-template-columns: 70px 52px 70px;
    grid-template-rows: 25px 25px;
    column-gap: 8px;
    row-gap: 4px;
    width: 208px;
    margin-left: 4px;
    flex: 0 0 auto;
}

.mac-arrow-left {
    grid-column: 1;
    grid-row: 1 / span 2;
    height: 54px;
}

.mac-arrow-up {
    grid-column: 2;
    grid-row: 1;
}

.mac-arrow-down {
    grid-column: 2;
    grid-row: 2;
}

.mac-arrow-right {
    grid-column: 3;
    grid-row: 1 / span 2;
    height: 54px;
}

.key-lock {
    position: relative;
}

.key-label {
    display: block;
    width: 100%;
}

.key-led {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #334155;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.key-led.on {
    background: #22c55e;
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.45);
}

.cluster-numpad .key {
    min-width: 52px;
}

.cluster-numpad .key-tall {
    grid-row: span 2;
    height: 116px;
}

.cluster-numpad .key-wide {
    grid-column: span 2;
    min-width: 112px;
}

.spacer.sm {
    min-width: 26px;
}

.arrow-spacer {
    min-width: 82px;
}

.w-60 {
    min-width: 60px;
}

.w-70 {
    min-width: 70px;
}

.w-78 {
    min-width: 78px;
}

.w-82 {
    min-width: 82px;
}

.w-90 {
    min-width: 90px;
}

.w-96 {
    min-width: 96px;
}

.w-100 {
    min-width: 100px;
}

.w-102 {
    min-width: 102px;
}

.w-110 {
    min-width: 110px;
}

.w-120 {
    min-width: 120px;
}

.w-124 {
    min-width: 124px;
}

.w-128 {
    min-width: 128px;
}

.w-132 {
    min-width: 132px;
}

.w-144 {
    min-width: 144px;
}

.w-148 {
    min-width: 148px;
}

.w-150 {
    min-width: 150px;
}

.w-168 {
    min-width: 168px;
}

.w-180 {
    min-width: 180px;
}

.w-220 {
    min-width: 220px;
}

.w-236 {
    min-width: 236px;
}

.w-362 {
    min-width: 362px;
}

.mouse-tester {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 136px));
    gap: 6px;
    width: min(100%, 432px);
    justify-content: center;
    margin: 0 auto;
}

.mouse-key {
    height: 54px;
    font-size: 14px;
    cursor: pointer;
    background: linear-gradient(180deg, #172337 0%, #0e1729 100%);
}

@media (max-width: 760px) {
    .tester-workspace {
        padding-inline: 14px;
        padding-bottom: 12px;
    }

    .panel-tester {
        padding: 10px;
    }

    .keyboard-shell {
        padding-bottom: 8px;
    }

    .keyboard-grid {
        gap: 12px;
    }

    .cluster,
    .row,
    .cluster-numpad {
        gap: 6px;
    }

    .mouse-tester {
        grid-template-columns: 1fr;
    }

    .tester-toolbar {
        flex-wrap: wrap;
    }

    .panel-actions-compact {
        width: 100%;
        justify-content: flex-start;
    }

    .log-box {
        min-height: 92px;
        height: 96px;
    }
}
