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

:root {
    --primary-color: #0F0F1D;
    --accent-color: #3D7CFF;
    --light-accent: #A4D8FA;
    --background: #FFFFFF;
    --surface: #F8FAFC;
    --border: #E5E7EB;
    --text-primary: #0F0F1D;
    --text-secondary: #6B7280;
    --success: #10B981;
    --error: #DC2626;
    --warning: #F59E0B;
    
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 2px 8px rgba(15, 15, 29, 0.08);
    --shadow-lg: 0 4px 16px rgba(15, 15, 29, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    gap: 1rem;
}

/* Header */
.header {
    text-align: center;
    padding: 1rem 0;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-shape {
    display: flex;
    flex-direction: column;
    gap: 3px;
    transform: rotate(-8deg);
}

.parallelogram {
    width: 48px;
    height: 10px;
    transform: skew(-18deg);
    border-radius: 2px;
}

.parallelogram.p1 { background-color: #A8BBD1; }
.parallelogram.p2 { background-color: #80A0C0; }
.parallelogram.p3 { background-color: #4D6B8C; }
.parallelogram.p4 { background-color: #1A2B3C; }

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main Grid */
.main-grid {
    display: grid;
    gap: 1rem;
    flex: 1;
    grid-template-columns: 1fr;
    align-content: start;
}

/* Card Base Styles */
.upload-card,
.options-card,
.action-card,
.results-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Upload Tabs */
.upload-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.upload-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.upload-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-color);
    background: var(--surface);
}

.upload-tab:hover:not(.active) {
    background: #F8FAFC;
}

/* Upload Section */
.upload-content {
    padding: 1rem;
}

.upload-area {
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px dashed var(--light-accent);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
}

.upload-area:hover {
    border-color: var(--accent-color);
    background: #F1F8FF;
    transform: translateY(-1px);
}

.upload-area.dragover {
    border-color: var(--accent-color);
    background: #E6F3FF;
    transform: scale(1.01);
}

.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.upload-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.upload-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.file-info {
    padding: 1rem;
    background: #F1F8FF;
    border-top: 1px solid var(--light-accent);
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.file-details span:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.file-details span:last-child {
    color: var(--text-secondary);
}

/* Recording Section */
.recording-area {
    text-align: center;
    padding: 1rem 0;
}

.recording-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.record-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
}

.record-btn:hover {
    background: #2563EB;
    transform: scale(1.05);
}

.record-btn.recording {
    background: var(--error);
    animation: pulse 2s infinite;
}

.record-btn.recording:hover {
    background: #B91C1C;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.record-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.record-text {
    font-size: 0.7rem;
    line-height: 1;
}

.recording-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--error);
}

.timer-dot {
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.recording-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.recording-status {
    font-weight: 500;
    margin-top: 0.5rem;
}

.recording-result {
    margin-top: 1rem;
}

.audio-preview {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border);
}

.audio-preview audio {
    width: 100%;
    margin-bottom: 1rem;
}

.recording-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.recording-actions .btn-secondary,
.recording-actions .btn-primary {
    flex: 1;
    max-width: 120px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

/* Options Section */
.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.options-header:hover {
    background: #F1F5F9;
}

.options-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.toggle-icon {
    transition: transform 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

.options-content {
    padding: 1rem;
    display: none;
}

.options-content.open {
    display: block;
}

.options-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.options-row:last-child {
    margin-bottom: 0;
}

/* Toggle Switches */
.option-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
}

.option-toggle input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #CBD5E1;
    border-radius: 12px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.option-toggle input:checked + .toggle-slider {
    background: var(--accent-color);
}

.option-toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.option-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.3;
}

/* Select and Input Groups */
.select-group,
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.select-group label,
.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.select-group select,
.input-group input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.select-group select:focus,
.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(61, 124, 255, 0.1);
}

/* Action Section */
.action-card {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-primary,
.btn-secondary {
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
}

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

.btn-primary:hover:not(:disabled) {
    background: #1A1A2E;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.results-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Dropdown */
.result-dropdown {
    position: relative;
}

.dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    min-width: 140px;
    justify-content: space-between;
}

.dropdown-btn:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(61, 124, 255, 0.1);
}

.dropdown-arrow {
    transition: transform 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.dropdown-arrow.rotated {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 100;
    display: none;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.dropdown-item:hover {
    background: var(--surface);
}

.dropdown-item:first-child {
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
}

/* Result Content */
.result-content {
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Transcript Styles */
.transcript-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.transcript-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.speaker-segment {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--surface);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.speaker-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    font-weight: 400;
}

/* JSON Styles */
.json-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.json-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-copy {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-copy:hover {
    background: #2563EB;
}

.json-content {
    background: #1F2937;
    color: #F3F4F6;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #374151;
}

.json-content .json-key { color: #60A5FA; }
.json-content .json-string { color: #34D399; }
.json-content .json-number { color: #F59E0B; }
.json-content .json-boolean { color: #F87171; }
.json-content .json-null { color: #9CA3AF; }

/* Messages */
.message-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    max-width: 320px;
}

.error-message {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--error);
    padding: 0.875rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
}

.success-message {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    color: #166534;
    padding: 0.875rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .app-container {
        padding: 0.75rem;
        gap: 0.875rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.875rem;
    }
    
    .parallelogram {
        width: 40px;
        height: 8px;
    }
    
    .upload-area {
        padding: 1.5rem 1rem;
    }
    
    .record-btn {
        width: 70px;
        height: 70px;
        font-size: 0.8rem;
    }
    
    .record-icon {
        font-size: 1.3rem;
    }
    
    .recording-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .recording-actions .btn-secondary,
    .recording-actions .btn-primary {
        max-width: none;
        width: 100%;
    }
    
    .upload-text {
        font-size: 0.9rem;
    }
    
    .upload-info {
        font-size: 0.75rem;
    }
    
    .options-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .options-row.form-row {
        flex-direction: row;
        gap: 1rem;
    }
    
    .option-label {
        font-size: 0.85rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .results-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .dropdown-btn {
        width: 100%;
        min-width: auto;
    }
    
    .dropdown-menu {
        left: 0;
        right: 0;
        min-width: auto;
    }
    
    .result-content {
        max-height: 50vh;
    }
    
    .json-content {
        font-size: 0.75rem;
        max-height: 300px;
    }
    
    .transcript-header {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .message-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0.5rem;
    }
    
    .upload-area {
        margin: 0.75rem;
        padding: 1.25rem 0.75rem;
    }
    
    .json-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-copy {
        width: 100%;
    }
}

/* Tablet and Desktop */
@media (min-width: 769px) {
    .app-container {
        padding: 1.5rem;
    }
    
    .main-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
    
    .upload-card {
        grid-column: 1 / -1;
    }
    
    .results-card {
        grid-column: 1 / -1;
    }
    
    .options-content {
        display: block;
    }
    
    .options-header {
        display: none;
    }
    
    .options-card {
        padding: 1rem;
        background: var(--surface);
    }
    
    .options-row.form-row {
        flex-direction: row;
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .main-grid {
        grid-template-columns: 2fr 1fr 1fr;
    }
    
    .upload-card {
        grid-column: 1 / 2;
        grid-row: 1;
    }
    
    .options-card {
        grid-column: 2 / 3;
        grid-row: 1;
    }
    
    .action-card {
        grid-column: 3 / 4;
        grid-row: 1;
    }
    
    .results-card {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}