:root,
html[data-theme="dark"] {
    --te-bg: #141218;
    --te-bg-soft: #1b1920;
    --te-surface: #211f26;
    --te-surface-2: #2b2930;
    --te-surface-3: #36343b;
    --te-primary: #d0bcff;
    --te-primary-strong: #b69df8;
    --te-on-primary: #381e72;
    --te-secondary: #ccc2dc;
    --te-text: #e6e0e9;
    --te-muted: #a8a2b0;
    --te-outline: #49454f;
    --te-success: #b5ccba;
    --te-error: #f2b8b5;
    --te-warning: #e7c36a;
    --te-radius: 22px;
    --te-radius-sm: 14px;
    --te-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    --te-glow: rgba(208, 188, 255, .18);
}

html[data-theme="light"] {
    --te-bg: #fef7ff;
    --te-bg-soft: #f7f2fa;
    --te-surface: #ffffff;
    --te-surface-2: #f3edf7;
    --te-surface-3: #ece6f0;
    --te-primary: #6750a4;
    --te-primary-strong: #55418f;
    --te-on-primary: #ffffff;
    --te-secondary: #625b71;
    --te-text: #1d1b20;
    --te-muted: #5f5a66;
    --te-outline: #cac4d0;
    --te-success: #386a4a;
    --te-error: #b3261e;
    --te-warning: #7a5900;
    --te-shadow: 0 24px 60px rgba(56, 30, 114, .12);
    --te-glow: rgba(103, 80, 164, .14);
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--te-bg);
    color: var(--te-text);
    font-family: "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-image:
        radial-gradient(1100px 600px at 8% -10%, var(--te-glow), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(239, 184, 200, .10), transparent 55%);
    background-attachment: fixed;
}

a {
    color: var(--te-primary);
    text-decoration: none;
}

::selection {
    background: var(--te-primary);
    color: var(--te-on-primary);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

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

/* ---------- Navigation progress ---------- */

#te-nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 3000;
    pointer-events: none;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, var(--te-primary), #efb8c8 55%, #a8c7fa);
    transition: transform .25s ease, opacity .2s ease;
}

#te-nav-progress.active {
    opacity: 1;
    transform: scaleX(.82);
    transition: transform 2s cubic-bezier(.1, .7, .2, 1), opacity .15s ease;
}

/* ---------- Shell ---------- */

.te-appbar {
    background: color-mix(in srgb, var(--te-bg) 82%, transparent) !important;
    backdrop-filter: blur(18px);
    border-bottom: 1px solid color-mix(in srgb, var(--te-outline) 45%, transparent);
    color: var(--te-text) !important;
}

.te-brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--te-text);
    margin-left: .25rem;
    white-space: nowrap;
}

.te-brand span {
    background: linear-gradient(100deg, var(--te-primary), #efb8c8 60%, #a8c7fa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.te-user {
    display: flex;
    align-items: center;
    gap: .55rem;
    border: 0;
    background: transparent;
    color: var(--te-text);
    padding: .25rem .4rem;
    border-radius: 999px;
    cursor: pointer;
}

.te-user:hover {
    background: var(--te-surface-2);
}

.te-user-name {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .9rem;
    font-weight: 500;
}

.te-logout-form {
    margin: 0;
}

.te-login-btn {
    margin-left: .5rem;
}

.te-drawer {
    background: color-mix(in srgb, var(--te-bg-soft) 92%, transparent) !important;
    border-right: 1px solid color-mix(in srgb, var(--te-outline) 40%, transparent) !important;
}

.te-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.te-drawer-footer {
    margin-top: auto;
    padding: 1.25rem 1.5rem;
    color: var(--te-muted);
    font-size: .8rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    border-top: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
}

.te-nav {
    padding-top: .75rem;
}

.te-nav .mud-nav-link {
    border-radius: 999px;
    margin: 2px 10px;
    padding: .55rem 1rem;
    color: var(--te-muted);
    font-weight: 500;
}

.te-nav .mud-nav-link:hover {
    background: var(--te-surface-2);
    color: var(--te-text);
}

.te-nav .mud-nav-link.active {
    background: color-mix(in srgb, var(--te-primary) 18%, transparent);
    color: var(--te-primary);
}

.te-nav-caption {
    color: var(--te-muted);
    letter-spacing: .14em;
    font-size: .68rem;
}

.te-main {
    background: transparent;
}

.te-page {
    padding: 2rem 1.5rem 4rem;
}

.te-main .mud-main-content {
    min-height: calc(100vh - 64px);
}

/* ---------- Typography & common ---------- */

.te-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.te-eyebrow {
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: .7rem;
    font-weight: 600;
    color: var(--te-primary);
    margin: 0 0 .4rem;
}

.te-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    line-height: 1.08;
    letter-spacing: -.03em;
    font-weight: 700;
    margin: 0;
}

