/* Reset & Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0e1a;
    --panel: #13192b;
    --primary: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: rgba(255,255,255,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* Header compact */
.header {
    background: var(--panel);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.header h1 {
    font-size: 1.5em;
    font-weight: 600;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
}

.api-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.api-led.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* Sections */
.section {
    background: var(--panel);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.section h2 {
    font-size: 1.1em;
    margin-bottom: 12px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.section h2:hover {
    color: var(--primary);
}

/* Files row */
.file-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.file-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-item label:first-child {
    font-size: 0.9em;
    color: var(--text-muted);
    font-weight: 500;
}

input[type="file"] {
    display: none;
}

.btn-file {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    font-size: 0.9em;
    transition: all 0.2s;
    border: none;
}

.btn-file:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.info {
    font-size: 0.85em;
    color: var(--success);
    min-height: 18px;
}

/* Config grid */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-item label {
    font-size: 0.85em;
    color: var(--text-muted);
}

.config-item small {
    font-size: 0.75em;
    color: var(--text-muted);
    font-style: italic;
}

input, select, textarea {
    width: 100%;
    background: rgba(255,255,255,0.05);
    color: #9e9ea1;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    font-family: inherit;
    font-size: 0.9em;
    transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

select:disabled, input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

textarea {
    min-height: 80px;
    resize: vertical;
    font-family: 'Courier New', monospace;
}

/* Range input */
input[type="range"] {
    height: 4px;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.range-value {
    font-size: 0.85em;
    color: var(--primary);
    font-weight: 600;
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 0;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Buttons */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text);
}

/* Progress */
.progress {
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    overflow: hidden;
    height: 24px;
    position: relative;
    margin-top: 12px;
}

.progress .bar {
    background: linear-gradient(90deg, var(--primary), var(--success));
    height: 100%;
    transition: width 0.3s;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85em;
    font-weight: 600;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
}

.stat {
    background: rgba(255,255,255,0.03);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat span {
    display: block;
    font-size: 1.8em;
    font-weight: 700;
    color: var(--primary);
}

.stat small {
    font-size: 0.8em;
    color: var(--text-muted);
}

/* Timeline */
.timeline {
    max-height: 300px;
    overflow-y: auto;
}

.timeline .empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 20px;
}

.word-item {
    background: rgba(255,255,255,0.03);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 6px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 0.85em;
    border: 1px solid var(--border);
}

.word-item:hover {
    background: rgba(255,255,255,0.06);
}

.speaker-badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.delete-btn {
    background: var(--danger);
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.8em;
}

.delete-btn:hover {
    background: #dc2626;
}

/* Collapsible */
.collapsible {
    display: block;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--panel);
    padding: 24px;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.modal-content h3 {
    margin-bottom: 12px;
}

.modal-content textarea {
    min-height: 400px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.close-modal {
    float: right;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.close-modal:hover {
    color: var(--primary);
}

/* Audio player */
#audioPlayer {
    width: 100%;
    height: 32px;
    margin-top: 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

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

::-webkit-scrollbar-thumb:hover {
    background: #2563eb;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .file-row {
        grid-template-columns: 1fr;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .word-item {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
}
