/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --primary-dark: #357abd;
    --secondary-color: #50c878;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-dark: #2c3e50;
    --border-color: #e1e8ed;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部样式 */
.header {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 0;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.logo-mark {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.1;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.nav-link:hover::after {
    width: 100%;
}

/* 英雄区域 */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 3rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 1rem;
    opacity: 0.9;
}

/* 键盘测试区域 */
.keyboard-test-section {
    padding: 2rem 0 4rem;
    overflow-x: auto;
}

.test-panel {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 2rem;
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.test-header h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.test-controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* 测试统计 */
.test-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    transition: var(--transition);
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-box .stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-box .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* 按键显示区域 */
.key-display-area {
    margin-top: 2rem;
}

.key-display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.key-display-header h4 {
    font-size: 1.2rem;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.key-log {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.key-item {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    animation: keyPress 0.3s ease;
}

@keyframes keyPress {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.key-name {
    font-weight: 600;
}

.key-code {
    font-size: 0.8rem;
    opacity: 0.8;
}

.key-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* 虚拟键盘 - 完全按照参考图重写 */
.virtual-keyboard {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.keyboard-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.keyboard-title-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.keyboard-header h4 {
    font-size: 1.2rem;
    margin: 0;
}

.keyboard-type-selector {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 8px;
}

.keyboard-type-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.keyboard-type-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.keyboard-type-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow);
}

.keyboard-icon {
    font-size: 1.2rem;
}

/* 键盘布局容器 */
#keyboard {
    background: #e8e8e8;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-direction: row;
    gap: 0.6rem;
    align-items: flex-start;
    overflow-x: auto;
    min-width: 100%;
}

/* 键盘行 */
.kb-row {
    display: flex;
    gap: 0.3rem;
    align-items: flex-start;
    min-height: 44px;
    justify-content: space-between;
}

/* 按键基础样式，固定尺寸对齐网格 */
.kb-key {
    background: #ffffff;
    border: 1px solid #8fb3d1;
    border-radius: 4px;
    width: 48px;
    height: 44px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: #2f6a92;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: default;
    transition: all 0.1s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.kb-key.pressed {
    background: #4a90e2;
    color: white;
    border-color: #357abd;
    transform: translateY(1px);
}

.kb-key.tested {
    background: #50c878;
    color: white;
    border-color: #3fa85f;
}

/* 功能行间隔占位 */
.kb-gap {
    width: 16px;
    height: 44px;
    visibility: hidden;
    flex-shrink: 0;
}

/* 主键盘区 */
.kb-main {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

/* 特殊键宽度 */
.kb-tab { width: 70px; }
.kb-caps { width: 80px; }
.kb-backspace { width: 90px; }
.kb-shift { width: 130px; }
.kb-space { width: 320px; }
.kb-fn { width: 52px; font-size: 0.8rem; }

/* Enter键 - L形，跨越两行 */
.kb-enter-main {
    width: 120px;
    height: 44px;
}

/* 右Shift */
.kb-main .kb-row:nth-child(4) .kb-shift:last-child {
    width: 150px;
}

/* 调整 Shift 行（第5行）间距略紧凑，左右 Shift 更宽 */
.kb-main .kb-row:nth-child(5) {
    gap: 0.3rem;
}

/* 上方前5行：收紧间距 */
.kb-main .kb-row:not(:nth-child(6)) {
    gap: 0.3rem;
}

/* 底部 Space 行：键加宽，间距更紧凑 */
.kb-main .kb-row:nth-child(6) {
    gap: 0.3rem;
}
.kb-main .kb-row:nth-child(6) .kb-key {
    width: 68px;
}
.kb-main .kb-row:nth-child(6) .kb-space {
    width: 300px;
}

/* 编辑/导航区 */
.kb-nav {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 170px;
}

.kb-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-auto-rows: 44px;
    gap: 0.5rem;
}

.kb-arrow-up {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 170px;
    margin-top: 3.2rem; /* 下移约一行高度，空出一排键位 */
}

.kb-arrow-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 170px;
}

/* 数字键盘区 */
.kb-numpad {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* 与主键盘一致的行距 */
    width: 240px;
    margin-top: 52px; /* 下移约一键位，使底部与主键盘对齐 */
}

.kb-np-row-1 {
    margin-top: 0;
}
.kb-np-row-2 {
    min-height: 44px;
    position: relative;
    margin-top: 0;
}
.kb-np-row-3 {
    min-height: 44px;
}
.kb-np-row-4 {
    min-height: 44px;
    position: relative;
}
.kb-np-row-5 {
    min-height: 44px;
    margin-top: 0;
}

.kb-nav-row {
    width: 170px;
}

.kb-arrow-bottom {
    width: 170px;
    justify-content: center;
}

.kb-numpad .kb-row:nth-child(2) {
    position: relative;
    padding-right: 62px; /* 为 + 键预留空间，避免挤压 */
}

.kb-plus {
    width: 52px;
    height: 92px;
    position: absolute;
    right: 0;
    top: 0;
}

.kb-numpad .kb-row:nth-child(3) {
    padding-right: 62px; /* 与上行保持一致，行距统一 */
}

.kb-numpad .kb-row:nth-child(4) {
    position: relative;
    padding-right: 62px; /* 为 Enter 键预留空间，避免挤压 */
}

.kb-enter {
    width: 52px;
    height: 92px;
    position: absolute;
    right: 0;
    top: 0;
}

.kb-numpad .kb-row:nth-child(5) {
    padding-right: 62px; /* 与上行保持一致，行距统一 */
}

.kb-zero {
    width: 112px;
}

/* 功能特点区域 */
.features-section {
    padding: 4rem 0;
    background: var(--bg-primary);
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.8;
}

/* 使用帮助区域 */
.help-section {
    padding: 4rem 0;
}

.help-content {
    max-width: 800px;
    margin: 0 auto;
}

.help-item {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.help-item h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.help-item p {
    color: var(--text-secondary);
    line-height: 1.8;
}

.seo-hero {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.seo-hero img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-hover);
}

/* 页脚 */
.footer {
    background: var(--bg-dark);
    color: white;
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h4 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.footer-section p {
    opacity: 0.8;
    line-height: 1.8;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: var(--transition);
}

.footer-links a:hover {
    opacity: 1;
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
    margin: 0.5rem 0;
    opacity: 0.8;
}

.footer-bottom a {
    color: white;
    text-decoration: none;
}

.footer-bottom a:hover {
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero-stats {
        flex-direction: column;
        gap: 1.5rem;
    }

    .test-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .test-stats {
        grid-template-columns: 1fr;
    }

    .nav {
        flex-direction: column;
        gap: 1rem;
    }

    #keyboard {
        flex-direction: column;
        gap: 2rem;
    }

    .kb-main,
    .kb-nav,
    .kb-numpad {
        min-width: 100%;
    }

    .kb-row {
        flex-wrap: wrap;
    }

    .kb-space {
        min-width: 200px;
    }

    .keyboard-title-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .keyboard-type-selector {
        width: 100%;
    }

    .keyboard-type-btn {
        flex: 1;
        justify-content: center;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 焦点样式 */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.test-panel {
    animation: fadeIn 0.5s ease;
}