.te-subtitle {
    color: var(--te-muted);
    font-size: 1.02rem;
    line-height: 1.6;
    max-width: 62ch;
    margin: .6rem 0 0;
}

.te-section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    letter-spacing: -.01em;
}

.te-muted {
    color: var(--te-muted);
}

.te-empty {
    padding: 2.5rem;
    border: 1px dashed var(--te-outline);
    border-radius: var(--te-radius);
    text-align: center;
    color: var(--te-muted);
    background: color-mix(in srgb, var(--te-surface) 55%, transparent);
}

/* ---------- Buttons ---------- */

.te-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .7rem 1.25rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

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

.te-btn-primary {
    background: var(--te-primary);
    color: var(--te-on-primary);
}

.te-btn-primary:hover {
    background: var(--te-primary-strong);
}

.te-btn-ghost {
    background: transparent;
    color: var(--te-text);
    border-color: var(--te-outline);
}

.te-btn-ghost:hover {
    background: var(--te-surface-2);
}

.mud-button-root {
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 600 !important;
}

.mud-card {
    border-radius: var(--te-radius) !important;
    background: var(--te-surface) !important;
}

.mud-paper {
    border-radius: var(--te-radius) !important;
}

.mud-input-control {
    border-radius: var(--te-radius-sm) !important;
}

/* ---------- Hero & cards ---------- */

.te-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(1.6rem, 4vw, 3rem);
    border-radius: calc(var(--te-radius) + 6px);
    border: 1px solid color-mix(in srgb, var(--te-outline) 50%, transparent);
    background:
        radial-gradient(700px 300px at 85% -20%, var(--te-glow), transparent 70%),
        linear-gradient(135deg, color-mix(in srgb, var(--te-surface) 94%, transparent), color-mix(in srgb, var(--te-bg-soft) 92%, transparent));
    box-shadow: var(--te-shadow);
    margin-bottom: 2rem;
}

.te-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 55%, rgba(208, 188, 255, .08));
    pointer-events: none;
}

.te-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(220px, .6fr);
    gap: 2rem;
    align-items: center;
}

.te-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

.te-stat {
    padding: 1rem;
    border-radius: var(--te-radius-sm);
    background: color-mix(in srgb, var(--te-surface-2) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
}

.te-stat strong {
    display: block;
    font-size: 1.5rem;
    line-height: 1.1;
    color: var(--te-primary);
}

.te-stat span {
    color: var(--te-muted);
    font-size: .78rem;
}

.te-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.25rem;
}

.te-course-card {
    display: flex;
    flex-direction: column;
    min-height: 240px;
    padding: 1.35rem;
    border-radius: var(--te-radius);
    background: var(--te-surface);
    border: 1px solid color-mix(in srgb, var(--te-outline) 40%, transparent);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
    color: var(--te-text);
}

.te-course-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--te-primary) 45%, transparent);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .18);
}

.te-course-cover {
    height: 120px;
    border-radius: var(--te-radius-sm);
    background:
        radial-gradient(240px 120px at 20% 0%, rgba(208, 188, 255, .40), transparent 70%),
        linear-gradient(135deg, #4f378b, #211f26 70%);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-end;
    padding: 1rem;
    color: #eadDFF;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.03em;
    overflow: hidden;
}

.te-course-cover img {
    width: calc(100% + 2rem);
    height: calc(100% + 2rem);
    margin: -1rem;
    object-fit: cover;
}

.te-course-card h3 {
    margin: 0 0 .4rem;
    font-size: 1.08rem;
    font-weight: 600;
    line-height: 1.3;
}

.te-course-card p {
    margin: 0;
    color: var(--te-muted);
    font-size: .88rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.te-course-meta {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: auto;
    padding-top: 1rem;
    color: var(--te-muted);
    font-size: .78rem;
}

.te-progress {
    height: 8px;
    border-radius: 999px;
    background: var(--te-surface-3);
    overflow: hidden;
}

.te-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--te-primary), #efb8c8);
}

