:root {
  --ink: #17201b;
  --ink-soft: #34433a;
  --muted: #6c7a71;
  --faint: #96a199;
  --line: #dfe7e1;
  --line-strong: #cad7ce;
  --canvas: #f5f7f5;
  --surface: #ffffff;
  --surface-soft: #f9fbf9;
  --green: #18794e;
  --green-dark: #11613e;
  --green-soft: #e8f5ed;
  --green-pale: #f2faf5;
  --red: #c73d45;
  --red-soft: #fff0f1;
  --amber: #b56c16;
  --amber-soft: #fff7e8;
  --blue: #376f9e;
  --blue-soft: #edf5fb;
  --shadow-sm: 0 1px 2px rgba(26, 42, 32, .05), 0 3px 10px rgba(26, 42, 32, .035);
  --shadow-md: 0 10px 35px rgba(25, 48, 34, .09);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --header-height: 72px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, summary, label, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(24,121,78,.35); outline-offset: 3px; }
a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green-dark); }
[hidden] { display: none !important; }
::selection { background: #ccebd8; color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Header and navigation */
.app-header {
  position: sticky; top: 0; z-index: 40; min-height: var(--header-height); padding: 0 24px;
  display: flex; align-items: center; gap: 28px; background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(28, 47, 35, .02); backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; flex: 0 0 auto; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #208a5a, #126a43); font-size: 17px; font-weight: 800; box-shadow: 0 6px 18px rgba(24, 121, 78, .2); }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 16px; letter-spacing: -.01em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.main-nav { display: flex; align-self: stretch; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); padding: 0 14px; cursor: pointer; font-size: 13px; font-weight: 650; white-space: nowrap; transition: color .16s, background .16s; }
.tab::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.tab:hover { color: var(--ink); background: var(--surface-soft); }
.tab.active { color: var(--green-dark); }
.tab.active::after { background: var(--green); }
.header-account { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.account-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; color: var(--green-dark); background: var(--green-soft); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.account-name { max-width: 130px; overflow: hidden; color: var(--ink-soft); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.account-logout { min-height: 31px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface); cursor: pointer; font-size: 11px; font-weight: 700; }
.account-logout:hover { color: var(--red); border-color: #e5b8bb; background: var(--red-soft); }

/* Main shell */
.app-shell { display: grid; grid-template-columns: 390px minmax(0, 1fr); min-height: calc(100vh - var(--header-height)); }
.filter-sidebar { position: sticky; top: var(--header-height); align-self: start; height: calc(100vh - var(--header-height)); padding: 24px 22px 40px; overflow: auto; background: #fbfcfb; border-right: 1px solid var(--line); scrollbar-color: #cfd9d2 transparent; scrollbar-width: thin; }
.aside-title { display: flex; align-items: center; justify-content: space-between; margin: 0 5px 18px; }
.aside-title > div { display: grid; gap: 2px; }
.aside-title strong { font-size: 18px; letter-spacing: -.02em; }
.eyebrow { color: var(--green); font-size: 11px; line-height: 1.2; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.icon { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--green); cursor: pointer; font-size: 21px; line-height: 1; box-shadow: var(--shadow-sm); transition: transform .15s, border-color .15s, background .15s; }
.icon:hover { transform: translateY(-1px); border-color: #a9cbb6; background: var(--green-pale); }
.search-field { position: relative; display: block; }
.search-field::before { content: "⌕"; position: absolute; left: 13px; top: 8px; z-index: 1; color: var(--muted); font-size: 20px; transform: rotate(-18deg); pointer-events: none; }
.filter-search { width: 100%; padding-left: 39px !important; margin: 0 !important; background: var(--surface) !important; }
.filter-help { margin: 9px 8px 14px; color: var(--faint); font-size: 11px; }
.tag-match-control { margin: 0 0 16px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border: 1px solid var(--line); border-radius: 11px; background: #eef3ef; }
.tag-match-control legend { width: 100%; padding: 0 4px 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.tag-match-control label { position: relative; cursor: pointer; }
.tag-match-control input { position: absolute; opacity: 0; pointer-events: none; }
.tag-match-control span { min-height: 34px; display: grid; place-items: center; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 750; transition: color .15s, background .15s, box-shadow .15s; }
.tag-match-control input:checked + span { color: var(--green-dark); background: var(--surface); box-shadow: var(--shadow-sm); }
.tag-match-control input:focus-visible + span { outline: 3px solid rgba(24,121,78,.35); outline-offset: 1px; }
.content { width: 100%; max-width: 1180px; min-width: 0; padding: 34px 44px 90px; }
.toolbar { min-height: 42px; margin-bottom: 20px; padding: 8px 10px 8px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); background: rgba(255, 255, 255, .72); border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
.toolbar > div { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 2px 24px; }
.page-heading h1 { margin: 5px 0 3px; font-size: clamp(25px, 3vw, 34px); line-height: 1.15; letter-spacing: -.035em; }
.page-heading p { max-width: 660px; margin: 0; color: var(--muted); }
.compact-heading { margin-bottom: 19px; }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.editor-card { padding: 24px; }

/* Fields and controls */
input, textarea, select { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
input:hover, textarea:hover, select:hover { border-color: #aebeb3; }
input:focus, textarea:focus, select:focus { border-color: #70a98a; box-shadow: 0 0 0 4px rgba(24, 121, 78, .1); }
input::placeholder, textarea::placeholder { color: #9aa59e; }
input:disabled, textarea:disabled, select:disabled { color: #657168; background: #eef2ef; cursor: not-allowed; }
textarea { min-height: 112px; resize: vertical; }
.field-label { display: block; margin: 0 0 7px; color: var(--ink-soft); font-size: 12px; font-weight: 750; }
.title-input { margin-bottom: 18px; padding: 12px 14px; font-size: 18px; font-weight: 700; }
.task-body { min-height: 180px; margin-bottom: 18px; padding: 14px; line-height: 1.65; }
.editor-meta { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr); gap: 14px; align-items: stretch; }
.upload-field { position: relative; min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px dashed #b9cabf; border-radius: 12px; background: var(--surface-soft); cursor: pointer; transition: border-color .15s, background .15s; }
.upload-field:hover { border-color: var(--green); background: var(--green-pale); }
.upload-field input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-field > span:not(.upload-icon) { display: grid; }
.upload-field small, .difficulty small { color: var(--muted); font-size: 11px; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 21px; }
.difficulty { min-height: 74px; margin: 0; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; }
.difficulty > span { display: grid; flex: 0 0 auto; }
.difficulty > div { display: flex; gap: 6px; }
.difficulty button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 700; transition: transform .15s, background .15s, color .15s, border-color .15s; }
.difficulty button:hover { transform: translateY(-1px); border-color: var(--green); color: var(--green); }
.difficulty button.active { color: #fff; background: var(--green); border-color: var(--green); box-shadow: 0 5px 12px rgba(24, 121, 78, .18); }
#materialPreview { margin-top: 12px; }
#materialPreview:empty { display: none; }
img.preview, .entity-material img { max-width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; }
.task-images-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.task-image-preview { position: relative; margin: 0; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.task-image-preview img { width: 100%; height: 120px; display: block; object-fit: contain; border-radius: 7px; background: #fff; }
.task-image-preview figcaption { padding: 6px 2px 0; color: var(--muted); font-size: 11px; }
.task-image-preview button { position: absolute; top: 11px; right: 11px; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px; color: var(--red); background: rgba(255,255,255,.94); box-shadow: var(--shadow-sm); cursor: pointer; font-size: 18px; line-height: 1; }
.disclosure { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); overflow: hidden; }
.disclosure summary { display: flex; justify-content: space-between; gap: 10px; padding: 13px 15px; cursor: pointer; font-weight: 700; list-style: none; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "⌄"; color: var(--muted); font-size: 18px; transition: transform .15s; }
.disclosure[open] summary::after { transform: rotate(180deg); }
.disclosure summary small { margin-left: auto; color: var(--faint); font-weight: 500; }
.source-grid { display: grid; grid-template-columns: 1.3fr .7fr .55fr 1fr; gap: 9px; padding: 0 14px 14px; }

/* Buttons */
.primary, .secondary { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; padding: 9px 15px; cursor: pointer; font-weight: 700; line-height: 1.1; transition: transform .15s, background .15s, border-color .15s, box-shadow .15s, color .15s; }
.primary { color: #fff; background: var(--green); border: 1px solid var(--green); box-shadow: 0 5px 14px rgba(24, 121, 78, .18); }
.primary:hover { background: var(--green-dark); border-color: var(--green-dark); transform: translateY(-1px); box-shadow: 0 7px 18px rgba(24, 121, 78, .22); }
.secondary { color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 1px 1px rgba(20, 40, 27, .03); }
.secondary:hover { color: var(--ink); background: var(--surface-soft); border-color: #aebeb3; transform: translateY(-1px); }
.primary:disabled, .secondary:disabled, button:disabled { opacity: .52; cursor: not-allowed; transform: none !important; box-shadow: none; }
.compact { min-height: 31px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.add-button { min-height: 34px; padding: 7px 10px; color: var(--green); border-color: #bdd2c4; font-size: 12px; }

/* Catalog filters */
.entity { margin: 5px 0; border: 1px solid transparent; border-radius: 12px; overflow: hidden; transition: border-color .15s, background .15s, box-shadow .15s; }
.entity:not(.collapsed) { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
.entity-head { min-height: 45px; display: flex; gap: 7px; align-items: center; padding: 5px 8px; cursor: pointer; }
.entity-head:hover { background: rgba(236, 244, 239, .55); }
.expand { width: 29px; height: 29px; flex: 0 0 auto; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 19px; transition: transform .18s, background .15s; }
.collapsed .expand { transform: rotate(-90deg); }
.entity-name { min-width: 0; flex: 1; font-size: 13px; font-weight: 720; overflow-wrap: anywhere; }
.tag-count, .pill { padding: 3px 7px; border-radius: 99px; color: var(--muted); background: #edf1ee; font-size: 10px; font-weight: 700; white-space: nowrap; }
.entity-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.entity:hover .entity-actions, .entity:focus-within .entity-actions { opacity: 1; }
.entity-actions button, .entity-actions label { width: 25px; height: 25px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.entity-actions button:hover, .entity-actions label:hover { background: var(--surface); color: var(--ink); }
.entity-file { display: none; }
.tags { padding: 3px 8px 8px 43px; }
.tag { min-height: 35px; display: flex; gap: 8px; align-items: center; margin: 2px 0; padding: 6px 7px; border-radius: 8px; color: var(--ink-soft); cursor: pointer; font-size: 13px; }
.tag:hover { background: #f0f4f1; }
.tag.selected { color: var(--green-dark); background: var(--green-soft); font-weight: 650; }
.tag input { width: 15px; height: 15px; padding: 0; margin: 0; accent-color: var(--green); }
.tag-text { flex: 1; }
.tag button { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--faint); opacity: 0; cursor: pointer; }
.tag:hover button { opacity: 1; }
.tag button:hover { color: var(--ink); background: var(--surface); }
.collapsed .tags, .collapsed .add-tag, .collapsed .all-entity-tasks, .collapsed .entity-material { display: none; }
.add-tag { margin: 0 8px 10px 43px; padding: 5px 7px; border: 0; background: transparent; color: var(--green); cursor: pointer; font-size: 12px; font-weight: 650; }
.all-entity-tasks { margin: 0 8px 5px 43px; padding: 5px 7px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 650; text-align: left; }
#appNotice { position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: 420px; padding: 13px 16px; border-radius: 10px; color: #fff; background: #a33a3a; box-shadow: 0 10px 30px rgba(45,20,20,.24); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .18s, transform .18s; }
#appNotice.visible { opacity: 1; transform: translateY(0); }
.student-form { display: grid; grid-template-columns: repeat(2,minmax(180px,1fr)); gap: 12px; margin: 14px 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.student-form label { display: grid; gap: 5px; font-size: 13px; font-weight: 650; }
.student-form > div { display: flex; align-items: end; gap: 8px; }
.student-access { display: grid; gap: 5px; margin: 14px 0; padding: 14px; border: 1px solid #a9d2b7; border-radius: 12px; color: #174b2d; background: var(--green-soft); }
.student-access code { padding: 2px 5px; border-radius: 4px; color: inherit; background: rgba(255,255,255,.7); }
.task-condition { white-space: pre-wrap; padding: 10px; border-radius: 8px; background: var(--surface-soft); }
.entity-material { padding: 3px 12px 8px 43px; }
.entity-material img { max-height: 100px; }

/* Editor blocks */
.blocks { display: grid; gap: 14px; margin: 16px 0; }
.blocks > section { padding: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.section-head > div { display: flex; align-items: center; gap: 10px; }
.section-head > div > span:last-child { display: grid; }
.section-head strong { font-size: 14px; }
.section-head small { color: var(--muted); font-size: 11px; }
.section-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font-weight: 850; }
.hint-icon { color: var(--amber); background: var(--amber-soft); }
.solution-icon { color: var(--blue); background: var(--blue-soft); }
.answer-icon { color: var(--green); background: var(--green-soft); }
.dynamic-list:empty::after { content: "Пока ничего не добавлено"; display: block; padding: 13px 44px; color: var(--faint); font-size: 12px; }
.form-row { position: relative; display: grid; grid-template-columns: minmax(130px, .8fr) minmax(220px, 2fr) auto; gap: 8px; margin: 10px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.form-row > textarea:only-of-type { grid-column: 1 / 3; }
.form-row input, .form-row textarea, .form-row select { margin: 0; min-width: 0; }
.form-row textarea { min-height: 76px; }
.answer-fields { display: flex; gap: 8px; }
.answer-editor { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.answer-editor .section-head { margin: 0; }
.remove { width: 34px; height: 34px; align-self: start; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--faint); cursor: pointer; font-size: 21px; }
.remove:hover { color: var(--red); background: var(--red-soft); }
.sticky-actions { position: sticky; z-index: 15; bottom: 14px; display: flex; align-items: center; gap: 9px; margin-top: 18px; padding: 11px; border: 1px solid rgba(198, 215, 203, .9); border-radius: 14px; background: rgba(255, 255, 255, .94); box-shadow: 0 10px 35px rgba(25, 48, 34, .13); backdrop-filter: blur(14px); }
.sticky-actions .primary { min-width: 160px; }
.action-hint { margin-left: auto; color: var(--muted); font-size: 12px; }

/* Assignment and task cards */
.assign-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; gap: 14px; margin-bottom: 16px; padding: 15px; }
.assign-top > label { min-width: 0; }
.assign-top select { min-width: 0; }
.assign-difficulty { min-width: 0; }
.assign-top .issued-filter { min-height: 41px; display: flex; align-items: center; gap: 8px; padding: 0 2px; color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.assign-top .issued-filter input { width: 16px; height: 16px; flex: 0 0 auto; margin: 0; padding: 0; accent-color: var(--green); }
.assign-top > .primary { min-width: 0; }
.range-fields { min-height: 41px; display: flex; align-items: center; gap: 8px; }
.range-fields label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.range-fields select { width: 68px; min-width: 68px; padding-right: 28px; }
.range-dash { color: var(--faint); }
.task-filter-summary { display: flex; justify-content: space-between; gap: 10px; margin: 4px 2px 12px; color: var(--muted); font-size: 12px; }
.task-filter-summary span:first-child { color: var(--ink-soft); font-weight: 750; }
.task-filter-empty { display: grid; gap: 4px; margin: 10px 0; padding: 26px 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.58); }
.task-filter-empty strong { color: var(--ink-soft); }
.task-filter-empty span { font-size: 13px; }
.import-panel { max-width: 920px; }
.import-card { padding: 22px; }
.import-card + .import-card { margin-top: 14px; }
.import-upload { min-height: 120px; display: grid; place-items: center; gap: 7px; padding: 20px; border: 1px dashed #aac7b5; border-radius: 12px; color: var(--muted); background: var(--surface-soft); cursor: pointer; text-align: center; }
.import-upload:hover { border-color: var(--green); background: var(--green-pale); }
.import-upload input { display: none; }
.import-upload strong { color: var(--ink-soft); }
.import-status { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.import-error { color: var(--red); }
.import-preview { display: grid; gap: 14px; }
.import-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.import-summary span { padding: 5px 9px; border-radius: 99px; color: var(--ink-soft); background: #edf1ee; font-size: 12px; font-weight: 700; }
.import-new-tags { padding: 13px 14px; border: 1px solid #efd2a1; border-radius: 10px; background: var(--amber-soft); }
.import-new-tags strong { display: block; margin-bottom: 5px; }
.import-new-tags ul { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 13px; }
.import-task-list { margin: 0; padding-left: 21px; color: var(--ink-soft); font-size: 13px; }
.import-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.import-note { color: var(--muted); font-size: 12px; }
.task-card { position: relative; display: flex; gap: 13px; margin: 10px 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; }
.task-card:hover { border-color: #c4d3c9; box-shadow: 0 7px 22px rgba(25, 48, 34, .075); }
.task-card > div { min-width: 0; flex: 1; }
.task-card h3 { margin: 0 0 6px; font-size: 15px; line-height: 1.35; }
.task-card p { margin: 6px 0; color: var(--ink-soft); white-space: pre-wrap; }
.task-card > input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--green); }
.pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.student-picker { display: block; max-width: 360px; margin-bottom: 17px; }
.student-task { margin: 12px 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.student-task > h3, .student-task summary h3 { margin-top: 0; }
.student-task details { margin-top: 10px; border-top: 1px solid var(--line); }
.student-task details summary { padding: 10px 0; cursor: pointer; font-weight: 650; }
.fraction { display: inline-grid; grid-template-rows: auto auto; text-align: center; vertical-align: middle; line-height: 1.1; }
.fraction b { padding: 0 4px; border-bottom: 1px solid; }

/* Statuses, statistics, management and materials created dynamically */
body .review-green { border-color: #9fd0b0 !important; border-left: 5px solid #25945d !important; background: var(--green-pale) !important; }
body .review-red { border-color: #efb7ba !important; border-left: 5px solid var(--red) !important; background: #fff7f7 !important; }
body .review-orange { border-color: #ebd19d !important; border-left: 5px solid #d68a27 !important; background: #fffaf0 !important; }
body .review-gray { border-left: 5px solid #9aa59e !important; }
.result-label { display: inline-flex; padding: 4px 8px; border-radius: 99px; background: rgba(255, 255, 255, .8); font-size: 12px; font-weight: 800; }
.expected { margin: 10px 0 !important; padding: 10px 12px !important; border: 1px solid var(--line); border-radius: 9px !important; background: rgba(255, 255, 255, .84) !important; color: var(--ink-soft); font-size: 12px !important; }
.teacher-panel, .material-editor { max-width: none !important; }
.student-title { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; }
.student-title h2, .teacher-panel > h2, .material-editor > h2 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.teacher-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; padding: 13px 14px !important; border: 1px solid var(--line) !important; border-radius: 11px; background: var(--surface); }
.teacher-row span { min-width: 0; flex: 1; }
.teacher-row small { color: var(--muted); }
.stats-grid { display: grid !important; grid-template-columns: repeat(5, minmax(110px, 1fr)) !important; gap: 10px !important; margin: 18px 0 25px !important; }
.stat { min-height: 92px; padding: 14px !important; border: 1px solid var(--line) !important; border-radius: 12px !important; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--muted); }
.stat b { display: block; margin-bottom: 5px; color: var(--ink); font-size: 26px !important; letter-spacing: -.03em; }
.stats-table { width: 100%; margin: 10px 0 25px !important; border-spacing: 0; border-collapse: separate !important; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stats-table th { color: var(--muted); background: var(--surface-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.stats-table td, .stats-table th { padding: 10px 12px !important; border-bottom: 1px solid var(--line) !important; text-align: left; }
.stats-table tr:last-child td { border-bottom: 0 !important; }
.material-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.material-filter { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
.material-filter select { width: auto; }
.material-page-head h2 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.material-page-head p { margin: 6px 0 0; color: var(--muted); }
.material-grid { display: grid !important; grid-template-columns: 270px minmax(0, 1fr) !important; gap: 15px !important; }
.material-list { position: static !important; height: auto !important; max-height: 720px; padding: 10px !important; border: 1px solid var(--line) !important; border-radius: 12px; background: var(--surface-soft); overflow: auto; }
.material-list-item { margin: 4px 0; padding: 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; }
.material-list-item:hover, .material-list-item.active { border-color: var(--line); background: var(--surface); }
.material-card-title { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: var(--ink); cursor: pointer; font: inherit; font-weight: 750; line-height: 1.35; text-align: left; }
.material-card-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.material-card-tags { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.material-card-tags.muted { color: #9aa7b5; }
.material-card-actions { display: flex; gap: 12px; margin-top: 9px; font-size: 12px; font-weight: 700; }
.material-card-actions a, .material-card-actions button { padding: 0; border: 0; color: var(--blue); background: transparent; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.material-card-actions button { color: var(--muted); }
.material-workspace { min-width: 0; }
.material-viewer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.material-viewer-head h3 { margin: 0; font-size: 20px; }
.material-viewer-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.material-viewer-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.material-open { display: inline-flex; align-items: center; text-decoration: none; }
.material-preview { width: 100%; height: 560px !important; border: 1px solid var(--line) !important; border-radius: 11px !important; background: #fff; }
.material-code-editor { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.material-code-editor > summary { padding: 13px 15px; cursor: pointer; color: var(--ink); font-weight: 700; }
.material-code-editor[open] > summary { border-bottom: 1px solid var(--line); }
.material-fields { padding: 16px; }
.material-fields h3 { margin: 18px 0 6px; font-size: 13px; }
.material-fields textarea { min-height: 160px !important; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace !important; }
.material-options, .material-actions { display: flex !important; flex-wrap: wrap; gap: 12px !important; margin: 11px 0 !important; }
.material-options label { display: flex; align-items: center; gap: 6px; }
.material-options input { width: 16px; height: 16px; padding: 0; }
.common-material-css { margin-top: 16px; }
.common-material-css > summary { cursor: pointer; font-weight: 650; }
.common-material-css textarea { margin-top: 10px; }

/* Homework builder overrides dynamic inline styles */
body .homework-box { margin: 0 0 18px !important; padding: 17px !important; border: 1px solid #bcd8c6 !important; border-radius: 14px !important; background: linear-gradient(145deg, #eff9f2, #f8fcf9) !important; box-shadow: 0 8px 25px rgba(22, 101, 52, .07) !important; }
body .homework-head strong { font-size: 17px !important; }
body .homework-count { min-width: 28px; text-align: center; background: var(--green) !important; }
body .homework-items { gap: 8px !important; }
body .homework-item { padding: 11px 12px !important; border-color: #cfe2d5 !important; border-radius: 10px !important; box-shadow: 0 1px 2px rgba(20, 50, 31, .03); }
body .homework-requirements { padding: 5px 8px; border-radius: 8px; background: var(--surface-soft); }
body .homework-requirements input { width: 15px; height: 15px; padding: 0; accent-color: var(--green); }
body .add-homework { border-radius: 9px !important; background: var(--green) !important; }
body .add-homework:hover { background: var(--green-dark) !important; }
.history-tasks { padding-top: 8px; }

/* Authentication and student portal */
.login-page { min-height: 100vh; display: grid !important; grid-template-columns: 1fr !important; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, #e5f4eb 0, transparent 30%), radial-gradient(circle at 85% 85%, #eaf1ed 0, transparent 28%), var(--canvas); }
body .student-login { width: min(100%, 410px); max-width: 410px !important; margin: 0 !important; padding: 30px !important; border: 1px solid rgba(202, 215, 206, .95) !important; border-radius: var(--radius-lg) !important; background: rgba(255, 255, 255, .96) !important; box-shadow: var(--shadow-md) !important; }
.student-login::before { content: "З"; width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 14px; color: #fff; background: var(--green); font-size: 19px; font-weight: 850; }
.student-login h2 { margin: 0 0 7px !important; font-size: 25px; letter-spacing: -.03em; }
.student-login h2::after { content: "Используйте выданные данные для входа"; display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.student-login label { display: block; margin-top: 14px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.student-login input { margin: 6px 0 0 !important; }
.student-login .primary { width: 100%; margin-top: 7px; }
.student-message { min-height: 20px; margin: 9px 0; color: var(--red); font-size: 12px; }
#studentApp.login-page { display: block !important; padding: 0; background: var(--canvas); }
#studentApp .student-login { margin: 8vh auto !important; }
.loading-state { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; }
.loading-spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--green); border-radius: 50%; animation: loading-spin .75s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.student-portal { width: min(100%, 900px); margin: 0 auto; padding: 28px 22px 70px; }
.student-portal > .student-title { position: sticky; top: 0; z-index: 10; margin: 0 -22px 22px; padding: 16px 22px; background: rgba(245, 247, 245, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.student-portal > .student-title h2 { font-size: 24px; }
.student-portal .student-task { margin-bottom: 18px; padding: 18px; border-radius: 16px; }
.student-portal .student-task > h3 { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.student-portal .task-card { box-shadow: none; background: var(--surface-soft); }
.student-answer { min-height: 96px; margin-top: 7px; }
.solution-photo { margin: 7px 0; padding: 10px; background: var(--surface); }
.student-welcome { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.empty-state, .fatal-state { max-width: 560px; margin: 9vh auto; padding: 38px 24px; border: 1px dashed var(--line-strong); border-radius: 18px; background: rgba(255,255,255,.65); text-align: center; }
.empty-state > span { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 15px; color: var(--green); background: var(--green-soft); font-size: 22px; font-weight: 850; }
.empty-state h3, .fatal-state h2 { margin: 0 0 6px; }
.empty-state p, .fatal-state p { margin: 0 0 16px; color: var(--muted); }
.homework-card { padding: 0 !important; overflow: hidden; }
.homework-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.homework-card-head h3 { margin: 7px 0 1px; font-size: 19px; letter-spacing: -.02em; }
.homework-card-head small { color: var(--muted); }
.homework-state { display: inline-flex; padding: 4px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.homework-state.is-open { color: var(--green-dark); background: var(--green-soft); }
.homework-state.is-submitted { color: var(--blue); background: var(--blue-soft); }
.locked-note { color: var(--muted); font-size: 11px; }
.student-task-list { padding: 10px 16px; }
.student-answer-card { box-shadow: none; }
.student-answer-card.status-correct { border-left: 4px solid var(--green); background: var(--green-pale); }
.student-answer-card.status-wrong { border-left: 4px solid var(--red); background: #fff8f8; }
.student-answer-card.status-review { border-left: 4px solid var(--amber); background: #fffbf4; }
.student-answer-card.status-draft { border-left: 4px solid #b7c3bb; }
.task-number { width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; color: var(--muted); background: #edf1ee; font-size: 12px; font-weight: 800; }
.student-answer-card > .task-number { min-width: 30px; flex: 0 0 30px; }
.task-card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-card-title h3 { margin: 3px 0 0; }
.task-status { flex: 0 0 auto; padding: 4px 8px; border: 1px solid currentColor; border-radius: 99px; color: var(--muted); background: rgba(255,255,255,.7); font-size: 10px; font-weight: 800; }
.status-correct .task-status { color: var(--green); }
.status-wrong .task-status { color: var(--red); }
.status-review .task-status { color: var(--amber); }
.task-statement { margin: 9px 0 12px !important; line-height: 1.65; }
.task-illustrations { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0 14px; }
.task-illustration { display: block; width: 100%; max-height: 480px; border: 1px solid var(--line); border-radius: 10px; background: #fff; object-fit: contain; }
.response-requirements { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.response-requirements span { padding: 4px 8px; border-radius: 7px; color: var(--ink-soft); background: #eaf0ec; font-size: 10px; font-weight: 750; }
.answer-field, .photo-field { display: block; margin-top: 11px; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.photo-link { display: inline-flex; margin-top: 8px; font-size: 12px; font-weight: 700; }
.draft-actions { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.save-state { color: var(--green); font-size: 11px; }
.save-state.is-error { color: var(--red); }
.teacher-note { display: grid; gap: 3px; margin-top: 12px; padding: 10px 12px; border: 1px solid #efd2a1; border-radius: 9px; color: var(--ink-soft); background: var(--amber-soft); font-size: 12px; }
.submit-homework { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--line); background: var(--surface-soft); }
.submit-homework > div { display: grid; }
.submit-homework span { color: var(--muted); font-size: 11px; }

/* Responsive */
@media (max-width: 1050px) {
  .app-header { gap: 16px; padding: 0 17px; }
  .brand-copy small { display: none; }
  .app-shell { grid-template-columns: 350px minmax(0, 1fr); }
  .content { padding: 30px 28px 80px; }
  .source-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

@media (max-width: 760px) {
  :root { --header-height: 116px; }
  .app-header { position: sticky; min-height: var(--header-height); padding: 10px 14px 0; display: block; }
  .brand { height: 48px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-copy small { display: block; }
  .main-nav { height: 57px; margin: 0 -14px; padding: 0 10px; border-top: 1px solid var(--line); }
  .header-account { position: absolute; top: 17px; right: 14px; }
  .account-name { display: none; }
  .tab { padding: 0 11px; font-size: 12px; }
  .app-shell { display: block; }
  .filter-sidebar { position: static; width: auto; height: auto; max-height: 45vh; padding: 17px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .filter-sidebar[hidden] { display: none; }
  .content { padding: 22px 14px 70px; }
  .toolbar { align-items: flex-start; }
  .page-heading { margin-bottom: 18px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading p { font-size: 13px; }
  .editor-card { padding: 16px; }
  .editor-meta, .source-grid { grid-template-columns: 1fr; }
  .difficulty { align-items: flex-start; flex-direction: column; }
  .difficulty > div { width: 100%; justify-content: space-between; }
  .difficulty button { width: 38px; }
  .section-head { align-items: flex-start; }
  .section-head small { display: none; }
  .form-row { grid-template-columns: 1fr auto; }
  .form-row > select, .form-row > input, .form-row > textarea, .form-row > .answer-fields { grid-column: 1; }
  .form-row > .remove { grid-column: 2; grid-row: 1; }
  .answer-fields { flex-direction: column; }
  .sticky-actions { bottom: 8px; flex-wrap: wrap; }
  .sticky-actions .primary { flex: 1; }
  .action-hint { width: 100%; margin: 0; padding: 0 4px; }
  .assign-top { align-items: stretch; flex-direction: column; }
  .assign-top > label, .assign-top > label select, .assign-difficulty { min-width: 0; width: 100%; }
  .range-fields select { width: 74px; min-width: 74px; }
  body .homework-item { align-items: flex-start !important; flex-wrap: wrap; }
  body .homework-item > span { flex-basis: calc(100% - 70px) !important; }
  body .homework-requirements { width: 100%; order: 3; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .material-page-head, .material-viewer-head { flex-direction: column; }
  .material-viewer-actions { justify-content: flex-start; }
  .material-grid { grid-template-columns: 1fr !important; }
  .material-list { max-height: 220px; }
  .material-preview { height: 440px !important; }
  body .student-login { padding: 24px !important; }
  .homework-card-head, .submit-homework { align-items: stretch; flex-direction: column; }
  .task-card-title { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 430px) {
  .brand-copy small { display: none; }
  .toolbar { flex-direction: column; }
  .toolbar .secondary { align-self: flex-end; }
  .section-icon { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .task-card { padding: 13px; }
  .student-portal { padding-left: 12px; padding-right: 12px; }
  .student-portal > .student-title { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
