/* Компоненты дизайн-системы. */

/* ── Кнопки ─────────────────────────────────────────────── */
.btn {
    --btn-bg: var(--accent);
    --btn-fg: var(--on-accent);
    --btn-border: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    min-height: 38px;
    padding: var(--sp-3) var(--sp-5);
    font-family: inherit;
    font-size: var(--fs-14);
    font-weight: 600;
    line-height: 1.2;
    color: var(--btn-fg);
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-1);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background var(--dur-2) var(--ease),
        color var(--dur-2) var(--ease),
        border-color var(--dur-2) var(--ease),
        box-shadow var(--dur-2) var(--ease),
        transform var(--dur-1) var(--ease);
}

.btn:hover {
    --btn-bg: var(--accent-hover);
    color: var(--on-accent);
    box-shadow: var(--shadow-2);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: var(--shadow-1);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-border: var(--border-strong);
}

.btn-secondary:hover {
    --btn-bg: var(--accent-soft);
    --btn-fg: var(--accent-800);
    --btn-border: var(--accent-300);
}

.btn-light {
    --btn-bg: #ffffff;
    --btn-fg: var(--accent-900);
    --btn-border: var(--accent-200);
}

.btn-light:hover {
    --btn-bg: var(--accent-50);
    --btn-fg: var(--accent-900);
    --btn-border: var(--accent-300);
}

.btn-ghost {
    --btn-bg: transparent;
    --btn-fg: var(--text-muted);
    --btn-border: transparent;
    box-shadow: none;
}

.btn-ghost:hover {
    --btn-bg: var(--canvas-alt);
    --btn-fg: var(--text);
    box-shadow: none;
}

.btn-danger {
    --btn-bg: var(--danger-ink);
    --btn-fg: #fff;
}

.btn-danger:hover {
    --btn-bg: #8a3123;
}

.btn-quiet {
    --btn-bg: var(--accent-tint);
    --btn-fg: var(--accent-800);
}

.btn-quiet:hover {
    --btn-bg: var(--accent-200);
    --btn-fg: var(--accent-900);
}

.btn-sm {
    min-height: 30px;
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--fs-13);
    border-radius: var(--r-sm);
}

.btn-lg {
    min-height: var(--touch);
    padding: var(--sp-4) var(--sp-7);
    font-size: var(--fs-15);
}

.btn-block {
    width: 100%;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    text-decoration: none;
    transition:
        background var(--dur-2) var(--ease),
        color var(--dur-2) var(--ease);
}

.icon-btn:hover {
    color: var(--accent-800);
    background: var(--accent-soft);
}

/* ── Иконки ─────────────────────────────────────────────── */
.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.icon-sm {
    width: 15px;
    height: 15px;
}
.icon-lg {
    width: 22px;
    height: 22px;
}
.icon-xl {
    width: 30px;
    height: 30px;
    stroke-width: 1.5;
}

/* ── Формы ──────────────────────────────────────────────── */
label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text);
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
    width: 100%;
    min-height: 38px;
    padding: var(--sp-3) var(--sp-4);
    font-family: inherit;
    font-size: var(--fs-14);
    line-height: 1.45;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    transition:
        border-color var(--dur-2) var(--ease),
        box-shadow var(--dur-2) var(--ease);
}

textarea {
    min-height: 96px;
    resize: vertical;
    line-height: var(--lh-loose);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--accent-300);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: var(--ring);
}

select {
    appearance: none;
    padding-right: var(--sp-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e675f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

input[type="file"] {
    padding: var(--sp-3);
    background: var(--surface-sunken);
    border-style: dashed;
}

input[type="checkbox"],
input[type="radio"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent-600);
    cursor: pointer;
    flex: 0 0 auto;
}

.form-field {
    margin-bottom: var(--sp-5);
    min-width: 0;
}

.form-field > .help-text,
.help-text {
    margin-top: var(--sp-2);
    font-size: var(--fs-13);
    color: var(--text-muted);
    line-height: 1.45;
}

.form-grid {
    display: grid;
    gap: var(--sp-4) var(--sp-5);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.form-grid .form-field {
    margin-bottom: 0;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.checkline {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
}

.checkline label {
    margin: 0;
    font-weight: 500;
    font-size: var(--fs-14);
}

.errorlist {
    margin: var(--sp-2) 0 0;
    padding-left: var(--sp-5);
    font-size: var(--fs-13);
    color: var(--danger-ink);
    list-style: none;
}

.errorlist li::before {
    content: "•";
    margin-right: var(--sp-2);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"],
.field-error input,
.field-error textarea,
.field-error select {
    border-color: var(--danger-ink);
    background: #fffafa;
}

/* ── Карточки и панели ──────────────────────────────────── */
.card {
    min-width: 0;
    padding: var(--sp-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
    overflow-wrap: break-word;
}

.card + .card {
    margin-top: var(--sp-5);
}

/* Карточки — элементы сеток: вертикальный ритм задаёт gap сетки,
   а соседний margin-top сдвигал бы 2-ю/3-ю карточку ряда вниз. */
.home-grid > .card + .card,
.archive-grid > .card + .card,
.library-grid > .card + .card {
    margin-top: 0;
}

.card-flat {
    box-shadow: none;
}

.card-pad-sm {
    padding: var(--sp-4);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
    flex-wrap: wrap;
}

.card-head h2,
.card-head h3 {
    margin: 0;
}

.card-title {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-width: 0;
}

.card-title .icon {
    color: var(--accent-500);
}

.section-note {
    margin: 0 0 var(--sp-5);
    font-size: var(--fs-13);
    color: var(--text-muted);
}

.panel {
    padding: var(--sp-5);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

.callout {
    display: flex;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: var(--accent-soft);
    border: 1px solid var(--accent-200);
    border-left: 3px solid var(--accent-500);
    border-radius: var(--r-md);
    font-size: var(--fs-14);
    color: var(--accent-900);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
}

.callout > div,
.callout > span,
.callout > p {
    min-width: 0;
    max-width: 100%;
}

.callout .icon {
    color: var(--accent-600);
    margin-top: 2px;
}

.callout-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    border-left-color: var(--warning-ink);
    color: #5d4610;
}

.callout-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    border-left-color: var(--danger-ink);
    color: #7d2b20;
}

.callout-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    border-left-color: var(--info-ink);
    color: #3b3a6d;
}

/* ── Сообщения (django messages) ────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    margin-bottom: var(--sp-4);
    font-size: var(--fs-14);
    border: 1px solid transparent;
    border-radius: var(--r-md);
}

.alert .icon {
    margin-top: 1px;
}

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

.alert-error,
.alert-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-ink);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-ink);
}

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

/* ── Бейджи, чипы, теги ─────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    font-size: var(--fs-12);
    font-weight: 600;
    line-height: 1.7;
    color: var(--neutral-ink);
    background: var(--neutral-bg);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    white-space: nowrap;
}

/* Длинная подпись (например, режим и модель ИИ) переносится, а не растягивает страницу. */
.badge-wrap {
    white-space: normal;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.badge .icon {
    width: 13px;
    height: 13px;
    stroke-width: 2.2;
}

.badge-new {
    background: var(--st-new-bg);
    color: var(--st-new-ink);
}
.badge-submitted {
    background: var(--st-submitted-bg);
    color: var(--st-submitted-ink);
}
.badge-in_review {
    background: var(--st-in-review-bg);
    color: var(--st-in-review-ink);
}
.badge-needs_revision {
    background: var(--st-revision-bg);
    color: var(--st-revision-ink);
}
.badge-checked {
    background: var(--st-checked-bg);
    color: var(--st-checked-ink);
}
.badge-draft {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
}
.badge-accent {
    background: var(--accent-tint);
    color: var(--accent-800);
}
.badge-sand {
    background: var(--sand-100);
    color: var(--sand-800);
}
.badge-info {
    background: var(--info-bg);
    color: var(--info-ink);
}
.badge-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 4px 11px;
    font-size: var(--fs-13);
    font-weight: 550;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-pill);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition:
        color var(--dur-2) var(--ease),
        background var(--dur-2) var(--ease),
        border-color var(--dur-2) var(--ease);
}

/* Чип с длинным названием: текст переносится, иначе страница уезжает вбок на телефоне. */
.chip-wrap {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
}

.chip-wrap .icon {
    flex: 0 0 auto;
}

.chip:hover {
    color: var(--accent-800);
    border-color: var(--accent-300);
    background: var(--accent-soft);
}

.chip[aria-pressed="true"],
.chip.is-active {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

.chip .count {
    padding: 0 6px;
    font-size: var(--fs-11);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.55);
    border-radius: var(--r-pill);
}

.chip[aria-pressed="true"] .count,
.chip.is-active .count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    font-size: var(--fs-11);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    background: var(--canvas-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    white-space: nowrap;
}

.tag-skill {
    color: var(--info-ink);
    background: var(--info-bg);
    border-color: var(--info-border);
}

.tag-cefr {
    color: var(--sand-800);
    background: var(--sand-100);
    border-color: var(--sand-200);
    font-weight: 700;
}

/* ── Аватар ─────────────────────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    font-size: var(--fs-13);
    font-weight: 700;
    color: var(--accent-800);
    background: var(--accent-tint);
    border: 1px solid var(--accent-200);
    border-radius: var(--r-pill);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.avatar-lg {
    width: 44px;
    height: 44px;
    font-size: var(--fs-16);
}

/* ── Таблицы ────────────────────────────────────────────── */
.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: var(--fs-14);
}

.table-scroll table {
    min-width: 680px;
}

caption {
    padding: var(--sp-4) var(--sp-5);
    text-align: left;
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

th,
td {
    padding: var(--sp-4) var(--sp-5);
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
    word-break: normal;
    overflow-wrap: break-word;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-subtle);
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    transition: background var(--dur-1) var(--ease);
}

tbody tr:hover {
    background: var(--accent-soft);
}

tbody tr:last-child td {
    border-bottom: none;
}

td.numeric,
th.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Фильтры над таблицей: один ряд компактных селектов, без отдельной панели. */
.table-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.table-filter {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 0;
}

.table-filters label {
    font-size: var(--fs-12);
    font-weight: 600;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
}

.table-filters select {
    min-width: 160px;
    max-width: 260px;
    height: 36px;
    padding-block: 0;
    font-size: var(--fs-14);
}

/* Сортировка: заголовок целиком кликабелен, стрелка показывает направление. */
.th-sort {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.th-sort .icon {
    width: 14px;
    height: 14px;
    opacity: 0.35;
}

.th-sort:hover,
.th-sort:focus-visible {
    text-decoration: underline;
}

.th-sort:hover .icon,
.th-sort:focus-visible .icon,
.th-sort.is-active .icon {
    opacity: 1;
}

@media (max-width: 640px) {
    .table-filters select {
        min-width: 0;
        width: 100%;
    }

    .table-filter {
        flex: 1 1 100%;
    }
}

/* ── Утилиты форм ────────────────────────────────────────── */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.form-section {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-5);
    margin: 0 0 var(--sp-4);
    background: var(--surface-sunken);
}

.form-section legend {
    font-size: var(--fs-14);
    font-weight: 700;
    padding: 0 var(--sp-2);
    color: var(--text);
}

.form-row {
    display: flex;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.form-row > * {
    flex: 1 1 240px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    font-weight: 600;
    font-size: var(--fs-13);
    color: var(--text);
}

.form-help {
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.form-error {
    font-size: var(--fs-12);
    color: var(--danger-ink);
    font-weight: 600;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
}

/* У файлового инпута в Chrome фиксированная ширина: не даём ей распирать форму. */
input[type="file"] {
    max-width: 100%;
}

.btn-primary {
    --btn-bg: var(--accent);
    --btn-fg: var(--on-accent);
    --btn-border: transparent;
}

.btn-primary:hover {
    --btn-bg: var(--accent-hover);
    color: var(--on-accent);
}

.password-display {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.05em;
    background: var(--surface-sunken);
    color: var(--accent-800);
}

/* ── Списки-строки (вместо тяжёлых таблиц) ──────────────── */
.rows {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
}

.row-item {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-1);
    transition:
        border-color var(--dur-2) var(--ease),
        box-shadow var(--dur-2) var(--ease),
        transform var(--dur-2) var(--ease);
    min-width: 0;
}

.row-item:hover {
    border-color: var(--accent-300);
    box-shadow: var(--shadow-2);
}

.row-item.is-urgent {
    border-left: 3px solid var(--warning-ink);
}

.row-item.is-late {
    border-left: 3px solid var(--danger-ink);
}

.row-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.row-title {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    word-break: normal;
    overflow-wrap: break-word;
}

a.row-title:hover {
    color: var(--accent-800);
    text-decoration: underline;
}

.row-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    font-size: var(--fs-13);
    color: var(--text-muted);
}

.row-side {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex: 0 0 auto;
}

/* ── Вкладки и сегментированный переключатель ───────────── */
.tabs {
    display: flex;
    gap: var(--sp-1);
    padding: 3px;
    background: var(--canvas-alt);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 14px;
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background var(--dur-2) var(--ease),
        color var(--dur-2) var(--ease);
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.7);
}