.te-progress-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: .8rem;
}

.te-progress-row .te-progress {
    flex: 1;
}

.te-progress-label {
    font-size: .78rem;
    color: var(--te-muted);
    min-width: 3ch;
    text-align: right;
}

.te-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .7rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--te-primary) 16%, transparent);
    color: var(--te-primary);
}

.te-badge-success {
    background: color-mix(in srgb, var(--te-success) 16%, transparent);
    color: var(--te-success);
}

/* ---------- Course page ---------- */

.te-course-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 2rem;
    align-items: start;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border-radius: calc(var(--te-radius) + 4px);
    border: 1px solid color-mix(in srgb, var(--te-outline) 45%, transparent);
    background:
        radial-gradient(600px 260px at 100% 0%, var(--te-glow), transparent 65%),
        var(--te-surface);
    margin-bottom: 1.5rem;
}

.te-course-aside {
    padding: 1.15rem;
    border-radius: var(--te-radius-sm);
    background: color-mix(in srgb, var(--te-surface-2) 75%, transparent);
    border: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
}

.te-module {
    margin-bottom: 1.5rem;
}

.te-module-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .65rem;
}

.te-module-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.te-lesson {
    border-radius: var(--te-radius-sm);
    border: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
    background: color-mix(in srgb, var(--te-surface) 75%, transparent);
    overflow: hidden;
    margin-bottom: .6rem;
}

.te-lesson-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--te-outline) 25%, transparent);
    font-weight: 500;
    font-size: .92rem;
}

.te-step-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1rem;
    color: var(--te-text);
    border-top: 1px solid color-mix(in srgb, var(--te-outline) 18%, transparent);
}

.te-step-row:first-of-type {
    border-top: 0;
}

.te-step-row:hover {
    background: var(--te-surface-2);
}

.te-step-row.done {
    color: var(--te-muted);
}

.te-step-row .te-step-points {
    margin-left: auto;
    font-size: .75rem;
    color: var(--te-muted);
}

/* ---------- Learning page ---------- */

.te-learn-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.te-step-nav {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 110px);
    overflow: auto;
    padding: 1rem;
    border-radius: var(--te-radius);
    border: 1px solid color-mix(in srgb, var(--te-outline) 40%, transparent);
    background: color-mix(in srgb, var(--te-surface) 80%, transparent);
}

.te-step-nav h4 {
    margin: .9rem .4rem .4rem;
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--te-muted);
}

.te-step-link {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .5rem .6rem;
    border-radius: 10px;
    color: var(--te-muted);
    font-size: .84rem;
    line-height: 1.35;
}

.te-step-link:hover {
    background: var(--te-surface-2);
    color: var(--te-text);
}

.te-step-link.active {
    background: color-mix(in srgb, var(--te-primary) 16%, transparent);
    color: var(--te-primary);
}

.te-step-link.done {
    color: var(--te-success);
}

.te-step-link .kind {
    opacity: .75;
    font-size: .95rem;
}

.te-step-stage {
    min-width: 0;
}

.te-step-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    margin-bottom: .25rem;
}

.te-step-head h1 {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: -.02em;
    line-height: 1.15;
}

.te-step-paper {
    padding: clamp(1.2rem, 3vw, 2rem);
    border-radius: var(--te-radius);
    border: 1px solid color-mix(in srgb, var(--te-outline) 40%, transparent);
    background: var(--te-surface);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .08);
}

.te-step-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid color-mix(in srgb, var(--te-outline) 30%, transparent);
}

/* ---------- Markdown ---------- */

.markdown-body {
    color: var(--te-text);
    font-size: 1rem;
    line-height: 1.72;
    overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: var(--te-text);
    letter-spacing: -.02em;
    line-height: 1.2;
    margin: 1.6em 0 .55em;
}

.markdown-body h1 {
    font-size: 1.75rem;
}

.markdown-body h2 {
    font-size: 1.35rem;
}

