/* ===== Дизайн-система учебной платформы ===== */
:root {
    --bg: #f5f6fa;
    --surface: #fff;
    --surface-2: #f9fafb;
    --text: #1a1f2b;
    --muted: #667085;
    --border: #e3e6ec;
    --border-strong: #cfd4dc;
    --primary: #4f46e5;
    --primary-600: #4338ca;
    --primary-50: #eef0ff;
    --primary-100: #dfe3ff;
    --green: #12805c;
    --green-50: #e7f6ef;
    --amber: #a15c07;
    --amber-50: #fdf3dc;
    --red: #c8321f;
    --red-50: #fdeceb;
    --blue: #1d5fd1;
    --blue-50: #e8f0fe;
    --gray-50: #f0f2f5;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
    --sidebar-w: 248px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font: 15px/1.5 var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

body.modal-open {
    overflow: hidden;
}

h1,
h2,
h3,
h4 {
    line-height: 1.25;
    margin: 0 0 .5em;
    font-weight: 650;
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.2rem;
}

h3 {
    font-size: 1.05rem;
}

p {
    margin: 0 0 .75em;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: .85rem;
}

.center {
    text-align: center;
}

.nowrap {
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: var(--primary);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    z-index: 100;
}

.skip-link:focus {
    left: 8px;
}

/* ----- Каркас ----- */
.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
}

.sidebar-head {
    padding: 18px 18px 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.02rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font: 700 12px var(--mono);
    flex: none;
}

.brand-lg {
    font-size: 1.25rem;
    margin-bottom: 1.2rem;
}

.nav {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: #3a4152;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--gray-50);
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-50);
    color: var(--primary-600);
}

.nav-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    text-align: center;
}

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: grid;
    gap: 8px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 4px;
    min-width: 0;
}

.user-chip-text {
    display: grid;
    min-width: 0;
    line-height: 1.2;
}

.user-chip-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .9rem;
}

.user-chip-text small {
    color: var(--muted);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary-600);
    display: grid;
    place-items: center;
    font-weight: 700;
    flex: none;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-title {
    font-weight: 650;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.view {
    padding: 28px 32px 60px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    outline: none;
}

.view.wide {
    max-width: none;
}

.scrim {
    display: none;
}

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s;
        box-shadow: var(--shadow-lg);
    }

    body.nav-open .sidebar {
        transform: none;
    }

    body.nav-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, .45);
        z-index: 35;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        display: flex;
    }

    .view {
        padding: 18px 14px 50px;
    }
}

/* ----- Страница ----- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.page-head h1 {
    margin: 0;
}

.page-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 18px 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head h2,
.card-head h3 {
    margin: 0;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-stats {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.grid-cards {
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

@media (max-width: 900px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

.stack>*+* {
    margin-top: 16px;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.spread {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stat {
    display: block;
    padding: 16px 18px;
    color: inherit;
}

a.stat:hover {
    text-decoration: none;
    border-color: var(--primary);
}

.stat .stat-label {
    color: var(--muted);
    font-size: .83rem;
}

.stat .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    margin-top: 2px;
    letter-spacing: -.02em;
}

.stat .stat-sub {
    color: var(--muted);
    font-size: .8rem;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
    margin-right: 6px;
}

.dot.on {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .2);
}

/* ----- Кнопки ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 550;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--gray-50);
    text-decoration: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-600);
}

.btn-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: #a82817;
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
}

.btn-ghost:hover {
    background: var(--gray-50);
}

.btn-success {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-success:hover {
    background: #0e6b4c;
}

.btn-sm {
    padding: 5px 10px;
    font-size: .86rem;
}

.btn-icon {
    padding: 7px;
}

.btn-block {
    width: 100%;
}

.btn-left {
    justify-content: flex-start;
}

.btn-lg {
    padding: 11px 20px;
    font-size: 1rem;
}

.btn.ok {
    color: var(--green);
}

/* ----- Формы ----- */
.field {
    display: block;
    margin-bottom: 14px;
}

.field>span:first-child,
.field>.label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: #344054;
}

.field .hint {
    display: block;
    color: var(--muted);
    font-size: .8rem;
    margin-top: 4px;
    font-weight: 400;
}

