/* ===== Design System Variables ===== */
:root {
    --cs-accent:       #ea580c;
    --cs-accent-dark:  #c2410c;
    --cs-accent-light: #fff7ed;
    --cs-dark:         #1e293b;
    --cs-darker:       #0f172a;
    --cs-surface:      #f8fafc;
    --cs-border:       #e2e8f0;
    --cs-text:         #0f172a;
    --cs-text-muted:   #64748b;
    --cs-radius:       12px;
    --cs-radius-sm:    8px;
    --cs-tab-height:   64px;
}

/* ===== Base ===== */

html, body {
    font-family: 'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--cs-text);
}

h1, h2, h3, h4 {
    font-family: 'Syne', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: var(--cs-accent);
}

.btn-primary {
    color: #fff;
    background-color: var(--cs-accent);
    border-color: var(--cs-accent-dark);
}

.btn-primary:hover,
.btn-primary:active {
    background-color: var(--cs-accent-dark);
    border-color: var(--cs-accent-dark);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--cs-accent);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    background: lightyellow;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    color-scheme: light only;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ===== Chat Components ===== */

.chat-window {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    word-wrap: break-word;
}

.user-message {
    align-self: flex-end;
    background-color: var(--cs-accent);
    color: #fff;
}

.assistant-message {
    align-self: flex-start;
    background-color: #f0f0f0;
    color: #333;
}

.message-role {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    opacity: 0.7;
}

.message-content {
    white-space: pre-wrap;
    line-height: 1.5;
}

.markdown-content {
    white-space: normal;
}

.markdown-content p {
    margin: 0 0 0.5rem;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.9em;
}

.markdown-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.85em;
}

.markdown-content ul, .markdown-content ol {
    margin: 0.25rem 0;
    padding-left: 1.5rem;
}

.markdown-content strong {
    font-weight: 600;
}

.markdown-content blockquote {
    border-left: 3px solid var(--cs-accent);
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    color: #555;
}

.typing-indicator {
    font-style: italic;
    opacity: 0.7;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--cs-border);
    background: #fff;
}

.chat-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--cs-border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--cs-accent);
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--cs-accent);
}

.chat-input button {
    align-self: flex-end;
}

/* ===== Session Page ===== */

.session-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.session-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.voice-mode-toggle.ms-auto {
    flex-basis: 100%;
    justify-content: flex-end;
}

.session-header h2 {
    margin: 0;
}

.phase-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.phase-badge.socratic {
    background-color: var(--cs-accent-light);
    color: var(--cs-accent-dark);
}

.phase-badge.quiz {
    background-color: #fff3cd;
    color: #856404;
}

.phase-badge.completed {
    background-color: #d4edda;
    color: #155724;
}

.grade-result {
    margin-bottom: 1rem;
}

/* ===== Track View ===== */

.track-view .topic-card {
    transition: box-shadow 0.15s;
}

.track-view .topic-card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.1);
}

.lock-icon {
    opacity: 0.5;
}

.track-view .topic-card.locked {
    background-color: #f8f9fa;
    color: #6c757d;
}

.track-view .topic-card.locked h5 {
    color: #6c757d;
}

.topic-number {
    font-weight: 600;
    color: var(--cs-accent);
    font-size: 0.95rem;
    min-width: 1.5rem;
}

/* ===== Grade Badges ===== */

