/* Mathematics workspace in «Конструктив»: tokens and ms-* components from moskovka.css.
   The table is part of the page — no inner vertical scroll; its header sticks under the site header. */
.math-workspace{--math-name-width:220px;--math-col:56px;--math-head-1:64px;--math-head-2:44px;position:relative;min-width:0;max-width:100%;padding:24px 0 32px;color:var(--text);font:400 16px/24px var(--font-ui)}
.math-workspace *{box-sizing:border-box;min-width:0}
.math-workspace h1{margin:0;font:400 36px/42px var(--font-head);letter-spacing:.01em;text-transform:uppercase;overflow-wrap:anywhere}
.math-workspace h2{margin:0;font:700 16px/24px var(--font-ui);overflow-wrap:anywhere}
.math-workspace .ms-head-s{font:400 18px/24px var(--font-head);letter-spacing:.01em;text-transform:uppercase}
.math-workspace p,.math-workspace a{overflow-wrap:anywhere}
.math-workspace a:not(.ms-btn):not(.ms-iconbtn):not(.math-band__text){color:var(--accent-ink);text-underline-offset:4px}
.math-workspace :is(button,input,select,a,summary):focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.math-workspace :is(input,select){caret-color:var(--accent-ink);color-scheme:inherit}
.math-workspace label{display:block;color:var(--text-muted);font:500 14px/20px var(--font-ui)}
.math-workspace label>.input{display:block;width:100%;margin-top:8px}
.math-workspace .ms-btn .ms-icon{vertical-align:0}
.math-workspace ::selection{background:var(--accent-ink);color:var(--bg)}
.math-workspace a.ms-iconbtn{text-decoration:none}

/* heading, back link, status line */
.math-heading{margin:8px 0 24px}
.math-heading__title{display:flex;align-items:center;gap:8px 12px;flex-wrap:wrap}
.math-heading p{margin:6px 0 0;color:var(--text-muted);font-size:14px;line-height:20px;font-variant-numeric:tabular-nums lining-nums}
.math-backlink{margin:0 0 8px -12px}
.math-status{min-height:24px;max-width:72ch;margin-bottom:8px;font-size:14px}
.math-status:not(.is-error){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;margin:0}
.math-status.is-error{color:var(--danger);font-weight:600}
.math-error{max-width:72ch;margin:0 0 16px;color:var(--danger)}
.math-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}

/* help behind one icon: the panel floats over the content below its row */
.math-help>summary{list-style:none}
.math-help>summary::-webkit-details-marker{display:none}
.math-help[open]>summary{background:var(--surface-2);color:var(--text)}
.math-help__panel{position:absolute;z-index:20;top:calc(100% + 8px);right:0;width:max-content;max-width:min(400px,100%);padding:16px 20px;border:1px solid var(--line-strong);border-top:4px solid var(--accent);background:var(--surface);box-shadow:var(--shadow-pop);color:var(--text);font:400 14px/20px var(--font-ui)}
.math-heading .math-help__panel{right:auto;left:0}
.math-help__panel p{margin:0 0 12px}
.math-help__panel>:last-child{margin-bottom:0}
.math-heading{position:relative}
.math-keys{display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px 16px;align-items:center;margin:0}
.math-keys dt{display:flex;flex-wrap:wrap;align-items:center;gap:4px;color:var(--text-muted)}
.math-keys dd{margin:0}

/* board toolbar: group, search, actions */
.math-board-toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:0 0 16px}
.math-tablebar>.math-board-toolbar{margin:0}
.math-board-toolbar label>.input{margin-top:0}
.math-group-select{flex:0 1 260px}
.math-pupil-search{position:relative;flex:1 1 220px;max-width:360px}
.math-pupil-search>.ms-icon{position:absolute;top:50%;left:12px;transform:translateY(-50%);color:var(--text-subtle);pointer-events:none}
.math-pupil-search>.input{padding-left:36px}
.math-toolbar-actions{margin-left:auto}
.math-board-toolbar .ms-iconbtn{width:40px;height:40px;border:1px solid var(--line-strong);color:var(--text)}