.tab[aria-current="page"],
.tab[aria-selected="true"],
.tab.is-active {
    color: var(--accent-900);
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-1);
}

.tab .count {
    padding: 0 6px;
    font-size: var(--fs-11);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    background: var(--canvas-alt);
    border-radius: var(--r-pill);
}

.tab[aria-current="page"] .count {
    color: var(--accent-800);
    background: var(--accent-tint);
}

/* ── Хлебные крошки ─────────────────────────────────────── */
.crumbs {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin: 0 0 var(--sp-4);
    padding: 0;
    font-size: var(--fs-13);
    color: var(--text-muted);
    list-style: none;
    min-width: 0;
}

.crumbs li {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0;
    min-width: 0;
}

.crumbs a {
    color: var(--text-muted);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 34ch;
}

.crumbs a:hover {
    color: var(--accent-800);
    text-decoration: underline;
}

.crumbs .sep {
    color: var(--text-subtle);  /* aria-hidden, но видимый разделитель */
    flex: 0 0 auto;
}

.crumbs [aria-current="page"] {
    color: var(--text);
    font-weight: 600;
}

/* ── Прогресс ───────────────────────────────────────────── */
.progress {
    position: relative;
    height: 6px;
    background: var(--canvas-alt);
    border-radius: var(--r-pill);
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--accent-500);
    border-radius: var(--r-pill);
    transition: width var(--dur-3) var(--ease);
}

.progress-success > span {
    background: var(--success-ink);
}
.progress-warning > span {
    background: var(--warning-ink);
}
.progress-sand > span {
    background: var(--sand-300);
}
.progress-danger > span {
    background: var(--danger-ink);
}

.skill-row {
    margin-bottom: 12px;
}

.skill-row:last-of-type {
    margin-bottom: 0;
}

.skill-meta {
    margin-top: 4px;
    margin-bottom: 0;
}

.progress-lg {
    height: 10px;
}

.ring {
    --value: 0;
    --size: 56px;
    --thick: 6px;
    width: var(--size);
    height: var(--size);
    flex: 0 0 auto;
    border-radius: 50%;
    background:
        conic-gradient(
            var(--accent-500) calc(var(--value) * 1%),
            var(--canvas-alt) calc(var(--value) * 1%)
        );
    display: grid;
    place-items: center;
    position: relative;
}

.ring::after {
    content: "";
    position: absolute;
    inset: var(--thick);
    background: var(--surface);
    border-radius: 50%;
}

.ring > span {
    position: relative;
    z-index: 1;
    font-size: var(--fs-12);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent-800);
}

/* ── Статистика ─────────────────────────────────────────── */
.stats {
    display: grid;
    gap: var(--sp-4);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
}

.stat {
    padding: var(--sp-4) var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-1);
}

.stat-value {
    font-size: var(--fs-24);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: var(--tracking-tight);
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.stat-label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-1);
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.stat-accent .stat-value {
    color: var(--accent-700);
}
.stat-warning .stat-value {
    color: var(--warning-ink);
}
.stat-danger .stat-value {
    color: var(--danger-ink);
}
.stat-success .stat-value {
    color: var(--success-ink);
}

/* ── Дерево курса ───────────────────────────────────────── */
.tree {
    --indent: 16px;
    min-width: 0;
}

.tree ul {
    margin: 0;
    padding: 0 0 0 var(--indent);
    list-style: none;
    border-left: 1px solid var(--border);
    margin-left: 11px;
}

.tree > ul {
    border-left: 0;
    margin-left: 0;
    padding-left: 0;
}

.tree li {
    margin: 0;
    position: relative;
}

.tree-node {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 6px var(--sp-3);
    border-radius: var(--r-md);
    min-width: 0;
    transition: background var(--dur-1) var(--ease);
}

.tree-node:hover {
    background: var(--accent-soft);
}

.tree-node.is-current {
    background: var(--accent-tint);
    box-shadow: inset 2px 0 0 var(--accent-600);
}

.tree-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
}

.tree-caret:hover {
    color: var(--accent-800);
    background: rgba(255, 255, 255, 0.8);
}

.tree-caret .icon {
    width: 14px;
    height: 14px;
    transition: transform var(--dur-2) var(--ease);
}

.tree-node[aria-expanded="false"] .tree-caret .icon {
    transform: rotate(-90deg);
}

.tree-caret-placeholder {
    width: 20px;
    flex: 0 0 auto;
}

.tree-icon {
    color: var(--accent-500);
    flex: 0 0 auto;
}

.tree-link {
    flex: 1 1 auto;
    min-width: 0;
    font-size: var(--fs-14);
    font-weight: 550;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-link:hover {
    color: var(--accent-800);
    text-decoration: underline;
}

.tree-link.is-draft {
    color: var(--text-muted);
    font-style: italic;
}

.tree-side {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex: 0 0 auto;
    font-size: var(--fs-11);
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
}

.tree-progress {
    width: 44px;
}

.tree-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--dur-2) var(--ease);
}

.tree-node:hover .tree-actions,
.tree-node:focus-within .tree-actions {
    opacity: 1;
}

.tree-actions .icon-btn {
    width: 26px;
    height: 26px;
}

.tree-empty {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-13);
    color: var(--text-subtle);
}

/* ── Пустые состояния ───────────────────────────────────── */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-9) var(--sp-6);
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    color: var(--accent-500);
    background: var(--accent-soft);
    border: 1px solid var(--accent-100);
    border-radius: var(--r-lg);
}

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

.empty p {
    max-width: 46ch;
    margin: 0;
    font-size: var(--fs-14);
}

