/* ================================================================
   菜刀客在线工具页 · keyboard-tester.html 私有样式
   需在 /css/common.css 之后加载。
   ================================================================ */

.container {
    max-width: 1400px;
}

.main {
    grid-template-columns: 1fr;
}

/* ---- 键盘区（占满整行，靠上） ---- */
.kb-stage {
    padding: 15px;
    overflow-x: auto;
}

/* ---- 左侧：测试进度面板（占满整行，横向排布） ---- */
.kb-side {
    padding: 15px;
    display: grid;
    grid-template-columns: 300px 300px 1fr;
    gap: 14px;
    align-items: stretch;
}

.kb-progress-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
}

.kb-progress-card .kb-legend {
    margin-top: auto;
    padding-top: 12px;
}

.kb-progress-card .kb-legend .chip {
    color: rgba(255,255,255,0.92);
}

.kb-progress-card .kb-legend .dot {
    border-color: rgba(255,255,255,0.7);
}

.kb-progress-card .label {
    font-size: 13px;
    opacity: 0.9;
}

.kb-progress-card .amount {
    font-size: 30px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.kb-progress-card .amount small {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.85;
}

.kb-progress {
    height: 10px;
    background: rgba(255,255,255,0.25);
    border-radius: 6px;
    margin-top: 10px;
    overflow: hidden;
}

.kb-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffffff;
    border-radius: 6px;
    transition: width 0.25s;
}

.kb-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.kb-legend .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #6b7280;
}

.kb-legend .dot {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    flex: none;
}

.kb-legend .dot.dot-tested { background: #d1fae5; border-color: #10b981; }
.kb-legend .dot.dot-pressed { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-color: #5a6fd6; }
.kb-legend .dot.dot-heat1 { background: #a7f3d0; border-color: #34d399; }
.kb-legend .dot.dot-heat3 { background: #fcd34d; border-color: #f59e0b; }
.kb-legend .dot.dot-heat5 { background: #f87171; border-color: #ef4444; }

.kb-log-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.kb-log-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.kb-log {
    list-style: none;
    flex: 1;
    min-height: 0;
    max-height: 156px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
}

.kb-log li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: #4b5563;
    border-bottom: 1px solid #f3f4f6;
}

.kb-log li:last-child {
    border-bottom: none;
}

.kb-log li code {
    background: rgba(102,126,234,0.1);
    color: #4338ca;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.kb-log li .log-time {
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}

.kb-log-empty {
    padding: 24px 10px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

/* ---- 右侧：键盘区 ---- */
.kb-mode-group {
    display: flex;
    gap: 6px;
}

.mode-opt {
    cursor: pointer;
    user-select: none;
    padding: 5px 10px !important;
    font-size: 12px !important;
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.mode-opt input {
    display: none;
}

.mode-sep {
    width: 1px;
    height: 18px;
    background: #e5e7eb;
    margin: 0 2px;
}

.mode-opt.active {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
}

.kb-stage {
    padding: 15px;
    overflow-x: auto;
}

.kb-inner {
    min-width: 780px;
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.kb-block {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.kb-main { flex: 15 1 0; }
.kb-nav  { flex: 3 1 0; }
.kb-num  { flex: 4 1 0; }

.kb-row {
    display: flex;
    gap: 5px;
}

.kb-hgap {
    flex: 0.667 1 0;
}

.kb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    flex: 1;
}

.kb-num .kb-grid {
    grid-template-columns: repeat(4, 1fr);
}

.kb-key {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 2px 0 #d1d5db;
    color: #374151;
    font-size: 12px;
    line-height: 1.1;
    user-select: none;
    cursor: default;
    transition: background 0.08s, color 0.08s, transform 0.08s, box-shadow 0.08s;
    text-align: center;
    padding: 2px;
}

.kb-key .sub {
    font-size: 9px;
    color: #9ca3af;
    line-height: 1;
}

.kb-key .kb-badge {
    display: none;
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    font-weight: 600;
    color: #6b7280;
    line-height: 1;
}

.kb-stage.mode-heat .kb-key.tested .kb-badge {
    display: block;
}

/* 按下瞬间：品牌渐变高亮 */
.kb-key.pressed {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #5a6fd6;
    color: #ffffff;
    transform: translateY(2px);
    box-shadow: 0 0 0 #d1d5db;
}

.kb-key.pressed .sub {
    color: rgba(255,255,255,0.85);
}

/* 测试通过（按下正常）：绿色记录 */
.kb-key.tested {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.kb-key.tested .sub {
    color: #059669;
}

/* 热力图：按敲击次数分 5 档着色 */
.kb-stage.mode-heat .kb-key.tested.heat-1 { background: #a7f3d0; border-color: #34d399; color: #065f46; }
.kb-stage.mode-heat .kb-key.tested.heat-2 { background: #6ee7b7; border-color: #10b981; color: #064e3b; }
.kb-stage.mode-heat .kb-key.tested.heat-3 { background: #fcd34d; border-color: #f59e0b; color: #78350f; }
.kb-stage.mode-heat .kb-key.tested.heat-4 { background: #fb923c; border-color: #ea580c; color: #7c2d12; }
.kb-stage.mode-heat .kb-key.tested.heat-5 { background: #f87171; border-color: #ef4444; color: #7f1d1d; }

.kb-stage.mode-heat .kb-key.tested.heat-3 .sub,
.kb-stage.mode-heat .kb-key.tested.heat-4 .sub,
.kb-stage.mode-heat .kb-key.tested.heat-5 .sub {
    color: inherit;
    opacity: 0.75;
}

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }

    .kb-side {
        grid-template-columns: 1fr;
    }

    .kb-key {
        min-height: 38px;
        font-size: 11px;
    }
}