.markdown-body h3 {
    font-size: 1.12rem;
}

.markdown-body p {
    margin: 0 0 1em;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.4rem;
    margin: 0 0 1em;
}

.markdown-body li {
    margin: .25em 0;
}

.markdown-body a {
    color: var(--te-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.markdown-body blockquote {
    margin: 1.2em 0;
    padding: .8rem 1rem;
    border-left: 3px solid var(--te-primary);
    background: color-mix(in srgb, var(--te-primary) 8%, transparent);
    border-radius: 0 12px 12px 0;
    color: var(--te-muted);
}

.markdown-body code {
    font-family: "Roboto Mono", Consolas, monospace;
    font-size: .88em;
    background: var(--te-surface-2);
    border: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
    border-radius: 6px;
    padding: .12em .38em;
}

.markdown-body pre {
    margin: 1.2em 0;
    padding: 1rem 1.1rem;
    border-radius: var(--te-radius-sm);
    background: #17151c;
    border: 1px solid var(--te-outline);
    overflow: auto;
    line-height: 1.55;
}

.markdown-body pre code {
    background: transparent;
    border: 0;
    padding: 0;
    font-size: .86rem;
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--te-radius-sm);
    border: 1px solid var(--te-outline);
    margin: .8rem 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    font-size: .9rem;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--te-outline);
    padding: .5rem .65rem;
    text-align: left;
}

.markdown-body th {
    background: var(--te-surface-2);
}

.markdown-body hr {
    border: 0;
    border-top: 1px solid var(--te-outline);
    margin: 2em 0;
}

.markdown-body input[type="checkbox"] {
    accent-color: var(--te-primary);
    margin-right: .4rem;
}

/* ---------- Quiz ---------- */

.te-quiz-options {
    display: grid;
    gap: .65rem;
    margin: 1.2rem 0;
}

.te-quiz-option {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1rem;
    border-radius: var(--te-radius-sm);
    border: 1px solid var(--te-outline);
    background: color-mix(in srgb, var(--te-surface-2) 45%, transparent);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    line-height: 1.5;
}

.te-quiz-option:hover {
    border-color: color-mix(in srgb, var(--te-primary) 50%, transparent);
}

.te-quiz-option.selected {
    border-color: var(--te-primary);
    background: color-mix(in srgb, var(--te-primary) 12%, transparent);
}

.te-quiz-option.correct {
    border-color: var(--te-success);
    background: color-mix(in srgb, var(--te-success) 14%, transparent);
}

.te-quiz-option.wrong {
    border-color: var(--te-error);
    background: color-mix(in srgb, var(--te-error) 12%, transparent);
}

.te-quiz-option input {
    margin-top: .25rem;
    accent-color: var(--te-primary);
}

.te-result {
    margin-top: 1.1rem;
    padding: .9rem 1rem;
    border-radius: var(--te-radius-sm);
    border: 1px solid var(--te-outline);
    background: var(--te-surface-2);
}

.te-result.ok {
    border-color: color-mix(in srgb, var(--te-success) 55%, transparent);
    background: color-mix(in srgb, var(--te-success) 10%, transparent);
}

.te-result.bad {
    border-color: color-mix(in srgb, var(--te-error) 55%, transparent);
    background: color-mix(in srgb, var(--te-error) 9%, transparent);
}

/* ---------- Code editor & tests ---------- */

.te-code-editor {
    position: relative;
    width: 100%;
    height: 380px;
    border-radius: var(--te-radius-sm);
    border: 1px solid var(--te-outline);
    overflow: hidden;
    background: #1d1b20;
    margin: 1rem 0;
}

.te-code-editor > .monaco-editor {
    position: absolute;
    inset: 0;
}

.te-code-fallback {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    resize: vertical;
    border: 0;
    outline: none;
    padding: 1rem;
    background: #1d1b20;
    color: #e6e0e9;
    font-family: "Roboto Mono", Consolas, monospace;
    font-size: .9rem;
    line-height: 1.5;
    tab-size: 4;
}

.te-test-grid {
    display: grid;
    gap: .75rem;
    margin-top: 1rem;
}

.te-test-card {
    padding: .85rem 1rem;
    border-radius: var(--te-radius-sm);
    border: 1px solid var(--te-outline);
    background: var(--te-surface-2);
}