/* ── Пагинация ──────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin: var(--sp-5) 0 0;
    font-size: var(--fs-13);
    color: var(--text-muted);
}

.pagination a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    text-decoration: none;
    font-weight: 600;
}

.pagination a:hover {
    border-color: var(--accent-300);
    background: var(--accent-soft);
    color: var(--accent-800);
}

.pagination [aria-current="page"] {
    font-variant-numeric: tabular-nums;
}

/* ── Поиск и тулбар ─────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    min-width: 0;
}

.search {
    position: relative;
    flex: 1 1 240px;
    min-width: 180px;
}

.search .icon {
    position: absolute;
    top: 50%;
    left: 11px;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
}

.search input {
    padding-left: 34px;
}

.filters {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .form-field {
    margin: 0;
    min-width: 160px;
}

/* ── Скелетоны и спиннеры ───────────────────────────────── */
.skeleton {
    height: 12px;
    background: linear-gradient(90deg, var(--canvas-alt) 25%, var(--surface-sunken) 50%, var(--canvas-alt) 75%);
    background-size: 200% 100%;
    border-radius: var(--r-sm);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-200);
    border-top-color: var(--accent-600);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
}

/* ── Таймлайн истории ───────────────────────────────────── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    position: relative;
    display: flex;
    gap: var(--sp-4);
    margin: 0;
    padding: 0 0 var(--sp-5) var(--sp-6);
    border-left: 1px solid var(--border);
}

.timeline li:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.timeline li::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 4px;
    width: 9px;
    height: 9px;
    background: var(--surface);
    border: 2px solid var(--accent-400);
    border-radius: 50%;
}

.timeline-time {
    flex: 0 0 auto;
    font-size: var(--fs-12);
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
    min-width: 96px;
}

.timeline-body {
    min-width: 0;
    font-size: var(--fs-14);
}

/* ── Попытки/карточки ответа ────────────────────────────── */
.attempt {
    padding: var(--sp-5) 0;
    border-top: 1px solid var(--border-subtle);
}

.attempt:first-child {
    border-top: 0;
    padding-top: 0;
}

.attempt-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

.attempt pre {
    margin: var(--sp-3) 0;
}

.grade-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    padding: 3px 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: var(--success-bg);
    color: var(--success-ink);
    border: 1px solid var(--success-border);
    border-radius: var(--r-pill);
}

.grade-pill.is-low {
    background: var(--danger-bg);
    color: var(--danger-ink);
    border-color: var(--danger-border);
}

.grade-pill.is-mid {
    background: var(--warning-bg);
    color: var(--warning-ink);
    border-color: var(--warning-border);
}

/* Балл читается тем же цветом, что и оценка: полупрозрачность роняла контраст. */
.grade-pill small {
    font-weight: 600;
    color: inherit;
}

/* На песочном тинте базовый янтарный тон не добирает 4.5:1 для мелкого текста. */
.grade-pill.is-mid {
    color: #6b4e0d;
}

/* ── Медиа ──────────────────────────────────────────────── */
.media-frame {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.media-frame img {
    display: block;
    max-height: 420px;
    width: auto;
    margin: 0 auto;
    border-radius: var(--r-sm);
    background: #fff;
}

audio {
    width: 100%;
    height: 40px;
}

/* ── Модальные окна и шторки ────────────────────────────── */
.drawer {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: var(--z-drawer);
    width: min(460px, 100%);
    padding: var(--sp-6);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-3);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--dur-3) var(--ease);
}

.drawer.is-open {
    transform: none;
}

.backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: rgba(42, 46, 53, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-3) var(--ease);
}

.backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Прочее ─────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: var(--sp-5) 0;
    border: 0;
}

.pill-note {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 3px 10px;
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--canvas-alt);
    border-radius: var(--r-pill);
}

.inline-form {
    display: inline;
}

.login-card {
    max-width: 420px;
    margin: 8vh auto;
    padding: var(--sp-8);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0 auto var(--sp-5);
    color: var(--accent-700);
    background: var(--accent-tint);
    border: 1px solid var(--accent-200);
    border-radius: var(--r-lg);
}

/* ── Дополнения интерфейса преподавателя и тренажёра ─────────────────────── */
.login-card h1 {
    margin-bottom: var(--sp-2);
    text-align: center;
}

.alert.is-fading {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.btn.icon-only {
    padding-inline: 8px;
}

.btn-danger-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--danger-ink);
}

.btn-danger-ghost:hover,
.btn-danger-ghost:focus-visible {
    background: color-mix(in srgb, var(--danger-ink) 8%, transparent);
    border-color: color-mix(in srgb, var(--danger-ink) 40%, var(--border));
}

.check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 0;
    font-size: var(--fs-14);
    line-height: 1.45;
    cursor: pointer;
}

.check input {
    margin-top: 2px;
    flex: 0 0 auto;
}

.is-correct {
    color: var(--success-ink);
    font-weight: 600;
}

.def-list {
    display: grid;
    grid-template-columns: minmax(96px, 38%) 1fr;
    gap: 6px 12px;
    margin: 0;
    font-size: var(--fs-14);
}

.def-list dt {
    color: var(--text-muted);
}

.def-list dd {
    margin: 0;
    overflow-wrap: break-word;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
    gap: 12px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.grade-pill-muted {
    background: var(--surface-sunken);
    color: var(--text-muted);
    border-color: var(--border);
}

table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    min-width: 180px;
    text-align: left;
}

table thead .sticky-col {
    background: var(--surface-sunken);
    z-index: 2;
}

table .grade-col {
    min-width: 92px;
    text-align: center;
    white-space: nowrap;
}

.block-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: var(--r-sm);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    color: var(--accent-800);
    font-size: var(--fs-13);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.draft-excerpt {
    margin: 8px 0 0;
    padding: 8px 10px;
    border-left: 3px solid var(--accent-200);
    background: var(--surface-sunken);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    overflow-wrap: break-word;
}

/* Короткий комментарий преподавателя в списках результатов. */
.feedback-note {
    margin-top: 4px;
    overflow-wrap: break-word;
}

/* ── Формы: заголовки секций и обязательные поля ─────────── */
.section-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-4);
    font-size: var(--fs-16);
    font-weight: 650;
    color: var(--text);
}

.section-title .icon {
    width: 16px;
    height: 16px;
    color: var(--accent-700);
}

.required {
    color: var(--danger-ink);
}

/* Список внутри боковой карточки: плотный, без лишних отступов. */
.rail-list {
    margin: 0;
    padding-left: var(--sp-5);
}

.deadline-shortcuts {
    margin-top: var(--sp-2);
}

/* ── Библиотека шаблонов: быстрые заготовки заданий ─────── */
.preset-grid {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
}

.preset-card {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4);
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition:
        border-color var(--dur-2) var(--ease),
        box-shadow var(--dur-2) var(--ease),
        background var(--dur-2) var(--ease);
}

.preset-card:hover {
    border-color: var(--accent-300);
    box-shadow: var(--shadow-2);
}

.preset-card[aria-pressed="true"] {
    border-color: var(--accent-600);
    background: var(--accent-soft);
}

.preset-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    color: var(--accent-800);
    background: var(--accent-100);
    border-radius: var(--r-sm);
}

.preset-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.preset-label {
    font-size: var(--fs-14);
    font-weight: 650;
    color: var(--text);
}

.preset-tagline {
    font-size: var(--fs-12);
    color: var(--text-muted);
}

/* Заголовок группы шаблонов: уровень CEFR или экзамен. */
.preset-topic {
    margin: var(--sp-5) 0 var(--sp-3);
    font-size: var(--fs-13);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-subtle);
}

.preset-topic:first-of-type {
    margin-top: var(--sp-3);
}

.preset-meta {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-top: var(--sp-1);
}

/* Фильтр библиотеки шаблонов по уровню: чипсы, без JS всё видно. */
.level-filter {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

/* Строки выбора шаблона на странице карточек: просмотр + импорт. */
.preset-pick-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-2);
    padding: 0;
    list-style: none;
}

.preset-pick {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}

.preset-pick:hover {
    border-color: var(--accent-300);
    background: var(--accent-soft);
}

.preset-pick .preset-text {
    flex: 1 1 auto;
}

.preset-pick-actions {
    display: flex;
    gap: var(--sp-2);
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 620px) {
    .preset-pick {
        flex-wrap: wrap;
    }
    .preset-pick-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ── Готовые формулировки блоков и тем ──────────────────── */
.suggestion-list {
    gap: var(--sp-2);
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.suggestion {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-3);
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}

.suggestion:hover {
    border-color: var(--accent-300);
    background: var(--accent-soft);
}

.suggestion[aria-pressed="true"] {
    border-color: var(--accent-600);
    background: var(--accent-soft);
}

.suggestion-label {
    font-size: var(--fs-13);
    font-weight: 650;
}

.suggestion-note {
    font-size: var(--fs-12);
    color: var(--text-muted);
}

/* ── Библиотека курсов ──────────────────────────────────── */
.library-grid {
    display: grid;
    gap: var(--sp-5);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
    align-items: start;
}

.library-card .stats {
    margin-bottom: var(--sp-4);
}

.library-details {
    border-top: 1px solid var(--border-subtle);
    padding-top: var(--sp-4);
}

.library-details summary {
    cursor: pointer;
    font-size: var(--fs-13);
    font-weight: 650;
    color: var(--accent-800);
}

/* ── Доска заданий по теме: панели и свернутый список ────── */
.topic-tools {
    padding: 0;
    overflow: hidden;
}

.topic-tools__summary {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 52px;
    padding: var(--sp-3) var(--sp-5);
    list-style: none;
    cursor: pointer;
    color: var(--text);
}

.topic-tools__summary::-webkit-details-marker {
    display: none;
}

.topic-tools__summary:hover {
    background: var(--canvas-alt);
}

.topic-tools__summary:focus-visible,
.assignment-row:focus-visible {
    outline: 3px solid var(--accent-600);
    outline-offset: -3px;
}

.topic-tools__summary-title {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 700;
}

.topic-tools__summary-title .icon {
    color: var(--accent-600);
}

.topic-tools__summary-hint {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.topic-tools__chevron {
    flex: 0 0 auto;
    color: var(--text-muted);
    transition: transform var(--dur-2) var(--ease);
}

.topic-tools[open] > .topic-tools__summary {
    border-bottom: 1px solid var(--border-subtle);
}

.topic-tools[open] .topic-tools__chevron {
    transform: rotate(180deg);
}

.topic-tools__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: var(--sp-3);
    padding: var(--sp-4);
}

.topic-tools__section {
    min-width: 0;
    padding: var(--sp-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    background: var(--surface-sunken);
}

.topic-tools__section .rail-title {
    margin-bottom: var(--sp-3);
}

.assignment-list {
    gap: var(--sp-3);
}

.assignment-list > .assignment-accordion + .assignment-accordion {
    margin-top: 0;
}

.assignment-accordion {
    padding: 0;
    overflow: hidden;
}

.assignment-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 58px;
    padding: var(--sp-3) var(--sp-5);
    list-style: none;
    cursor: pointer;
}

.assignment-row::-webkit-details-marker {
    display: none;
}

.assignment-row:hover {
    background: var(--canvas-alt);
}

.assignment-row__chevron {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--text-muted);
    transition: transform var(--dur-2) var(--ease);
}

