:root {
    --bg-dark: #0a0f1d;
    --bg-card: rgba(15, 23, 42, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-teal: #14b8a6;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

body {
    background: radial-gradient(circle at top right, #0f172a, #0a0f1d);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 18px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    box-shadow: 0 0 20px rgba(20, 184, 166, 0.4);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, #99f6e4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.system-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--accent-emerald);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-glow);
    position: relative;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.phase-tag {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 12px;
}

.phase-3 { background: rgba(20, 184, 166, 0.15); color: #2dd4bf; }
.phase-1 { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

.input-card, .output-card {
    background: rgba(10, 15, 29, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.provider-badge {
    font-size: 11px;
    font-weight: 500;
    background: rgba(139, 92, 246, 0.15);
    color: #c084fc;
    padding: 3px 8px;
    border-radius: 6px;
}

.recorder-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--border-color);
    padding: 14px 20px;
    border-radius: var(--radius-sm);
}

.visualizer-wave {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
}

.visualizer-wave span {
    width: 4px;
    height: 8px;
    background: var(--accent-teal);
    border-radius: 2px;
    transition: height 0.2s ease;
}

.visualizer-wave.recording span {
    animation: waveAnim 1s infinite ease-in-out alternate;
}

.visualizer-wave.recording span:nth-child(2) { animation-delay: 0.2s; }
.visualizer-wave.recording span:nth-child(3) { animation-delay: 0.4s; }
.visualizer-wave.recording span:nth-child(4) { animation-delay: 0.1s; }
.visualizer-wave.recording span:nth-child(5) { animation-delay: 0.3s; }

@keyframes waveAnim {
    0% { height: 6px; }
    100% { height: 28px; background: #ef4444; }
}

.recorder-timer {
    font-family: monospace;
    font-size: 16px;
    color: var(--text-secondary);
}

.btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
    color: #fff;
    box-shadow: 0 4px 14px rgba(20, 184, 166, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(20, 184, 166, 0.5);
}

.btn-record {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-record:hover { background: rgba(239, 68, 68, 0.3); }

.btn-stop { background: #ef4444; color: #fff; }

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.audio-file-fallback {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.file-input-hidden { display: none; }

.file-name-display {
    font-size: 12px;
    color: var(--accent-teal);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease;
    position: relative;
}

.drop-zone:hover { border-color: var(--accent-teal); }

.drop-icon {
    font-size: 28px;
    color: var(--accent-teal);
    margin-bottom: 8px;
}

.drop-zone p { font-size: 13px; color: var(--text-secondary); }
.drop-zone .hint { font-size: 11px; color: var(--text-muted); display: block; margin-top: 4px; }

.image-preview-container {
    position: relative;
    max-height: 180px;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.image-preview-container img {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.btn-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 12px;
    font-family: var(--font-body);
    font-size: 13px;
    resize: vertical;
    outline: none;
}

textarea:focus { border-color: var(--accent-teal); }

.btn-submit {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 15px;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 29, 0.85);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.spinner-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(20, 184, 166, 0.2);
    border-top-color: var(--accent-teal);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

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

.loading-status { font-size: 14px; color: var(--accent-teal); }

.audio-player-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-audio-player { width: 100%; outline: none; }

.auto-play-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.markdown-body {
    font-size: 14px;
    line-height: 1.6;
    color: #e5e7eb;
    white-space: pre-wrap;
}

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

.transcript-text {
    font-size: 13px;
    color: var(--accent-teal);
    font-style: italic;
    background: rgba(20, 184, 166, 0.08);
    padding: 10px;
    border-left: 3px solid var(--accent-teal);
    border-radius: 4px;
}

.trace-timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}

.trace-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid var(--accent-teal);
    padding: 10px 14px;
    border-radius: 6px;
}

.trace-item.failed { border-left-color: #ef4444; }

.trace-step-number {
    font-weight: 700;
    font-size: 12px;
    color: var(--accent-teal);
    background: rgba(20, 184, 166, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.trace-content { flex: 1; }

.trace-header-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
}

.trace-provider-name { color: var(--text-secondary); font-weight: 400; }
.trace-duration { color: var(--text-muted); font-size: 11px; }
.trace-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 12px; }

.hidden { display: none !important; }
