/* ========================================
   键盘检测工具样式 (状态面板固定 + 特殊键名修正)
   ======================================== */

/* 主内容 */
.main-content { 
    width: 100%; 
    max-width: 1200px;
    height: calc(100vh - 70px); 
    display: flex; 
    flex-direction: column;
    padding: 20px;
    padding-bottom: 50px; 
    z-index: 10; 
    overflow-y: auto; 
    gap: 20px;
}
.container { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 20px; }

@media (max-height: 850px), (max-width: 1350px) {
    .container { gap: 10px; }
}

/* 信息面板 - 布局重构 */
.info-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 24px;
    display: grid; /* 使用 Grid 确保对齐 */
    grid-template-columns: repeat(3, 1fr); /* 三列等宽 */
    gap: 20px;
    align-items: center;
}
.status-display { 
    display: flex; 
    align-items: baseline; 
    gap: 10px; 
}
.status-display .label { 
    color: var(--text-muted); 
    font-size: 13px; 
    font-weight: 600; 
    min-width: 70px; /* 固定标签宽度 */
    text-align: right; /* 标签右对齐，更美观 */
}
.status-display span:not(.label) { 
    font-size: 16px; 
    font-family: monospace; 
    color: var(--primary-color); 
    font-weight: bold; 
    min-width: 100px; /* 固定数值区域最小宽度，防止跳动 */
    display: inline-block;
}

.tips { 
    grid-column: 1 / -1; /* 占满整行 */
    width: 100%; 
    font-size: 12px; 
    color: #888; 
    border-top: 1px solid #333; 
    padding-top: 12px; 
    margin-top: 4px; 
}

/* 布局切换 */
.keyboard-selector { display: flex; gap: 12px; justify-content: center; }
.layout-btn {
    padding: 10px 24px;
    background: #111;
    border: 1px solid #333;
    color: #888;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.3s;
    font-size: 14px;
}
.layout-btn:hover { color: #fff; border-color: #555; }
.layout-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); box-shadow: 0 0 15px var(--shadow-primary); }

/* 布局标签 (all 模式) */
.layout-label {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 0;
}

/* 键盘容器 */
.keyboard-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px 0;
    position: relative;
    gap: 20px;
}

/* 激活提示覆盖层 */
#activateOverlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    cursor: pointer;
    border-radius: 16px;
}
.activate-box {
    background: #1a1a24;
    padding: 30px 50px;
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(20, 184, 166, 0.3);
    animation: pulse-box 2s infinite;
}
.activate-box i { font-size: 40px; color: var(--primary-color); margin-bottom: 10px; }
.activate-box p { color: #fff; font-size: 16px; margin: 0; }
.activate-box span { color: #888; font-size: 12px; }

@keyframes pulse-box {
    0% { box-shadow: 0 0 20px rgba(20, 184, 166, 0.2); }
    50% { box-shadow: 0 0 40px rgba(20, 184, 166, 0.5); }
    100% { box-shadow: 0 0 20px rgba(20, 184, 166, 0.2); }
}

/* 键盘主体 */
.keyboard {
    width: 1100px; 
    background: #15151a;
    border: 2px solid #2a2a35;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    user-select: none;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
}

/* 键盘行 */
.row { 
    display: flex; 
    gap: 8px; 
    width: 100%; 
    align-items: stretch;
}

/* 按键基础样式 */
.key {
    height: 56px; 
    background: #252530;
    border: 1px solid #383845;
    border-bottom: 3px solid #181820;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px; 
    color: #ccc;
    font-weight: 500;
    transition: all 0.1s;
    position: relative;
    cursor: default;
    box-sizing: border-box;
    flex: 1 1 0px; 
    min-width: 0; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0; 
}

.key:hover { border-color: #555; background: #303040; }
.key.pressed {
    background: var(--primary-color);
    border-color: var(--primary-color);
    border-bottom-width: 1px;
    color: #fff;
    transform: translateY(2px);
    box-shadow: 0 0 10px var(--primary-color);
}

.key.tested {
    background: #22c55e;
    border-color: #22c55e;
    border-bottom-width: 1px;
    color: #fff;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* 按键宽度权重 */
.w-1 { flex: 1 1 0px; }           
.w-1-25 { flex: 1.25 1 0px; }    
.w-1-5 { flex: 1.5 1 0px; }      
.w-1-75 { flex: 1.75 1 0px; }    
.w-1-8 { flex: 1.8 1 0px; }      
.w-2 { flex: 2 1 0px; }          
.w-2-25 { flex: 2.25 1 0px; }    
.w-2-5 { flex: 2.5 1 0px; }      
.w-2-75 { flex: 2.75 1 0px; }    
.w-3 { flex: 3 1 0px; }          
.w-6-25 { flex: 6.25 1 0px; }    

/* 箭头键组 */
.arrow-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    flex: 3 1 0px;
    height: 56px;
    box-sizing: border-box;
}
.arrow-group .key {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    font-size: 14px;
    border-bottom-width: 2px;
    white-space: nowrap;
    overflow: hidden;
}
.arrow-group .key.pressed {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

/* Lenovo X13/T14: 3-column top row (PgUp/↑/PgDn) + bottom row (←/↓/→) */
.key-pgup  { grid-column: 1; grid-row: 1; border-radius: 4px 2px 2px 2px; }
.key-up    { grid-column: 2; grid-row: 1; border-radius: 4px 4px 2px 2px; }
.key-pgdn  { grid-column: 3; grid-row: 1; border-radius: 2px 4px 2px 2px; }
.key-left  { grid-column: 1; grid-row: 2; border-radius: 4px 2px 2px 4px; }
.key-down  { grid-column: 2; grid-row: 2; border-radius: 2px 2px 4px 4px; }
.key-right { grid-column: 3; grid-row: 2; border-radius: 2px 4px 4px 2px; }

.mac-key .key { font-size: 17px; }

.counter-panel { text-align: center; color: #555; font-size: 12px; }
.counter-panel span { color: var(--primary-color); font-weight: bold; }

/* 响应式缩放 - 适配 1920x1200 @ 150% (约 1280x800) 及更小屏幕 */
/* 响应式缩放 - 宽度缩放 */
@media (max-width: 1350px) and (min-height: 851px) {
    .keyboard { transform: scale(0.85); transform-origin: center center; }
}
@media (max-width: 1100px) and (min-height: 701px) {
    .keyboard { transform: scale(0.75); transform-origin: center center; }
    .info-panel { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 950px) and (min-height: 601px) {
    .keyboard { transform: scale(0.65); transform-origin: center center; }
}

/* 响应式缩放 - 高度优先 (适配 1920x1200 @ 150% 即 1280x800) */
@media (max-height: 850px) {
    .keyboard { transform: scale(0.7) !important; transform-origin: center center; }
    .keyboard-wrapper { padding: 0; }
    .info-panel { padding: 4px 12px; gap: 4px; margin-bottom: 0; }
    .status-display span:not(.label) { font-size: 14px; }
    .tips { display: none; } /* 隐藏提示文案以节省空间 */
}
@media (max-height: 700px) {
    .keyboard { transform: scale(0.6) !important; transform-origin: center center; }
    .info-panel { padding: 2px 8px; gap: 2px; }
}
@media (max-height: 600px) {
    .keyboard { transform: scale(0.5) !important; transform-origin: center center; }
}