input[type=text],
input[type=password],
input[type=search],
input[type=number],
input[type=url],
input[type=date],
input[type=datetime-local],
input[type=email],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    min-height: 38px;
}

textarea {
    resize: vertical;
    min-height: 84px;
    line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 2px solid var(--primary-100);
    outline-offset: 0;
}

input[type=checkbox],
input[type=radio] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 10px;
    cursor: pointer;
}

.check span {
    font-size: .93rem;
}

.field-error input,
.field-error select,
.field-error textarea {
    border-color: var(--red);
}

.field-msg {
    color: var(--red);
    font-size: .82rem;
    margin-top: 4px;
}

.form-error {
    color: var(--red);
    font-size: .9rem;
    min-height: 1.2em;
    margin-bottom: 8px;
}

.input-group {
    display: flex;
    gap: 6px;
}

.input-group input {
    flex: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.toolbar .search {
    flex: 1;
    min-width: 200px;
    max-width: 360px;
    position: relative;
}

.toolbar .search input {
    padding-left: 34px;
}

.toolbar .search .icon {
    position: absolute;
    left: 10px;
    top: 10px;
    color: var(--muted);
}

.toolbar select {
    width: auto;
    min-width: 150px;
}

/* ----- Таблицы ----- */
.table-scroll {
    overflow-x: auto;
}

table.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 650;
    background: var(--surface-2);
    white-space: nowrap;
}

.table th a {
    color: inherit;
}

.table tbody tr:hover {
    background: #fafbff;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table .actions-cell {
    text-align: right;
    white-space: nowrap;
}

.cell-title {
    font-weight: 600;
    display: block;
}

.cell-sub {
    color: var(--muted);
    font-size: .82rem;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 650;
    white-space: nowrap;
}

.badge-gray {
    background: var(--gray-50);
    color: #475467;
}

.badge-green {
    background: var(--green-50);
    color: var(--green);
}

.badge-amber {
    background: var(--amber-50);
    color: var(--amber);
}

.badge-red {
    background: var(--red-50);
    color: var(--red);
}

.badge-blue {
    background: var(--blue-50);
    color: var(--blue);
}

.badge-purple {
    background: var(--primary-50);
    color: var(--primary-600);
}

.progress {
    height: 7px;
    background: var(--gray-50);
    border-radius: 999px;
    overflow: hidden;
    min-width: 70px;
}

.progress>span {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    transition: width .3s;
}

.progress.green>span {
    background: #22a06b;
}

.progress.lg {
    height: 11px;
}

.progress-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 130px;
}

.progress-cell .progress {
    flex: 1;
}

.progress-cell small {
    color: var(--muted);
    width: 38px;
    text-align: right;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    overflow-x: auto;
}

.tab {
    padding: 9px 14px;
    border: 0;
    background: none;
    cursor: pointer;
    font-weight: 550;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary-600);
    border-color: var(--primary);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 5px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: .86rem;
    font-weight: 550;
}

.chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.chip small {
    opacity: .75;
    margin-left: 4px;
}

/* ----- Состояния ----- */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 14px;
    font-size: .93rem;
}

.alert-error {
    background: var(--red-50);
    border-color: #f4c1bb;
    color: #8f2214;
}

.alert-success {
    background: var(--green-50);
    border-color: #b4e3cd;
    color: #0b5e42;
}

.alert-info {
    background: var(--blue-50);
    border-color: #bcd3f8;
    color: #174a9f;
}

.alert-warn {
    background: var(--amber-50);
    border-color: #f2d799;
    color: #7a4505;
}

.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--muted);
}

.empty h3 {
    color: var(--text);
    margin-bottom: 4px;
}

.empty p {
    max-width: 420px;
    margin: 0 auto 14px;
}

.empty-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary);
    display: grid;
    place-items: center;
}

.skeleton-wrap {
    display: grid;
    gap: 12px;
}

