:root {
    color-scheme: light;
    --background: #f5f7fb;
    --surface: #ffffff;
    --text: #182230;
    --muted: #667085;
    --border: #e4e7ec;
    --primary: #3157d5;
    --primary-hover: #2447bb;
    --success: #067647;
    --success-bg: #ecfdf3;
    --error: #b42318;
    --error-bg: #fef3f2;
    --info: #175cd3;
    --info-bg: #eff8ff;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    color: var(--text);
    background: var(--background);
}

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

.site-header {
    min-height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 750;
    text-decoration: none;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.main-nav form {
    margin: 0;
}

.main-nav a,
.link-button {
    padding: 0;
    color: var(--muted);
    background: none;
    border: 0;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.main-nav a:hover,
.link-button:hover {
    color: var(--primary);
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0;
    flex: 1;
}

.site-footer {
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.auth-card,
.panel,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(16, 24, 40, 0.05);
}
.brand { display:flex; align-items:center; gap:10px; }
.brand img { width:42px; height:42px; object-fit:contain; }

.auth-card {
    width: min(440px, 100%);
    margin: 4vh auto 0;
    padding: 32px;
}

.panel {
    padding: 28px;
}

.panel.narrow {
    width: min(560px, 100%);
    margin: 0 auto;
}

h1,
h2 {
    margin-top: 0;
    letter-spacing: -0.025em;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(28px, 4vw, 40px);
}

h2 {
    font-size: 22px;
}

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

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-heading {
    margin-bottom: 28px;
}
.heading-actions,.inline-form,.check-row { display:flex; align-items:center; gap:14px; }
.heading-actions { justify-content:space-between; }
.inline-form input { max-width:360px; }
.check-row { font-weight:500; }
.check-row input { width:auto; }
.check-grid { display:grid; gap:10px; margin-top:12px; }
fieldset { border:1px solid var(--border); border-radius:10px; padding:16px; }
table { width:100%; border-collapse:collapse; }
th,td { padding:13px; text-align:left; border-bottom:1px solid var(--border); }
.table-wrap { overflow-x:auto; }

.form-stack {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 650;
}

input:not([type="radio"]),
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid #cbd1dc;
    border-radius: 9px;
    font: inherit;
}

input:not([type="radio"]):focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(49, 87, 213, 0.14);
}
textarea { resize: vertical; }

.button {
    min-height: 44px;
    padding: 10px 18px;
    color: white;
    background: var(--primary);
    border: 0;
    border-radius: 9px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.button-secondary {
    color: var(--primary);
    background: #eef2ff;
}

.button-secondary:hover {
    background: #dfe6ff;
}

.alert {
    margin-bottom: 20px;
    padding: 13px 15px;
    border-radius: 10px;
}

.alert-success {
    color: var(--success);
    background: var(--success-bg);
}

.alert-error {
    color: var(--error);
    background: var(--error-bg);
}

.alert-info {
    color: var(--info);
    background: var(--info-bg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 24px;
    display: grid;
    gap: 4px;
}

.stat-value {
    font-size: 34px;
    font-weight: 800;
}

.course-grid,
.test-form {
    display: grid;
    gap: 20px;
}

.course-card,
.question-card {
    padding: 22px;
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.course-card h3,
.lesson-item h3 {
    margin: 8px 0;
}

.progress-row,
.card-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.progress-row progress {
    width: 100%;
    height: 12px;
}

.progress-wide {
    max-width: 560px;
    margin-top: 20px;
}

.card-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.lesson-list {
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
    list-style: none;
}

.lesson-item {
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.lesson-item.is-locked {
    opacity: 0.65;
}

.status {
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}

.status-success {
    color: var(--success);
    background: var(--success-bg);
}

.status-info {
    color: var(--info);
    background: var(--info-bg);
}

.status-error {
    color: var(--error);
    background: var(--error-bg);
}

.status-muted {
    color: var(--muted);
    background: #f2f4f7;
}

.top-gap {
    margin-top: 24px;
}

.prose {
    max-width: 760px;
    font-size: 17px;
    line-height: 1.7;
}

.prose h2 {
    margin-top: 32px;
}

.question-card {
    margin: 0;
}

.question-card legend {
    padding: 0 8px;
    font-size: 17px;
    font-weight: 750;
}

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

.answer-option {
    padding: 12px;
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
}

.answer-option input {
    flex: 0 0 auto;
}

.result-card {
    max-width: 680px;
    margin: 4vh auto 0;
    text-align: center;
}

.result-score {
    margin: 22px 0 4px;
    font-size: 64px;
    font-weight: 850;
    letter-spacing: -0.05em;
}

.result-card .card-actions {
    justify-content: center;
    margin-top: 28px;
}
.media-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:18px; }
.media-card { display:grid; gap:10px; padding:14px; background:var(--surface); border:1px solid var(--border); border-radius:12px; overflow:hidden; }
.media-card img { width:100%; height:150px; object-fit:cover; border-radius:8px; }
.media-card code { overflow-wrap:anywhere; font-size:11px; }
.editor-list { display:grid; gap:14px; }
.editor-list-item { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:18px; background:#fbfcfe; border:1px solid var(--border); border-radius:12px; }
.editor-list-item h3 { margin:8px 0; }
.item-actions { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.item-actions form { margin:0; }
.mini-button,.editor-toolbar button { min-height:36px; padding:6px 10px; color:var(--text); background:var(--surface); border:1px solid var(--border); border-radius:7px; cursor:pointer; }
.mini-button:hover,.editor-toolbar button:hover { color:var(--primary); border-color:var(--primary); }
.answer-editor-list { display:grid; gap:10px; }
.answer-editor-row { display:grid; grid-template-columns:auto 1fr; align-items:center; gap:10px; }
.answer-editor-row input[type="radio"] { width:auto; }
.editor-toolbar { display:flex; flex-wrap:wrap; gap:6px; padding:10px; background:#f8f9fc; border:1px solid var(--border); border-bottom:0; border-radius:10px 10px 0 0; }
.visual-editor { min-height:380px; max-width:none; padding:20px; background:var(--surface); border:1px solid #cbd1dc; border-radius:0 0 10px 10px; outline:none; }
.visual-editor:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(49,87,213,.14); }
.visual-editor img,.prose img { max-width:100%; height:auto; border-radius:8px; }
.media-picker { display:grid; grid-template-columns:repeat(auto-fill,minmax(130px,1fr)); gap:10px; }
.media-picker button { padding:8px; display:grid; gap:6px; color:var(--text); background:var(--surface); border:1px solid var(--border); border-radius:8px; cursor:pointer; text-align:left; }
.media-picker img { width:100%; height:80px; object-fit:cover; border-radius:6px; }
.media-picker span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.assignment-box { padding:22px; background:#f8f9fc; border:1px solid var(--border); border-radius:12px; }
.submission-answer { padding:18px; white-space:normal; line-height:1.65; background:#f8f9fc; border:1px solid var(--border); border-radius:10px; }

@media (max-width: 720px) {
    .site-header {
        padding: 0 16px;
    }

    .container {
        padding: 28px 0;
    }

    .auth-card,
    .panel {
        padding: 22px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .lesson-item {
        align-items: stretch;
        flex-direction: column;
    }
    .editor-list-item { align-items:stretch; flex-direction:column; }

    .card-actions .button {
        width: 100%;
    }
}
