:root {
    color-scheme: light;
    --bg: #f7fbff;
    --surface: #ffffff;
    --surface-soft: #eef8ff;
    --surface-warm: #fff6dc;
    --text: #172033;
    --muted: #667085;
    --brand: #087e8b;
    --brand-strong: #075f69;
    --accent: #ff6b5f;
    --accent-2: #f7b731;
    --ink-blue: #2f62d6;
    --border: #dce7ef;
    --danger: #c0392b;
    --success: #23885b;
    --shadow: 0 16px 40px rgba(22, 45, 75, 0.10);
    --font-sans: "Segoe UI", "Be Vietnam Pro", "Noto Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 88px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    background:
        linear-gradient(180deg, #eaf8ff 0, rgba(247, 251, 255, 0) 360px),
        var(--bg);
    color: var(--text);
}

a {
    color: var(--brand);
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(30px, 4vw, 52px);
    line-height: 1.04;
}

h2 {
    margin: 0 0 14px;
    font-size: 22px;
    line-height: 1.2;
}

h3 {
    margin: 0 0 8px;
    font-size: 17px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 70px;
    padding: 0 max(18px, calc((100vw - 1180px) / 2));
    border-bottom: 1px solid rgba(220, 231, 239, 0.8);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--brand);
    color: #ffffff;
    font-size: 13px;
    letter-spacing: 0;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav a,
.link-button {
    min-height: 36px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.nav a:hover,
.link-button:hover {
    background: var(--surface-soft);
    color: var(--brand);
}

.app-main {
    width: min(1120px, calc(100% - 28px));
    margin: 22px auto 58px;
}

.page-heading,
.learning-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 22px;
}

.page-heading {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.page-heading.compact {
    margin-bottom: 18px;
    padding: 0;
    border: 0;
    box-shadow: none;
}

.learning-hero {
    min-height: 310px;
    padding: 28px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.learning-hero > div {
    position: relative;
    z-index: 1;
    max-width: 540px;
}

.learning-hero img {
    width: min(48%, 520px);
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
}

.compact-hero {
    min-height: 240px;
}

.compact-hero h1 {
    font-size: clamp(30px, 3.5vw, 44px);
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.lead {
    max-width: 700px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.6;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

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

.button.primary {
    background: var(--brand);
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(8, 126, 139, 0.18);
}

.button.primary:hover {
    background: var(--brand-strong);
}

.button.secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

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

.message {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(22, 45, 75, 0.08);
}

.message.success {
    border-color: #9bd7bd;
    color: var(--success);
}

.message.error {
    border-color: #e7aaa3;
    color: var(--danger);
}

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

.auth-panel,
.narrow-panel {
    width: min(560px, 100%);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.narrow-panel {
    margin: 0 auto;
}

.form-stack {
    display: grid;
    gap: 14px;
}

.form-stack label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 800;
}

input,
textarea,
select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: 3px solid rgba(8, 126, 139, 0.16);
    border-color: var(--brand);
}

textarea {
    min-height: 120px;
}

.errorlist {
    margin: 4px 0 0;
    padding-left: 18px;
    color: var(--danger);
    font-weight: 400;
}

.muted,
.empty-state {
    color: var(--muted);
}

.metric-grid,
.course-grid,
.card-grid,
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric,
.function-card,
.course-card,
.activity-panel,
.lesson-row,
.lesson-content article,
.vocab-card,
.exercise-card,
.dashboard-focus article {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(22, 45, 75, 0.06);
}

.metric {
    display: grid;
    gap: 9px;
    min-height: 118px;
    padding: 18px;
}

.metric span {
    color: var(--muted);
    font-weight: 800;
}

.metric strong {
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.05;
}

.metric:nth-child(1) {
    background: #eaf9f8;
}

.metric:nth-child(2) {
    background: #fff6dc;
}

.metric:nth-child(3) {
    background: #eef3ff;
}

.metric:nth-child(4) {
    background: #fff0ef;
}

.metric-date {
    font-size: 18px;
}

.course-dashboard {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 22px;
}

.dashboard-focus,
.profile-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.dashboard-focus article {
    padding: 20px;
}

.dashboard-focus h2 {
    margin-bottom: 8px;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 18px;
    margin-top: 26px;
}

.function-card,
.course-card {
    display: grid;
    gap: 14px;
    align-content: space-between;
    min-height: 230px;
    padding: 18px;
}

.function-card p,
.course-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.course-milestone {
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

.course-card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
}

.activity-panel {
    padding: 18px;
}

.activity-row {
    display: grid;
    gap: 4px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.activity-row span,
.activity-row time {
    color: var(--muted);
    font-size: 14px;
}

.pill,
.status-done,
.completion-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--brand);
    font-size: 13px;
    font-weight: 800;
}

.completion-badge {
    min-width: 76px;
    min-height: 76px;
    border-radius: 8px;
    font-size: 21px;
    background: var(--accent-2);
    color: var(--text);
}

.progress-line,
.lesson-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.progress-line span,
.lesson-row p,
.lesson-order {
    color: var(--muted);
}

.lesson-list {
    display: grid;
    gap: 12px;
}

.lesson-row {
    padding: 16px;
}

.lesson-row h2 {
    margin: 4px 0;
    font-size: 18px;
}

.lesson-meta {
    margin: 4px 0 0;
    font-size: 14px;
}

.status-not_started .status-done {
    color: var(--muted);
}

.status-in_progress .status-done {
    background: #fff6dc;
    color: #98640c;
}

.status-completed .status-done {
    background: #e6f7ef;
    color: var(--success);
}

.lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
    gap: 18px;
    align-items: start;
}

.lesson-content,
.exercise-section {
    display: grid;
    gap: 14px;
}

.lesson-content article,
.exercise-card {
    padding: 18px;
}

.lesson-content p,
.exercise-card p {
    line-height: 1.62;
}

.vocab-section {
    margin-top: 22px;
}

.vocab-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.vocab-card {
    min-height: 145px;
    padding: 16px;
}

.vocab-card span,
.vocab-card small {
    color: var(--muted);
}

.exercise-section {
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 108px);
    overflow: auto;
    padding-right: 3px;
}

.exercise-card {
    scroll-margin-top: 96px;
}

.exercise-card:target {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 4px rgba(247, 183, 49, 0.22), var(--shadow);
}

.answer-form {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.choice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.choice:hover {
    border-color: var(--brand);
    background: var(--surface-soft);
}

.choice input {
    width: auto;
    min-height: auto;
}

.check-row {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: auto;
    min-height: auto;
}

@media (max-width: 980px) {
    .learning-hero {
        min-height: auto;
        align-items: stretch;
        flex-direction: column;
    }

    .learning-hero > div {
        max-width: none;
    }

    .learning-hero img {
        width: 100%;
        max-height: 280px;
    }

    .split-layout,
    .dashboard-focus,
    .profile-layout,
    .lesson-layout {
        grid-template-columns: 1fr;
    }

    .exercise-section {
        position: static;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }
}

@media (max-width: 680px) {
    .app-header,
    .page-heading,
    .lesson-row {
        align-items: stretch;
        flex-direction: column;
    }

    .app-header {
        min-height: auto;
        padding: 12px 14px;
    }

    .brand {
        width: 100%;
    }

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

    .app-main {
        width: min(100% - 20px, 1120px);
        margin-top: 14px;
    }

    .learning-hero,
    .page-heading,
    .auth-panel,
    .narrow-panel {
        padding: 16px;
    }

    .learning-hero img {
        aspect-ratio: 4 / 3;
    }

    .hero-actions,
    .button {
        width: 100%;
    }
}
