:root {
    color-scheme: dark;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-muted: #1a2436;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #34d399;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at top left, #1f2a44, var(--bg));
    color: var(--text);
    min-height: 100vh;
}

main {
    display: block;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(56, 189, 248, 0.25);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.brand-logo {
    width: 40px;
    height: 40px;
}

.site-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 0.5rem;
    color: var(--text);
    padding: 0.5rem;
}

.menu-bars,
.menu-bars::before,
.menu-bars::after {
    display: block;
    background: currentColor;
    height: 2px;
    width: 20px;
    position: relative;
    transition: transform 0.2s ease;
}

.menu-bars::before,
.menu-bars::after {
    content: '';
    position: absolute;
    left: 0;
}

.menu-bars::before {
    top: -6px;
}

.menu-bars::after {
    top: 6px;
}

.site-nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover,
.nav-link:focus {
    color: var(--text);
    background: rgba(56, 189, 248, 0.15);
}

.nav-link.active {
    color: var(--text);
    background: rgba(56, 189, 248, 0.3);
}

.page-content {
    padding: 2rem clamp(1rem, 4vw, 5rem);
    max-width: 960px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.page-heading {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 1rem;
}

.lead {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin: 0 auto 2rem;
    max-width: 48ch;
}

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

.primary-cta,
.secondary-cta {
    text-decoration: none;
    padding: 0.9rem 1.6rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-cta {
    background: linear-gradient(135deg, var(--accent-strong), #6366f1);
    color: white;
    box-shadow: 0 12px 24px rgba(14, 165, 233, 0.2);
}

.secondary-cta {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text);
}

.primary-cta:hover,
.secondary-cta:hover {
    transform: translateY(-2px);
}

.feature-grid {
    display: grid;
    gap: 1.5rem;
    margin: 3rem 0;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.feature {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
}

.details ul {
    list-style: disc;
    padding-left: 1.5rem;
    color: var(--text-muted);
}

.practice {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

.instruction {
    max-width: 56ch;
    color: var(--text-muted);
}

.start-button {
    width: min(90%, 420px);
    font-size: 1.4rem;
    padding: 1.2rem;
    border-radius: 1rem;
    border: none;
    background: linear-gradient(135deg, var(--accent-strong), #6366f1);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.start-button:hover,
.start-button:focus {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(14, 165, 233, 0.25);
}

.countdown {
    display: flex;
    justify-content: center;
    width: 100%;
}

.countdown-circle {
    width: min(280px, 70vw);
    height: min(280px, 70vw);
    border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--progress, 0) * 360deg), rgba(15, 23, 42, 0.6) 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 6px solid rgba(148, 163, 184, 0.2);
    position: relative;
    transition: background 0.15s linear;
}

.countdown-circle::after {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: var(--surface);
}

.countdown-label {
    position: relative;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
}

.countdown-circle.recording::after {
    background: rgba(15, 23, 42, 0.8);
}

.recording-dot {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    background: var(--danger);
    border-radius: 999px;
    margin-right: 0.5rem;
    animation: pulse 1s ease-in-out infinite;
}

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

.stop-button {
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    cursor: pointer;
}

.status-message {
    min-height: 1.5rem;
    color: var(--text-muted);
}

.status-message.error {
    color: var(--danger);
}

.hidden {
    display: none !important;
}

.text-page {
    background: rgba(15, 23, 42, 0.7);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35);
    line-height: 1.6;
}

.text-page a {
    color: var(--accent);
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 1rem;
    overflow: hidden;
}

table th,
table td {
    padding: 0.9rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

table th {
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(15, 23, 42, 0.9);
}

.audio-feedback {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.audio-column {
    flex: 1 1 200px;
    display: flex;
    justify-content: center;
}

.audio-button {
    border: 1px solid rgba(56, 189, 248, 0.6);
    background: rgba(56, 189, 248, 0.12);
    color: var(--text);
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: lowercase;
    cursor: pointer;
    text-align: center;
}

.audio-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.score-summary {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35);
}

.score-value {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent-strong), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}

.score-description {
    font-size: 1.05rem;
    margin-bottom: 0.3rem;
}

.score-meta {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.transcript {
    margin-top: 2rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.15);
}

.transcript-text {
    line-height: 2;
    font-size: 1.05rem;
}

.word {
    display: inline-block;
    margin: 0.1rem 0.3rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.5rem;
    background: rgba(148, 163, 184, 0.1);
}

.word.low-confidence {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

.back-links {
    margin-top: 2.5rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.back-links a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

@media (max-width: 900px) {
    .site-nav {
        position: absolute;
        top: 70px;
        right: 1.5rem;
        flex-direction: column;
        background: rgba(15, 23, 42, 0.95);
        padding: 1rem;
        border-radius: 0.75rem;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(56, 189, 248, 0.25);
        display: none;
    }

    .site-nav.open {
        display: flex;
    }

    .menu-toggle {
        display: inline-flex;
    }
}

@media (max-width: 600px) {
    .score-summary {
        flex-direction: column;
    }

    .audio-feedback {
        flex-direction: column;
    }
}