/* sheet chips (left) and save state + help (right) above the table */
.math-tablebar{position:relative;display:flex;align-items:flex-end;justify-content:space-between;gap:12px 24px;flex-wrap:wrap;margin:0 0 12px}
.math-sheet-picker{flex:1 1 480px;margin:0;padding:0;border:0;min-inline-size:0}
.math-sheet-picker>div{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.math-sheet-picker label{position:relative;display:flex;align-items:center;gap:8px;min-height:44px;max-width:300px;padding:6px 16px;border:1px solid var(--line-strong);color:var(--text);font:700 14px/18px var(--font-ui);cursor:pointer;transition:background-color var(--duration-fast) var(--ease-out),border-color var(--duration-fast) var(--ease-out),color var(--duration-fast) var(--ease-out)}
.math-sheet-picker label>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.math-sheet-picker label:hover{border-color:var(--text-subtle);background:var(--surface-2)}
.math-sheet-picker label:has(input:checked){border-color:var(--accent);background:var(--accent);color:var(--on-accent)}
.math-sheet-picker label:has(input:checked) small{color:inherit;opacity:.8}
.math-sheet-picker label:has(input:focus-visible){outline:2px solid var(--focus);outline-offset:2px}
/* the checkbox stays in the accessibility tree; the fill shows its state */
.math-sheet-picker input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:inherit}
.math-sheet-picker label:has(input:disabled){cursor:default}
.math-sheet-picker small{margin-left:6px;color:inherit;opacity:.75;font:600 11px/16px var(--font-ui);letter-spacing:.06em;text-transform:uppercase}
.math-sheet-picker .is-extra{display:none}
.math-sheet-picker.is-open .is-extra{display:flex}
.math-sheet-more{width:44px;height:44px;border:1px solid var(--line-strong)}
.math-sheet-more[aria-expanded="true"] .ms-icon{transform:rotate(180deg)}
.math-tools{display:flex;align-items:center;gap:4px;margin-left:auto}
.math-save{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.math-save__state{display:inline-flex;align-items:center;gap:8px;min-height:32px;margin:0;padding:0 8px;color:var(--text-subtle);font:600 14px/20px var(--font-ui)}
.math-save__state[data-state="saved"]{color:var(--success)}
.math-save__state[data-state="saving"],.math-save__state[data-state="pending"]{color:var(--text-muted)}
.math-save__state[data-state="error"]{color:var(--danger)}

/* notices, conflicts, empty states */
.math-notice{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:0 0 16px}
.math-notice>p{display:inline-flex;align-items:center;gap:8px;min-height:32px;margin:0;padding:4px 12px;border:1px solid var(--line-strong);color:var(--text-muted);font:700 12px/16px var(--font-ui);letter-spacing:.06em;text-transform:uppercase}
.math-conflicts{margin:0 0 16px;padding:16px 20px;border:1px solid var(--line-strong);border-top:4px solid var(--warning);background:var(--surface)}
.math-conflicts ul{list-style:none;margin:12px 0 0;padding:0}
.math-conflicts li{padding:12px 0;border-top:1px solid var(--line)}
.math-conflicts li p{margin:0 0 8px;font-size:14px;line-height:20px}
.math-empty{max-width:640px;margin:0;padding:32px 0;border-top:1px solid var(--line);color:var(--text-muted)}

/* table: flows with the page; horizontal scroll only when it is wider than the column */
.math-table-frame{position:relative}
.math-table-frame::before,.math-table-frame::after{content:'';position:absolute;z-index:6;top:1px;bottom:1px;width:32px;opacity:0;pointer-events:none;transition:opacity var(--duration-fast) var(--ease-out)}
.math-table-frame::before{left:calc(var(--math-name-width) + 1px);background:linear-gradient(to right,var(--scrim),transparent)}
.math-table-frame::after{right:1px;background:linear-gradient(to left,var(--scrim),transparent)}
.math-table-frame.has-left::before,.math-table-frame.has-right::after{opacity:1}
.math-tools [data-math="pan"][hidden]{display:none}
.math-table-scroll{max-width:100%;scroll-padding-left:var(--math-name-width)}
.math-table-scroll.is-scrollable{overflow-x:auto;scrollbar-color:var(--line-strong) var(--surface);scrollbar-width:thin}
.math-table-scroll:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
/* natural width is name + 56 px per task; a short table stretches to the column, at most 72 px per task */
.math-grid{width:max(calc(var(--math-name-width) + var(--math-columns, 1) * var(--math-col) + 2px),min(100%,calc(var(--math-name-width) + var(--math-columns, 1) * 72px)));border:1px solid var(--line-strong);border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:14px;line-height:20px;font-variant-numeric:tabular-nums lining-nums}
.math-grid .math-name-col{width:var(--math-name-width)}
.math-grid .math-task-col{width:var(--math-col)}
.math-grid :is(th,td){min-width:var(--math-col);padding:4px;vertical-align:middle;border-right:1px solid var(--line);border-bottom:1px solid var(--line);text-align:center;background:var(--bg)}
.math-grid tr>:last-child{border-right:0}
.math-grid tbody tr:last-child>*{border-bottom:0}
.math-grid thead th{position:sticky;top:var(--header-h,0px);z-index:2;height:var(--math-head-1);background:var(--surface)}
/* problem labels in mono: Golos bold makes «3б» read as «36» */
.math-grid thead tr:nth-child(2) th{top:calc(var(--header-h,0px) + var(--math-head-1));height:var(--math-head-2);padding:8px 4px;border-bottom-color:var(--line-strong);font:600 14px/20px var(--font-mono)}
.math-grid thead tr:nth-child(2) span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* a horizontal scroller is a scroll container, so CSS sticky stops at its edge: the header then rides on a transform from JS */
.is-scrollable .math-grid thead th{top:0}
.is-scrollable .math-grid thead tr:nth-child(2) th{top:var(--math-head-1)}
.is-scrollable .math-grid thead{position:relative;z-index:4}
.math-grid .math-name{position:sticky;left:0;z-index:1;width:var(--math-name-width);min-width:var(--math-name-width);max-width:var(--math-name-width);padding:10px 12px;border-right-color:var(--line-strong);background:var(--surface);text-align:left;overflow-wrap:anywhere;font:500 14px/20px var(--font-ui)}
.math-grid thead .math-name{z-index:3;vertical-align:bottom;border-bottom-color:var(--line-strong);color:var(--text-muted);font:700 12px/16px var(--font-ui);letter-spacing:.06em;text-transform:uppercase}
.math-grid thead .math-name small{display:block;margin-top:2px;color:var(--text);font:700 20px/28px var(--font-ui);letter-spacing:0}
.math-grid tbody .math-name small{display:block;margin-top:4px;color:var(--text-muted);font:400 11px/15px var(--font-ui)}
.math-grid tbody tr:focus-within>.math-name{box-shadow:inset 4px 0 0 var(--accent)}
.math-grid tr[data-member-row]:focus{outline:2px solid var(--focus);outline-offset:-2px}
.math-grid .math-sheet-band{padding:0;text-align:left;border-right-color:var(--line-strong);box-shadow:inset 0 4px 0 var(--accent)}
.math-band{display:flex;padding:8px 4px 4px 12px}
.math-band__sticky{position:sticky;left:calc(var(--math-name-width) + 12px);display:flex;align-items:center;gap:4px;max-width:100%;min-width:0}
.math-band__text{min-width:0;color:var(--text);text-decoration:none}
.math-band__text>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:700 14px/20px var(--font-ui)}
.math-band__text:hover>span{color:var(--accent-ink);text-decoration:underline;text-underline-offset:4px}
.math-band small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-muted);font:400 12px/16px var(--font-ui)}
.math-grid .math-sheet-start{border-left:1px solid var(--line-strong)}
.math-grid td.is-dirty{background:var(--surface-2)}
.math-grid td.is-unavailable{background:var(--surface-2)}

