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

/* Dark Blue Theme Variables */
:root {
    --bg: #0b1220;
    --bg-elev: #0f1a2e;
    --card: #111a31;
    --muted: #8ea2c6;
    --text: #e9f0ff;
    --accent: #4f7cff;
    --accent-2: #6d59ff;
    --accent-3: #1fa0ff;
    --stroke: rgba(255, 255, 255, 0.08);
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(1200px 800px at 20% -10%, rgba(79,124,255,0.18), transparent),
                radial-gradient(1200px 800px at 110% 10%, rgba(31,160,255,0.18), transparent),
                var(--bg);
    min-height: 100vh;
    color: var(--text);
}

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

header { text-align: center; margin-bottom: 24px; }
.hero { display: flex; flex-direction: column; gap: 16px; padding: 28px; background: linear-gradient(180deg, rgba(17,26,49,0.9), rgba(17,26,49,0.6)); border: 1px solid var(--stroke); border-radius: 20px; }
.brand { display: flex; align-items: center; gap: 14px; justify-content: center; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-weight: 800; color: white; letter-spacing: 0.5px; }
.brand-text { display: flex; align-items: baseline; gap: 10px; }
.brand-text h1 { font-size: 1.8rem; font-weight: 800; }
.badge { padding: 4px 8px; border-radius: 999px; background: rgba(79,124,255,0.15); color: var(--accent); font-weight: 700; font-size: 0.75rem; border: 1px solid var(--stroke); }
.subtitle { color: var(--muted); }

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.upload-section { background: var(--bg-elev); border: 1px solid var(--stroke); border-radius: 18px; padding: 22px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }

.upload-area { border: 2px dashed rgba(79,124,255,0.45); border-radius: 16px; padding: 36px 26px; text-align: center; cursor: pointer; transition: all 0.25s ease; background: linear-gradient(180deg, rgba(17,26,49,0.65), rgba(17,26,49,0.4)); }

.upload-area:hover { border-color: var(--accent-3); background: rgba(31,160,255,0.08); transform: translateY(-1px); }

.upload-area.dragover { border-color: var(--accent); background: rgba(79,124,255,0.12); transform: scale(1.01); }

.upload-icon { font-size: 3rem; margin-bottom: 14px; opacity: 0.9; }

.upload-area h3 { font-size: 1.25rem; margin-bottom: 8px; color: var(--text); }

.upload-area p { color: var(--muted); margin-bottom: 16px; }

.browse-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; border: none; padding: 12px 22px; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: all 0.2s ease; }
.options-section { background: var(--card); border: 1px solid var(--stroke); border-radius: 16px; padding: 18px; }

.options-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.option label { display: block; font-weight: 700; color: var(--text); margin-bottom: 8px; }

.option select { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--stroke); background: #0c1528; color: var(--text); font-size: 1rem; outline: none; }

.option select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(79,124,255,0.15); }

@media (max-width: 900px) {
    .upload-section {
        grid-template-columns: 1fr;
    }
    .options-row {
        grid-template-columns: 1fr;
    }
}

.browse-btn:hover {
    transform: translateY(-1px);
}

.progress-section {
    background: var(--bg-elev);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    padding: 22px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #0c1528;
    border: 1px solid var(--stroke);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-3));
    width: 0%;
    transition: width 0.25s ease;
    border-radius: 999px;
}

.progress-text {
    text-align: center;
    font-weight: 700;
    color: var(--muted);
}

.results-section {
    background: var(--bg-elev);
    border: 1px solid var(--stroke);
    border-radius: 18px;
    padding: 18px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.results-actions {
    display: flex;
    gap: 8px;
}

.auto-save-notice {
    background: rgba(79, 124, 255, 0.1);
    color: var(--accent);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(79, 124, 255, 0.3);
}

.audio-convert-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.audio-convert-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.audio-convert-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.voice-config-btn {
    background: linear-gradient(135deg, #9c88ff, #8c7ae6);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.voice-config-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.save-edits-btn {
    background: linear-gradient(135deg, #10ac84, #00d2d3);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.save-edits-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.voice-config-section {
    background: linear-gradient(180deg, rgba(156, 136, 255, 0.08), rgba(140, 122, 230, 0.05));
    border: 1px solid rgba(156, 136, 255, 0.2);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
}

.voice-config-header {
    margin-bottom: 16px;
}

.voice-config-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px 0;
}

.voice-config-header p {
    font-size: 0.9rem;
    color: var(--muted);
    margin: 0;
}

.voice-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.voice-config-item {
    background: var(--card);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    padding: 16px;
}

.voice-config-item h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-config-item select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--stroke);
    background: #0c1528;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}

.voice-config-item select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,124,255,0.15);
}