.assignment-accordion[open] > .assignment-row {
    border-bottom: 1px solid var(--border-subtle);
}

.assignment-accordion[open] > .assignment-row .assignment-row__chevron {
    transform: rotate(90deg);
    color: var(--accent-600);
}

.assignment-row__title {
    flex: 1 1 auto;
    min-width: 12ch;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.assignment-accordion__body {
    padding: var(--sp-5);
}

.assignment-accordion__body > .card-head:first-child {
    margin-top: 0;
}

@media (max-width: 560px) {
    .topic-tools__summary {
        gap: var(--sp-2);
        padding-inline: var(--sp-4);
    }

    .topic-tools__summary-hint {
        display: none;
    }

    .assignment-row {
        flex-wrap: wrap;
        gap: var(--sp-2);
        padding-inline: var(--sp-4);
    }

    .assignment-row__title {
        flex-basis: calc(100% - 32px);
    }

    .assignment-accordion__body {
        padding: var(--sp-4);
    }
}

.library-toc {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}

.library-block-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-2);
    font-size: var(--fs-13);
    font-weight: 650;
    color: var(--text);
}

.library-toc ul {
    margin: 0;
    padding-left: var(--sp-5);
}

.library-item {
    display: flex;
    align-items: baseline;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

/* Список без маркеров и отступов: интервал задаёт сам контейнер (.col/.rows). */
.list-plain {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ── Карточки курса: обложка, метаданные, быстрые действия ── */
.classes-head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-5);
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
}

.classes-title {
    margin: 0;
    font-size: var(--fs-24);
    letter-spacing: var(--tracking-tight);
}

.classes-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: center;
}

.search-pill {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-width: min(100%, 320px);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-1);
    transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.search-pill:focus-within {
    border-color: var(--accent-300);
    box-shadow: var(--ring);
}

.search-pill input {
    border: 0;
    padding: 0;
    min-height: auto;
    background: transparent;
    box-shadow: none;
    outline: 0;
}

.search-pill .icon {
    color: var(--text-subtle);
    flex: 0 0 auto;
}

.filter-pills {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    align-items: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--dur-2) var(--ease);
}

.pill:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--canvas-alt);
}

.pill.is-active,
.pill[aria-current="page"] {
    color: var(--accent-900);
    background: var(--accent-tint);
    border-color: var(--accent-200);
}

.pill.is-active.turquoise {
    color: var(--turquoise-ink);
    background: var(--turquoise-bg);
    border-color: var(--turquoise-100);
}

.class-grid {
    display: grid;
    gap: var(--sp-5);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

.class-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
    text-decoration: none;
    color: inherit;
}

.class-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
    border-color: var(--border-strong);
}

.class-card:focus-visible {
    outline: 0;
    box-shadow: var(--ring), var(--shadow-2);
}

.class-cover {
    position: relative;
    aspect-ratio: 16 / 10;
    display: grid;
    place-items: center;
    padding: var(--sp-5);
    overflow: hidden;
    background: var(--cover-1);
    isolation: isolate;
}

.class-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(120% 80% at 30% 20%, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0) 55%);
    pointer-events: none;
}

.class-cover-emoji {
    font-size: 3rem;
    line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.08));
    z-index: 1;
}

/* Обложка курса (parts/cover.html): сцена по теме + плашка с названием.
   Свои курсы всегда показывают название и инициалы на цветном фоне. */
.cover-scene {
    font-size: 2.75rem;
    line-height: 1;
    z-index: 1;
    transform: translateY(-10px);
    filter: drop-shadow(0 3px 10px rgba(38, 55, 44, 0.18));
}

.cover-plate {
    position: absolute;
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-1);
    z-index: 1;
}

.cover-initials {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    font-size: var(--fs-12);
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--accent-700);
    border-radius: 50%;
}

