* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0a0a; color: #e0e0e0;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
}
#app { text-align: center; padding: 2rem; width: 100%; max-width: 600px; }
h1 { font-size: 2rem; margin-bottom: 1rem; color: #fff; }
#status { font-size: 0.9rem; color: #888; margin-bottom: 0.5rem; }
.connected { color: #2ecc71 !important; }
.disconnected { color: #e74c3c !important; }

#pipeline-state {
    font-size: 0.9rem; margin-bottom: 2rem; padding: 0.3rem 0.8rem;
    display: inline-block; border-radius: 1rem;
}
.state-idle { color: #888; }
.state-listening { color: #3498db; animation: pulse 1s infinite; }
.state-processing { color: #f39c12; animation: pulse 0.5s infinite; }
.state-speaking { color: #2ecc71; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#mic-btn {
    width: 120px; height: 120px; border-radius: 50%;
    border: 3px solid #333; background: #1a1a1a;
    color: #fff; font-size: 2.5rem; cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
#mic-btn:active:not(:disabled), #mic-btn.active {
    background: #e74c3c; border-color: #e74c3c;
    transform: scale(1.1);
}
#mic-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Audio Level Meter */
#level-meter {
    width: 200px; height: 14px; margin: 1rem auto 0;
    background: #111; border-radius: 7px; overflow: hidden;
    border: 1px solid #333; position: relative;
    transition: opacity 0.3s;
}
#level-meter.hidden { opacity: 0; pointer-events: none; }
#level-bar {
    height: 100%; width: 0%; border-radius: 7px 0 0 7px;
    background: linear-gradient(90deg, #2ecc71 0%, #2ecc71 55%, #f1c40f 55%, #f1c40f 78%, #e74c3c 78%, #e74c3c 100%);
    transition: width 60ms linear;
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.4);
}
/* LED segment overlay */
#level-meter::after {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px, transparent 8px,
        #0a0a0a 8px, #0a0a0a 10px
    );
    border-radius: 7px;
    pointer-events: none;
}

#conversation {
    margin-top: 2rem; text-align: left;
    max-height: 400px; overflow-y: auto;
    padding: 0 1rem;
}
.msg {
    margin-bottom: 0.8rem; padding: 0.5rem 0.8rem;
    border-radius: 0.5rem; font-size: 0.95rem;
    line-height: 1.4;
}
.msg-user { background: #1a2a3a; border-left: 3px solid #3498db; }
.msg-assistant { background: #1a2a1a; border-left: 3px solid #2ecc71; }
.msg-label { font-size: 0.75rem; color: #888; margin-bottom: 0.2rem; }

#latency { margin-top: 1rem; font-size: 0.8rem; color: #555; }

/* Debug Panel */
#debug-toggle {
    position: fixed; top: 8px; right: 8px; z-index: 9999;
    background: #1a1a2e; color: #0f0; border: 1px solid #0f03;
    border-radius: 4px; padding: 4px 10px; font-size: 12px;
    cursor: pointer; font-family: 'SF Mono', 'Fira Code', monospace;
    transition: all 0.2s;
}
#debug-toggle:hover { background: #2a2a4e; border-color: #0f0; }
#debug-toggle.active { background: #0f02; border-color: #0f0; color: #0f0; }

#debug-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    max-height: 40vh; z-index: 9998;
    background: #0d1117; border-top: 2px solid #0f03;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 11px; color: #c9d1d9;
    display: none; flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}
#debug-panel.open { display: flex; }

#debug-stats {
    display: flex; gap: 16px; flex-wrap: wrap;
    padding: 6px 12px; background: #161b22;
    border-bottom: 1px solid #21262d;
    font-size: 10px; color: #8b949e;
}
#debug-stats .stat { white-space: nowrap; }
#debug-stats .stat-val { color: #58a6ff; font-weight: 600; }
#debug-stats .stat-val.ok { color: #3fb950; }
#debug-stats .stat-val.err { color: #f85149; }

#debug-log {
    overflow-y: auto; padding: 6px 12px; flex: 1;
    max-height: calc(40vh - 30px);
}
#debug-log div {
    padding: 1px 0; border-bottom: 1px solid #21262d08;
    line-height: 1.5;
}
#debug-log .ts { color: #484f58; }
#debug-log .ws-open { color: #3fb950; }
#debug-log .ws-close { color: #f85149; }
#debug-log .ws-err { color: #f85149; font-weight: 600; }
#debug-log .audio-send { color: #8b949e; }
#debug-log .audio-recv { color: #a371f7; }
#debug-log .transcript { color: #58a6ff; }
#debug-log .response { color: #3fb950; }
#debug-log .state-change { color: #d29922; }
#debug-log .info { color: #8b949e; }