.skeleton {
    background: linear-gradient(90deg, #eceff4 25%, #f5f6fa 50%, #eceff4 75%);
    background-size: 200% 100%;
    animation: sk 1.3s infinite;
    border-radius: 8px;
}

.skeleton-line {
    height: 18px;
}

.skeleton-line:nth-child(odd) {
    width: 85%;
}

@keyframes sk {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

#toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 200;
    display: grid;
    gap: 8px;
    max-width: min(380px, calc(100vw - 32px));
}

.toast {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: #1f2937;
    color: #fff;
    box-shadow: var(--shadow-lg);
    animation: tin .2s;
    font-size: .92rem;
}

.toast-success {
    background: #0f7a56;
}

.toast-error {
    background: #b42318;
}

.toast.out {
    opacity: 0;
    transition: opacity .25s;
}

@keyframes tin {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .5);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 14px 14px;
    overflow-y: auto;
}

.modal {
    background: #fff;
    border-radius: 14px;
    width: min(560px, 100%);
    box-shadow: var(--shadow-lg);
}

.modal.modal-sm {
    width: min(430px, 100%);
}

.modal.modal-lg {
    width: min(760px, 100%);
}

.modal.modal-xl {
    width: min(1000px, 100%);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-body {
    padding: 18px 20px;
}

.modal-foot,
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0;
}

.modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 14px 14px;
}

.modal-actions {
    margin-top: 6px;
}

.cred {
    display: grid;
    gap: 8px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 10px 0;
}

.cred-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cred-row span {
    color: var(--muted);
    width: 70px;
    flex: none;
    font-size: .85rem;
}

.cred-row code {
    flex: 1;
    font: 600 .95rem var(--mono);
    word-break: break-all;
}

.kv {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 8px 14px;
    margin: 0;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
}