.cover-words {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cover-name {
    font-size: var(--fs-13);
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cover-tag {
    font-size: var(--fs-11);
    font-weight: 600;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Тематические акценты обложки: бейдж инициалов + кромка плашки.
   Белый текст на тёмном бейдже держит AA (проверено: 5.8–9.5:1). */
.cover-theme-travel .cover-initials { background: #1e6e68; }
.cover-theme-travel .cover-plate { border-left: 4px solid #63c3bc; }
.cover-theme-movie .cover-initials { background: #4a3f6b; }
.cover-theme-movie .cover-plate { border-left: 4px solid #9a8fc4; }
.cover-theme-business .cover-initials { background: #3d4b5c; }
.cover-theme-business .cover-plate { border-left: 4px solid #8fa3b8; }
.cover-theme-exam .cover-initials { background: #7a3b2e; }
.cover-theme-exam .cover-plate { border-left: 4px solid #d08a7a; }
.cover-theme-ielts .cover-initials { background: #3f5a47; }
.cover-theme-ielts .cover-plate { border-left: 4px solid #a6c3aa; }
.cover-theme-it .cover-initials { background: #2f4a7a; }
.cover-theme-it .cover-plate { border-left: 4px solid #7f9cd4; }
.cover-theme-kids .cover-initials { background: #8a5a2b; }
.cover-theme-kids .cover-plate { border-left: 4px solid #d9a75f; }
.cover-theme-teens .cover-initials { background: #5c4d8a; }
.cover-theme-teens .cover-plate { border-left: 4px solid #a394d4; }
.cover-theme-happy .cover-initials { background: #7a5c10; }
.cover-theme-happy .cover-plate { border-left: 4px solid #d9b95f; }
.cover-theme-grammar .cover-initials { background: #2f6b45; }
.cover-theme-grammar .cover-plate { border-left: 4px solid #8fc0a0; }

.class-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.class-cover .badge {
    position: absolute;
    top: var(--sp-3);
    right: var(--sp-3);
    z-index: 2;
}

.class-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-5);
    flex: 1;
}

.class-title {
    margin: 0;
    font-size: var(--fs-16);
    font-weight: 700;
    line-height: var(--lh-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.class-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    align-items: center;
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.class-foot {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: auto;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--fs-12);
    color: var(--text-subtle);
}

.class-avatars {
    display: flex;
    margin-left: 2px;
}

.class-avatars .avatar {
    width: 22px;
    height: 22px;
    font-size: 10px;
    border: 2px solid var(--surface);
    margin-left: -6px;
}

.class-avatars .avatar:first-child {
    margin-left: 0;
}

/* Создание карточки — пунктирная рамка-приглашение */
.class-card.is-create {
    border-style: dashed;
    border-width: 1.5px;
    background: var(--canvas);
    justify-content: center;
    align-items: center;
    min-height: 220px;
    color: var(--turquoise-ink);
}

.class-card.is-create:hover {
    background: var(--turquoise-bg);
    border-color: var(--turquoise-200);
}

.class-card.is-create .icon {
    width: 28px;
    height: 28px;
    color: var(--turquoise-ink);
}

/* ── Урок: секции с шагами занятия ───────────────────────── */
.lesson-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--sp-6);
    align-items: start;
}

.lesson-main {
    min-width: 0;
}

.lesson-side {
    position: sticky;
    top: calc(var(--topbar-h) + var(--sp-5));
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    max-height: calc(100vh - var(--topbar-h) - var(--sp-6));
    overflow: auto;
}

.lesson-video-box {
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
    background: var(--surface-sunken);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-lg);
    color: var(--text-subtle);
    font-size: var(--fs-13);
    text-align: center;
    padding: var(--sp-5);
}

.lesson-sections {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
}

.lesson-sections-title {
    margin: 0 0 var(--sp-3);
    font-size: var(--fs-13);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-subtle);
}

.lesson-section {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-3);
    border-radius: var(--r-md);
    font-size: var(--fs-14);
    color: var(--text-muted);
    text-decoration: none;
    transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}

.lesson-section:hover {
    background: var(--canvas-alt);
    color: var(--text);
}

.lesson-section.is-active {
    background: var(--turquoise-bg);
    color: var(--turquoise-ink);
    font-weight: 650;
}

.lesson-section.is-active::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--turquoise);
    flex: 0 0 auto;
}

.lesson-section .icon {
    width: 16px;
    height: 16px;
}

/* ── Упражнения: новые типы ─────────────────────────────── */
.ex {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.ex + .ex {
    margin-top: var(--sp-4);
}

.ex:hover {
    border-color: var(--border-strong);
}

.ex-head {
    display: flex;
    gap: var(--sp-4);
    padding: var(--sp-5) var(--sp-5) var(--sp-3);
    border-bottom: 1px solid var(--border-subtle);
}

.ex-num {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    font-size: var(--fs-12);
    font-weight: 700;
    color: var(--turquoise-ink);
    background: var(--turquoise-bg);
    border-radius: 50%;
}

.ex-head-main {
    min-width: 0;
    flex: 1;
}

.ex-title {
    font-size: var(--fs-15);
    font-weight: 600;
    line-height: var(--lh);
}

.ex-meta {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    margin-top: var(--sp-2);
}

.ex-body {
    padding: var(--sp-5);
}

.opts {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.opt {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all var(--dur-2) var(--ease);
    font-size: var(--fs-14);
}

.opt:hover {
    background: var(--accent-soft);
    border-color: var(--accent-200);
}

.opt:has(input:checked) {
    background: var(--accent-tint);
    border-color: var(--accent-300);
    color: var(--accent-900);
}

.opt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.opt-mark {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: 50%;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    transition: all var(--dur-2) var(--ease);
}

.opt:has(input[type="checkbox"]) .opt-mark {
    border-radius: var(--r-xs);
}

.opt:has(input:checked) .opt-mark {
    background: var(--accent-700);
    border-color: var(--accent-700);
    color: #fff;
}

.opt:has(input:checked) .opt-mark::after {
    content: "";
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
}

.tiles {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}

.tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 6px 14px;
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-pill);
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: all var(--dur-2) var(--ease);
    user-select: none;
}

.tile:hover {
    border-color: var(--turquoise-300);
    background: var(--turquoise-bg);
    transform: translateY(-1px);
}

.tile.is-used {
    opacity: 0.35;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

.tile.is-letter {
    min-width: 40px;
    font-variant-caps: all-small-caps;
}

.slot-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    min-height: 44px;
    padding: var(--sp-3);
    background: var(--canvas-alt);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-4);
}

.slot-row:empty::before {
    content: "Нажмите на слова по порядку";
    color: var(--text-subtle);
    font-size: var(--fs-13);
}

.slot-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    font-size: var(--fs-13);
    font-weight: 600;
    box-shadow: var(--shadow-1);
}

.slot-chip button {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: var(--text-subtle);
    line-height: 1;
}

/* ── Словарь: личный кабинет слов ───────────────────────── */
.dict-grid {
    display: grid;
    gap: var(--sp-5);
    grid-template-columns: minmax(0, 1fr) 320px;
}

.dict-words {
    display: grid;
    gap: var(--sp-3);
}

.word-row {
    display: flex;
    gap: var(--sp-4);
    align-items: flex-start;
    padding: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    transition: border-color var(--dur-2) var(--ease);
}

.word-row:hover {
    border-color: var(--border-strong);
}

.word-main {
    flex: 1;
    min-width: 0;
}

.word-term {
    font-weight: 700;
    font-size: var(--fs-15);
}

.word-translation {
    color: var(--text-muted);
    font-size: var(--fs-14);
}

.word-example {
    margin-top: var(--sp-2);
    font-size: var(--fs-13);
    color: var(--text-subtle);
    font-style: italic;
}

.word-side {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex: 0 0 auto;
}

/* ── Таймлайн урока / прогресс-чипсы ────────────────────── */
.progress-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all var(--dur-2) var(--ease);
}

.progress-dot.is-done {
    background: var(--success-ink);
}

.progress-dot.is-current {
    width: 22px;
    border-radius: var(--r-pill);
    background: var(--turquoise);
}

/* ── Пустое состояние с иллюстрацией ────────────────────── */
.empty-ill {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    margin: 0 auto var(--sp-4);
    background: var(--cover-1);
    border-radius: var(--r-xl);
    font-size: 2.2rem;
}

/* ── Бейджи: дополнительные ─────────────────────────────── */
.badge-turquoise {
    color: var(--turquoise-ink);
    background: var(--turquoise-bg);
    border: 1px solid var(--turquoise-100);
}

.tag-cefr {
    background: var(--sand-100);
    color: var(--sand-800);
    border: 1px solid var(--sand-200);
}

/* ── Адаптив новых компонентов ──────────────────────────── */
@media (max-width: 960px) {
    .lesson-shell,
    .dict-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .lesson-side {
        position: static;
        max-height: none;
        overflow: visible;
        order: -1;
    }
    .class-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    }
}

@media (max-width: 620px) {
    .classes-head {
        flex-direction: column;
        align-items: stretch;
    }
    .search-pill {
        min-width: 0;
        width: 100%;
    }
    .class-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--sp-3);
    }
    .class-body {
        padding: var(--sp-4);
    }
}

/* ── Login split — responsive, no overflow at 320px ────── */
.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 32px;
    align-items: start;
    max-width: 1080px;
    margin: 0 auto;
    min-width: 0;
}

.login-promo {
    min-width: 0;
}

.login-promo-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

@media (max-width: 900px) {
    .login-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .login-card {
        max-width: none;
        margin: 0;
    }
}

@media (max-width: 620px) {
    .login-layout {
        gap: var(--sp-4);
    }
    .login-promo {
        padding: var(--sp-5) !important;
    }
    .login-card {
        padding: var(--sp-5);
    }
}

/* ── Карточки типа задания и чипы навыков ───────────────── */
.type-cards > div,
.type-cards #id_assignment_type {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.type-cards div {
    margin: 0;
}

.type-cards label {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    margin: 0;
    padding: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    font-weight: 650;
    line-height: 1.3;
}

.type-cards label:hover {
    border-color: var(--accent-300);
    background: var(--accent-soft);
}

.type-cards label:has(input:checked) {
    border-color: var(--accent-600);
    background: var(--accent-soft);
    box-shadow: var(--shadow-1);
}

.type-cards input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

#id_skills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

#id_skills > div {
    margin: 0;
}

#id_skills label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    font-weight: 550;
}

#id_skills label:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent-400);
    color: var(--accent-900);
}

.search-pill {
    position: relative;
}

.suggest-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    max-height: 280px;
    overflow-y: auto;
}

.suggest-list[hidden] {
    display: none;
}

.suggest-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 8px 10px;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    font: inherit;
    color: var(--text);
}

.suggest-item:hover,
.suggest-item.is-active {
    background: var(--accent-soft);
}

.suggest-item-label {
    font-size: var(--fs-14);
    font-weight: 650;
}

.suggest-item-hint {
    font-size: var(--fs-12);
    color: var(--text-muted);
}


/* ── Переключатель языка RU|ENG ─────────────────────────── */
.lang-switch {
    display: inline-flex;
    align-items: center;
    padding: 2px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
}

.lang-switch-option {
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-size: var(--fs-11);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.35;
}

.lang-switch-option:hover {
    color: var(--accent-800);
    background: var(--accent-soft);
}

.lang-switch-option.is-active {
    background: var(--accent-700);
    color: var(--text-inverse);
}

.lang-switch-option:focus-visible {
    outline: 2px solid var(--accent-600);
    outline-offset: 2px;
}

@media (max-width: 720px) {
    .lang-switch-option {
        padding: 4px 8px;
        letter-spacing: 0;
    }
}

@media (max-width: 460px) {
    .lang-switch {
        padding: 1px;
    }
    .lang-switch-option {
        padding: 3px 6px;
    }
}

.lang-switch-compact {
    background: transparent;
    border-color: transparent;
}

.mobile-nav-lang {
    display: flex;
    justify-content: center;
    padding: var(--sp-3) 0;
}

.mobile-nav-lang .lang-switch {
    background: var(--surface);
}

/* ── Приём файлов перетаскиванием ───────────────────────── */
.dropzone {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-sunken) 100%);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
    /* Адаптируемся к ширине самого блока, а не окна: одна и та же зона живёт
       и в широкой форме, и в узкой боковой колонке проверки (320px). */
    container-type: inline-size;
}

.dropzone-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
}

/* Узкий контейнер (боковая колонка проверки, телефон): иконка и текст сверху,
   кнопки — отдельной строкой на всю ширину, чтобы ничего не «сбивалось». */
@container (max-width: 360px) {
    .dropzone-actions {
        flex: 1 1 100%;
    }
    .dropzone-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

.dropzone:hover {
    border-color: var(--accent-400);
    background: var(--accent-50);
}

.dropzone:focus-visible {
    outline: 2px solid var(--accent-600);
    outline-offset: 2px;
}

.dropzone.is-dragging {
    border-color: var(--accent-600);
    border-style: solid;
    background: var(--accent-100);
    transform: scale(1.005);
}

.dropzone-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: var(--r-md);
    background: var(--accent-100);
    color: var(--accent-700);
}

.dropzone-body {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
}

.dropzone-title {
    display: block;
    margin: 0;
    font-size: var(--fs-14);
    font-weight: 650;
    color: var(--text);
}

.dropzone-hint {
    display: block;
    margin: 2px 0 0;
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.dropzone-file {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 0;
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--accent-800);
    word-break: break-all;
}

.dropzone-size {
    font-weight: 500;
    color: var(--text-muted);
}

.dropzone-error {
    display: block;
    margin: 6px 0 0;
    font-size: var(--fs-12);
    font-weight: 600;
    color: var(--danger-ink);
}

/* Поле файла внутри зоны: фокус с клавиатуры подсвечивает всю зону. */
.dropzone:focus-within {
    outline: 2px solid var(--accent-600);
    outline-offset: 2px;
}

