/* === Fonts === */
@font-face {
    font-family: 'MVTyper';
    src: url('/static/mvtyper.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* === Variables === */
:root {
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-thaana: 'MVTyper', 'Faruma', sans-serif;

    --bg: #f7f5f2;
    --bg-card: #ffffff;
    --bg-inset: #f0ede8;
    --bg-hover: #ebe8e3;

    --text: #1a1a1a;
    --text-secondary: #6b6560;
    --text-tertiary: #9e9892;

    --accent: #0d7c66;
    --accent-light: #e8f5f1;
    --accent-hover: #0a6654;

    --border: #e4e0db;
    --border-light: #eeebe7;

    --error: #c53030;
    --error-bg: #fef2f2;
    --success: #0d7c66;

    --speaker-1: #0d7c66;
    --speaker-2: #b45309;
    --speaker-3: #6d28d9;
    --speaker-4: #be185d;
    --speaker-5: #0369a1;
    --speaker-6: #15803d;

    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
}

/* === Reset === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* === Auth Overlay === */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    animation: authFadeIn 0.4s ease;
}

.auth-overlay.hiding {
    animation: authFadeOut 0.5s ease forwards;
}

@keyframes authFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes authFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 2.5rem 2rem;
    text-align: center;
    animation: authSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-brand {
    margin-bottom: 2.5rem;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.auth-tagline {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    font-weight: 400;
}

.auth-form label {
    display: block;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.auth-input-wrap {
    display: flex;
    gap: 0.5rem;
}

.auth-input-wrap input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.auth-input-wrap input:focus {
    border-color: var(--accent);
}

.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.auth-submit:hover {
    background: var(--accent-hover);
}

.auth-submit svg {
    width: 18px;
    height: 18px;
    color: white;
}

.auth-error {
    color: var(--error);
    font-size: 0.8125rem;
    margin-top: 0.75rem;
    min-height: 1.2em;
}

.auth-footer {
    margin-top: 2.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* === Top Bar === */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(247, 245, 242, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.topbar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 0.8125rem;
    border-radius: 7px;
    letter-spacing: -0.02em;
}

.topbar-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.topbar-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

/* === Container === */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* === Hero === */
.hero {
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.hero-sub {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
    max-width: 520px;
}

.hero-coming {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem 0.875rem;
    background: var(--accent-light);
    border-radius: 20px;
    font-size: 0.8125rem;
    color: var(--accent);
    font-weight: 450;
}

.hero-coming svg {
    flex-shrink: 0;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

/* === Upload === */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-inset);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.upload-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.upload-area:hover .upload-icon-wrap,
.upload-area.dragover .upload-icon-wrap {
    background: var(--accent);
}

.upload-area:hover .upload-icon,
.upload-area.dragover .upload-icon {
    color: white;
}

.upload-label {
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.upload-hint {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

.file-types {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--bg-inset);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-inset);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0;
}

.file-info-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.file-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
}

.btn-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.btn-clear:hover {
    background: var(--bg-hover);
    color: var(--error);
}

/* === Buttons === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary svg {
    fill: currentColor;
    stroke: none;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

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

/* === Progress === */
.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.progress-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.progress-pct {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    height: 6px;
    background: var(--bg-inset);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.625rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-status {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-bottom: 1.5rem;
}

.progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 0.25rem;
    margin-bottom: 1.5rem;
    border-radius: 1px;
    transition: background 0.3s;
}

.step-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-inset);
    border: 2px solid var(--border);
    transition: all 0.3s;
    position: relative;
}

.step span {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.step.active .step-dot {
    border-color: var(--accent);
    background: var(--accent-light);
    animation: stepPulse 1.8s infinite;
}

.step.active .step-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.step.active span {
    color: var(--accent);
}

.step.completed .step-dot {
    border-color: var(--success);
    background: var(--success);
}

.step.completed span {
    color: var(--text);
}

.step.completed + .step-line {
    background: var(--success);
}

@keyframes stepPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13, 124, 102, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(13, 124, 102, 0); }
}

/* === Results === */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.results-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.audio-player-wrap {
    margin-bottom: 1.5rem;
}

.audio-player-wrap audio {
    width: 100%;
    height: 40px;
    border-radius: var(--radius);
}

/* === Segments === */
.segments-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.segment {
    background: var(--bg-inset);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--speaker-1);
}

.segment[data-speaker="1"] { border-left-color: var(--speaker-1); }
.segment[data-speaker="2"] { border-left-color: var(--speaker-2); }
.segment[data-speaker="3"] { border-left-color: var(--speaker-3); }
.segment[data-speaker="4"] { border-left-color: var(--speaker-4); }
.segment[data-speaker="5"] { border-left-color: var(--speaker-5); }
.segment[data-speaker="6"] { border-left-color: var(--speaker-6); }

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

.speaker-label {
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.segment[data-speaker="1"] .speaker-label { color: var(--speaker-1); }
.segment[data-speaker="2"] .speaker-label { color: var(--speaker-2); }
.segment[data-speaker="3"] .speaker-label { color: var(--speaker-3); }
.segment[data-speaker="4"] .speaker-label { color: var(--speaker-4); }
.segment[data-speaker="5"] .speaker-label { color: var(--speaker-5); }
.segment[data-speaker="6"] .speaker-label { color: var(--speaker-6); }

.segment-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.segment-controls {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}

.btn-play {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-play:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-play svg {
    width: 14px;
    height: 14px;
    fill: white;
}

.btn-play.playing svg {
    fill: none;
    stroke: white;
    stroke-width: 3;
}

.segment-progress {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.segment-progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 2px;
}

.segment-duration {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    min-width: 42px;
    text-align: right;
}

/* === Thaana / RTL Text === */
.segment-words {
    line-height: 2;
    direction: rtl;
    text-align: right;
    font-family: var(--font-thaana);
    font-size: 1.0625rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.word {
    display: inline;
    padding: 0.15rem 0.25rem;
    border-radius: 3px;
    transition: all 0.15s ease;
    cursor: default;
}

.word:hover {
    background: rgba(13, 124, 102, 0.08);
}

.word.active {
    background: var(--accent);
    color: white;
    border-radius: 4px;
}

.word.past {
    color: var(--text-tertiary);
}

/* === Error Section === */
.error-section {
    border-color: rgba(197, 48, 48, 0.2);
    background: var(--error-bg);
}

.error-content {
    text-align: center;
    padding: 1.5rem 0;
}

.error-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(197, 48, 48, 0.08);
    border-radius: 50%;
    margin-bottom: 1rem;
    color: var(--error);
}

.error-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--error);
    margin-bottom: 0.375rem;
}

.error-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.error-section .btn-primary {
    width: auto;
    display: inline-flex;
    background: var(--error);
}

.error-section .btn-primary:hover {
    background: #a52828;
}

/* === Footer === */
.app-footer {
    text-align: center;
    padding: 2rem 0;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* === Responsive === */
@media (max-width: 640px) {
    .container {
        padding: 1.25rem 1rem 3rem;
    }

    .hero h1 {
        font-size: 1.375rem;
    }

    .hero-sub {
        font-size: 0.875rem;
    }

    .card {
        padding: 1.25rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .progress-steps {
        gap: 0;
    }

    .step span {
        font-size: 0.6rem;
    }

    .auth-card {
        padding: 2rem 1.5rem;
    }
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* === Focus styles === */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible {
    outline-offset: 2px;
}

/* === Transitions for app reveal === */
.app-wrap {
    animation: appReveal 0.4s ease;
}

@keyframes appReveal {
    from { opacity: 0; }
    to { opacity: 1; }
}