/* «+»: Dela Gothic One in the accent ink, 44 px hit area */
.math-mark{display:flex;align-items:center;justify-content:center;width:44px;min-width:44px;height:44px;padding:0;margin:auto;border:1px solid transparent;border-radius:var(--radius-s);background:transparent;color:var(--text-muted);font:400 22px/1 var(--font-ui);cursor:pointer;scroll-margin:calc(var(--math-head-1) + var(--math-head-2) + 8px) 8px 8px calc(var(--math-name-width) + 8px);transition:background-color var(--duration-fast) var(--ease-out),border-color var(--duration-fast) var(--ease-out)}
.math-mark.is-solved{color:var(--accent-ink);font:400 24px/1 var(--font-head)}
.math-mark.is-legacy{color:var(--text-muted)}
.math-mark:hover:not(:disabled){border-color:var(--line-strong);background:var(--surface-2)}
.math-mark:not(.is-solved):not(.is-legacy):hover:not(:disabled)::after{content:'+';color:var(--text-subtle);font:400 24px/1 var(--font-head)}
.math-mark:active:not(:disabled){background:var(--surface)}
.math-mark:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
.math-mark:disabled{cursor:default;background:transparent}
.math-mark.is-solved:disabled{color:var(--text-muted)}
.math-unavailable{display:block;width:44px;margin:auto;color:var(--text-subtle);font-size:14px;line-height:44px}
.math-data-legend{margin:12px 0 0;color:var(--text-muted);font:400 13px/19px var(--font-ui)}