.te-test-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .5rem;
    font-size: .85rem;
    font-weight: 600;
}

.te-test-io {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
}

.te-test-io label {
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--te-muted);
}

.te-test-io pre {
    margin: .25rem 0 0;
    padding: .55rem .65rem;
    border-radius: 8px;
    background: #17151c;
    color: #e6e0e9;
    font-family: "Roboto Mono", monospace;
    font-size: .78rem;
    white-space: pre-wrap;
    min-height: 2.2rem;
    max-height: 160px;
    overflow: auto;
}

html[data-theme="light"] .te-test-io pre {
    background: #f6f2fb;
    color: #1d1b20;
}

.te-dot {
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    display: inline-block;
    background: var(--te-muted);
}

.te-dot.ok {
    background: var(--te-success);
}

.te-dot.bad {
    background: var(--te-error);
}

.te-dot.wait {
    background: var(--te-warning);
    animation: te-pulse 1.1s infinite;
}

@keyframes te-pulse {
    50% {
        opacity: .35;
    }
}

/* ---------- Auth ---------- */

.auth-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    overflow: hidden;
    background:
        radial-gradient(700px 500px at 20% 0%, rgba(208, 188, 255, .18), transparent 65%),
        radial-gradient(700px 500px at 90% 100%, rgba(239, 184, 200, .14), transparent 65%),
        var(--te-bg);
}

.auth-glow {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(90px);
    background: var(--te-primary);
    opacity: .12;
    top: -120px;
    left: -80px;
    pointer-events: none;
}

.auth-card {
    position: relative;
    width: min(460px, 100%);
    padding: clamp(1.6rem, 5vw, 2.6rem);
    border-radius: 28px;
    border: 1px solid color-mix(in srgb, var(--te-outline) 55%, transparent);
    background: color-mix(in srgb, var(--te-surface) 92%, transparent);
    box-shadow: var(--te-shadow);
    backdrop-filter: blur(20px);
}

.auth-brand {
    display: inline-block;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.03em;
    color: var(--te-text);
    margin-bottom: .4rem;
}

.auth-brand span {
    background: linear-gradient(100deg, var(--te-primary), #efb8c8 60%, #a8c7fa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-tagline {
    margin: 0 0 1.6rem;
    color: var(--te-muted);
    font-size: .85rem;
    line-height: 1.5;
}

.auth-footer {
    position: absolute;
    bottom: 1.4rem;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--te-muted);
    font-size: .75rem;
    letter-spacing: .04em;
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-error {
    margin-bottom: 1rem;
    padding: .7rem .85rem;
    border-radius: 12px;
    background: color-mix(in srgb, var(--te-error) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--te-error) 45%, transparent);
    color: var(--te-error);
    font-size: .85rem;
}

.te-label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--te-muted);
    margin: .65rem 0 .35rem;
}

.te-input {
    width: 100%;
    box-sizing: border-box;
    padding: .8rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--te-outline);
    background: var(--te-surface-2);
    color: var(--te-text);
    font-size: .95rem;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.te-input:focus {
    border-color: var(--te-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--te-primary) 18%, transparent);
}

.validation-message {
    color: var(--te-error);
    font-size: .78rem;
    margin-top: .25rem;
}

.auth-check {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin: 1rem 0 1.3rem;
    color: var(--te-muted);
    font-size: .82rem;
    cursor: pointer;
}

.auth-check input {
    accent-color: var(--te-primary);
}

.auth-submit {
    width: 100%;
    padding: .85rem 1rem;
    font-size: .95rem;
}

.auth-hint {
    margin: 1.2rem 0 0;
    color: var(--te-muted);
    font-size: .78rem;
    line-height: 1.5;
    text-align: center;
}

.auth-title {
    margin: 0 0 .5rem;
    font-size: 1.6rem;
}

/* ---------- Admin ---------- */

.te-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.te-admin-tile {
    padding: 1.2rem;
    border-radius: var(--te-radius);
    border: 1px solid var(--te-outline);
    background: var(--te-surface);
    color: var(--te-text);
    transition: border-color .15s ease, transform .15s ease;
}

.te-admin-tile:hover {
    border-color: var(--te-primary);
    transform: translateY(-2px);
}

