:root {
    --bg-dark: #0a0a0a;
    --bg-card: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent: #00e5ff;
    --accent-glow: rgba(0, 229, 255, 0.3);
    --key-bg: #2a2a2a;
    --key-active: #00e5ff;
    --border: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

.app-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
}

/* Header */
.app-header {
    text-align: center;
    padding: 8px 0;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

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

/* Main Grid - 上下布局 */
.main-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

/* Bottom Panel - 鼠标和麦克风并排 */
.bottom-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-height: 200px;
}

.zone-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

#key-display {
    float: right;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Keyboard Zone */
.keyboard-zone {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    overflow: hidden;
    max-width: 1450px;
    margin: 0 auto;
    width: 100%;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 功能键行 */
.function-row {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #222;
}

.fn-spacer {
    width: 30px;
}

.fn-spacer-sm {
    width: 12px;
}

.fn-group {
    display: flex;
    gap: 6px;
}

.region-spacer {
    width: 40px;
}

/* 主键盘区域容器 */
.main-keyboard-area {
    display: flex;
    gap: 20px;
}

/* 主键盘区 */
.main-keys {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kb-row {
    display: flex;
    gap: 6px;
}

/* 编辑键区 */
.edit-keys {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.edit-group-top,
.edit-group-mid {
    display: flex;
    gap: 6px;
}

.edit-spacer {
    height: 12px;
}

.arrow-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.arrow-row-top {
    display: flex;
    justify-content: center;
}

.arrow-row-bottom {
    display: flex;
    gap: 6px;
}

/* 数字键盘区 */
.numpad-keys {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.numpad-row {
    display: flex;
    gap: 6px;
    position: relative;
}

/* Key Styles */
.key {
    background: var(--key-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s ease;
}

.key.k-sm {
    width: 50px;
    height: 50px;
    font-size: 0.85rem;
}

/* 特殊按键尺寸 */
.key.k-backspace {
    width: 100px;
}

.key.k-tab {
    width: 75px;
}

.key.k-backslash {
    width: 75px;
}

.key.k-caps {
    width: 90px;
}

.key.k-enter {
    width: 110px;
}

.key.k-shift-left {
    width: 120px;
}

.key.k-shift-right {
    width: 140px;
}

.key.k-ctrl {
    width: 70px;
}

.key.k-win {
    width: 65px;
}

.key.k-alt {
    width: 65px;
}

.key.k-menu {
    width: 65px;
}

.key.k-space {
    flex: 1;
}

.key.k-wide-numpad {
    width: 106px;
}

.key.k-tall {
    position: absolute;
    right: 0;
    height: 106px;
}

.key.active {
    background: var(--key-active);
    color: #000;
    box-shadow: 0 0 12px var(--accent-glow);
    transform: translateY(-1px);
}

/* Side Panel - 已移除，改为bottom-panel */

/* Mouse Zone */
.mouse-zone {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    flex: 1;
    min-width: 0;
}

.mouse-content {
    display: flex;
    gap: 12px;
}

.mouse-visual {
    flex: 0 0 100px;
}

.mouse-body {
    width: 80px;
    height: 110px;
    background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
    border: 2px solid var(--border);
    border-radius: 40px 40px 30px 30px;
    position: relative;
    padding: 8px;
}

.mouse-btn-top {
    display: grid;
    grid-template-columns: 1fr 20px 1fr;
    gap: 2px;
    height: 50px;
}

.btn-left,
.btn-right,
.btn-wheel {
    background: var(--key-bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.1s;
    cursor: pointer;
}

.btn-left {
    border-radius: 20px 0 0 0;
}

.btn-right {
    border-radius: 0 20px 0 0;
}

.btn-wheel {
    border-radius: 10px;
    flex-direction: column;
}

.wheel-indicator {
    width: 12px;
    height: 12px;
    background: var(--border);
    border-radius: 50%;
    transition: all 0.1s;
}

.btn-left.active,
.btn-right.active,
.btn-wheel.active {
    background: var(--key-active);
    color: #000;
}

.btn-wheel.active .wheel-indicator {
    background: #000;
}

.mouse-side {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-side {
    background: var(--key-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.1s;
}

.btn-side.active {
    background: var(--key-active);
    color: #000;
}

.mouse-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-row {
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.info-row span {
    color: var(--accent);
    font-weight: 600;
}

.dblclick-test {
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.dblclick-test.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* Microphone Zone */
.mic-zone {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    flex: 1;
    min-width: 0;
}

.mic-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mic-controls {
    display: flex;
    gap: 8px;
}

.mic-dropdown {
    flex: 1;
    background: var(--key-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
}

.mic-dropdown:focus {
    outline: none;
    border-color: var(--accent);
}

.mic-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mic-btn:hover {
    background: #00b8cc;
}

.mic-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.mic-visualizer {
    background: #000;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    height: 100px;
}

#mic-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.mic-level {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.level-label {
    color: var(--text-secondary);
}

.level-bar {
    flex: 1;
    height: 12px;
    background: var(--key-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.level-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #00ff88);
    width: 0%;
    transition: width 0.1s;
}

#level-text {
    color: var(--accent);
    font-weight: 600;
    min-width: 35px;
}

/* History Bar */
.history-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
}

.history-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-list {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.history-list::-webkit-scrollbar {
    height: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.history-item {
    background: var(--key-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    color: var(--text-primary);
}

.clear-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.clear-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}