:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #64748b;
    --line: #d9e1ec;
    --brand: #2457c5;
    --brand-dark: #173f96;
    --green: #1d8f5f;
    --red: #bd2f3c;
    --amber: #a86608;
}

* {
    box-sizing: border-box;
}

/* Атрибут hidden должен реально скрывать элемент, даже если на нём есть display:grid/flex
   (иначе скрытые поля выбора получателей показываются все сразу). */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: var(--brand);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    padding: 10px 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary,
button.secondary {
    background: #eef2ff;
    color: var(--brand-dark);
}

.button.secondary:hover,
button.secondary:hover {
    background: #dbeafe;
}

button:hover,
.button:hover {
    background: var(--brand-dark);
}

.compact-button {
    min-height: 36px;
    padding: 8px 12px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 58%, #edf7f2 100%);
}

.auth-card,
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(25, 36, 60, 0.08);
}

.auth-card {
    width: min(520px, 100%);
    padding: 30px;
}

.auth-card.wide {
    width: min(880px, 100%);
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 20px;
}

.auth-code-contact {
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    color: #334155;
    line-height: 1.5;
}

.auth-code-contact a {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.auth-back-link {
    display: inline-flex;
    margin-bottom: 20px;
    font-weight: 700;
    text-decoration: none;
}

.field-help {
    margin: -6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.consent-field {
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.45;
}

.honeypot-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.dashboard-shell {
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px clamp(18px, 4vw, 42px);
    background: #0f172a;
    color: #fff;
}

.topbar a {
    color: #dbeafe;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.layout {
    width: min(1320px, calc(100% - 32px));
    margin: 28px auto;
    display: grid;
    gap: 22px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}

.card {
    padding: 20px;
}

.span-4 {
    grid-column: span 4;
}

.span-6 {
    grid-column: span 6;
}

.span-8 {
    grid-column: span 8;
}

.span-12 {
    grid-column: span 12;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

/* Компактная форма (напр. «Занятия и посещаемость»): мелкие поля сами переносятся,
   не налезая друг на друга; крупные (тема, ссылка, текст) — на всю ширину. */
.compact-form {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
}

.compact-form label {
    min-width: 0;
}

.compact-form .span-6,
.compact-form .span-12 {
    grid-column: 1 / -1;
}

.owner-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    align-items: end;
}

.owner-filter-form label {
    min-width: 0;
}

.owner-filter-search,
.owner-filter-actions {
    grid-column: 1 / -1;
}

.owner-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.task-editor-form {
    gap: 18px;
}

.task-editor-section {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.task-editor-section .eyebrow {
    margin-bottom: 0;
}

.task-editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    align-items: start;
}

.task-editor-grid label {
    min-width: 0;
}

.task-editor-grid .checkbox-inline {
    grid-column: 1 / -1;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-inline input {
    width: auto;
}

.stack {
    display: grid;
    gap: 14px;
}

.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.list {
    display: grid;
    gap: 12px;
    padding: 0;
    list-style: none;
}

.item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfdff;
}

.eyebrow {
    color: var(--brand);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.notice.success {
    background: #eaf8f0;
    color: var(--green);
}

.notice.error {
    background: #fff0f1;
    color: var(--red);
}

.notice.info {
    background: #edf4ff;
    color: #1d4ed8;
}

.pill {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 10px;
    background: #e8eefc;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 800;
}

.calendar-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.video-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 8px;
    background: #0f172a;
}

.material-link {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
}

.section-line {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.normalize-kim-one-form {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 16px;
}

.task-bank-list,
.task-checkbox-list,
.attached-tasks {
    display: grid;
    gap: 10px;
}

.task-bank-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.quick-edit-form {
    display: grid;
    grid-template-columns: minmax(74px, 0.6fr) minmax(86px, 0.7fr) minmax(150px, 1.35fr) minmax(72px, 0.55fr);
    gap: 10px;
    align-items: end;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.task-bank-preview {
    display: grid;
    gap: 12px;
    margin-top: 14px;
    padding: 14px;
    max-width: 960px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.preview-meta,
.preview-matching {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preview-prompt,
.preview-line,
.preview-item,
.preview-heading {
    margin: 0;
    line-height: 1.45;
}

.preview-prompt {
    font-weight: 700;
}

.preview-item {
    padding-left: 12px;
}

.preview-matching {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 14px;
}

.preview-column {
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 14px;
    border: 1px solid #d8cff6;
    border-radius: 8px;
    background: #f7f2ff;
}

.preview-heading {
    color: #4b2e83;
    font-weight: 800;
    text-transform: uppercase;
}

.preview-table-wrap {
    overflow-x: auto;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.preview-table th,
.preview-table td {
    padding: 10px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.preview-table th {
    background: #eef2ff;
}

.preview-history-table {
    min-width: 720px;
    table-layout: fixed;
}

.preview-history-table th,
.preview-history-table td {
    text-align: center;
    vertical-align: middle;
    white-space: pre-line;
}

.preview-matching-table th,
.preview-matching-table td {
    width: 50%;
    text-align: left;
    vertical-align: top;
    white-space: normal;
}

.preview-matching-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.preview-matching-list li {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 7px;
}

.preview-placeholder {
    display: inline-block;
    min-width: 42px;
    padding: 0 10px 3px;
    border-bottom: 2px solid #5b3a8e;
    color: #4b2e83;
    font-weight: 800;
}

.preview-history-options,
.preview-source-fragment {
    padding: 12px 14px;
    border: 1px solid #d8cff6;
    border-radius: 8px;
    background: #faf8ff;
}

.preview-history-options h4,
.preview-source-fragment h4,
.preview-source-fragment p,
.preview-answer-order {
    margin: 0;
}

.preview-history-options ol {
    margin: 10px 0 0;
    padding-left: 28px;
}

.preview-source-fragments {
    display: grid;
    gap: 12px;
}

.preview-source-fragment p {
    margin-top: 8px;
    line-height: 1.55;
}

.preview-answer-order {
    padding: 10px 12px;
    border-left: 4px solid #6842a5;
    border-radius: 6px;
    background: #f3effc;
    color: #4b2e83;
    font-weight: 700;
}

.preview-image {
    max-width: min(100%, 640px);
    height: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.quick-edit-form label {
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
}

.quick-edit-form input {
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 6px;
}

.quick-solution-field {
    grid-column: 1 / -1;
}

.quick-solution-field textarea {
    min-height: 220px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.45;
}

.quick-edit-list-form {
    display: grid;
    gap: 14px;
}

.sticky-save-bar {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 14px 34px rgba(25, 36, 60, 0.14);
}

.sticky-save-bar p {
    margin: 0;
}

.hidden-form {
    display: none;
}

.examly-app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    background: #f6f8fc;
}

.examly-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px 18px;
    background: #101827;
    color: #f8fafc;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e8f1ff;
    color: var(--brand);
    font-weight: 900;
}

.sidebar-brand small,
.sidebar-logout {
    color: #cbd5e1;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.owner-tabs {
    align-content: start;
}

.sidebar-nav a,
.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 700;
}

.sidebar-nav a:hover,
.sidebar-nav a[aria-current="true"] {
    background: #1e2a44;
    color: #fff;
}

.sidebar-logout {
    margin-top: auto;
}

.homework-badge {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    line-height: 1;
}

.nav-badge {
    flex: none;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}

.examly-main {
    min-width: 0;
}

.examly-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px clamp(18px, 4vw, 36px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.examly-topbar h1 {
    margin-bottom: 0;
}

.topbar-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
}

.topbar-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-weight: 700;
}

.examly-content {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
    display: grid;
    gap: 22px;
}

.examly-content > *,
.table-scroll {
    min-width: 0;
    max-width: 100%;
}

.student-section,
.owner-panel {
    scroll-margin-top: 92px;
}

.student-home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
    gap: 18px;
}

.student-calendar,
.upcoming-events,
.homework-card,
.material-card {
    box-shadow: 0 14px 34px rgba(25, 36, 60, 0.07);
}

.calendar-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.calendar-day {
    min-height: 120px;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.calendar-day span,
.calendar-day small {
    color: var(--muted);
}

.calendar-day.homework {
    border-color: #fecaca;
    background: #fff7f7;
}

.calendar-day.webinar {
    border-color: #bfdbfe;
    background: #f3f8ff;
}

.calendar-day.mock {
    border-color: #bbf7d0;
    background: #f1fcf5;
}

.clean-list {
    display: grid;
    gap: 12px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.clean-list li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    margin-top: 5px;
    border-radius: 999px;
    background: var(--brand);
}

.status-dot.homework {
    background: #dc2626;
}

.status-dot.webinar {
    background: #2563eb;
}

.status-dot.mock {
    background: #16a34a;
}

.compact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 14px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.status-badge {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 6px 10px;
    background: #eef2ff;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 800;
}

.status-badge.done {
    background: #eaf8f0;
    color: var(--green);
}

.status-badge.review,
.status-badge.progress {
    background: #fff7ed;
    color: var(--amber);
}

.status-badge.muted {
    background: #edf2f7;
    color: var(--muted);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.meta-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.meta-grid dd {
    margin: 0;
    font-weight: 800;
}

.teacher-comment {
    padding: 10px 12px;
    border-radius: 8px;
    background: #f1f5f9;
}

.homework-runner summary {
    width: fit-content;
    list-style: none;
}

.task-practice-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.practice-task details,
.homework-runner {
    margin-top: 12px;
}

.compact-filter {
    margin-bottom: 16px;
}

.quick-task-builder {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.homework-builder-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.apply-task-filter {
    margin-top: 12px;
    width: auto;
    min-width: 220px;
}

.selected-homework-panel {
    position: sticky;
    top: 18px;
    border: 1px solid #cfe0ff;
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
    box-shadow: 0 18px 42px rgba(29, 78, 216, 0.12);
}

.selected-homework-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.selected-homework-head h3 {
    margin: 4px 0 0;
}

.selected-homework-list {
    display: grid;
    gap: 10px;
    max-height: 460px;
    overflow: auto;
    padding-right: 4px;
}

.selected-task-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.selected-task-row:hover,
.task-picker-card:hover {
    border-color: #8fb3ff;
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.10);
}

.selected-task-row small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.selected-task-row button,
.ghost-button {
    border: 0;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--brand);
    padding: 8px 12px;
    font-weight: 800;
    cursor: pointer;
}

.selected-task-row button:hover,
.ghost-button:hover {
    background: #dbe8ff;
}

.task-picker-card {
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.audience-picker {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #f8fbff;
}

.student-subject-picker {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #f8fbff;
}

.student-subject-picker legend {
    padding: 0 6px;
    color: var(--text);
    font-weight: 800;
}

.student-subject-picker .audience-student-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    max-height: none;
}

.audience-student-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    margin-top: 10px;
    padding-right: 4px;
}

.mini-check {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #d7e2f2;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    cursor: pointer;
}

.mini-check:hover {
    border-color: #8fb3ff;
}

@media (max-width: 980px) {
    .homework-builder-layout {
        grid-template-columns: 1fr;
    }

    .selected-homework-panel {
        position: static;
    }
}

.review-card textarea {
    min-height: 90px;
}

.owner-bank-row.is-hidden {
    display: none;
}

.owner-bank-load-more {
    margin-top: 14px;
}

.owner-panel {
    display: grid;
    gap: 18px;
}

.checkbox-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.checkbox-card input {
    width: auto;
    margin-top: 3px;
}

.checkbox-card span {
    display: grid;
    gap: 4px;
}

.checkbox-card small {
    color: var(--muted);
    line-height: 1.35;
}

.textarea-large {
    min-height: 220px;
}

.attached-tasks {
    margin: 10px 0;
    justify-items: start;
}

.builder-tabs,
.builder-actions,
.builder-card-actions,
.builder-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.builder-tab {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 999px;
    padding: 10px 16px;
}

.builder-tab.is-active {
    border-color: var(--primary);
    background: #eaf1ff;
    color: var(--primary);
}

.builder-panel.is-hidden {
    display: none;
}

.owner-builder-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 18px;
}

.inner-builder-card,
.builder-basket {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: 18px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.07);
}

.builder-basket {
    position: sticky;
    top: 18px;
}

.builder-spec-list,
.builder-task-list,
.bank-picker-results {
    display: grid;
    gap: 10px;
}

.builder-spec-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

.builder-task-card,
.bank-picker-result {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
    padding: 14px;
    display: grid;
    gap: 10px;
}

.builder-task-card.is-personal {
    border-color: #c7d2fe;
    background: #f5f7ff;
}

.builder-task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.builder-summary {
    justify-content: space-between;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
    margin: 12px 0;
}

.target-picker-options {
    display: grid;
    gap: 10px;
}

.target-picker-option.is-hidden {
    display: none;
}

.quick-task-text-field,
.quick-answer-field {
    grid-column: 1 / -1;
}

.quick-task-text-field textarea {
    min-height: 96px;
}

.quick-actions-grid,
.activity-feed,
.weak-topic-list {
    display: grid;
    gap: 10px;
}

.quick-actions-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card h2 {
    font-size: 38px;
    margin-bottom: 6px;
}

.table-scroll {
    overflow-x: auto;
}

.owner-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.owner-table th,
.owner-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

.owner-table th {
    color: var(--muted);
    font-size: 13px;
}

.shared-access-note {
    padding: 14px 16px;
    border: 1px solid #a7e4c8;
    border-radius: 10px;
    background: #ecfdf5;
    color: #166534;
    line-height: 1.5;
}

.owner-students-table-scroll {
    max-height: min(68vh, 720px);
    margin-top: 12px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.owner-students-table-scroll .owner-table {
    min-width: 1560px;
}

.owner-students-table-scroll .owner-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 0 1px 0 var(--line);
}

.student-delete-dialog {
    width: min(520px, calc(100% - 32px));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
}

.student-delete-dialog::backdrop {
    background: rgba(15, 23, 42, 0.62);
}

.student-delete-dialog__panel {
    display: grid;
    gap: 16px;
    padding: 24px;
}

.student-delete-dialog__panel p,
.student-delete-dialog__panel h2 {
    margin-bottom: 0;
}

.owner-filter-bar {
    margin-top: 16px;
}

.activity-row {
    display: grid;
    grid-template-columns: 150px minmax(140px, 220px) minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
}

.activity-row p {
    margin: 0;
}

.owner-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.owner-calendar-grid > strong {
    color: var(--muted);
    font-size: 13px;
    padding: 4px;
}

.owner-calendar-cell {
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 9px;
    display: grid;
    align-content: start;
    gap: 5px;
}

.owner-calendar-cell.is-muted {
    background: #f8fafc;
    color: #94a3b8;
}

.owner-event-pill {
    display: block;
    border-radius: 999px;
    padding: 4px 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #e0ecff;
    color: #1d4ed8;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s, box-shadow 0.15s;
}

a.owner-event-pill:hover {
    filter: brightness(0.95);
    text-decoration: none;
}

.owner-event-pill.is-editing {
    box-shadow: 0 0 0 2px var(--green, #0f3d2e);
    font-weight: 800;
}

.owner-event-pill.deadline,
.calendar-mini-event.deadline {
    background: #ffe4e6;
    color: #be123c;
}

.owner-event-pill.mock,
.calendar-mini-event.mock {
    background: #dcfce7;
    color: #166534;
}

.owner-event-pill.review,
.calendar-mini-event.review {
    background: #fef3c7;
    color: #92400e;
}

.clean-list {
    display: grid;
    gap: 10px;
    padding-left: 18px;
}

.weak-topic-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
}

.weak-topic-row i {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: var(--brand);
}

@media (max-width: 860px) {
    .examly-app-shell {
        grid-template-columns: 1fr;
    }

    .examly-sidebar {
        position: static;
        min-height: auto;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .examly-topbar,
    .card-head,
    .student-home-grid {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .grid,
    .form-grid,
    .task-editor-grid,
    .quick-edit-form,
    .split,
    .calendar-list,
    .owner-builder-grid {
        grid-template-columns: 1fr;
    }

    .builder-basket {
        position: static;
    }

    .span-4,
    .span-6,
    .span-8,
    .span-12 {
        grid-column: span 1;
    }

    .task-bank-row,
    .activity-row {
        grid-template-columns: 1fr;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

.owner-student-access {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
}

.owner-mock-list {
    margin-top: 18px;
}

.owner-mock-card details {
    margin-top: 16px;
}

.owner-mock-card summary {
    cursor: pointer;
    color: var(--brand);
    font-weight: 800;
}

.owner-mock-review-details > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 22px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    list-style: none;
}

.owner-mock-review-details > summary::-webkit-details-marker {
    display: none;
}

.owner-mock-review-details[open] > summary {
    margin-bottom: 16px;
}

/* Открытая проверка пробника разворачивает карточку на всю ширину списка,
   чтобы задания и ответы читались, а не ютились в узкой колонке. */
.owner-mock-list .owner-mock-card:has(.owner-mock-review-details[open]) {
    grid-column: 1 / -1;
}

.owner-mock-review-details[open] > .owner-mock-review-form,
.owner-mock-review-details[open] > .row-actions {
    max-width: 1100px;
}

.owner-mock-result {
    color: var(--brand);
    font-size: 28px;
}

.owner-review-task {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
}

.owner-review-task h4 {
    margin: 0 0 8px;
}

.owner-review-prompt {
    line-height: 1.65;
}

.owner-review-prompt .cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.owner-review-prompt .box,
.owner-review-prompt .source-text {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.owner-review-prompt .source-text {
    max-height: 560px;
    overflow: auto;
}

.owner-review-prompt svg,
.owner-review-prompt img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px auto;
}

.owner-review-prompt .mock-exam-diagram {
    width: min(100%, 620px);
    border: 0;
}

.owner-review-prompt .mock-exam-diagram-task-21 {
    width: min(100%, 420px);
}

.owner-review-options {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.owner-review-option {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.owner-review-option > strong {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 8px;
    background: #f2f4f7;
}

.owner-review-option > em {
    color: var(--brand);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

.owner-review-option.is-selected {
    border-color: var(--brand);
    background: #eef4ff;
}

.owner-student-answer-label {
    display: block;
    margin-top: 14px;
}

.owner-student-answer {
    margin: 10px 0;
    padding: 12px;
    border-radius: 10px;
    background: #fff;
    white-space: pre-wrap;
}

@media (max-width: 700px) {
    .owner-student-access {
        align-items: stretch;
        flex-direction: column;
    }

    .owner-review-prompt .cols {
        grid-template-columns: 1fr;
    }

    .owner-review-option {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .owner-review-option > em {
        grid-column: 2;
    }
}

/* Theory access (student_topic_access) on the student card */
.topic-access-section {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: #fff;
}
.topic-access-section > summary {
    cursor: pointer;
    font-size: 15px;
    padding: 4px 0;
}
.topic-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    margin-top: 10px;
}
.topic-access-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: #f8fafc;
}
.topic-access-row.is-open {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.topic-access-label {
    font-size: 13px;
    line-height: 1.3;
}
.topic-access-code {
    display: inline-block;
    min-width: 34px;
    font-weight: 700;
    color: #2563eb;
}
.topic-access-row .compact-button {
    flex: 0 0 auto;
}

/* Theory editor / topic links */
.topic-access-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.theory-topic-link { text-decoration: none; color: inherit; display: block; }
.theory-topic-link:hover { border-color: #6366f1; }
.theory-topic-link.has-theory { border-color: #a7f3d0; background: #f0fdf4; }
.theory-topic-link h3 { font-size: 14px; margin: 0 0 4px; }
.button.danger,
button.danger { background: #ef4444; border-color: #ef4444; color: #fff; }
.button.danger:hover,
button.danger:hover { background: #dc2626; }

.topic-tag-badge { display:inline-block; padding:2px 10px; border-radius:999px; background:#eef2ff; color:#4338ca; font-size:12px; font-weight:600; }

/* Homework constructor: full task text + picker layout */
.hw-tpl-text { display:block; margin:6px 0; line-height:1.5; white-space:normal; }
.hw-pick-item { display:flex; gap:10px; align-items:flex-start; cursor:pointer; }
.hw-pick-item .hw-pick-check { flex:0 0 auto; padding-top:2px; }
.hw-pick-item .hw-tpl-text { margin:4px 0; }

.hw-tpl-img { max-width: 100%; max-height: 320px; border-radius: 8px; margin: 6px 0; display: block; }