.te-admin-tile strong {
    display: block;
    font-size: 1.8rem;
    color: var(--te-primary);
    line-height: 1.1;
}

.te-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1rem;
}

.te-table-wrap {
    border-radius: var(--te-radius);
    border: 1px solid var(--te-outline);
    overflow: hidden;
    background: var(--te-surface);
}

.te-credential {
    font-family: "Roboto Mono", monospace;
    font-size: .95rem;
    padding: .5rem .7rem;
    border-radius: 10px;
    background: var(--te-surface-2);
    border: 1px dashed var(--te-outline);
}

.te-structure-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .6rem;
    border-radius: 12px;
    border: 1px solid transparent;
}

.te-structure-row:hover {
    border-color: var(--te-outline);
    background: var(--te-surface-2);
}

.te-structure-row .grow {
    flex: 1;
    min-width: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .te-hero-grid,
    .te-course-hero,
    .te-learn-layout {
        grid-template-columns: 1fr;
    }

    .te-step-nav {
        position: static;
        max-height: none;
    }

    .te-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .te-page {
        padding: 1.25rem .9rem 3rem;
    }

    .te-user-name {
        display: none;
    }

    .te-test-io {
        grid-template-columns: 1fr;
    }

    .te-course-hero {
        padding: 1.2rem;
    }

    .te-step-paper {
        padding: 1.1rem;
    }
}

/* ---------- Tables, hints, admin code ---------- */

.te-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}

.te-table th {
    text-align: left;
    padding: .7rem .85rem;
    color: var(--te-muted);
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    font-weight: 600;
    border-bottom: 1px solid var(--te-outline);
    white-space: nowrap;
}

.te-table td {
    padding: .75rem .85rem;
    border-bottom: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
    vertical-align: middle;
}

.te-table tbody tr:last-child td {
    border-bottom: 0;
}

.te-table tbody tr:hover {
    background: color-mix(in srgb, var(--te-surface-2) 65%, transparent);
}

.te-table a {
    color: var(--te-text);
    font-weight: 500;
}

.te-table a:hover {
    color: var(--te-primary);
}

.te-hints {
    margin: 1.5rem 0;
}

.te-hint {
    margin-bottom: .5rem;
    border: 1px solid var(--te-outline);
    border-radius: var(--te-radius-sm);
    background: color-mix(in srgb, var(--te-surface-2) 55%, transparent);
    padding: .55rem .8rem;
}

.te-hint summary {
    cursor: pointer;
    color: var(--te-primary);
    font-size: .85rem;
    font-weight: 500;
    list-style: none;
}

.te-hint summary::-webkit-details-marker {
    display: none;
}

.te-hint summary::before {
    content: "＋";
    display: inline-block;
    margin-right: .45rem;
    color: var(--te-muted);
}

.te-hint[open] summary::before {
    content: "−";
}

.te-hint .markdown-body {
    margin-top: .6rem;
    font-size: .9rem;
}

.te-code-block {
    margin: 0 0 1.5rem;
    padding: 1rem 1.15rem;
    border-radius: var(--te-radius-sm);
    border: 1px solid var(--te-outline);
    background: #17151c;
    color: #e6e0e9;
    font-family: "Roboto Mono", Consolas, monospace;
    font-size: .82rem;
    line-height: 1.55;
    overflow: auto;
    max-height: 520px;
    white-space: pre-wrap;
}

html[data-theme="light"] .te-code-block {
    background: #f6f2fb;
    color: #1d1b20;
}

.te-step-nav-lesson {
    margin: .9rem .45rem .25rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--te-text);
    opacity: .8;
}

.te-option-row {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.te-toolbar .mud-input-control {
    min-width: 220px;
}

.te-credential {
    display: inline-block;
}

.te-solution {
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px solid color-mix(in srgb, var(--te-outline) 35%, transparent);
}

.te-solution summary {
    cursor: pointer;
    color: var(--te-primary);
    font-size: .85rem;
    font-weight: 500;
}

.te-solution .te-code-block {
    margin-top: .8rem;
    max-height: 420px;
}

@media (max-width: 720px) {
    .te-table-wrap {
        overflow-x: auto;
    }

    .te-table {
        min-width: 640px;
    }
}
