:root{
  --bg:#EEF0F3; --surface:#FFFFFF; --sub:#EEF0F3; --ink:#15171C; --muted:#555B66; --line:#15171C; --hair:#D5D8DE;
  --accent:#1F4FD8; --accent-soft:#DCE6FF; --accent-ink:#15379A; --on-accent:#FFFFFF;
  --mid:#9DB5F5; --warn:#C2410C; --warn-soft:#FFF3E8; --on-warn:#FFFFFF;
  --nav:#15171C; --nav-fg:#FFFFFF; --nav-muted:#B9BEC8;
  --f-display:'Unbounded','Arial Black',sans-serif;
  --f-body:'Golos Text','Segoe UI',system-ui,sans-serif;
  --f-mono:'JetBrains Mono',ui-monospace,'Courier New',monospace;
}
@media (prefers-color-scheme: dark){ :root{
  --bg:#0F1115; --surface:#1A1D23; --sub:#23262D; --ink:#ECEEF2; --muted:#A3A9B4; --line:#5A606B; --hair:#2E323A;
  --accent:#7C9CFF; --accent-soft:#1E2A4D; --accent-ink:#B7C9FF; --on-accent:#0F1115;
  --mid:#3D5AA8; --warn:#FF8A4C; --warn-soft:#3A2116; --on-warn:#0F1115;
  --nav:#08090C; --nav-fg:#FFFFFF; --nav-muted:#9AA0AA; color-scheme:dark }}

*{box-sizing:border-box}
body{margin:0; background:var(--bg); color:var(--ink); font-family:var(--f-body); font-size:15px; line-height:1.5; min-height:100vh; display:flex; flex-direction:column}
a{color:var(--accent)}
button,input,select,textarea{font:inherit; color:inherit}
button{cursor:pointer}
:focus-visible{outline:3px solid var(--accent); outline-offset:2px}
sub,sup{font-size:.72em}
.mono{font-family:var(--f-mono)}
h1,h2,h3{font-family:var(--f-display); margin:0; text-wrap:balance}
h1{font-size:clamp(24px,3.5vw,32px)}
h2{font-size:18px}

.top{background:var(--nav); color:var(--nav-fg); padding-block:12px; padding-inline:max(16px, calc((100% - 1200px)/2))}
.top-in{display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px}
.brand{display:flex; align-items:center; gap:10px; color:var(--nav-fg); text-decoration:none}
.brand-mark{width:36px; height:36px; border:2px solid var(--nav-fg); border-radius:6px; display:grid; place-items:center; font-family:var(--f-mono); font-weight:700; font-size:12px}
.brand-name{font-family:var(--f-display); font-weight:700; font-size:19px; letter-spacing:1px}
.menu{display:flex; flex-wrap:wrap; align-items:center; gap:6px}
.menu a{color:var(--nav-fg); text-decoration:none; padding:9px 12px; border-radius:6px}
.menu a[aria-current="page"]{background:var(--nav-fg); color:var(--nav)}
.menu a:hover{text-decoration:underline; text-underline-offset:4px}
.logout{margin:0}
.logout button{background:transparent; border:1px solid var(--nav-muted); color:var(--nav-fg); border-radius:6px; padding:8px 12px}

.page{flex:1; width:100%; max-width:1200px; margin:0 auto; padding-inline:16px; padding-block:28px 48px; display:flex; flex-direction:column; gap:20px}
.foot{padding-block:18px; padding-inline:16px; display:flex; flex-wrap:wrap; justify-content:center; gap:16px; font-size:13px; color:var(--muted)}

.head{display:flex; flex-wrap:wrap; justify-content:space-between; align-items:flex-end; gap:12px}
.eyebrow{font-family:var(--f-mono); font-size:12px; letter-spacing:1px; color:var(--muted); text-transform:uppercase}
.panel{background:var(--surface); border:2px solid var(--line); border-radius:8px; padding:20px; min-width:0}
.panel > h2{margin-bottom:14px}
.grid2{display:grid; grid-template-columns:repeat(auto-fit, minmax(320px, 1fr)); gap:16px; align-items:start}
.stack{display:flex; flex-direction:column; gap:12px}
.muted{color:var(--muted)}
.small{font-size:13px}

.flash{border:2px solid var(--accent); background:var(--accent-soft); border-radius:8px; padding:14px 16px}
.flash.err{border-color:var(--warn); background:var(--warn-soft)}
.flash code, .secret{font-family:var(--f-mono); font-size:16px; font-weight:700; background:var(--surface); padding:2px 8px; border-radius:4px}

.btn{display:inline-flex; align-items:center; justify-content:center; min-height:46px; padding:0 18px; border-radius:6px; border:0; background:var(--accent); color:var(--on-accent); font-weight:600; text-decoration:none}
.btn.ghost{background:var(--surface); color:var(--ink); border:2px solid var(--line)}
.btn.danger{background:var(--warn); color:var(--on-warn)}
.btn.sm{min-height:38px; padding:0 12px; font-size:14px}

.field{display:flex; flex-direction:column; gap:6px; min-width:0}
.field label{font-size:13px; color:var(--muted)}
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=url], .field select, .field textarea{
  min-height:44px; border:2px solid var(--line); border-radius:6px; padding:8px 12px; background:var(--surface); width:100%}
.field textarea{min-height:90px; resize:vertical}
.row{display:flex; flex-wrap:wrap; gap:12px}
.row > .field{flex:1 1 160px}
.checks{display:flex; flex-wrap:wrap; gap:8px}
.check{display:inline-flex; align-items:center; gap:8px; border:1.5px solid var(--line); border-radius:20px; padding:6px 14px; min-height:40px}
.check input{width:18px; height:18px}
.hint{font-size:13px; color:var(--muted); margin:0}

.table-wrap{overflow-x:auto}
table{width:100%; border-collapse:collapse; font-size:14px; min-width:640px}
th{font-family:var(--f-mono); font-size:11px; letter-spacing:1px; color:var(--muted); text-align:left; font-weight:500; padding:10px 12px; text-transform:uppercase}
td{padding:12px; border-top:1px solid var(--hair); vertical-align:top}
.chip{display:inline-block; border:1.5px solid var(--line); border-radius:4px; padding:1px 8px; font-family:var(--f-mono); font-size:12px; font-weight:700; margin:0 4px 4px 0}
.pill{display:inline-block; border-radius:4px; padding:2px 8px; font-size:12px; font-weight:600}
.pill.ok{background:var(--accent-soft); color:var(--accent-ink)}
.pill.bad{background:var(--warn); color:var(--on-warn)}

.stats{display:grid; grid-template-columns:repeat(auto-fit, minmax(150px,1fr)); gap:12px}
.stat{background:var(--surface); border:2px solid var(--line); border-radius:8px; padding:14px 16px}
.stat b{display:block; font-family:var(--f-display); font-size:26px; margin-top:4px; font-variant-numeric:tabular-nums}

.map{display:grid; grid-template-columns:repeat(auto-fill, minmax(52px,1fr)); gap:6px}
.cell{aspect-ratio:1; border-radius:5px; border:1px solid var(--hair); background:var(--sub); display:flex; flex-direction:column; align-items:center; justify-content:center; line-height:1.1; padding:0}
.cell .n{font-family:var(--f-mono); font-weight:700; font-size:14px}
.cell .p{font-size:11px; font-variant-numeric:tabular-nums}
.cell.none{background:transparent; border-style:dashed; color:var(--muted)}
.cell.fresh{background:var(--surface); border:1.5px solid var(--line)}
.cell.l4{background:var(--accent); color:var(--on-accent); border-color:var(--accent)}
.cell.l3{background:var(--mid); color:var(--ink); border-color:var(--mid)}
.cell.l2{background:var(--warn-soft); color:var(--ink); border-color:var(--warn)}
.cell.l1{background:var(--warn); color:var(--on-warn); border-color:var(--warn)}
button.cell{cursor:pointer}
.cell.sel{outline:3px solid var(--ink); outline-offset:1px}
.legend{display:flex; flex-wrap:wrap; gap:12px; margin-top:12px; font-size:12px; color:var(--muted)}
.legend span{display:inline-flex; align-items:center; gap:5px}
.sw{width:12px; height:12px; border-radius:3px; display:inline-block; border:1px solid var(--hair)}
.sw.l4{background:var(--accent)} .sw.l3{background:var(--mid)} .sw.l2{background:var(--warn-soft); border-color:var(--warn)} .sw.l1{background:var(--warn)} .sw.fresh{background:var(--surface); border-color:var(--line)}

.auth{max-width:420px; margin:40px auto 0; width:100%}
.legal{max-width:760px}
.legal h2{margin:22px 0 8px}
.legal p, .legal li{color:var(--ink)}
.empty{border:2px dashed var(--line); border-radius:8px; padding:24px; text-align:center; color:var(--muted); background:var(--surface)}

/* Домашки и Telegram */
.pill.wait{background:var(--sub); color:var(--ink); border:1px solid var(--hair)}
.strip-head{background:var(--ink); color:var(--bg); padding:8px 16px; font-family:var(--f-mono); font-size:12px; font-weight:700; letter-spacing:1px; display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; text-transform:uppercase}
.strip-head.past{background:var(--sub); color:var(--muted); border-bottom:1px solid var(--hair)}
.hwgrid{display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:16px}
.hw.late{border-color:var(--warn)}
.hw.late .strip-head.past{background:var(--warn); color:var(--on-warn); border-bottom:0}
.hwrow{display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; border-top:1px solid var(--hair); padding-top:8px}
.bar{height:8px; background:var(--accent-soft); border-radius:4px; overflow:hidden}
.bar i{display:block; height:8px; background:var(--accent); border-radius:4px}
.pick{border:0; padding:0; margin:0; min-width:0}
.pick legend{font-size:13px; color:var(--muted); margin-bottom:6px; padding:0}
.picklist{max-height:360px; overflow-y:auto; border:2px solid var(--line); border-radius:6px; padding:4px 12px 10px}
.lbl-track{font-family:var(--f-mono); font-size:11px; letter-spacing:1px; color:var(--muted); text-transform:uppercase; margin:10px 0 4px}
.pickrow{display:flex; gap:10px; align-items:flex-start; padding:8px 0; border-top:1px solid var(--hair); cursor:pointer}
.pickrow input{width:18px; height:18px; margin-top:3px; flex:0 0 auto}
.field input.dt, .field input[type=datetime-local]{min-height:44px; border:2px solid var(--line); border-radius:6px; padding:8px 12px; background:var(--surface); width:100%}
.steps{margin:0; padding-left:20px; display:flex; flex-direction:column; gap:10px}
details summary{cursor:pointer; color:var(--accent)}

/* Отбор заданий для домашки */
.pickbar{display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; justify-content:space-between; margin-bottom:8px}
.fchip{min-height:38px; padding:0 12px; border-radius:19px; border:1.5px solid var(--line); background:var(--surface); font-size:14px}
.fchip[aria-pressed="true"]{background:var(--ink); color:var(--bg); border-color:var(--ink); font-weight:600}
.fchip:disabled{opacity:.4; cursor:not-allowed}
.locked{font-size:13px; color:var(--muted)}

/* Типы заданий внутри номера */
a.cell{text-decoration:none; color:inherit}
.cell.fresh, .cell.l2{color:var(--ink)}
.taskrow{padding:14px 20px; border-bottom:1px solid var(--hair); display:flex; flex-direction:column; gap:6px}
.grp-num{display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; padding:8px 20px; background:var(--ink); color:var(--bg); font-family:var(--f-mono); font-size:12px; font-weight:700; letter-spacing:1px; text-transform:uppercase}
.grp-num a{color:var(--bg)}
.grp-type > summary{display:flex; justify-content:space-between; gap:10px; align-items:center; min-height:44px; padding:8px 20px; background:var(--sub); color:var(--ink); border-bottom:1px solid var(--hair); font-weight:600; list-style:none}
.grp-type > summary::-webkit-details-marker{display:none}
.grp-type > summary > span:first-child::before{content:'▸'; display:inline-block; width:18px; color:var(--muted)}
.grp-type[open] > summary > span:first-child::before{content:'▾'}
.grp-type.untyped > summary{background:var(--warn-soft)}
.suggest{display:flex; flex-wrap:wrap; align-items:center; gap:10px; border:2px solid var(--accent); background:var(--accent-soft); border-radius:6px; padding:8px 12px; font-size:14px}
.markrow{display:grid; grid-template-columns:minmax(0, 1fr) minmax(200px, 300px); gap:12px; align-items:start; border-top:1px solid var(--hair); padding-top:12px}
@media (max-width:640px){ .markrow{grid-template-columns:1fr} }
.field select.guess{border-color:var(--accent); background:var(--accent-soft)}
.pct{display:inline-block; min-width:48px; text-align:center; border-radius:4px; padding:2px 8px; font-family:var(--f-mono); font-size:12px; font-weight:700; border:1px solid transparent}
.pct.l4{background:var(--accent); color:var(--on-accent)} .pct.l3{background:var(--mid); color:var(--ink)}
.pct.l2{background:var(--warn-soft); color:var(--ink); border-color:var(--warn)} .pct.l1{background:var(--warn); color:var(--on-warn)}
table.types{min-width:520px}
.grid2.wide{grid-template-columns:minmax(0, 2fr) minmax(280px, 1fr)}
@media (max-width:900px){ .grid2.wide{grid-template-columns:1fr} }
.typeline{display:flex; justify-content:space-between; align-items:center; gap:10px; border-top:1px solid var(--hair); padding-top:8px}

/* Развёрнутые ответы и их проверка */
.badge{display:inline-block; min-width:20px; padding:0 6px; border-radius:10px; background:var(--warn); color:var(--on-warn); font-family:var(--f-mono); font-size:12px; font-weight:700; text-align:center; line-height:20px}
.shots{display:grid; grid-template-columns:repeat(auto-fill, minmax(180px, 1fr)); gap:10px}
.shots a{display:block; border:1.5px solid var(--hair); border-radius:6px; overflow:hidden; background:var(--sub); color:var(--ink)}
.shots img{display:block; width:100%; height:220px; object-fit:contain; background:var(--sub)}
.shots .doc{display:flex; align-items:center; justify-content:center; height:220px; padding:12px; text-align:center; overflow-wrap:anywhere; font-size:14px}
.shots .cap{display:block; padding:6px 8px; font-size:12px; color:var(--muted); border-top:1px solid var(--hair); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.qbox{background:var(--sub); border-radius:6px; padding:12px 14px; font-size:14px}

.chip.code{background:var(--ink); color:var(--bg); border-color:var(--ink)}

[hidden]{display:none !important}

/* Метки на карточках уроков: презентация, видео */
.tags{display:flex; flex-wrap:wrap; gap:6px}
.tag{font-size:12px; border-radius:10px; padding:2px 9px; background:var(--sub); display:inline-flex; gap:5px; align-items:center}

/* Картинки в условии и решении задания (чертежи на белом фоне и в тёмной теме) */
.timg{display:block; max-width:100%; height:auto; margin:10px 0; background:#fff; border-radius:4px}
.timg-a{display:block; text-decoration:none; color:var(--muted)}
.timg-a .timg{margin-bottom:2px}
@media (max-width:700px){ .timg-a::after{content:"Нажми на картинку, чтобы увеличить"; display:block; font-size:12px; margin-bottom:10px} }

/* Выбор заданий в домашке: «Открыть полностью» */
.pf-open{display:flex; width:fit-content; margin-top:6px; min-height:32px; padding:0 12px; font-size:13px}
.pf-full{display:flex; flex-direction:column; gap:6px; margin-top:8px; padding:12px 14px; background:var(--sub); border-radius:6px; font-size:15px; line-height:1.5; color:var(--ink); cursor:auto; overflow-wrap:anywhere}
.pf-full[hidden]{display:none}
.pf-fo{display:flex; flex-wrap:wrap; gap:4px 16px}
.pf-fl{font-family:var(--f-mono); font-size:11px; letter-spacing:1px; color:var(--muted); text-transform:uppercase; margin-top:4px}
.pf-solved .pill{margin-right:4px}
.pf-pop{position:fixed; z-index:50; max-height:min(70vh, 640px); overflow:auto; display:flex; flex-direction:column; gap:6px; padding:14px 16px; background:var(--surface); color:var(--ink); border:2px solid var(--ink); border-radius:8px; box-shadow:0 10px 30px rgba(0,0,0,.18); font-size:15px; line-height:1.5; overflow-wrap:anywhere}
.pf-pop[hidden]{display:none}
.pf-pop-h{font-family:var(--f-mono); font-size:12px; color:var(--muted)}
@media (hover:hover) and (pointer:fine){ .pf-open{display:none} }
.pf-edit{font-weight:600; white-space:nowrap}
.pf-pop-h{display:flex; justify-content:space-between; gap:12px; align-items:baseline}
.pf-pop-h .pf-edit{font-family:var(--f-body, inherit); font-size:13px}
.pickrow.pf-flash{animation:pfflash 2.4s ease-out}
@keyframes pfflash{0%,40%{background:var(--accent-soft)}100%{background:transparent}}
