        :root {
            --primary: #4f8a8b;
            --primary-dark: #3a6b6c;
            --accent: #ffd700;
            --bg: #0f1419;
            --bg2: #1a2332;
            --bg3: #243044;
            --text: #e8eaed;
            --text-dim: #9aa0a6;
            --border: #2d3a4a;
            --success: #34a853;
            --danger: #ea4335;
            --warning: #fbbc04;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg);
            color: var(--text);
            min-height: 100vh;
            padding: 20px 0;
        }
        .container { max-width: 100%; margin: 0; padding: 0; }
        .back-link {
            display: inline-block;
            margin: 0 20px 20px 20px;
            color: var(--primary);
            text-decoration: none;
            font-size: 0.85rem;
        }
        .back-link:hover { text-decoration: underline; }
        .header {
            text-align: center;
            margin: 0 20px 30px 20px;
        }
        .header h1 {
            font-size: 1.6rem;
            color: var(--primary);
            margin-bottom: 8px;
        }
        .header p { color: var(--text-dim); font-size: 0.85rem; }
        
        .card {
            background: var(--bg2);
            border: 1px solid var(--border);
            border-left: none;
            border-right: none;
            border-radius: 0;
            padding: 24px 20px;
            margin-bottom: 20px;
        }
        
        .btn {
            display: inline-block;
            padding: 12px 24px;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.2s;
            margin: 4px;
        }
        .btn-primary {
            background: var(--primary);
            color: white;
        }
        .btn-primary:hover { background: var(--primary-dark); }
        .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
        .btn-secondary {
            background: var(--bg3);
            color: var(--text);
            border: 1px solid var(--border);
        }
        .btn-secondary:hover { background: var(--border); }
        .btn-success { background: var(--success); color: white; }
        .btn-danger { background: var(--danger); color: white; }
        .btn-warning { background: var(--warning); color: #000; }
        
        .status-bar {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            padding: 16px;
            background: var(--bg3);
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .status-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: var(--text-dim);
        }
        .status-dot.recording { background: var(--danger); animation: pulse 1s infinite; }
        .status-dot.ready { background: var(--success); }
        .status-dot.midi { background: var(--warning); animation: pulse 1s infinite; }
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        
        .input-mode-selector {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        .mode-btn {
            flex: 1;
            min-width: 120px;
            padding: 10px 16px;
            background: var(--bg3);
            border: 2px solid var(--border);
            border-radius: 8px;
            color: var(--text-dim);
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }
        .mode-btn:hover { border-color: var(--primary); }
        .mode-btn.active {
            border-color: var(--primary);
            color: var(--text);
            background: rgba(79,138,139,0.2);
        }
        .mode-btn .mode-icon { font-size: 1.5rem; display: block; margin-bottom: 4px; }
        .mode-btn .mode-name { font-size: 0.85rem; }
        .mode-btn .mode-status { font-size: 0.7rem; color: var(--text-dim); margin-top: 2px; }
        
        .midi-device-select {
            margin-top: 12px;
            padding: 10px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            width: 100%;
            font-size: 0.9rem;
        }
        
        .visualizer {
            width: 100%;
            height: 200px;
            background: var(--bg3);
            border-radius: 8px;
            margin-bottom: 20px;
        }
        
        .pitch-display {
            text-align: center;
            padding: 20px;
        }
        .pitch-note {
            font-size: 4rem;
            font-weight: bold;
            color: var(--accent);
        }
        .pitch-freq {
            color: var(--text-dim);
            font-size: 0.9rem;
            margin-top: 8px;
        }
        
        /* 虚拟钢琴键盘 */
        .piano-container {
            margin: 24px -20px 0 -20px;  /* 抵消父卡片的左右 padding，撑满窗口 */
            padding: 0;
            background: var(--bg2);
            position: relative;
        }
        .piano-wrapper {
            position: relative;
            width: 100%;
        }
        .piano-scroll-area {
            width: 100%;
            overflow-x: auto;
            overflow-y: hidden;
            -webkit-overflow-scrolling: touch;  /* iOS 平滑滚动 */
        }
        /* 隐藏滚动条 */
        .piano-scroll-area::-webkit-scrollbar {
            display: none;
        }
        .piano-scroll-area {
            -ms-overflow-style: none;  /* IE/Edge */
            scrollbar-width: none;  /* Firefox */
        }
        .piano {
            display: flex;
            position: relative;
            height: 140px;
            min-width: fit-content;
        }
        .piano-octave {
            display: flex;
            position: relative;
            width: 252px; /* 7白键 * 36px */
            flex-shrink: 0;
        }
        .white-key {
            width: 36px;
            height: 100%;
            background: linear-gradient(to bottom, #fff 0%, #e8e8e8 100%);
            border: 1px solid #999;
            border-radius: 0 0 6px 6px;
            cursor: pointer;
            position: relative;
            z-index: 1;
            transition: all 0.1s;
        }
        .white-key:hover { background: linear-gradient(to bottom, #fff 0%, #d0d0d0 100%); }
        .white-key.active {
            background: linear-gradient(to bottom, var(--accent) 0%, #e6c200 100%);
            box-shadow: 0 0 12px var(--accent);
        }
        .white-key .key-label {
            position: absolute;
            bottom: 6px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 0.7rem;
            color: #666;
            pointer-events: none;
        }
        .black-key {
            width: 24px;
            height: 60%;
            background: linear-gradient(to bottom, #333 0%, #000 100%);
            border-radius: 0 0 4px 4px;
            position: absolute;
            z-index: 2;
            cursor: pointer;
            transition: all 0.1s;
        }
        .black-key:hover { background: linear-gradient(to bottom, #444 0%, #111 100%); }
        .black-key.active {
            background: linear-gradient(to bottom, var(--warning) 0%, #cc9900 100%);
            box-shadow: 0 0 10px var(--warning);
        }
        /* 黑键位置（每八度5个黑键，白键宽36px） */
        .black-key:nth-child(8) { left: 25px; }   /* C# */
        .black-key:nth-child(9) { left: 61px; }   /* D# */
        .black-key:nth-child(10) { left: 133px; }  /* F# */
        .black-key:nth-child(11) { left: 169px; }  /* G# */
        .black-key:nth-child(12) { left: 205px; }  /* A# */
        
        .midi-notes {
            max-height: 300px;
            overflow-y: auto;
            background: var(--bg);
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 20px;
        }
        .midi-note {
            display: inline-block;
            padding: 4px 10px;
            margin: 2px;
            background: var(--primary);
            color: white;
            border-radius: 4px;
            font-size: 0.85rem;
        }
        .midi-note.from-keyboard { background: var(--warning); color: #000; }
        .midi-note.chord {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 6px 12px;
            font-weight: 600;
            border: 1px solid rgba(255,255,255,0.3);
        }
        .note-duration {
            display: inline-block;
            font-size: 0.75rem;
            color: var(--text-dim);
            margin-left: 4px;
            margin-right: 12px;
            vertical-align: middle;
        }
        
        .settings-row {
            display: flex;
            gap: 16px;
            flex-wrap: wrap;
            margin-bottom: 16px;
        }
        .setting-item {
            flex: 1;
            min-width: 150px;
        }
        .setting-item label {
            display: block;
            font-size: 0.8rem;
            color: var(--text-dim);
            margin-bottom: 4px;
        }
        .setting-item select, .setting-item input {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg3);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            font-size: 0.9rem;
        }
        .setting-hint {
            font-size: 0.7rem;
            color: var(--text-dim);
            margin-top: 4px;
            opacity: 0.7;
        }
        
        .info-box {
            background: rgba(79,138,139,0.1);
            border-left: 3px solid var(--primary);
            padding: 12px 16px;
            font-size: 0.85rem;
            color: var(--text-dim);
            margin-bottom: 20px;
        }
        
        footer {
            text-align: center;
            margin: 40px 20px 0 20px;
            padding: 16px;
            color: var(--text-dim);
            font-size: 0.75rem;
            border-top: 1px solid var(--border);
        }
        footer a { color: var(--primary); text-decoration: none; }
        
        @media (max-width: 600px) {
            .settings-row { flex-direction: column; }
            .pitch-note { font-size: 3rem; }
            .input-mode-selector { flex-direction: column; }
            .mode-btn { min-width: 100%; }
        }