/* Короткая подсветка: видно, что Ctrl+V сработал именно в этой зоне. */
.dropzone.is-pasted {
    border-color: var(--accent-600);
    border-style: solid;
    background: var(--accent-100);
}

.dropzone.is-filled {
    border-style: solid;
    border-color: var(--accent-300);
    background: var(--accent-50);
}

.dropzone-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Опасная зона: удаление с содержимым ────────────────── */
.danger-zone {
    position: relative;
}

.danger-zone > summary {
    list-style: none;
    cursor: pointer;
}

.danger-zone > summary::-webkit-details-marker {
    display: none;
}

.danger-zone[open] > summary {
    background: color-mix(in srgb, var(--danger-ink) 8%, transparent);
    border-color: color-mix(in srgb, var(--danger-ink) 40%, var(--border));
}

.danger-panel {
    position: absolute;
    right: 0;
    z-index: 20;
    width: min(340px, 88vw);
    margin-top: 6px;
    display: grid;
    gap: 8px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-3);
}

/* layout.css задаёт .panel { max-width: 100% } — для абсолютной панели это ширина
   крошечной кнопки-summary, и текст схлопывался в нечитаемый столбик. */
.danger-zone > .danger-panel {
    max-width: none;
    padding: var(--sp-4);
}

.danger-panel .row {
    margin: 0;
}

.upload-block {
    padding: var(--sp-4);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

.upload-block > label {
    display: block;
    margin-bottom: var(--sp-3);
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
}

.upload-block .help-text {
    margin-top: var(--sp-3);
}

/* ── Редактор «Условия задания»: большой, но не на весь экран ── */
.editor-block {
    display: grid;
    gap: var(--sp-3);
    padding: var(--sp-4);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    transition: box-shadow 140ms ease, background 140ms ease;
}

.editor-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
}

.editor-head label {
    margin: 0;
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.editor-block textarea {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: var(--fs-13);
    line-height: 1.65;
    min-height: 220px;
    resize: vertical;
}

.editor-block.is-expanded {
    grid-column: 1 / -1;
    position: relative;
    z-index: 6;
    background: var(--surface);
    box-shadow: var(--shadow-3);
    border-color: var(--accent-300);
}

.editor-block.is-expanded textarea {
    min-height: min(62vh, 620px);
    font-size: var(--fs-14);
}

.editor-note {
    margin: 0;
}

/* ── Пошаговая проверка пунктов: «Принять» → ✓ / ✗ ─────────── */
.quiz-items {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    margin-top: var(--sp-4);
}

.quiz-items .ex + .ex {
    margin-top: 0;
}

.item {
    border-left: 4px solid var(--border);
    scroll-margin-top: calc(var(--topbar-h) + var(--sp-4));
}

.item-correct {
    border-color: var(--success-border);
    border-left-color: var(--success-ink);
}

.item-failed,
.item-wrong {
    border-color: var(--danger-border);
    border-left-color: var(--danger-ink);
}

.item-answered {
    border-left-color: var(--info-ink);
}

.item-correct .ex-num {
    color: var(--on-accent);
    background: var(--success-ink);
}

.item-failed .ex-num {
    color: var(--on-accent);
    background: var(--danger-ink);
}

.item-answered .ex-num {
    color: var(--info-ink);
    background: var(--info-bg);
}

.item-mark {
    flex: 0 0 auto;
    align-self: center;
}

.mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.mark .icon {
    width: 22px;
    height: 22px;
    stroke-width: 3;
}

.mark-ok {
    color: var(--on-accent);
    background: var(--success-ink);
}

.mark-bad {
    color: var(--on-accent);
    background: var(--danger-ink);
}

.mark-soft {
    color: var(--danger-ink);
    background: var(--danger-bg);
}

.item-feedback:empty {
    display: none;
}

.item-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-3);
    font-size: var(--fs-14);
    border-radius: var(--r-md);
    outline: none;
}

.item-note-ok {
    color: var(--success-ink);
    background: var(--success-bg);
}

.item-note-bad {
    color: var(--danger-ink);
    background: var(--danger-bg);
}

.item-note-warn {
    color: var(--warning-ink);
    background: var(--warning-bg);
}

.item-note-info {
    color: var(--info-ink);
    background: var(--info-bg);
}

.item-expected strong {
    color: var(--success-ink);
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
}

.item-wrong .item-actions .btn {
    --btn-bg: var(--danger-ink);
}

.opt-tried {
    border-style: dashed;
    color: var(--text-muted);
}

.opt-tried > span:nth-of-type(2) {
    text-decoration: line-through;
}

.opt-tried-note {
    margin-left: auto;
    color: var(--danger-ink);
}

tr.row-ok td:first-child {
    box-shadow: inset 3px 0 0 var(--success-ink);
}

tr.row-bad td {
    background: var(--danger-bg);
}

tr.row-bad td:first-child {
    box-shadow: inset 3px 0 0 var(--danger-ink);
}

.item-tries summary {
    cursor: pointer;
    color: var(--text-muted);
}

.item-tries ol {
    margin: var(--sp-2) 0 0;
    padding-left: var(--sp-5);
}

.is-wrong {
    color: var(--danger-ink);
}

.item.is-flash {
    box-shadow: 0 0 0 4px var(--ring);
}

@keyframes item-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

.item-wrong .item-mark {
    animation: item-shake var(--dur-3) var(--ease) 1;
}

/* Прогресс прохода — липкая плашка над пунктами. */
.quiz-progress {
    position: sticky;
    top: calc(var(--topbar-h) + var(--sp-2));
    z-index: var(--z-sticky);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
}

.quiz-progress.is-done {
    position: static;
    background: var(--success-bg);
    border-color: var(--success-border);
}

.quiz-progress-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
}

.quiz-progress-head .tiny {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.quiz-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: var(--text-muted);
}

.quiz-stat-ok {
    color: var(--success-ink);
}

.quiz-stat-bad {
    color: var(--danger-ink);
}

.quiz-finish {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border-subtle);
}

/* Разбор у преподавателя: попытки ученика по пункту. */
.review-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    margin-bottom: var(--sp-3);
    font-size: var(--fs-13);
}

.review-items {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.review-item {
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--border);
    border-radius: var(--r-md);
}

.review-item-correct {
    border-left-color: var(--success-ink);
}

.review-item-failed {
    border-left-color: var(--danger-ink);
}

.review-item-answered,
.review-item-open,
.review-item-new {
    border-left-color: var(--info-ink);
}

/* Прогресс ученика: темы раскрываются, внутри — задания с ответами. */
.topic-progress {
    margin-top: 6px;
    border-radius: var(--r-md);
}

.topic-progress__head {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    cursor: pointer;
    list-style: none;
}

.topic-progress__head::-webkit-details-marker {
    display: none;
}

.topic-progress__head:hover {
    background: var(--surface-sunken);
}

.topic-progress__head .row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.topic-chevron {
    flex: none;
    margin-top: 2px;
    color: var(--text-muted);
    transition: transform var(--dur-2) var(--ease);
}

.topic-progress:not([open]) .topic-chevron {
    transform: rotate(-90deg);
}

.topic-progress__body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3) var(--sp-3) calc(var(--sp-3) + 18px);
}

.assignment-progress {
    border-top: 1px dashed var(--border);
    padding-top: var(--sp-2);
    min-width: 0;
}

.assignment-progress__head {
    flex-wrap: wrap;
}

.assignment-progress .answer-body,
.assignment-progress .media-frame {
    margin-top: var(--sp-2);
}

.assignment-items {
    margin-top: var(--sp-2);
}

.try-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: var(--sp-2) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-13);
}

.try-list li {
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
}

.try-mark {
    font-weight: 700;
}

.try-ok {
    color: var(--success-ink);
}

.try-bad {
    color: var(--danger-ink);
}

.try-bad > span:last-child {
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

.item-points {
    margin: var(--sp-3) 0 0;
}

.item-points input {
    width: 88px;
}

/* ── Комментарий преподавателя ──────────────────────────── */
.feedback-composer {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4);
    margin-top: var(--sp-4);
    background: var(--accent-soft);
    border: 1px solid var(--accent-200);
    border-radius: var(--r-md);
}

.feedback-composer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
}

.feedback-current {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}

.feedback-current audio,
.feedback-audio audio {
    height: 36px;
}

