:root {
    color-scheme: light;
    --bg: #f7fbff;
    --surface: #ffffff;
    --surface-strong: #eff8ff;
    --text: #102844;
    --muted: #607089;
    --line: #d8e5f4;
    --accent: #217bea;
    --accent-dark: #0758c8;
    --brand-blue: #217bea;
    --brand-blue-dark: #0758c8;
    --brand-green: #56b91a;
    --brand-orange: #ffb508;
    --brand-purple: #8b4fd4;
    --brand-pink: #ff3c6d;
    --brand-cyan: #14b8e6;
    --navy: #07366d;
    --mint: #56b91a;
    --sun: #ffb508;
    --shadow: 0 18px 42px rgba(7, 54, 109, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(33, 123, 234, 0.07), rgba(255, 181, 8, 0.06) 46%, rgba(123, 209, 32, 0.07)),
        var(--bg);
    color: var(--text);
    font-family: Nunito, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
.button {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark));
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 700;
    padding: 0 16px;
    box-shadow: 0 10px 24px rgba(33, 123, 234, 0.18);
}

.button.secondary {
    background: #eef8e9;
    color: #255c0e;
    box-shadow: none;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

.button.secondary:hover {
    background: #e2f3d9;
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px clamp(16px, 4vw, 48px);
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(90deg, var(--brand-blue), var(--brand-green), var(--brand-orange), var(--brand-pink), var(--brand-purple), var(--brand-cyan)) top left / 100% 4px no-repeat,
        rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.brand,
.topnav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topnav {
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 10px 0;
}

.brand {
    flex: 0 0 auto;
}

.brand-logo {
    display: block;
    width: clamp(128px, 16vw, 176px);
    max-height: 58px;
    object-fit: contain;
}

.topnav form {
    margin: 0;
}

.language-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
}

.language-form {
    display: inline-flex;
}

.language-option {
    min-height: 34px;
    border-radius: 999px;
    background: transparent;
    color: var(--navy);
    gap: 6px;
    padding: 0 9px;
    box-shadow: none;
    font-size: 0.86rem;
    font-weight: 900;
}

.language-option:hover {
    background: #eef6ff;
    color: var(--brand-blue-dark);
}

.language-option.is-active {
    background: #fff2c8;
    color: #6b4300;
}

.language-flag {
    width: 22px;
    height: 16px;
    border-radius: 3px;
    display: inline-flex;
    flex: 0 0 auto;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(7, 54, 109, 0.12);
}

.language-flag img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.language-code {
    font-size: 0.72rem;
    line-height: 1;
}

.topnav > a {
    min-height: 38px;
    border-radius: 8px;
    color: var(--navy);
    display: inline-flex;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 800;
    padding: 0 10px;
}

.topnav > a:hover {
    background: #eef6ff;
    color: var(--brand-blue-dark);
}

.sr-only {
    width: 1px;
    height: 1px;
    position: absolute;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.page {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 36px 0 56px;
}

.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.message {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px 14px;
}

.message.success {
    border-color: #c9efb2;
    background: #f0ffe8;
    color: #255c0e;
}

.message.warning {
    border-color: #ffe19a;
    background: #fff8df;
    color: #7a4d00;
}

.dashboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.dashboard-head h1 {
    margin: 4px 0 0;
    font-size: clamp(2rem, 6vw, 4rem);
    line-height: 1;
    color: var(--navy);
}

.eyebrow {
    margin: 0;
    color: var(--brand-blue-dark);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.avatar {
    width: 92px;
    height: 92px;
    border-radius: 28px;
    background: var(--avatar-color, var(--accent));
    color: #fff;
    display: grid;
    flex: 0 0 auto;
    font-size: 2.25rem;
    font-weight: 900;
    place-items: center;
    box-shadow: 0 16px 34px rgba(33, 123, 234, 0.18);
}

.avatar.small {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    font-size: 1rem;
}

.grid {
    display: grid;
    gap: 18px;
}

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

.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.panel,
.auth-panel,
.article-card,
.quiz-card,
.question-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand-blue);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.quiz-card:nth-child(4n + 1),
.article-card:nth-child(4n + 1),
.panel:nth-child(4n + 1) {
    border-top-color: var(--brand-blue);
}

.quiz-card:nth-child(4n + 2),
.article-card:nth-child(4n + 2),
.panel:nth-child(4n + 2) {
    border-top-color: var(--brand-green);
}

.quiz-card:nth-child(4n + 3),
.article-card:nth-child(4n + 3),
.panel:nth-child(4n + 3) {
    border-top-color: var(--brand-orange);
}

.quiz-card:nth-child(4n + 4),
.article-card:nth-child(4n + 4),
.panel:nth-child(4n + 4) {
    border-top-color: var(--brand-purple);
}

.panel {
    min-height: 320px;
    padding: 22px;
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 1.05rem;
}

.page-panel p {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.65;
    margin: 0 0 18px;
    max-width: 720px;
}

.quiz-card {
    min-height: 260px;
    padding: 22px;
    display: grid;
    gap: 18px;
    align-content: space-between;
}

.quiz-card h2 {
    margin: 6px 0 10px;
    font-size: 1.25rem;
    color: var(--navy);
}

.quiz-card p {
    color: var(--muted);
    margin: 0;
}

.article-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.article-card {
    min-height: 240px;
    padding: 22px;
    display: grid;
    gap: 18px;
    align-content: space-between;
}

.article-card h2 {
    color: var(--navy);
    font-size: 1.3rem;
    margin: 6px 0 10px;
}

.article-card p {
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}

.article-detail {
    max-width: 820px;
}

.article-detail header {
    margin: 24px 0 26px;
}

.article-detail h1 {
    color: var(--navy);
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.05;
    margin: 8px 0 14px;
}

.article-detail header p {
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.65;
    margin: 0;
}

.article-body {
    border-top: 1px solid var(--line);
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.85;
    padding-top: 26px;
}

.article-body p {
    margin: 0 0 18px;
}

.article-body a {
    color: var(--brand-blue-dark);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.quiz-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quiz-meta span,
.stats div {
    border-radius: 8px;
    background: linear-gradient(135deg, #eef7ff, #f5ffef);
    padding: 8px 10px;
}

.lesson-attachments {
    display: grid;
    gap: 8px;
}

.lesson-attachments p {
    color: var(--navy);
    font-size: 0.9rem;
    font-weight: 900;
    margin: 0;
}

.lesson-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 10px;
}

.lesson-attachment:hover {
    border-color: var(--brand-blue);
    background: #f4f9ff;
}

.lesson-attachment strong,
.lesson-attachment small {
    display: block;
}

.lesson-attachment small {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.attachment-extension {
    min-width: 44px;
    border-radius: 8px;
    background: #fff2c8;
    color: #6b4300;
    font-size: 0.72rem;
    font-weight: 900;
    padding: 7px 8px;
    text-align: center;
}

.stats {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.stats div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.stats dt,
.stats dd {
    margin: 0;
}

.stats dt {
    color: var(--muted);
}

.stats dd {
    font-weight: 800;
}

.item-list,
.profile-grid {
    display: grid;
    gap: 12px;
}

.list-item,
.profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 64px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #f8fbff);
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

a.list-item:hover,
.profile-card:hover {
    border-color: rgba(33, 123, 234, 0.35);
    box-shadow: 0 12px 28px rgba(7, 54, 109, 0.08);
    transform: translateY(-1px);
}

.profile-card {
    justify-content: flex-start;
}

.list-item strong,
.profile-card strong {
    display: block;
}

.list-item span,
.profile-card span,
.list-item time {
    color: var(--muted);
    font-size: 0.9rem;
}

.score {
    min-width: 44px;
    text-align: right;
    font-weight: 800;
    color: var(--brand-green);
}

.empty {
    margin: 0;
    color: var(--muted);
}

.text-link {
    display: inline-flex;
    margin-top: 16px;
    color: var(--accent);
    font-weight: 800;
}

.text-link:hover {
    color: var(--brand-purple);
}

.quiz-form {
    display: grid;
    gap: 18px;
}

.question-panel {
    padding: 22px;
}

.question-title,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.question-title {
    color: var(--brand-blue-dark);
    font-size: 0.9rem;
    font-weight: 800;
}

.question-panel h2 {
    margin: 12px 0 18px;
    font-size: 1.2rem;
}

.code-card {
    margin: 0 0 18px;
    overflow: hidden;
    border: 1px solid #eceff4;
    border-radius: 20px;
    background: #f4f4f5;
    box-shadow: none;
}

.code-card figcaption {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 20px;
    color: #05070d;
    font-size: 0.95rem;
    font-weight: 900;
}

.code-card figcaption span {
    color: #05070d;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.8rem;
}

.code-card pre {
    margin: 0;
    padding: 2px 20px 18px;
    overflow-x: auto;
}

.code-card code {
    color: #111827;
    font-family: Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.75;
    tab-size: 4;
    white-space: pre;
}

.code-token.identifier {
    color: #4b32c3;
}

.code-token.operator {
    color: #e85d04;
}

.code-token.number {
    color: #d9480f;
}

.code-token.string {
    color: #168a43;
}

.code-token.keyword {
    color: #d6336c;
}

.code-token.builtin {
    color: #5b2ed6;
}

.answer-field ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.answer-field li label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
    padding: 12px;
    transition: border-color 160ms ease, background 160ms ease;
}

.answer-field li label:hover {
    border-color: rgba(86, 185, 26, 0.45);
    background: #f8fff3;
}

.answer-field input[type="radio"],
.answer-field input[type="checkbox"] {
    margin-top: 4px;
}

.answer-field textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    padding: 12px;
    resize: vertical;
}

.answer-field textarea:focus,
.auth-panel input:focus,
.language-option:focus-visible {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(33, 123, 234, 0.14);
    outline: none;
}

.errorlist {
    color: #a2281d;
    margin: 0 0 10px;
}

.result-score {
    min-width: 120px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-orange), #f49300);
    color: #3d2a00;
    font-size: 1.6rem;
    font-weight: 900;
    padding: 16px;
    text-align: center;
}

.answer-review {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #f8fbff);
    padding: 12px;
}

.answer-review span {
    color: var(--muted);
}

.answer-review em {
    justify-self: start;
    border-radius: 999px;
    background: #eef6ff;
    color: var(--text);
    font-style: normal;
    font-weight: 800;
    padding: 5px 9px;
}

.answer-review em.correct {
    background: #ecffe4;
    color: #255c0e;
}

.answer-review em.incorrect {
    background: #fff0f4;
    color: #ad1740;
}

.auth-shell {
    min-height: calc(100vh - 164px);
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 28px;
}

.auth-panel h1 {
    margin: 0 0 24px;
    font-size: 2rem;
    color: var(--navy);
}

.auth-intro,
.auth-switch {
    color: var(--muted);
    line-height: 1.55;
    margin: -12px 0 22px;
}

.auth-switch {
    margin: 16px 0 0;
    text-align: center;
}

.auth-switch a {
    color: var(--brand-blue-dark);
    font-weight: 800;
}

.auth-panel label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.auth-panel label span {
    color: var(--muted);
    font-weight: 700;
}

.auth-panel small,
.auth-panel .helptext {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.auth-panel input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    padding: 8px 12px;
}

.auth-panel button {
    width: 100%;
}

.form-error {
    border-radius: 8px;
    background: #fff0f4;
    color: #ad1740;
    padding: 12px;
}

@media (max-width: 980px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topnav {
        justify-content: flex-start;
        width: 100%;
    }
}

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

    .dashboard-head {
        align-items: flex-start;
    }

    .avatar {
        width: 68px;
        height: 68px;
        border-radius: 16px;
        font-size: 1.5rem;
    }

    .brand-logo {
        width: 138px;
        max-height: 50px;
    }

    .topnav {
        gap: 8px;
    }

    .topnav > a,
    .language-option,
    button,
    .button {
        min-height: 36px;
    }
}
