:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --bg-dark: #0f172a;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
}

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

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

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1e293b 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-box {
    background: var(--card-bg);
    padding: 3rem 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-box h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.login-box .subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-secondary:hover {
    background: #475569;
}

.btn-record {
    background: var(--error);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

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

.btn-record.recording {
    animation: pulse 1.5s infinite;
}

.btn-stop {
    background: var(--secondary);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

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

.error-message {
    color: var(--error);
    margin-top: 1rem;
    min-height: 1.5rem;
}

.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: var(--bg);
    color: var(--text);
}

.nav-link.logout {
    color: var(--error);
}

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

.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-header h1 {
    font-size: 1.75rem;
}

.stats {
    display: flex;
    gap: 1rem;
}

.stat-item {
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.stat-item span {
    font-weight: 600;
    color: var(--primary);
}

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters select, .filters input {
    width: auto;
    min-width: 150px;
}

.export-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    min-width: auto;
}

.stories-list {
    display: grid;
    gap: 1rem;
}

.story-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.story-card:hover {
    box-shadow: var(--shadow-lg);
}

.story-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.story-question {
    font-weight: 500;
    flex: 1;
}

.story-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-weight: 500;
}

.story-status.recorded { background: #fef3c7; color: #92400e; }
.story-status.transcribed { background: #dbeafe; color: #1e40af; }
.story-status.polished { background: #dcfce7; color: #166534; }

.story-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.story-excerpt {
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.interview-container {
    max-width: 700px;
    margin: 0 auto;
}

.question-display {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.question-display h2 {
    font-size: 1.5rem;
    line-height: 1.4;
}

.question-display .category {
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.recorder-container {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.recorder-visualizer {
    margin-bottom: 1.5rem;
}

.recorder-visualizer canvas {
    width: 100%;
    height: 100px;
    background: var(--bg);
    border-radius: 0.5rem;
}

.recording-time {
    font-size: 2rem;
    font-weight: 600;
    font-family: monospace;
    margin-top: 0.5rem;
    color: var(--text);
}

.recorder-controls {
    margin-bottom: 1.5rem;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.processing-status {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.5rem 0.5rem 0 0;
    transition: all 0.2s;
}

.tab:hover, .tab.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.questions-list {
    display: grid;
    gap: 0.75rem;
}

.question-item {
    background: var(--card-bg);
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.question-item.generated {
    border-left: 3px solid var(--primary);
}

.question-item.skipped {
    opacity: 0.7;
}

.question-text {
    flex: 1;
}

.question-category {
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

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

.question-actions button {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.story-detail h2 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.story-detail-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.story-detail audio {
    width: 100%;
    margin-bottom: 1.5rem;
}

.transcript-section {
    margin-bottom: 1.5rem;
}

.transcript-section h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.transcript-section p, .transcript-section textarea {
    background: var(--bg);
    padding: 1rem;
    border-radius: 0.5rem;
    white-space: pre-wrap;
}

.transcript-section textarea {
    min-height: 150px;
    resize: vertical;
}

.story-detail-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .container {
        padding: 1rem;
    }

    .filters {
        flex-direction: column;
    }

    .filters select, .filters input {
        width: 100%;
    }

    .export-controls {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    .view-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .stats {
        flex-wrap: wrap;
    }

    .question-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}