@media (max-width: 600px) {
    .kv {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .kv dt {
        margin-top: 8px;
    }
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list li {
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.list li:last-child {
    border-bottom: 0;
}

.feed li {
    align-items: flex-start;
}

.feed .feed-text {
    flex: 1;
    min-width: 0;
}

.feed time {
    color: var(--muted);
    font-size: .8rem;
    white-space: nowrap;
}

.chart-box {
    position: relative;
    height: 280px;
    padding: 8px 8px 0;
}

/* ----- Вход ----- */
.page-auth {
    background: radial-gradient(1200px 500px at 50% -10%, var(--primary-100), transparent), var(--bg);
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-card {
    background: #fff;
    width: min(420px, 100%);
    padding: 32px 30px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.auth-card h1 {
    font-size: 1.35rem;
    margin-bottom: 6px;
}

/* ----- Структура курсов ----- */
.course {
    margin-bottom: 18px;
}

.course-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    flex-wrap: wrap;
}

.course-head h2 {
    margin: 0;
    flex: 1;
    min-width: 180px;
    font-size: 1.1rem;
}

.module {
    border-top: 1px solid var(--border);
}

.module-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px 11px 30px;
    background: var(--surface-2);
    flex-wrap: wrap;
}

.module-head strong {
    flex: 1;
    min-width: 160px;
}

.lesson-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px 9px 44px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.lesson-row:hover {
    background: #fafbff;
}

.lesson-row .lr-title {
    flex: 1;
    min-width: 180px;
    font-weight: 550;
    color: var(--text);
}

.mini-actions {
    display: flex;
    gap: 2px;
}

/* ===== Статьи: единое оформление для редактора, предпросмотра и чтения ===== */
.article {
    font-size: 1.05rem;
    line-height: 1.75;
    color: #1d2330;
    overflow-wrap: break-word;
}

.article>*:first-child {
    margin-top: 0;
}

.article h1 {
    font-size: 1.9rem;
    margin: 1.6em 0 .6em;
}

.article h2 {
    font-size: 1.5rem;
    margin: 1.6em 0 .5em;
}

.article h3 {
    font-size: 1.25rem;
    margin: 1.4em 0 .4em;
}

.article h4 {
    font-size: 1.08rem;
    margin: 1.3em 0 .4em;
}

.article p {
    margin: 0 0 1em;
}

.article ul,
.article ol {
    margin: 0 0 1em;
    padding-left: 1.5em;
}

.article li>p {
    margin: 0 0 .3em;
}

.article li {
    margin: .2em 0;
}

.article blockquote {
    margin: 1.2em 0;
    padding: .3em 1.1em;
    border-left: 4px solid var(--primary-100);
    color: #475467;
    background: var(--surface-2);
    border-radius: 0 8px 8px 0;
}

.article hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

.article img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.article a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.article code {
    font-family: var(--mono);
    font-size: .88em;
    background: var(--gray-50);
    border: 1px solid var(--border);
    padding: .1em .38em;
    border-radius: 5px;
}

.article pre {
    margin: 0 0 1.2em;
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    font: .88rem/1.6 var(--mono);
    tab-size: 2;
}

.article pre code {
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    font-size: inherit;
    white-space: pre;
}

.article figure {
    margin: 1.4em 0;
    text-align: center;
}

.article figure img {
    display: block;
    margin: 0 auto;
}

.article figcaption {
    color: var(--muted);
    font-size: .88rem;
    margin-top: .5em;
}

.article figcaption:empty {
    display: none;
}

.article .table-wrap {
    overflow-x: auto;
    margin: 0 0 1.2em;
}

.article table {
    border-collapse: collapse;
    width: 100%;
    font-size: .95rem;
}

.article th,
.article td {
    border: 1px solid var(--border-strong);
    padding: 8px 12px;
    vertical-align: top;
    text-align: left;
    min-width: 60px;
}

.article th {
    background: var(--surface-2);
    font-weight: 650;
}

.article div[data-video] {
    position: relative;
    aspect-ratio: 16/9;
    margin: 1.2em 0;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}

.article div[data-video] iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.callout {
    margin: 1.2em 0;
    padding: .8em 1em .8em 3em;
    border-radius: 10px;
    border: 1px solid;
    position: relative;
}

.callout>*:last-child {
    margin-bottom: 0;
}

.callout::before {
    position: absolute;
    left: .9em;
    top: .75em;
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.callout-note {
    background: var(--blue-50);
    border-color: #bcd3f8;
}

.callout-note::before {
    content: "Примечание";
    color: var(--blue);
}

.callout-warning {
    background: var(--amber-50);
    border-color: #f2d799;
}

.callout-warning::before {
    content: "Внимание";
    color: var(--amber);
}

.callout-tip {
    background: var(--green-50);
    border-color: #b4e3cd;
}

.callout-tip::before {
    content: "Совет";
    color: var(--green);
}

.code-block {
    margin: 0 0 1.2em;
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
}

.code-block pre {
    margin: 0;
    border-radius: 0;
}

.code-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px 4px 14px;
    background: #1e293b;
    color: #94a3b8;
    font: 600 .75rem var(--mono);
    text-transform: uppercase;
}

.code-head .btn {
    color: #cbd5e1;
    font-size: .78rem;
}

.code-head .btn:hover {
    background: #334155;
}

.code-head .btn.ok {
    color: #4ade80;
}

.hljs-comment,
.hljs-quote {
    color: #7c8aa5;
    font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag,
.hljs-built_in {
    color: #c4a7ff;
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string {
    color: #8ee0a5;
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-link {
    color: #ffb074;
}

.hljs-title,
.hljs-section,
.hljs-class .hljs-title,
.hljs-title.function_ {
    color: #7dc4ff;
}

.hljs-name,
.hljs-tag,
.hljs-selector-id,
.hljs-selector-class {
    color: #ff8fa3;
}

.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-type,
.hljs-params {
    color: #ffd479;
}

.hljs-deletion {
    color: #ff8b8b;
}

.hljs-meta {
    color: #8fa3c4;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: 700;
}

/* ===== Редактор ===== */
.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

@media (max-width: 1100px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

.editor-bar {
    position: sticky;
    top: 0;
    z-index: 25;
    background: var(--bg);
    padding: 10px 0;
    margin: -10px 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

@media (max-width: 960px) {
    .editor-bar {
        top: 53px;
    }
}

.save-state {
    font-size: .86rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
}

.save-state.saved {
    color: var(--green);
}

.save-state.saving {
    color: var(--amber);
}

.save-state.error {
    color: var(--red);
    font-weight: 600;
}

.title-input {
    width: 100%;
    font-size: 1.6rem;
    font-weight: 700;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 8px 2px;
    background: transparent;
}

.title-input:focus {
    outline: 0;
    border-color: var(--primary);
}

.editor-card {
    overflow: visible;
}

.ed-toolbar {
    position: sticky;
    top: 56px;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

@media (max-width: 960px) {
    .ed-toolbar {
        top: 108px;
    }
}

.ed-group {
    display: flex;
    gap: 2px;
    padding-right: 6px;
    margin-right: 2px;
    border-right: 1px solid var(--border);
}

.ed-group:last-child {
    border-right: 0;
}

.ed-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 7px;
    border: 0;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 650;
    color: #344054;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: .86rem;
}

.ed-btn:hover {
    background: var(--gray-50);
}

.ed-btn.active {
    background: var(--primary-50);
    color: var(--primary-600);
}

.ed-btn:disabled {
    opacity: .35;
    cursor: default;
}

.ed-select {
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 6px;
    background: #fff;
    font-size: .86rem;
    min-height: 0;
    width: auto;
}

.ed-context {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 6px 10px;
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-100);
    font-size: .86rem;
}

.ed-surface {
    padding: 22px 30px;
    min-height: 480px;
}

@media (max-width: 600px) {
    .ed-surface {
        padding: 14px;
    }
}

.ed-surface .ProseMirror {
    outline: none;
    min-height: 440px;
}

.ProseMirror p.is-empty::before,
.ProseMirror h1.is-empty::before,
.ProseMirror h2.is-empty::before,
.ProseMirror h3.is-empty::before,
.ProseMirror h4.is-empty::before,
.ProseMirror figure.is-empty figcaption::before {
    content: attr(data-placeholder);
    color: #98a2b3;
    pointer-events: none;
    float: left;
    height: 0;
}

.ProseMirror p.is-empty::before {}

.ProseMirror figure.is-empty::after {
    content: attr(data-placeholder);
    color: #98a2b3;
    display: block;
    font-size: .88rem;
}

.ProseMirror figure.ProseMirror-selectednode,
.ProseMirror div[data-video].ProseMirror-selectednode,
.ProseMirror .ProseMirror-selectednode img {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.ProseMirror table {
    table-layout: auto;
}

.ProseMirror .selectedCell {
    background: var(--primary-100);
}

.ProseMirror div[data-video] iframe {
    pointer-events: none;
}

.ProseMirror pre {
    position: relative;
}

.ProseMirror pre::before {
    content: attr(data-language);
}

.side-panel {
    position: sticky;
    top: 64px;
    display: grid;
    gap: 14px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-right: 2px;
}

@media (max-width: 1100px) {
    .side-panel {
        position: static;
        max-height: none;
    }
}

.side-panel .card-pad {
    padding: 14px 16px;
}

.side-panel h3 {
    font-size: .95rem;
}

.cover-preview {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    object-fit: cover;
    background: var(--gray-50);
    margin-bottom: 8px;
    display: block;
}

.task-card {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--surface-2);
}

.task-card header {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.task-card header strong {
    flex: 1;
    font-size: .82rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .04em;
}

.opt-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.opt-row input[type=text] {
    flex: 1;
}

.kbd {
    font: 600 .78rem var(--mono);
    background: var(--gray-50);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 6px;
}

.preview-pane {
    padding: 22px 30px;
}

/* ===== Кабинет ученика ===== */
.hero {
    padding: 22px 24px;
    background: linear-gradient(135deg, #4f46e5, #6d5ef0);
    color: #fff;
    border-radius: var(--radius);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
}

.hero h1 {
    color: #fff;
    margin: 0 0 4px;
}

.hero p {
    margin: 0;
    opacity: .88;
}

.ring {
    --p: 0;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, .25) 0);
    display: grid;
    place-items: center;
    flex: none;
}

.ring>span {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #5a50e8;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.15rem;
}

.lesson-card {
    display: flex;
    flex-direction: column;
    color: inherit;
    padding: 0;
    overflow: hidden;
}

.lesson-card:hover {
    text-decoration: none;
    border-color: var(--primary);
}

.lesson-card .lc-cover {
    aspect-ratio: 16/7;
    background: linear-gradient(135deg, var(--primary-50), var(--blue-50));
    object-fit: cover;
    width: 100%;
    display: block;
}

.lesson-card .lc-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.lesson-card h3 {
    margin: 0;
}

.lesson-card p {
    color: var(--muted);
    font-size: .9rem;
    margin: 0;
}

.lesson-card .lc-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    font-size: .8rem;
    color: var(--muted);
    margin-top: auto;
    padding-top: 6px;
}

.lesson-item {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 13px 18px;
    border-top: 1px solid var(--border);
    color: inherit;
    flex-wrap: wrap;
}

.lesson-item:hover {
    background: #fafbff;
    text-decoration: none;
}

.lesson-item .li-main {
    flex: 1;
    min-width: 200px;
}

.lesson-item h3 {
    margin: 0 0 2px;
    font-size: 1rem;
}

.lesson-item p {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}

.lesson-item.locked {
    opacity: .6;
}

.status-ico {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex: none;
    background: var(--gray-50);
    color: var(--muted);
}

.status-ico.completed {
    background: var(--green);
    color: #fff;
}

.status-ico.in_progress {
    background: var(--amber-50);
    color: var(--amber);
}

.status-ico.new {
    background: var(--blue-50);
    color: var(--blue);
}

.reading-bar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: 3px;
    z-index: 50;
    background: transparent;
}

.reading-bar>span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width .1s;
}

@media (max-width: 960px) {
    .reading-bar {
        left: 0;
    }
}

.lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 36px;
    align-items: start;
}

.lesson-main {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
}

.toc {
    position: sticky;
    top: 20px;
    font-size: .88rem;
}

.toc h4 {
    font-size: .75rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .06em;
}

.toc a {
    display: block;
    padding: 4px 0 4px 10px;
    border-left: 2px solid var(--border);
    color: #475467;
}

.toc a:hover {
    color: var(--primary);
    text-decoration: none;
}

.toc a.active {
    border-color: var(--primary);
    color: var(--primary-600);
    font-weight: 600;
}

.toc .l3 {
    padding-left: 22px;
}

.toc .l4 {
    padding-left: 34px;
}

@media (max-width: 1100px) {
    .lesson-layout {
        grid-template-columns: 1fr;
    }

    .toc {
        display: none;
    }
}

.lesson-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 28px;
}

.lesson-nav a {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: inherit;
}

.lesson-nav a:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.lesson-nav small {
    color: var(--muted);
    display: block;
}

.lesson-nav .next {
    text-align: right;
}

.finish-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    margin-top: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.task {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 12px;
}

.task.done {
    border-color: #b4e3cd;
    background: #f7fcf9;
}

.task h4 {
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quiz-opt {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
}

.quiz-opt:hover {
    background: var(--surface-2);
}

.quiz-opt.right {
    border-color: #7ccaa6;
    background: var(--green-50);
}

.note-area {
    width: 100%;
}

.notif {
    display: flex;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.notif.unread {
    background: #f6f7ff;
}

.notif:last-child {
    border-bottom: 0;
}

.notif .n-ico {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-50);
    color: var(--primary);
    display: grid;
    place-items: center;
    flex: none;
}

.achv {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
}

.achv .a-ico {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--gray-50);
    color: var(--muted);
}

.achv.earned .a-ico {
    background: #fff3c4;
    color: #a15c07;
}

.achv:not(.earned) {
    opacity: .5;
}

.resume-banner {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--blue-50);
    color: #174a9f;
    margin-bottom: 18px;
    font-size: .92rem;
}

.cover-hero {
    width: 100%;
    aspect-ratio: 16/6;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 18px;
}

.lesson-title-block h1 {
    font-size: 2rem;
    margin-bottom: .3em;
}

.lesson-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: .88rem;
    margin-bottom: 20px;
    align-items: center;
}

@media print {

    .sidebar,
    .topbar,
    .reading-bar,
    .lesson-nav,
    .finish-bar,
    .toc {
        display: none !important;
    }

    .main {
        margin: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ===== Ãàëåðåÿ ===== */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.gallery-item { position: relative; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--gray-50); cursor: pointer; aspect-ratio: 4/3; box-shadow: var(--shadow); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.gallery-item:hover img { transform: scale(1.04); }
.gallery-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px; color: #fff; text-align: left; font-weight: 600; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.gallery-view { margin: 0 0 12px; text-align: center; } .gallery-view img { max-width: 100%; max-height: 70vh; border-radius: 8px; } .gallery-view figcaption { margin-top: 8px; }