.audio-section {
    background: linear-gradient(180deg, rgba(255, 107, 107, 0.08), rgba(238, 90, 36, 0.05));
    border: 1px solid rgba(255, 107, 107, 0.2);
    border-radius: 14px;
    padding: 18px;
    margin-top: 16px;
}

.audio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.audio-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.audio-info {
    font-size: 0.85rem;
    color: var(--muted);
}

.audio-player-container {
    background: rgba(255, 107, 107, 0.05);
    border: 1px solid rgba(255, 107, 107, 0.15);
    border-radius: 10px;
    padding: 12px;
}

/* Conversation Tabs */
.conversation-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--stroke);
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--stroke);
    padding: 10px 14px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.tab-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

/* Conversation Container */
.conversation-container {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.conversation-container::-webkit-scrollbar {
    width: 6px;
}

.conversation-container::-webkit-scrollbar-track {
    background: #0c1528;
    border-radius: 3px;
}

.conversation-container::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* Chat Messages */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 85%;
    animation: messageSlideIn 0.4s ease-out;
}

.chat-message.speaker-1 {
    align-self: flex-start;
}

.chat-message.speaker-2 {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.speaker-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.9em;
    flex-shrink: 0;
}

.speaker-1 .speaker-avatar {
    background: linear-gradient(45deg, #667eea, #764ba2);
}

.speaker-2 .speaker-avatar {
    background: linear-gradient(45deg, #f093fb, #f5576c);
}

.message-content {
    background: #0d1730;
    padding: 14px 16px;
    border-radius: 14px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.6;
    position: relative;
    border: 1px solid var(--stroke);
    min-height: fit-content;
}

.speaker-1 .message-content {
    background: linear-gradient(180deg, rgba(79,124,255,0.12), rgba(79,124,255,0.08));
    color: var(--text);
    border: 1px solid rgba(79,124,255,0.25);
}

.speaker-2 .message-content {
    background: linear-gradient(180deg, rgba(31,160,255,0.12), rgba(31,160,255,0.08));
    color: var(--text);
    border: 1px solid rgba(31,160,255,0.25);
}

.message-timestamp {
    font-size: 0.8em;
    color: var(--muted);
    margin-top: 6px;
}

.message-text {
    position: relative;
    min-height: 1.6em;
    overflow: hidden;
}

.message-text.editable {
    cursor: text;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.message-text.editable:hover {
    background: rgba(255, 255, 255, 0.05);
}

.message-text.editing {
    background: rgba(79, 124, 255, 0.1);
    border: 1px solid var(--accent);
    padding: 8px;
    overflow: visible;
}

.message-edit-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    outline: none;
    resize: none;
    min-height: 1.6em;
    max-height: 200px;
    overflow-y: auto;
    box-sizing: border-box;
}

.message-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.edit-btn {
    padding: 4px 8px;
    border-radius: 4px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-btn.save {
    background: var(--accent);
    color: white;
}

.edit-btn.cancel {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--stroke);
}

.edit-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* Placeholder */
.placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    margin: 50px 0;
    font-size: 1.1em;
}

/* Animation for new messages */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-section {
    background: var(--bg-elev);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
}

.error-card {
    background: #2a1620;
    border: 1px solid rgba(255, 77, 109, 0.3);
    border-radius: 14px;
    padding: 20px;
}

.error-card h3 {
    color: #ff6b81;
    margin-bottom: 10px;
    font-size: 1.25rem;
}

.error-card p {
    color: #ff99aa;
    margin-bottom: 18px;
    font-size: 1rem;
}

.retry-btn {
    background: linear-gradient(135deg, #ff4d6d, #ff6b6b);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

footer {
    text-align: center;
    margin-top: 24px;
    padding: 16px;
    color: var(--muted);
    border-top: 1px solid var(--stroke);
}

footer p {
    font-size: 0.85rem;
}

/* History Section */
.history-section {
    background: var(--bg-elev);
    border: 1px solid var(--stroke);
    border-radius: 18px;
    padding: 18px;
    margin-top: 24px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.history-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.history-btn.danger {
    background: #ff4d6d;
}

.history-btn.danger:hover {
    background: #ff3742;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-card {
    background: var(--card);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    padding: 14px;
    transition: all 0.2s ease;
}

.history-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.history-card h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px 0;
}

.history-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.history-actions-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn.small {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 5px;
}

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

.btn.outline:hover {
    background: var(--accent);
    color: white;
}

.btn.danger {
    background: #ff4d6d;
    color: white;
    border: none;
}

.btn.danger:hover {
    background: #ff3742;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--accent);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

/* Fade in animations */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .upload-area {
        padding: 40px 20px;
    }
    
    .result-card {
        padding: 20px;
    }
}