/* coordinator tools under the table */
.math-sheet-tools{margin-top:32px;border-top:1px solid var(--line)}
.math-sheet-tools>summary{display:inline-flex;align-items:center;gap:8px;min-height:44px;margin-top:8px;padding-right:12px;list-style:none;color:var(--text);font:700 14px/20px var(--font-ui);letter-spacing:.06em;text-transform:uppercase;cursor:pointer}
.math-sheet-tools>summary::-webkit-details-marker{display:none}
.math-sheet-tools>summary:hover{color:var(--accent-ink)}
.math-sheet-tools[open]>summary .ms-icon{transform:rotate(180deg)}
.math-sheet-tool{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--line)}
.math-sheet-tool>span{font:600 16px/24px var(--font-ui)}
.math-sheet-tool>span>small{display:block;color:var(--text-muted);font:400 12px/16px var(--font-ui);font-variant-numeric:tabular-nums lining-nums}
.math-sheet-tool>span>a{font-weight:600}
.math-confirm{grid-column:1/-1;max-width:640px;display:grid;gap:12px;padding:16px;border:1px solid var(--line-strong);border-top:4px solid var(--accent);background:var(--surface)}
.math-confirm p{margin:0;font-size:14px;line-height:20px}
.math-sheet-list{border-bottom:1px solid var(--line)}

/* pager */
.math-pager{display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap;margin-top:24px;font:600 14px/20px var(--font-ui);font-variant-numeric:tabular-nums lining-nums}
.math-pager .ms-iconbtn{width:40px;height:40px;border:1px solid var(--line-strong);color:var(--text)}

/* new sheet form */
.math-create{display:grid;gap:24px;max-width:850px}
.math-fields{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:16px}
.math-wide{grid-column:1/-1}
.math-create fieldset{margin:0;padding:24px 0 0;border:0;border-top:1px solid var(--line);min-inline-size:0}
.math-create legend{float:left;width:100%;margin:0 0 16px;padding:0;color:var(--text)}
.math-create [data-problems]{clear:both}
.math-problem{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr) auto;gap:12px;align-items:end;margin:0 0 12px}
.math-problem+.math-problem label>span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.math-problem+.math-problem label>.input{margin-top:0}
.math-problem .ms-iconbtn{width:40px;height:40px}
.math-problem .ms-iconbtn:hover{color:var(--danger)}
.math-create fieldset>.ms-btn{margin-top:4px}

/* history */
.math-history{list-style:none;max-width:880px;margin:0;padding:0;border-bottom:1px solid var(--line)}
.math-history>li{padding:16px 0;border-top:1px solid var(--line)}
.math-history .math-meta{margin:2px 0 8px;color:var(--text-muted);font-size:14px;line-height:20px;font-variant-numeric:tabular-nums lining-nums}
.math-history ul{margin:0;padding-left:20px}
.math-history ul li{padding:4px 0;overflow-wrap:anywhere;font-size:14px;line-height:20px}
.math-history ul p{margin:2px 0 0;color:var(--text-muted)}
.math-change{color:var(--accent-ink);font-weight:700;white-space:nowrap}
.math-history+.ms-btn{margin-top:24px}

@media (max-width:720px){
  .math-workspace{--math-name-width:150px}
  .math-toolbar-actions{width:100%;margin-left:0}
  .math-group-select,.math-pupil-search{flex:1 1 100%;max-width:none}
  .math-tablebar{flex-wrap:nowrap;align-items:center}
  .math-tablebar:has([data-state="error"]){flex-wrap:wrap}
  .math-sheet-picker{flex:1 1 0}
  .math-sheet-picker>div{flex-wrap:nowrap;overflow-x:auto;padding:2px 2px 6px;scrollbar-width:none}
  .math-sheet-picker .is-extra{display:flex}
  .math-sheet-picker label{flex:0 0 auto;max-width:240px}
  .math-sheet-picker label:has(input:checked){order:-1}
  .math-sheet-more{display:none}
  .math-grid tbody .math-name{font-size:13px;line-height:18px}
}
@media (max-width:560px){
  .math-workspace{padding-top:16px}
  .math-workspace h1{font-size:28px;line-height:32px}
  .math-fields{grid-template-columns:1fr}
  .math-problem{grid-template-columns:minmax(0,1fr) minmax(0,2fr) auto}
}
@media (max-width:640px),(pointer:coarse){
  .math-board-toolbar .ms-iconbtn,.math-problem .ms-iconbtn,.math-pager .ms-iconbtn{width:44px;height:44px}
}
@media (prefers-reduced-motion:reduce){.math-mark,.math-sheet-picker label{transition:none}}