/* ── Запись с микрофона ──────────────────────────────────── */
.recorder {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

.recorder-head,
.recorder-stage,
.recorder-take {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
}

.recorder-head {
    justify-content: space-between;
}

.recorder-clock {
    font-size: var(--fs-18);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.recorder.is-recording {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.recorder.is-ending .recorder-clock {
    color: var(--danger-ink);
}

.recorder-dot {
    width: 12px;
    height: 12px;
    background: var(--danger-ink);
    border-radius: 50%;
    animation: recorder-pulse 1s var(--ease) infinite;
}

@keyframes recorder-pulse {
    50% {
        opacity: 0.25;
    }
}

.recorder-meter > span {
    background: var(--danger-ink);
}

.recorder-take audio {
    max-width: 100%;
}

.recorder-error {
    color: var(--danger-ink);
}

.recorder-error:empty {
    display: none;
}

.recorder-upload summary {
    cursor: pointer;
    color: var(--link);
}

.recorder-upload input[type="file"] {
    margin-top: var(--sp-2);
    max-width: 100%;
}

.duration-input {
    display: flex;
    gap: var(--sp-2);
}

.duration-input .duration-value {
    width: 96px;
}

.duration-input .duration-unit {
    width: auto;
}

/* Матрица «ученик × пункт». */
.results-matrix th,
.results-matrix td {
    text-align: center;
    white-space: nowrap;
}

.results-matrix th[scope="row"],
.results-matrix thead th:first-child {
    text-align: left;
}

.results-rate {
    display: block;
    font-size: var(--fs-12);
    font-weight: 500;
    color: var(--text-muted);
}

.results-rate.is-hard {
    color: var(--danger-ink);
}

.results-cell sup {
    font-size: var(--fs-12);
}

/* Липкая плашка прогресса не должна закрывать пункт, к которому прокрутили. */
.quiz-items .item,
.quiz-items [data-recorder],
.quiz-items .item-note {
    scroll-margin-top: calc(var(--topbar-h) + 150px);
}

/* ── Карта курса: быстрые действия на доске ─────────────────────────── */
.row-grip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.grip-buttons {
    display: inline-flex;
    flex-direction: column;
    gap: 0;
}

.btn-grip {
    padding: 2px 4px;
    line-height: 1;
    min-height: 0;
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    border-radius: var(--r-sm);
    color: var(--text-subtle);
    cursor: grab;
    touch-action: none;
}

.drag-handle:hover,
.drag-handle:focus-visible {
    color: var(--accent-600);
    background: var(--surface-sunken);
}

.drag-handle:active {
    cursor: grabbing;
}

[data-assignment-row].is-dragging > .row-item,
.topic-panel.is-dragging,
[data-topic-panel].is-dragging {
    opacity: 0.45;
}

[data-assignment-row].drop-above > .row-item {
    box-shadow: 0 -3px 0 0 var(--accent-500);
}

[data-assignment-row].drop-below > .row-item {
    box-shadow: 0 3px 0 0 var(--accent-500);
}

.topic-panel.drop-above,
[data-topic-panel].drop-above,
[data-chapter-panel].drop-above {
    box-shadow: 0 -4px 0 0 var(--accent-500);
}

.topic-panel.drop-below,
[data-topic-panel].drop-below,
[data-chapter-panel].drop-below {
    box-shadow: 0 4px 0 0 var(--accent-500);
}

[data-chapter-panel].is-dragging {
    opacity: 0.45;
}

/* Глава на карте курса: обрамление между классом и темами */
.chapter {
    padding: 12px 14px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-400);
    border-radius: 12px;
    background: var(--surface-sunken, var(--canvas));
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.chapter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 100%;
}

.chapter-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

[data-chapter-topics].drop-block-active {
    outline: 2px dashed var(--accent-500);
    outline-offset: 2px;
    border-radius: 10px;
    min-height: 24px;
}

.drop-block-active {
    background: var(--accent-soft) !important;
    border-color: var(--accent-400) !important;
    box-shadow: 0 0 0 2px var(--accent-200) inset;
}

[data-block-topics].drop-block-active,
[data-block-id].drop-block-active {
    outline: 2px dashed var(--accent-500);
    outline-offset: 2px;
}

.inline-rename-input {
    font: inherit;
    padding: 4px 8px;
    border: 1px solid var(--accent-400);
    border-radius: var(--r-sm);
    width: min(460px, 100%);
    background: var(--surface);
    color: inherit;
}

.inline-rename-input:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-color: var(--accent-500);
}

/* 320px overflow fix: assignment-form and related grids must never exceed viewport */
@media (max-width: 400px) {
    #assignment-form,
    .form-grid,
    .preset-grid,
    .type-cards,
    .type-cards > div,
    .type-cards #id_assignment_type,
    .dropzone,
    .form-section,
    .callout {
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }
    .type-cards label,
    .preset-card,
    .dropzone,
    .callout {
        max-width: 100%;
        box-sizing: border-box;
        min-width: 0;
    }
    .preset-grid,
    .form-grid,
    .type-cards > div,
    .type-cards #id_assignment_type {
        grid-template-columns: minmax(0, 1fr) !important;
    }
    .callout {
        flex-wrap: wrap;
    }
    .callout .btn,
    .form-section .btn,
    .form-actions .btn {
        white-space: normal;
        max-width: 100%;
        box-sizing: border-box;
        overflow-wrap: break-word;
    }
    .row {
        max-width: 100%;
        box-sizing: border-box;
    }
}


/* Скрытое значение с «глазом»: выданный пароль ученика на странице у учителя */
.secret-field {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.secret-field__input {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 14px;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-sunken);
    color: var(--text);
}

.secret-field__input:focus-visible {
    outline: 2px solid var(--accent-400);
    outline-offset: 1px;
}


/* «Кому доступно»: назначения по иерархии (класс → глава → тема → задание) */
.audience-section .audience-note {
    margin: 0 0 12px;
}

.audience-section .callout {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

ul.audience-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
}

ul.audience-list li {
    margin: 0;
}

ul.audience-list label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 10px 4px 8px;
    font-size: var(--fs-13, 13px);
    font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

ul.audience-list label:hover {
    border-color: var(--border-strong);
}

ul.audience-list label:has(input:checked) {
    background: var(--accent-tint);
    border-color: var(--accent-400);
    color: var(--accent-800);
}

ul.audience-list input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--accent-600);
}

.audience-details summary {
    cursor: pointer;
    color: var(--accent-700);
    margin-bottom: 8px;
}

.audience-details summary::-webkit-details-marker {
    color: var(--text-muted);
}

/* Бейдж аудитории на карте курса: «👥 ОГЭ-А · +2 ученика» */
.audience-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 1px 8px;
    font-size: var(--fs-12);
    font-weight: 600;
    line-height: 1.6;
    color: var(--accent-800);
    background: var(--accent-tint);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audience-badge .icon {
    width: 12px;
    height: 12px;
    flex: none;
}

.audience-badge.is-inherited {
    color: var(--text-muted);
    background: transparent;
    border-color: var(--border);
    font-weight: 500;
}

a.audience-badge:hover {
    border-color: var(--accent-400);
}

/* ── Предпросмотр задания как видит ученик (в карточке ученика) ── */
.assignment-preview-wrapper {
    border-radius: var(--r-md);
    background: var(--surface-sunken);
    padding: var(--sp-2);
}

.assignment-preview-content {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    padding: var(--sp-3);
}

.assignment-preview-content .student-preview {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.assignment-preview-content .media-frame img {
    max-width: 100%;
    height: auto;
    border-radius: var(--r-md);
}

.assignment-preview-content .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-2);
    list-style: none;
    padding: 0;
    margin: 0;
}

.assignment-preview-content .tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.assignment-preview-content .tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    font-size: var(--fs-14);
}

/* ── Свёртка карты курса: классы → главы → темы ─────────────────
   Группы прячем атрибутом hidden, но .col задаёт display:flex —
   без !important свёртка не сработала бы. */
[data-curriculum-group][hidden],
[data-block-footer][hidden] {
    display: none !important;
}

.curriculum-depth {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
}

.curriculum-depth.is-compact {
    padding: 1px;
    border-color: transparent;
    background: transparent;
}

.curriculum-depth__option {
    padding: 3px 9px;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: var(--fs-11);
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

.curriculum-depth__option:hover {
    color: var(--accent-800);
    background: var(--accent-soft);
}

.curriculum-depth__option[aria-pressed="true"] {
    color: var(--text-inverse);
    background: var(--accent-700);
}

.curriculum-depth__option:focus-visible {
    outline: 2px solid var(--accent-600);
    outline-offset: 2px;
}

/* Заголовок класса или главы как кнопка-аккордеон: без лишней рамки и шума. */
.curriculum-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.curriculum-toggle:hover {
    color: var(--accent-800);
}

.curriculum-toggle:focus-visible {
    outline: 2px solid var(--accent-600);
    outline-offset: 3px;
    border-radius: 6px;
}

.curriculum-chevron {
    flex: 0 0 auto;
    transition: transform var(--dur-2) var(--ease);
}

.curriculum-toggle[aria-expanded="false"] .curriculum-chevron {
    transform: rotate(-90deg);
}

@media (prefers-reduced-motion: reduce) {
    .curriculum-chevron {
        transition: none;
    }
}

/* ── Подсветка комментариев в ответе ученика (как рецензия в Word) ────── */
.answer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-bottom: var(--sp-2);
}

[data-answer-text] {
    cursor: text;
}

[data-answer-text][data-editable="1"] {
    user-select: text;
}

.answer-highlight {
    background: var(--warning-bg);
    color: inherit;
    border-bottom: 2px solid var(--warning-border);
    border-radius: 3px;
    padding: 0 1px;
    cursor: pointer;
}

.answer-highlight:hover,
.answer-highlight:focus-visible {
    background: var(--warning-border);
    outline: none;
}

.answer-highlight--ai {
    background: var(--accent-soft);
    border-bottom: 2px solid var(--accent-500);
}

.answer-highlight--ai:hover,
.answer-highlight--ai:focus-visible {
    background: var(--accent-500);
    color: var(--text-inverse);
}

.answer-highlight-tooltip {
    position: absolute;
    z-index: 60;
    max-width: 320px;
    padding: var(--sp-2) var(--sp-3);
    background: var(--text);
    color: var(--text-inverse);
    font-size: var(--fs-13);
    line-height: var(--lh-tight);
    border-radius: var(--r-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.answer-highlight-tooltip.hidden {
    display: none;
}

.highlight-popover {
    position: absolute;
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: min(320px, 90vw);
    padding: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.highlight-popover textarea {
    width: 100%;
    resize: vertical;
    font: inherit;
}

.highlight-popover-actions {
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
}

/* ── Одно окно голосовых комментариев преподавателя ───────────────────── */
.voice-comments {
    margin-bottom: 0;
}

.voice-comments-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-subtle);
}

.voice-comments-bar .btn {
    margin-left: auto;
}

.audio-comment-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.audio-comment-list:empty {
    display: none;
}

.audio-comment-item {
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}

.audio-comment-item.is-removing {
    background: var(--surface-sunken);
    border-style: dashed;
}

.audio-comment-body,
.audio-comment-undo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
}

