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

:root {
    --primary-color: #4a5568;
    --primary-hover: #2d3748;
    --accent-color: #3182ce;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --sidebar-width: 280px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    color: var(--text-color);
}

/* Header */
header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    text-align: center;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

header .subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
}

/* Tab Navigation */
nav[role="tablist"] {
    display: flex;
    background: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
    padding: 0 1rem;
}

.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-color);
    background: var(--bg-color);
}

.tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

/* Main Content */
main {
    padding: 1rem;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Layout: Sidebar + Main Area */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.sidebar {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    height: fit-content;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar h3 {
    font-size: 0.95rem;
    margin: 1rem 0 0.5rem;
    color: var(--text-muted);
}

.main-area {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.main-area h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.main-area h3 {
    font-size: 1rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--text-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

select,
input[type="text"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

select:focus,
input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #2c5282;
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Result Area */
.result-area {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    min-height: 100px;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
}

/* Chat */
.chat-history {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
}

.chat-input-area input {
    flex: 1;
    margin-bottom: 0;
}

/* Voices Grid */
.voices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.voice-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
}

.voice-card h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.voice-card .voice-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.voice-card-actions {
    display: flex;
    gap: 0.5rem;
}

.voice-card-actions button {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.85rem;
}

/* Upload Methods */
.upload-methods {
    margin-top: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer p {
    margin: 0.25rem 0;
}

#api-status {
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }
    
    nav[role="tablist"] {
        overflow-x: auto;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

.status-ok {
    background: #d4edda;
    color: #155724;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

/* Drag and drop */
.voices-grid.drag-over {
    border: 2px dashed var(--accent-color);
    background: rgba(49, 130, 206, 0.05);
}

/* Recording state */
.btn-secondary.recording {
    background: #e53e3e;
    color: white;
    border-color: #e53e3e;
    animation: pulse 1s infinite;
}

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

/* Disabled button */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Required label */
.required {
    color: #e53e3e;
    font-weight: 600;
}

/* Feedback message */
.feedback-message {
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.feedback-message.success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.feedback-message.error {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
}
