:root {
    --teal: #0e8b88;
    --teal-dark: #075f5c;
    --teal-soft: #e3f7f5;
    --lime: #c7e51b;
    --lime-soft: #f3facb;
    --pink: #e6007e;
    --pink-soft: #fde6f2;
    --blue-soft: #e7f1fb;
    --ink: #20303b;
    --muted: #5d6b75;
    --line: #d6e2e4;
    --paper: #f4fbfa;
    --white: #fff;
    --ok: #1b7f4b;
    --ok-soft: #e4f6eb;
    --bad: #b33a36;
    --bad-soft: #fbe9e8;
    --shadow: 0 18px 45px rgba(6, 72, 71, .16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    padding: 16px;
    color: var(--ink);
    background: linear-gradient(135deg, #20c9c5 0%, #0e8b88 100%);
    font: 1rem/1.65 "Segoe UI", Arial, sans-serif;
}
button, textarea, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 999;
    transform: translateY(-150%);
    padding: .65rem 1rem;
    border-radius: 10px;
    background: var(--white);
    color: var(--teal-dark);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
    max-width: 1120px;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 auto;
    padding: .8rem clamp(1rem, 4vw, 2.5rem);
    color: var(--white);
    background: linear-gradient(100deg, #075f5c, #0e8b88);
    border-radius: 24px 24px 0 0;
}
.brand { display: inline-flex; align-items: center; gap: .8rem; text-decoration: none; }
.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 2px solid var(--lime);
    border-radius: 50%;
    color: var(--lime);
    font-weight: 900;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: .98rem; }
.brand small { color: #d7f3f0; font-size: .78rem; }
.top-actions { display: flex; gap: .5rem; }
.icon-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .75rem;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 10px;
    background: transparent;
    color: var(--white);
    cursor: pointer;
}
.icon-button:hover, .icon-button:focus-visible { background: rgba(255,255,255,.13); }

.course-shell {
    max-width: 1120px;
    min-height: 760px;
    display: block;
    margin: 0 auto;
    overflow: hidden;
    background: var(--white);
    border-radius: 0 0 24px 24px;
    box-shadow: var(--shadow);
}
.course-sidebar {
    padding: 1.2rem clamp(1rem, 4vw, 2.5rem) 1rem;
    color: var(--ink);
    background: var(--white);
    border-bottom: 1px solid var(--line);
}
.sidebar-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1.2rem; }
.kicker {
    margin: 0;
    color: var(--pink);
    font-size: .75rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.progress-copy { display: flex; justify-content: flex-end; align-items: baseline; gap: .6rem; }
.progress-copy strong { color: var(--teal-dark); font-size: 1.45rem; }
.progress-copy span { color: var(--muted); font-size: .82rem; }
.progress-track { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 999px; background: #e7eeee; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--lime); transition: width .2s ease; }
.mission-nav {
    display: flex;
    gap: .55rem;
    margin-top: 1rem;
    padding-bottom: .2rem;
    overflow-x: auto;
    scrollbar-width: thin;
}
.nav-section { display: none; }
.mission-link {
    min-width: 164px;
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    gap: .55rem;
    padding: .62rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    text-align: left;
    cursor: pointer;
}
.mission-link:hover { border-color: var(--teal); }
.mission-link.active { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.mission-link.done .nav-number { background: var(--ok); color: white; }
.nav-number {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--teal-dark);
    color: var(--lime);
    font-size: .72rem;
    font-weight: 900;
}
.nav-title { font-size: .79rem; font-weight: 750; line-height: 1.25; }
.sidebar-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .85rem; }
.teacher-toggle, .reset-button {
    min-height: 40px;
    padding: .45rem .75rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: white;
    cursor: pointer;
}
.teacher-toggle { color: var(--teal-dark); font-weight: 800; }
.teacher-toggle[aria-pressed="true"] { background: var(--teal-dark); color: white; }
.reset-button { color: var(--muted); font-size: .8rem; }

.course-main { min-width: 0; }
.course-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem clamp(1rem, 4vw, 2.5rem);
    border-bottom: 1px solid var(--line);
    background: rgba(244, 251, 250, .96);
    backdrop-filter: blur(8px);
}
.route-chip {
    padding: .25rem .65rem;
    border-radius: 999px;
    background: var(--lime-soft);
    color: #536300;
    font-size: .76rem;
    font-weight: 850;
}
.timer { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.timer span { min-width: 55px; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer button, .class-results-button, .class-results-close {
    min-height: 36px;
    padding: .35rem .6rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    cursor: pointer;
}
.class-results-button { color: var(--teal-dark); font-weight: 850; }

#missionMount { max-width: 980px; margin: 0 auto; padding: clamp(1.4rem, 4vw, 3.2rem); }
.mission { animation: missionIn .2s ease; }
@keyframes missionIn { from { opacity: 0; transform: translateY(6px); } }
.mission-head {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1.5rem;
}
.mission-index {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--teal-dark);
    color: var(--lime);
    font-size: 1.2rem;
    font-weight: 950;
}
.mission-head h1 { margin: .1rem 0 .35rem; color: var(--teal-dark); font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.05; letter-spacing: -.035em; }
.mission-head > div:last-child > p:not(.kicker) { max-width: 760px; margin: 0; color: var(--muted); font-size: 1.04rem; }
.mission-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.meta-chip { padding: .25rem .55rem; border-radius: 999px; background: var(--blue-soft); color: #275278; font-size: .72rem; font-weight: 800; }
.meta-chip.time { background: var(--lime-soft); color: #5b6900; }

.lesson-content { margin-bottom: 1.3rem; }
.lesson-intro {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border-left: 6px solid var(--pink);
    border-radius: 0 14px 14px 0;
    background: var(--pink-soft);
    font-size: 1.08rem;
}
.lesson-intro p { margin: 0; }
.lesson-intro strong, .theory-card strong { color: var(--teal-dark); }
.theory-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.theory-card {
    padding: 1rem 1.1rem;
    border: 1px solid #bcdedb;
    border-radius: 15px;
    background: linear-gradient(145deg, #fff, #f2fbfa);
}
.theory-card:nth-child(2n) { border-top: 5px solid var(--lime); }
.theory-card:nth-child(2n+1) { border-top: 5px solid var(--teal); }
.theory-card h2 { margin: 0 0 .45rem; color: var(--teal-dark); font-size: 1.15rem; line-height: 1.25; }
.theory-card p { margin: .35rem 0 0; }
.theory-card em { background: var(--lime-soft); font-style: normal; }

.quiz-section, .open-questions, .case-work {
    margin-top: 1.25rem;
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 18px;
}
.quiz-section { background: #f0f8fc; border: 1px solid #c9deeb; }
.open-questions { background: var(--lime-soft); border: 1px solid #d8e994; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; color: var(--teal-dark); font-size: 1.45rem; }
.section-heading p { margin: .15rem 0 0; color: var(--muted); }
.activity-score { flex: 0 0 auto; padding: .3rem .6rem; border-radius: 9px; background: white; color: var(--teal-dark); font-weight: 900; }
.question-list, .open-question-list { display: grid; gap: .85rem; }
.question-card { padding: 1rem; border: 1px solid var(--line); border-radius: 13px; background: white; }
.question-card.correct { border-color: #82c89f; background: var(--ok-soft); }
.question-card.incorrect { border-color: #e0a09d; background: var(--bad-soft); }
.question-text { margin: 0 0 .7rem; font-weight: 800; }
.options { display: grid; gap: .45rem; }
.option-button {
    width: 100%;
    min-height: 46px;
    display: grid;
    grid-template-columns: 30px 1fr;
    align-items: center;
    gap: .65rem;
    padding: .55rem .7rem;
    border: 1px solid #cbd9dc;
    border-radius: 10px;
    background: white;
    text-align: left;
    cursor: pointer;
}
.option-button > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font-weight: 900; }
.option-button:hover, .option-button:focus-visible { border-color: var(--teal); }
.option-button.selected { border-color: var(--teal-dark); box-shadow: inset 0 0 0 1px var(--teal-dark); }
.option-button.answer { border-color: var(--ok); background: var(--ok-soft); }
.feedback { margin: .7rem 0 0; padding: .6rem .75rem; border-radius: 9px; }
.feedback.ok { background: var(--ok-soft); color: #105932; }
.feedback.no { background: var(--bad-soft); color: #842923; }
.open-question { padding: 1rem; border-radius: 13px; background: white; }
.open-question label { display: block; margin-bottom: .55rem; }
.open-question textarea, .case-form textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: .75rem;
    border: 2px solid #ccdadd;
    border-radius: 10px;
    background: white;
}
.open-question textarea:focus, .case-form textarea:focus { outline: none; border-color: var(--teal); }

.case-work { display: grid; grid-template-columns: .8fr 1.2fr; gap: 1rem; background: #f0f8fc; border: 1px solid #c9deeb; }
.case-card { align-self: start; position: sticky; top: 76px; padding: 1.25rem; border-radius: 16px; background: var(--teal-dark); color: white; }
.case-tag { color: var(--lime); font-size: .75rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.case-card h2 { margin: .35rem 0 .6rem; font-size: 1.55rem; }
.case-card p { color: #e1f2f0; }
.case-form { display: grid; gap: .8rem; }
.case-field { padding: .9rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.case-field > label, .case-field > strong { display: block; margin-bottom: .5rem; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.check-grid label { display: flex; align-items: start; gap: .45rem; padding: .55rem; border-radius: 8px; background: var(--paper); }
.case-result { padding: .8rem; border-radius: 10px; background: var(--teal-soft); color: var(--teal-dark); }

.primary-button, .secondary-button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .65rem 1rem;
    border-radius: 10px;
    font-weight: 850;
    cursor: pointer;
}
.primary-button { border: 2px solid var(--lime); background: var(--lime); color: #273300; }
.primary-button:hover, .primary-button:focus-visible { background: #d8f038; border-color: #d8f038; }
.secondary-button { border: 2px solid var(--line); background: white; }
.mission-footer { max-width: 980px; display: flex; justify-content: space-between; gap: 1rem; margin: 0 auto; padding: 0 clamp(1.4rem, 4vw, 3.2rem) 3rem; }
.mission-footer button[disabled] { opacity: .38; cursor: not-allowed; }

.teacher-note { display: none; margin-top: 1rem; padding: 1rem; border: 2px dashed var(--pink); border-radius: 12px; background: var(--pink-soft); }
body.teacher-mode .teacher-note { display: block; }
.class-results-panel { max-width: 980px; margin: 1rem auto 0; padding: 1.2rem; border: 2px solid var(--teal-dark); border-radius: 16px; background: white; }
.class-results-head { display: flex; justify-content: space-between; gap: 1rem; }
.class-results-head h2 { margin: .1rem 0; }
.class-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: 1rem 0; }
.class-summary-card { padding: .75rem; border-radius: 10px; background: var(--paper); }
.class-summary-card strong { display: block; color: var(--teal-dark); font-size: 1.3rem; }
.class-summary-card span, .class-results-meta { color: var(--muted); font-size: .8rem; }
.class-question-result { padding: .75rem 0; border-top: 1px solid var(--line); }
.class-result-bar { height: 9px; overflow: hidden; border-radius: 999px; background: var(--line); }
.class-result-bar span { display: block; height: 100%; background: var(--ok); }
.class-note-list { display: grid; gap: .45rem; padding: 0; list-style: none; }
.class-note-list li { padding: .65rem; border-radius: 9px; background: var(--paper); white-space: pre-wrap; }

.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; max-width: min(360px, calc(100vw - 2rem)); padding: .8rem 1rem; border-radius: 12px; background: var(--teal-dark); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
footer { max-width: 1120px; display: flex; justify-content: space-between; gap: 1rem; margin: 1rem auto 0; padding: .8rem 1rem; color: white; font-size: .8rem; }
footer p { margin: 0; }

body.high-contrast { --teal: #005954; --teal-dark: #003f3b; --lime: #ffe000; --lime-soft: #fff5a8; --ink: #000; --muted: #222; --line: #666; }

@media (max-width: 760px) {
    body { padding: 0; }
    .topbar, .course-shell { border-radius: 0; }
    .brand small, .icon-button span { display: none; }
    .course-sidebar { padding-inline: .8rem; }
    .sidebar-head { grid-template-columns: 1fr; gap: .3rem; }
    .progress-copy { justify-content: flex-start; }
    .mission-link { min-width: 145px; }
    .route-chip { display: none; }
    .class-results-button { margin-right: auto; }
    #missionMount { padding: 1.2rem .8rem; }
    .mission-head { grid-template-columns: 48px 1fr; gap: .7rem; }
    .mission-index { width: 48px; height: 48px; font-size: .95rem; }
    .mission-head h1 { font-size: 2rem; }
    .theory-cards, .case-work { grid-template-columns: 1fr; }
    .case-card { position: static; }
    .check-grid { grid-template-columns: 1fr; }
    .section-heading { display: block; }
    .activity-score { display: inline-block; margin-top: .5rem; }
    .class-summary-grid { grid-template-columns: 1fr; }
    .mission-footer { padding: 0 .8rem 2rem; }
    .mission-footer button { flex: 1; }
    footer { display: grid; }
}

@media print {
    body { padding: 0; background: white; }
    .topbar, .course-sidebar, .course-toolbar, .mission-footer, .toast, footer, .class-results-panel { display: none !important; }
    .course-shell { box-shadow: none; }
    #missionMount { max-width: none; padding: 0; }
    .question-card, .theory-card, .open-question, .case-card, .case-field { break-inside: avoid; }
    .case-card { position: static; background: white; color: black; border: 1px solid #777; }
    .case-card p { color: black; }
}