.audio-comment-undo {
    justify-content: space-between;
}

.audio-comment-pick {
    flex: 0 0 auto;
}

.audio-comment-no {
    min-width: 1.5em;
    font-weight: 700;
    text-align: center;
}

.audio-comment-player {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: min(100%, 220px);
}

.audio-comment-item audio {
    width: 100%;
    height: 36px;
    min-width: 0;
}

/* ── Обязательная структура ИИ-помощника ──────────────────────────────── */
.ai-structure {
    margin: 0 0 var(--sp-5);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.ai-structure legend {
    padding: 0 var(--sp-2);
    font-weight: 700;
}

.ai-structure-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}

.ai-structure-step {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    min-width: 0;
}

.ai-structure-step label {
    font-size: var(--fs-13);
    font-weight: 600;
}

.ai-structure-step select,
.ai-structure-step input {
    width: 100%;
}

.step-num {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-right: var(--sp-1);
    color: var(--text-inverse);
    background: var(--accent-500);
    border-radius: 50%;
}

.ai-structure-confirm {
    margin-top: var(--sp-4);
}

@media (max-width: 900px) {
    .ai-structure-grid {
        grid-template-columns: 1fr;
    }
}

/* Аудитория: локальные исключения из назначений родителей. */
.audience-exclusion-box {
    margin-top: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--warning-border);
    border-radius: var(--r-md);
    background: var(--warning-bg);
}

ul.audience-exclusions label:has(input:checked) {
    color: var(--danger-ink);
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

/* Минимальный статус публикации класса, главы и темы. */
.publication-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    vertical-align: middle;
    color: var(--text-subtle);
    font-size: var(--fs-12);
    font-weight: 500;
}

.publication-indicator.is-published,
.publication-indicator.is-partial {
    color: var(--success-ink);
}

.publication-indicator.is-published {
    opacity: .72;
}

.publication-indicator__warning {
    display: inline-grid;
    place-items: center;
    width: 13px;
    height: 13px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
}

.publication-indicator__text {
    font-size: 10px;
    white-space: nowrap;
}

.btn-success-soft {
    color: var(--success-ink);
    background: var(--success-bg);
    border-color: var(--success-border);
}

.btn-success-soft:hover {
    color: var(--success-ink);
    border-color: var(--success-ink);
    background: var(--success-bg);
}

/* Статус публикации должен считываться с первого взгляда на карте курса. */
.publication-indicator.is-published,
.publication-indicator.is-partial,
.publication-indicator.is-draft {
    opacity: 1;
    padding: 3px 7px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-weight: 700;
    background: var(--surface);
}
.publication-indicator.is-published { color: var(--success-ink); background: var(--success-bg); }
.publication-indicator.is-partial { color: var(--warning-ink, #9a6700); background: var(--warning-bg, #fff8dc); }
.publication-indicator.is-draft { color: var(--text-subtle); background: var(--canvas); }

/* Сворачиваемая карта курса ученика: прогресс сразу виден на каждом уровне. */
.student-course-tree > .student-course-class + .student-course-class {
    margin-top: var(--sp-3);
}

.student-course-class.card {
    padding: 0;
    overflow: hidden;
    border-radius: var(--r-xl);
}

.student-course-class__summary,
.student-course-chapter__summary,
.student-course-topic__summary {
    display: grid;
    align-items: center;
    gap: var(--sp-3);
    cursor: pointer;
    list-style: none;
}

.student-course-class__summary::-webkit-details-marker,
.student-course-chapter__summary::-webkit-details-marker,
.student-course-topic__summary::-webkit-details-marker {
    display: none;
}

.student-course-class__summary {
    grid-template-columns: 44px minmax(0, 1fr) minmax(200px, auto) 18px;
    padding: var(--sp-4) var(--sp-5);
    background: linear-gradient(115deg, var(--surface), var(--canvas-alt));
    transition: background var(--dur-2) var(--ease);
}

.student-course-class__summary:hover {
    background: var(--accent-tint);
}

.student-course-class__mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--turquoise-ink);
    background: var(--turquoise-bg);
    border: 1px solid var(--turquoise-100);
    border-radius: 14px;
}

.student-course-class__mark .icon {
    width: 20px;
    height: 20px;
}

.student-course-class__identity,
.student-course-chapter__identity,
.student-course-topic__identity {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.student-course-class__eyebrow,
.student-course-chapter__eyebrow,
.student-course-topic__eyebrow {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--text-muted);
    font-size: var(--fs-11);
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.student-course-class__title {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: var(--fs-18);
    font-weight: 800;
    line-height: 1.25;
}

.student-course-class__description,
.student-course-chapter__description {
    overflow: hidden;
    color: var(--text-muted);
    font-size: var(--fs-12);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.student-course-class__summary-meta,
.student-course-chapter__stats,
.student-course-topic__stats {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-2);
    min-width: 0;
    flex-wrap: wrap;
}

.student-course-class__score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.student-course-class__score strong {
    color: var(--text);
    font-size: var(--fs-15);
    font-variant-numeric: tabular-nums;
}

.student-course-class__score > span {
    color: var(--text-muted);
    font-size: var(--fs-11);
}

.student-course-class__percent,
.student-course-chapter__stats > span:not(.student-progress-statuses),
.student-course-topic__stats > span:not(.student-progress-statuses) {
    padding: 4px 8px;
    color: var(--success-ink);
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: var(--r-pill);
    font-size: var(--fs-12);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.student-progress-statuses {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.student-progress-statuses .badge {
    font-size: var(--fs-11);
    white-space: nowrap;
}

.student-course-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    transition: transform var(--dur-2) var(--ease);
}

.student-course-class:not([open]) > .student-course-class__summary .student-course-chevron,
.student-course-chapter:not([open]) > .student-course-chapter__summary .student-course-chevron,
.student-course-topic:not([open]) > .student-course-topic__summary .student-course-chevron {
    transform: rotate(-90deg);
}

.student-course-class[open] > .student-course-class__summary {
    border-bottom: 1px solid var(--border-subtle);
}

.student-course-class__body {
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
}

.student-course-description {
    margin: 0 0 var(--sp-3);
    color: var(--text-muted);
    font-size: var(--fs-13);
}

.student-course-class__progress {
    margin: 0 0 var(--sp-3) 56px;
}

.student-course-chapter {
    border-top: 1px solid var(--border-subtle);
}

.student-course-chapter:first-child {
    border-top: 0;
}

.student-course-chapter__summary {
    grid-template-columns: 18px minmax(0, 1fr) minmax(170px, auto);
    padding: var(--sp-3) var(--sp-2);
    border-radius: var(--r-md);
    transition: background var(--dur-2) var(--ease);
}

.student-course-chapter__summary:hover,
.student-course-topic__summary:hover {
    background: var(--surface-sunken);
}

.student-course-chapter__title,
.student-course-topic__title {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: var(--fs-15);
    font-weight: 750;
    line-height: 1.3;
}

.student-course-chapter__body {
    padding: 0 var(--sp-2) var(--sp-3) calc(var(--sp-2) + 18px);
}

.student-course-chapter__progress {
    margin-bottom: var(--sp-2);
}

.student-course-topic {
    margin-top: var(--sp-2);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

.student-course-topic__summary {
    grid-template-columns: 18px minmax(0, 1fr) minmax(170px, auto);
    padding: var(--sp-3);
    border-radius: var(--r-md);
}

.student-course-topic__body {
    padding: 0 var(--sp-3) var(--sp-3) calc(var(--sp-3) + 18px);
}

.student-course-topic__progress {
    margin: 0 0 var(--sp-2);
}

.student-course-topic__tasks {
    margin: 0;
}

.student-home-class-progress {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 10px;
}

.student-home-class-progress .student-progress-statuses {
    justify-content: flex-start;
}

.student-home-class-progress .badge {
    white-space: normal;
}

.student-course-class__summary:focus-visible,
.student-course-chapter__summary:focus-visible,
.student-course-topic__summary:focus-visible {
    outline: 3px solid var(--accent-400);
    outline-offset: -3px;
}

@media (max-width: 720px) {
    .student-course-class__summary {
        grid-template-columns: 40px minmax(0, 1fr) 18px;
        gap: var(--sp-2);
        padding: var(--sp-3);
    }

    .student-course-class__mark {
        width: 38px;
        height: 38px;
    }

    .student-course-class__summary-meta {
        grid-column: 2 / 4;
        justify-content: flex-start;
    }

    .student-course-class__score {
        align-items: flex-start;
        margin-right: auto;
    }

    .student-course-class__description,
    .student-course-chapter__description {
        white-space: normal;
    }

    .student-course-chapter__summary,
    .student-course-topic__summary {
        grid-template-columns: 16px minmax(0, 1fr);
        align-items: start;
        gap: var(--sp-2);
    }

    .student-course-chapter__stats,
    .student-course-topic__stats {
        grid-column: 2;
        justify-content: flex-start;
    }

    .student-course-class__progress {
        margin-left: 0;
    }

    .student-course-chapter__body {
        padding-left: var(--sp-2);
    }

    .student-course-topic__body {
        padding-left: var(--sp-3);
    }
}