.grade-badge { padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.badge-mastered   { background: #ffd700; color: #333; }
.badge-solid      { background: #28a745; color: white; }
.badge-developing { background: #ffc107; color: #333; }
.badge-needswork  { background: #dc3545; color: white; }
.badge-ungraded   { background: #6c757d; color: white; }

/* ===== Progress Bar ===== */

.progress-bar-container {
    background: var(--cs-border);
    border-radius: 8px;
    height: 8px;
    margin: 4px 0 2px;
    overflow: hidden;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--cs-accent), var(--cs-accent-dark));
    border-radius: 8px;
    height: 100%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--cs-text-muted);
    margin-top: 2px;
    display: block;
}

/* ===== Progression Mode Selector ===== */

.progression-mode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.progression-mode label {
    font-weight: 600;
    margin-bottom: 0;
}

.progression-mode select {
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid var(--cs-border);
    font-size: 0.9rem;
}

/* ===== Streak Banner ===== */

.streak-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--cs-dark);
    color: white;
    border-radius: var(--cs-radius);
    margin-bottom: 1.5rem;
}

.streak-flame {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 2rem;
}

.streak-flame.active .flame-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

.streak-flame.inactive {
    opacity: 0.5;
    filter: grayscale(1);
}

.streak-count {
    font-size: 2.5rem;
    font-weight: 800;
    font-family: 'Syne', sans-serif;
}

.streak-details {
    display: flex;
    flex-direction: column;
}

.streak-label {
    font-size: 1.1rem;
    font-weight: 600;
}

.streak-longest {
    font-size: 0.85rem;
    opacity: 0.7;
}

.streak-banner.milestone {
    background: linear-gradient(135deg, #ff6b35, #ffd700);
    animation: celebrate 0.5s ease-out;
}

.milestone-message {
    margin-left: auto;
    font-weight: 700;
    font-size: 1rem;
    animation: fadeInUp 0.5s ease-out;
}

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

@keyframes celebrate {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

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

/* ===== Dashboard ===== */

.dashboard { max-width: 800px; margin: 0 auto; }
.track-cards { display: grid; gap: 1rem; margin-bottom: 2rem; }
.track-card {
    padding: 1.5rem;
    background: white;
    border-radius: var(--cs-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--cs-border);
}
.track-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.recent-sessions { display: flex; flex-direction: column; gap: 0.5rem; }
.recent-session-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: var(--cs-radius-sm);
    cursor: pointer;
    border: 1px solid var(--cs-border);
    transition: background 0.15s;
}
.recent-session-item:hover { background: var(--cs-surface); }
.session-topic { flex: 1; font-weight: 500; }
.session-date { font-size: 0.85rem; color: var(--cs-text-muted); }

/* ===== Grade Card ===== */

.grade-card {
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    margin: 16px 0;
    animation: grade-reveal 0.4s ease-out;
}

@keyframes grade-reveal {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.grade-card-emoji    { font-size: 3rem; margin-bottom: 8px; }
.grade-card-name     { font-size: 2rem; font-weight: 700; font-family: 'Syne', sans-serif; margin-bottom: 4px; }
.grade-card-subtitle { font-size: 1rem; opacity: 0.85; margin-bottom: 16px; }
.grade-card-feedback { font-size: 0.9rem; text-align: left; margin-bottom: 16px; }

.grade-card-mastered   { background: #dcfce7; color: #166534; }
.grade-card-solid      { background: #dbeafe; color: #1e40af; }
.grade-card-developing { background: #fef9c3; color: #854d0e; }
.grade-card-needswork  { background: #fee2e2; color: #991b1b; }

/* ===== Voice Mode Toggle ===== */

.voice-mode-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.voice-mode-group-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cs-text-muted);
}

.voice-mode-toggle {
    display: flex;
    gap: 4px;
    align-items: center;
}

.voice-btn {
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--cs-border);
    background: white;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.voice-btn:hover  { background: var(--cs-surface); border-color: var(--cs-accent); }
.voice-btn.active { background: var(--cs-accent); color: white; border-color: var(--cs-accent); font-weight: 600; }

/* ===== Mic Button ===== */

.mic-btn {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
}

/* ===== Speaker Button ===== */

.speaker-btn {
    display: inline-block;
    margin-left: 8px;
    min-height: 44px;
    min-width: 44px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
    vertical-align: middle;
    border-radius: 4px;
    transition: opacity 0.15s;
}

.speaker-btn:hover { opacity: 1; background: rgba(0,0,0,0.06); }

/* ===== Recording Bar ===== */

.recording-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--cs-accent);
    border-radius: var(--cs-radius);
    color: white;
    animation: bar-slide-up 0.2s ease-out;
}

/* ===== Recording bar — processing state ===== */

.recording-bar-processing {
    background: var(--cs-dark);
    color: #fff;
}

.recording-bar-processing .recording-bar-transcript {
    animation: processing-pulse 1s ease-in-out infinite alternate;
}

@keyframes processing-pulse {
    from { opacity: 1; }
    to   { opacity: 0.4; }
}

@keyframes bar-slide-up {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

.recording-bar-transcript {
    flex: 1;
    font-size: 0.95rem;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.92;
}

.recording-bar-cancel {
    font-size: 1.4rem;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    min-height: 44px;
    padding: 10px 14px;
    line-height: 1;
    flex-shrink: 0;
}

.recording-bar-cancel:hover { opacity: 0.8; }

.recording-bar-send {
    background: white;
    color: var(--cs-accent);
    border: none;
    border-radius: var(--cs-radius-sm);
    min-height: 44px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.recording-bar-send:hover:not(:disabled) { background: var(--cs-accent-light); }

.recording-bar-send:disabled {
    opacity: 0.45;
    cursor: default;
}

.recording-wave { display: flex; align-items: center; gap: 3px; height: 20px; flex-shrink: 0; }
.recording-wave span {
    display: inline-block; width: 3px; border-radius: 2px;
    background: white; opacity: 0.85;
    animation: wave-bar 1.1s ease-in-out infinite;
}
.recording-wave span:nth-child(1) { animation-delay: 0s;    height: 60%; }
.recording-wave span:nth-child(2) { animation-delay: 0.15s; height: 100%; }
.recording-wave span:nth-child(3) { animation-delay: 0.3s;  height: 40%; }
.recording-wave span:nth-child(4) { animation-delay: 0.45s; height: 80%; }
.recording-wave span:nth-child(5) { animation-delay: 0.6s;  height: 55%; }
@keyframes wave-bar {
    0%, 100% { transform: scaleY(0.3); opacity: 0.5; }
    50%       { transform: scaleY(1);   opacity: 1; }
}

/* ===== Language Selection ===== */

.select-language-page {
    max-width: 480px;
    margin: 40px auto;
    padding: 24px 16px;
    text-align: center;
}
.select-language-header h1 { font-size: 2rem; font-weight: 800; }
.select-language-subtitle  { color: var(--cs-text-muted); margin-bottom: 32px; }

.language-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.language-card {
    border-radius: 16px;
    padding: 24px 16px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
}

.language-card-available {
    background: var(--cs-dark);
    color: white;
    border-color: var(--cs-accent);
}
.language-card-available:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(234,88,12,0.3);
}
.language-card-coming-soon { background: var(--cs-surface); color: #94a3b8; cursor: default; }
.language-card-icon   { font-size: 2.5rem; margin-bottom: 8px; }
.language-card-name   { font-size: 1.2rem; font-weight: 700; }
.language-card-tracks { font-size: 0.75rem; margin-top: 6px; opacity: 0.8; }
.language-card-badge  {
    display: inline-block;
    background: var(--cs-border);
    color: var(--cs-text-muted);
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.7rem;
    margin-top: 8px;
}
.language-toast {
    background: var(--cs-dark);
    color: white;
    border-radius: var(--cs-radius);
    padding: 10px 20px;
    display: inline-block;
    font-size: 0.9rem;
    margin-top: 16px;
}

/* ===== Bottom Tab Bar ===== */

.bottom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--cs-tab-height);
    display: flex;
    background: var(--cs-darker);
    border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 1000;
}

.tab-bar-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tab-bar-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #64748b;
    text-decoration: none;
    font-size: 0.65rem;
    padding: 8px 0 6px;
    width: 100%;
    justify-content: center;
    transition: color 0.15s;
    position: relative;
}

.tab-bar-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    width: 50%;
    height: 2px;
    border-radius: 0 0 4px 4px;
    background: var(--cs-accent);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.tab-bar-link.tab-active::before {
    transform: scaleX(1);
}

.tab-bar-icon {
    font-size: 1.3rem;
    transition: transform 0.15s;
}

.tab-bar-label { font-size: 0.65rem; }

.tab-bar-link.tab-active {
    color: var(--cs-accent);
}

.tab-bar-link.tab-active .tab-bar-icon {
    transform: translateY(-1px);
}

.tab-bar-link:hover {
    color: var(--cs-accent);
}

/* Prevent content from hiding behind the tab bar */
.page-with-tabs main {
    padding-bottom: calc(var(--cs-tab-height) + 16px);
}

.page-with-tabs {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Learn Page ===== */

.learn-page { padding: 16px; }
.learn-track-list { display: flex; flex-direction: column; gap: 16px; }
.learn-track-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    border: 2px solid var(--cs-border);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.learn-track-card:hover {
    border-color: var(--cs-accent);
    box-shadow: 0 4px 16px rgba(234,88,12,0.12);
    transform: translateY(-1px);
}
.learn-track-card h3 { margin-bottom: 6px; font-size: 1.1rem; }

/* ===== Dashboard — Language Badge, Nudge, Hero, Track Progress ===== */

.language-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--cs-accent-light);
    color: var(--cs-accent-dark);
    border: 1px solid #fed7aa;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 12px;
    transition: background 0.15s;
}
.language-badge:hover { background: #fde8d0; }

.daily-nudge {
    background: #fef3c7;
    color: #92400e;
    border-radius: var(--cs-radius-sm);
    padding: 10px 16px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.hero-cta {
    background: var(--cs-dark);
    color: white;
    border-radius: 16px;
    padding: 28px 24px;
    margin: 16px 0;
    text-align: center;
}
.hero-cta-label  { font-size: 0.7rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }
.hero-cta-topic  { font-size: 1.5rem; font-weight: 700; font-family: 'Syne', sans-serif; margin: 8px 0 4px; }
.hero-cta-track  { font-size: 0.85rem; margin-bottom: 20px; opacity: 0.7; }
.hero-cta-btn    { padding: 10px 32px; font-size: 1rem; }

.track-progress-rows  { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.track-progress-row   { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 12px; }
.track-progress-name  { font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-progress-link  { font-size: 0.82rem; white-space: nowrap; color: var(--cs-accent); }

/* ===== Profile Page ===== */

.profile-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.profile-stat-card {
    background: var(--cs-surface);
    border-radius: var(--cs-radius);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--cs-border);
}
.profile-stat-value { font-size: 2rem; font-weight: 700; color: var(--cs-accent); font-family: 'Syne', sans-serif; }
.profile-stat-label { font-size: 0.75rem; color: var(--cs-text-muted); margin-top: 4px; }

.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.achievement-card {
    background: var(--cs-surface);
    border-radius: var(--cs-radius);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--cs-border);
}
.achievement-card.unlocked { background: var(--cs-accent-light); border-color: #fed7aa; }
.achievement-emoji { font-size: 2rem; margin-bottom: 8px; }
.achievement-name { font-size: 0.85rem; font-weight: 600; }

.voice-mode-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.profile-section-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cs-text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--cs-border);
}

/* ===== Session Recap ===== */

.session-recap-page  { max-width: 640px; margin: 0 auto; padding: 16px; }
.recap-summary       { background: var(--cs-surface); border-radius: var(--cs-radius); padding: 16px; margin: 16px 0; font-size: 0.9rem; color: #475569; border: 1px solid var(--cs-border); }
.recap-nav-buttons   { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.btn-back-to-track   { padding: 10px 20px; border-radius: var(--cs-radius-sm); background: var(--cs-accent); color: white; border: none; cursor: pointer; font-size: 0.95rem; font-weight: 500; }
.btn-back-to-track:hover { background: var(--cs-accent-dark); }
.recap-score-list { list-style: none; padding: 0; margin: 16px 0; }
.recap-score-row  { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--cs-surface); }
.recap-score-correct { color: #16a34a; font-size: 1.2rem; flex-shrink: 0; }
.recap-score-wrong   { color: #dc2626; font-size: 1.2rem; flex-shrink: 0; }
.recap-score-note    { font-size: 0.85rem; color: #475569; }

/* ===== Rank Badge (Home page) ===== */

.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--cs-dark);
    color: white;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.rank-badge-emoji { font-size: 1.1rem; }
.rank-badge-name  { letter-spacing: 0.01em; }

/* ===== Rank Display (Profile page) ===== */

.rank-display {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 12px 0 20px;
}

.rank-display-emoji {
    font-size: 2.8rem;
    line-height: 1;
}

.rank-display-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rank-display-name {
    font-family: 'Syne', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--cs-text);
}

.rank-progress {
    height: 6px;
    background: var(--cs-border);
    border-radius: 99px;
    overflow: hidden;
    width: 160px;
}

.rank-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--cs-accent), #f97316);
    border-radius: 99px;
    transition: width 0.4s ease;
}

.rank-progress-label {
    font-size: 0.75rem;
    color: var(--cs-text-muted);
}

/* ===== Dark Mode (system-aware) ===== */

@media (prefers-color-scheme: dark) {
    :root {
        --cs-surface: #1e293b;
        --cs-border:  #334155;
        --cs-text:    #f1f5f9;
        --cs-text-muted: #94a3b8;
        --cs-accent-light: #431407;
    }

    body {
        color: var(--cs-text);
    }

    /* Chat */
    .chat-window { background: #0f172a; }
    .chat-input  { background: #1e293b; border-color: var(--cs-border); }
    .chat-input textarea {
        background: #0f172a;
        color: var(--cs-text);
        border-color: var(--cs-border);
    }
    .chat-message.assistant-message .message-content { background: #1e293b; }

    /* Cards and surfaces */
    .profile-stat-card,
    .achievement-card,
    .track-progress-row,
    .recent-session-item { background: #1e293b; color: var(--cs-text); }

    .profile-stat-card .profile-stat-label,
    .profile-stat-card .profile-stat-value { color: var(--cs-text); }

    /* Inputs */
    input, select, textarea {
        background: #1e293b;
        color: var(--cs-text);
        border-color: var(--cs-border);
    }

    /* Modals and overlays */
    .modal-content { background: #1e293b; }

    /* Phase badge */
    .phase-badge { background: var(--cs-border); color: var(--cs-text); }
}
