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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 1rem;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
}

header h1 {
    font-size: 1.4rem;
    color: #e94560;
}

/* Split Layout */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #0f3460;
    min-height: calc(100vh - 60px);
}

.panel {
    background: #1a1a2e;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel h2 {
    font-size: 1.1rem;
    color: #e94560;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 0.5rem;
}

/* Service Controls */
.service-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.service-controls select {
    flex: 1;
    padding: 0.5rem;
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-size: 0.9rem;
}

.icon-btn {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
}

.icon-btn:hover {
    background: #0f3460;
}

/* Talk Button */
.recording-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.talk-btn {
    padding: 0.75rem 2rem;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    min-width: 140px;
}

.talk-btn:hover:not(:disabled) {
    background: #c73450;
}

.talk-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

.talk-btn.recording {
    background: #ff1744;
    animation: pulse 1s infinite;
}

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

#waveform-canvas {
    background: #16213e;
    border-radius: 4px;
    border: 1px solid #0f3460;
    flex: 1;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn {
    padding: 0.5rem 1rem;
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.secondary-btn:hover:not(:disabled) {
    background: #0f3460;
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-btn {
    padding: 0.5rem 1.5rem;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
}

.primary-btn:hover {
    background: #c73450;
}

/* Transcription Area */
.transcription-area {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.transcription-area label,
.tts-input-area label {
    font-size: 0.85rem;
    color: #888;
}

#transcription-output {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

/* TTS Input */
.tts-input-area {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#tts-text-input {
    padding: 0.5rem;
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-size: 0.9rem;
}

#tts-text-input:disabled {
    opacity: 0.5;
}

/* TTS Playback */
.tts-playback {
    display: flex;
    align-items: center;
}

.tts-playback audio {
    width: 100%;
}

/* Latency Stats */
.latency-stats {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem;
    background: #16213e;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: monospace;
}

.latency-stats .label {
    color: #888;
}

/* Error Display */
.error-display {
    background: #2d1b1b;
    border: 1px solid #e94560;
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 0.85rem;
    color: #ff6b6b;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* Test Result */
.test-result {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.test-result.success {
    background: #1b2d1b;
    border: 1px solid #4caf50;
    color: #81c784;
}

.test-result.failure {
    background: #2d1b1b;
    border: 1px solid #e94560;
    color: #ff6b6b;
}

/* API Request Display */
.api-request-area {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.api-request-area label {
    font-size: 0.85rem;
    color: #888;
}

.api-request-area textarea {
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 0.5rem;
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 0.8rem;
    resize: vertical;
    overflow-y: auto;
}

/* Copy to TTS Button */
.copy-to-tts-btn {
    align-self: flex-end;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #0f3460;
}

.modal-header h3 {
    color: #e94560;
}

#config-editor {
    flex: 1;
    margin: 1rem 1.5rem;
    padding: 0.75rem;
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    resize: vertical;
    tab-size: 2;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #0f3460;
}

/* Responsive */
@media (max-width: 768px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
}
