/* Практикум лекции 4: детектор — страница студента (practice/detect.js).
   Токены — из css/base.css и practice.css (светлая и тёмная темы). Префикс классов — dx-. */

:root {
  --dx-stage: #2b2e34;
  --dx-stage-ink: #e9ebef;
  --dx-gt: #16a34a;
  --dx-tp: #2563eb;
  --dx-fp: #dc2626;
  --dx-good-fill: var(--good-ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --dx-stage: #08090b;
    --dx-stage-ink: #c3c6cc;
  }
}
:root[data-theme='dark'] {
  --dx-stage: #08090b;
  --dx-stage-ink: #c3c6cc;
}

/* ---------------------------------------------------------------- шапка и вкладки */

.detect-page .task-head {
  margin-bottom: 14px;
}
.dx-tabs {
  flex: none;
}
.dx-tabs .seg-item {
  flex: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.2;
}
.dx-tabs .seg-item[aria-selected='true'] {
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 18, 22, 0.1);
}
.dx-tabs .seg-item[aria-selected='true'] .seg-num {
  background: var(--accent);
  color: var(--accent-ink);
}
.dx-tabs .seg-item > * {
  flex: none;
}
.dx-tab-note {
  display: inline-flex;
  flex: none;
  min-width: max-content;
  white-space: nowrap;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.dx-tab-note:empty {
  display: none;
}
.dx-tab-note.ok {
  color: var(--good-ink);
}
.dx-tab-note.live {
  color: var(--accent);
}
.dx-tab-note .ico {
  width: 14px;
  height: 14px;
}
.dx-tabs-row {
  margin-bottom: 14px;
}
.dx-view {
  min-width: 0;
}
.dx-err {
  max-width: 560px;
  margin: 24px auto;
}

/* ---------------------------------------------------------------- 1. выбор набора */

.dx-desc {
  margin-bottom: 20px;
}
.dx-pick-head {
  margin: 4px 0 16px;
}
.dx-pick-head h2 {
  font-size: 22px;
  margin: 0 0 6px;
}
.dx-ds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 16px;
  align-items: stretch;
}
.card.dx-ds {
  padding: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
  transition: box-shadow 0.15s ease;
}
.dx-ds.on {
  box-shadow: 0 0 0 2px var(--accent);
}
.dx-ds-img {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: var(--bg-3);
  aspect-ratio: 1472 / 744;
  cursor: pointer;
  overflow: hidden;
}
.dx-ds-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}
.dx-ds-img:hover img {
  transform: scale(1.02);
}
.dx-ds-noimg {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}
.dx-ds-cur {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}
.dx-ds-cur .ico {
  width: 16px;
  height: 16px;
}
.dx-ds-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
}
.dx-ds-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}
.dx-ds-short {
  margin: -4px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}
.dx-ds-classes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.dx-ds-classes li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 13px;
  font-weight: 500;
}
.dx-sw {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c, var(--muted));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.dx-ds-more summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
}
.dx-ds-more p {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.dx-ds-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  font-size: 13.5px;
}
.dx-ds-progress .dx-meter {
  grid-column: 1 / -1;
}
.dx-ds-count {
  color: var(--ink-2);
}
.dx-ds-best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--good-ink);
  font-weight: 600;
}
.dx-ds-best .ico {
  width: 15px;
  height: 15px;
}
.dx-ds-progress {
  margin-top: auto;
  padding-top: 4px;
}
.dx-ds-go {
  align-self: flex-start;
}
.dx-ds-ready {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  margin: -4px 0 0;
  color: var(--good-ink);
}
.dx-ds-ready .ico {
  width: 15px;
  height: 15px;
}

/* полоса прогресса «готово N из 30 (макс. 40)» */
.dx-meter {
  position: relative;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-3);
}
.dx-meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}
.dx-meter.ok .dx-meter-fill {
  background: var(--good);
}
.dx-meter-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink-2);
}

/* ---------------------------------------------------------------- 2. разметка */

.dx-work {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 290px;
  grid-template-areas: 'left center right';
  gap: 14px;
  height: clamp(540px, calc(100dvh - 176px), 1100px);
}
.dx-left {
  grid-area: left;
}
.dx-center {
  grid-area: center;
}
.dx-right {
  grid-area: right;
}
.dx-left,
.dx-center,
.dx-right {
  min-width: 0;
  min-height: 0;
}

/* центр: палитра, холст, навигация */
.dx-center {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
}
.dx-stagebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.dx-palette {
  display: flex;
  gap: 6px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.dx-palette::-webkit-scrollbar {
  display: none;
}
.dx-cls {
  --c: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  min-height: 36px;
  padding: 0 11px 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.dx-cls:hover {
  border-color: var(--c);
  color: var(--ink);
}
.dx-cls kbd {
  min-width: 22px;
  text-align: center;
  padding: 1px 5px;
  font-size: 12px;
}
.dx-cls[aria-checked='true'] {
  border-color: var(--c);
  box-shadow: inset 0 0 0 1px var(--c);
  background: color-mix(in srgb, var(--c) 14%, var(--bg));
  color: var(--ink);
}
.dx-cls[aria-checked='true'] kbd {
  background: var(--c);
  color: #fff;
}
.dx-cls .dx-sw {
  width: 12px;
  height: 12px;
}
.dx-cls-n {
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.dx-cls-n:empty {
  display: none;
}
.dx-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.dx-tool:disabled {
  opacity: 0.35;
  cursor: default;
  background: transparent;
}
.dx-tools-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--line);
}

.dx-stage {
  position: relative;
  min-height: 0;
  background: var(--dx-stage);
  overflow: hidden;
}
.dx-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.dx-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border: 0;
  border-radius: 7px;
  background: rgba(16, 18, 22, 0.66);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.85;
}
.dx-zoom.fitted {
  opacity: 0.55;
}
.dx-zoom:hover {
  opacity: 1;
}
.dx-stage-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: calc(100% - 120px);
  padding: 6px 12px;
  border-radius: 9px;
  background: rgba(16, 18, 22, 0.72);
  color: #fff;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}
.dx-stage-msg {
  position: absolute;
  inset: auto 12px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bad-soft);
  color: var(--ink);
  font-size: 14px;
}
.dx-stage-msg .ico {
  color: var(--bad-ink);
}
.dx-stage.dx-loading::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.9s linear infinite;
  pointer-events: none;
}

.dx-navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.dx-nav-btn {
  width: 36px;
  padding: 0;
}
.dx-pos {
  font-size: 14px;
  white-space: nowrap;
}
.dx-file {
  font-size: 13px;
}
.dx-done {
  gap: 7px;
}
.dx-done-box {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  color: transparent;
}
.dx-done-box .ico {
  width: 14px;
  height: 14px;
}
.dx-done.on {
  border-color: var(--good-ink);
  background: var(--good-soft);
  color: var(--good-ink);
}
.dx-done.on .dx-done-box {
  border-color: var(--good-ink);
  background: var(--good-ink);
  color: var(--bg);
}
.dx-navbar .dx-save {
  order: 10;
  flex-basis: auto;
}
.dx-done-next kbd {
  font-size: 11.5px;
}

/* превью пула */
.dx-left {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
}
.dx-thumbs-head {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.dx-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.dx-check {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.dx-thumbs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.dx-thumb {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--bg-3);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
}
/* высота превью — через отступ (строки сетки — max-content, иначе прокручиваемая сетка их сжимает) */
.dx-thumb::before {
  content: '';
  display: block;
  padding-top: 75%;
}
.dx-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dx-thumb:hover {
  box-shadow: 0 0 0 2px var(--line-strong);
}
.dx-thumb.cur {
  box-shadow: 0 0 0 2.5px var(--accent);
}
.dx-thumb-n {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(16, 18, 22, 0.66);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 17px;
}
.dx-thumb-st {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
}
.dx-thumb-st:empty {
  display: none;
}
.dx-thumb-st .ico {
  width: 14px;
  height: 14px;
}
.dx-thumb.is-done .dx-thumb-st {
  background: var(--good);
  color: #fff;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
.dx-thumb.is-started .dx-thumb-st {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
.dx-thumb.is-done img {
  opacity: 0.72;
}
.dx-thumb.is-extra .dx-thumb-st {
  background: var(--muted);
}
.dx-thumb.is-extra::after {
  content: 'сверх 40';
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(16, 18, 22, 0.66);
  color: #fff;
  font-size: 10.5px;
  line-height: 16px;
}
.dx-thumbs.todo .dx-thumb.is-done:not(.cur) {
  display: none;
}

/* правая панель */
.dx-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 1px;
  margin: -1px;
}
.card.dx-card {
  padding: 14px 16px;
}
.dx-ds-label {
  display: grid;
  gap: 2px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.dx-ds-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.35;
}
.dx-ds-label-row .linklike {
  font-size: 13px;
  flex: none;
}
.dx-prog {
  display: grid;
  gap: 8px;
}
.dx-prog-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.dx-prog-big {
  font-size: 15px;
  color: var(--ink-2);
}
.dx-prog-big b {
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
}
.dx-prog-max {
  font-size: 13px;
}
.dx-prog-facts {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.dx-prog-note {
  margin: 0;
}
.dx-prog-ok {
  display: grid;
  gap: 8px;
  justify-items: start;
}
.dx-prog-ok .fine {
  margin: 0;
}
.dx-side-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 14.5px;
}
.dx-side-title > .ico {
  color: var(--accent);
}
.dx-side-n {
  margin-left: auto;
  font-weight: 600;
}
.dx-boxes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.dx-boxes > li {
  min-width: 0;
}
.dx-boxes-empty {
  font-size: 13.5px;
  line-height: 1.45;
}
.dx-boxrow {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
}
.dx-boxrow.on {
  background: var(--accent-soft);
}
.dx-boxrow-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.dx-boxrow-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dx-boxrow .icon-btn {
  width: 28px;
  height: 28px;
}
.dx-boxrow .icon-btn .ico {
  width: 16px;
  height: 16px;
}
.dx-tips > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.dx-tips > summary::-webkit-details-marker {
  display: none;
}
.dx-tips > summary .ico {
  color: var(--warning);
}
.dx-tips > summary::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-3px);
}
.dx-tips[open] > summary::after {
  transform: rotate(-135deg) translateY(-1px);
}
.dx-tips ul {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.dx-tips li {
  margin: 5px 0;
}
.dx-tips li b {
  color: var(--ink);
}

/* диалоги: клавиши и просмотр предсказаний */
.dx-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 18px 20px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 24px 64px rgba(0, 0, 0, 0.35);
}
.dx-dialog::backdrop {
  background: rgba(8, 9, 11, 0.6);
}
.dx-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.dx-dialog-head h2 {
  margin: 0;
  font-size: 19px;
}
.dx-keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.dx-keys td {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.dx-keys td:first-child {
  width: 44%;
  padding-right: 14px;
  white-space: nowrap;
}
.dx-gesture {
  font-weight: 600;
  white-space: nowrap;
}
.dx-keys tr:last-child td {
  border-bottom: 0;
}
.dx-lightbox {
  width: min(1100px, calc(100vw - 24px));
  padding: 12px 14px 14px;
}
.dx-lb-stage {
  display: grid;
  place-items: center;
  background: var(--dx-stage);
  border-radius: 10px;
  overflow: hidden;
  min-height: 200px;
}
.dx-lb-stage img {
  max-width: 100%;
  max-height: calc(100dvh - 190px);
  object-fit: contain;
}
.dx-lb-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 14px;
}
.dx-lb-nav {
  width: 40px;
  height: 40px;
  background: var(--bg-2);
}

/* ---------------------------------------------------------------- 3. обучение */

.dx-train {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.dx-train-main,
.dx-train-side {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.dx-train-main > *,
.dx-train-side > * {
  min-width: 0;
}
.dx-notices {
  display: grid;
  gap: 10px;
}
.dx-notices:empty {
  display: none;
}
span.dx-cancel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.dx-reason {
  color: var(--ink);
  font-weight: 600;
}

/* карточка задания */
.dx-job {
  min-height: 200px;
}
.dx-job-body {
  display: grid;
  gap: 16px;
}
.dx-job-body > * {
  min-width: 0;
}
.dx-cancel {
  margin-left: auto;
}
.pill.st-wait {
  background: var(--warn-soft);
  color: var(--warn-ink);
}
.pill.st-off {
  background: var(--bg-2);
  color: var(--muted);
}
.dx-empty .ico.lg {
  color: var(--accent);
}
.dx-queued,
.dx-running,
.dx-result,
.dx-error {
  display: grid;
  gap: 14px;
}
.dx-queued > *,
.dx-running > *,
.dx-result > *,
.dx-error > * {
  min-width: 0;
}
.dx-queued .fine,
.dx-running .fine,
.dx-result .fine,
.dx-error .fine {
  margin: 0;
}
.dx-big-status {
  display: flex;
  align-items: center;
  gap: 14px;
}
.dx-big-status .ico.lg {
  color: var(--warn-ink);
}
.dx-big-status > div {
  display: grid;
  gap: 2px;
}
.dx-big-status b {
  font-size: 22px;
  line-height: 1.2;
}
.dx-big-status span {
  font-size: 14px;
}

.dx-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13.5px;
  color: var(--muted);
}
.dx-stages li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.dx-stages li.past {
  color: var(--ink-2);
}
.dx-stages li.now {
  color: var(--ink);
  font-weight: 700;
}
.dx-stage-dot {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}
.dx-stage-dot .ico {
  width: 14px;
  height: 14px;
}
.dx-stages li.past .dx-stage-dot {
  border-color: var(--good-ink);
  background: var(--good-ink);
  color: var(--bg);
}
.dx-stages li.now .dx-stage-dot {
  border-color: var(--accent);
  color: var(--accent);
}
.dx-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-3);
  overflow: hidden;
}
.dx-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 1.2s linear;
}
.dx-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dx-stat {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  min-width: 0;
}
.dx-stat-label {
  font-size: 12.5px;
  color: var(--muted);
}
.dx-stat b {
  font-size: 20px;
  line-height: 1.25;
}
.dx-stat-note {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* мини-графики */
.dx-curves {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.dx-chart {
  margin: 0;
  padding: 10px 12px 6px;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--line);
  min-width: 0;
}
.dx-chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.dx-chart-legend {
  display: inline-flex;
  gap: 10px;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
}
.dx-leg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dx-leg i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}
.dx-leg.c-map i {
  background: var(--s3);
}
.dx-leg.c-map2 i {
  background: var(--s7);
}
.dx-chart-svg {
  width: 100%;
  height: auto;
}
.dx-chart-svg .g {
  stroke: var(--grid);
  stroke-width: 1;
}
.dx-chart-svg .t {
  fill: var(--muted);
  font-size: 10.5px;
  font-family: var(--font);
}
.dx-chart-svg .ln {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.dx-chart-svg .c-loss {
  stroke: var(--s2);
  fill: var(--s2);
}
.dx-chart-svg .c-map {
  stroke: var(--s3);
  fill: var(--s3);
}
.dx-chart-svg .c-map2 {
  stroke: var(--s7);
  fill: var(--s7);
  stroke-dasharray: 4 3;
}
.dx-chart-svg .ln.c-loss,
.dx-chart-svg .ln.c-map,
.dx-chart-svg .ln.c-map2 {
  fill: none;
}
.dx-chart-svg .pt {
  stroke: var(--bg);
  stroke-width: 1.5;
  stroke-dasharray: none;
}

/* результат */
.dx-bigs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dx-big {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-2);
  min-width: 0;
}
.dx-big-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.dx-big b {
  font-size: 24px;
  line-height: 1.2;
}
.dx-big.main b {
  font-size: 36px;
  letter-spacing: -0.02em;
}
.dx-big.main {
  background: var(--accent-soft);
}
.dx-big-note {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}
.dx-ap {
  display: grid;
  gap: 8px;
}
.dx-ap-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(80px, 1.3fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: center;
  font-size: 13.5px;
}
.dx-ap-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dx-ap-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dx-ap-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-3);
  overflow: hidden;
}
.dx-ap-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--c, var(--accent));
}
.dx-ap-bar.none {
  background: repeating-linear-gradient(45deg, var(--bg-3) 0 4px, transparent 4px 8px);
}
.dx-ap-val {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-ap-gt {
  font-size: 12.5px;
}

.dx-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.dx-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dx-leg-item i {
  width: 16px;
  height: 12px;
  border-radius: 2px;
  border: 2.5px solid;
}
.dx-leg-item i.dx-leg-gt {
  border-color: var(--dx-gt);
}
.dx-leg-item i.dx-leg-tp {
  border-color: var(--dx-tp);
}
.dx-leg-item i.dx-leg-fp {
  border-color: var(--dx-fp);
}
.dx-preds {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.dx-pred {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--dx-stage);
  cursor: zoom-in;
  box-shadow: 0 0 0 1px var(--line);
}
.dx-pred img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}
.dx-pred:hover img {
  transform: scale(1.04);
}
.dx-quality {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.dx-q {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  min-width: 0;
}
.dx-q-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.dx-q b {
  font-size: 20px;
}
.dx-q-note {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}
.dx-quality + .fine {
  margin-top: 10px;
}
.dx-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 16px;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
.dx-facts > div {
  min-width: 0;
}
.dx-facts dt {
  font-size: 12.5px;
  color: var(--muted);
}
.dx-facts dd {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}
.dx-more > summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
}
.dx-log pre {
  max-height: 320px;
}

/* история */
.dx-hist {
  display: grid;
  gap: 4px;
}
.dx-hist-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.dx-hist-item:hover {
  background: var(--bg-2);
}
.dx-hist-item.current {
  background: var(--accent-soft);
}
.dx-hist-item .hist-ico {
  color: var(--muted);
}
.dx-hist-item.st-done .hist-ico {
  color: var(--good-ink);
}
.dx-hist-item.st-error .hist-ico {
  color: var(--bad-ink);
}
.dx-hist-item.st-run .hist-ico,
.dx-hist-item.st-wait .hist-ico {
  color: var(--accent);
}
.dx-hist-main {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}
.dx-hist-model {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
}
.dx-hist-sub {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-hist-res {
  display: grid;
  justify-items: end;
  font-size: 14px;
  white-space: nowrap;
}
.dx-hist-res b {
  font-size: 16px;
}
.dx-hist-res.muted {
  font-size: 13px;
}
.dx-delta {
  font-size: 12px;
  font-weight: 600;
}
.dx-delta.up {
  color: var(--good-ink);
}
.dx-delta.down {
  color: var(--bad-ink);
}
.dx-best-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 7px 0 5px;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good-ink);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 19px;
}
.dx-best-tag .ico {
  width: 13px;
  height: 13px;
}
.dx-hist-legend {
  margin: 6px 10px 0;
}

/* ---------------------------------------------------------------- 3. код и запуск (§9: train.py / inference.py) */

.dxc.dx-train {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
}
.dxc-editor {
  display: flex;
  flex-direction: column;
}
/* вкладки файлов — как в редакторе кода */
.dxc-files {
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  background: var(--code-gutter);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.dxc-file {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  padding: 8px 14px 9px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.dxc-file:hover {
  color: var(--ink);
}
.dxc-file b {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}
.dxc-file .ico {
  width: 16px;
  height: 16px;
}
.dxc-file[aria-selected='true'] {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}
.dxc-file[aria-selected='true'] b {
  color: var(--ink);
}
.dxc-file[aria-selected='true'] .ico {
  color: var(--accent);
}
.dxc-file:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.dxc-file-role {
  font-size: 12.5px;
}
.dxc-file-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}
.dxc-file-dot.dirty {
  background: var(--warning);
}
.dxc-file-dot.error {
  background: var(--bad-ink);
}
.dxc-sol {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  margin: 0 4px 6px auto;
  padding: 2px 9px;
  align-self: center;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good-ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.dxc-sol[hidden] {
  display: none;
}
.dxc-sol .ico {
  width: 14px;
  height: 14px;
}
.dxc-sol-short {
  display: none;
}
.dxc-removed {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 13.5px;
}
.dxc-run .dxc-run-ico {
  display: inline-flex;
}
.dxc-editor .run-btn {
  min-width: 210px;
}
.save-state.hidden {
  display: none;
}
/* строка контекста: готовность разметки или выбор модели */
.dxc-launch {
  display: grid;
  gap: 6px;
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.dxc-launch > * {
  min-width: 0;
}
.dxc-ready,
.dxc-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}
.dxc-ready .dx-meter {
  flex: 1 1 160px;
  max-width: 320px;
}
.dxc-ctx-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.dxc-ready-count {
  font-size: 13.5px;
  color: var(--ink-2);
}
.dxc-ready-count b {
  font-size: 15px;
  color: var(--ink);
}
.dxc-select {
  flex: 1 1 280px;
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.dxc-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.dxc-note {
  margin: 0;
}
.dxc-lim {
  color: var(--muted);
}
.dxc-msg.show {
  margin: 10px 14px 0;
}
.dxc-ed-status {
  padding: 18px 16px;
}
.dxc-ed-status[hidden] {
  display: none;
}
.dxc-ed-status .notice {
  align-items: center;
}
.dxc-ed-status .notice > div {
  flex: 1;
}
.dxc-host[hidden] {
  display: none;
}
.dxc-editor .editor-host .CodeMirror {
  height: clamp(340px, calc(100dvh - 360px), 820px);
}
.cm-s-altair .CodeMirror-code .dxc-errline,
.dxc-errline {
  background: color-mix(in srgb, var(--bad-ink) 16%, transparent);
}
.dxc-errgutter .CodeMirror-linenumber {
  color: var(--bad-ink);
  font-weight: 700;
}

/* подсказка про пути и формат */
.dxc-help {
  padding: 0;
}
.dxc-help > summary {
  padding: 14px 18px;
}
.dxc-help-body {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
  font-size: 14px;
  line-height: 1.5;
}
.dxc-help-body > * {
  margin: 0;
  min-width: 0;
}
.dxc-help-body h3 {
  margin-top: 6px;
  font-size: 15px;
}
.dxc-help-body ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}
.dxc-paths {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.dxc-paths th,
.dxc-paths td {
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.dxc-paths th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.dxc-paths td:nth-child(-n + 2) {
  white-space: nowrap;
}
.dxc-paths code,
.dxc-help-body h3 code {
  font-family: var(--mono);
  font-size: 0.93em;
}
.dxc-sample {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--code-bg);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-x: auto;
}

/* шапка карточки: статус и «Отменить» — первой строкой, подробности — второй */
.dxc .dx-job-head .run-meta {
  order: 3;
  flex: 1 1 100%;
}
.dxc .dx-job-head .dx-cancel,
.dxc-cancel-box {
  margin-left: auto;
}
.dxc-cancel-box:empty {
  display: none;
}
/* задание в работе */
.dxc-live {
  display: grid;
  gap: 12px;
}
.dxc-live > *,
.dxc-train-done > * {
  margin: 0;
  min-width: 0;
}
.dxc-time {
  display: grid;
  gap: 8px;
}
.dxc-time-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.dxc-time-label {
  font-weight: 600;
}
.dxc-time-text {
  margin-left: auto;
  font-size: 22px;
  font-weight: 700;
}
.dxc-time-limit {
  color: var(--muted);
  font-size: 14px;
}
.dxc-time-bar.late > span {
  background: var(--warning);
}
.dxc-live-facts[hidden] {
  display: none;
}

/* журнал */
.dxc-logbox {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
.dxc-log-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--code-gutter);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.dxc-log-head .ico {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.dxc-log-title {
  font-weight: 600;
}
.dxc-log-head .spacer {
  flex: 1;
}
.dxc-dl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.dxc-dl:hover {
  text-decoration: underline;
}
.dxc-dl .ico {
  color: inherit;
}
.dxc-log {
  margin: 0;
  padding: 10px 12px;
  height: 300px;
  overflow: auto;
  background: var(--code-bg);
  font-size: 12.5px;
  /* таблицы ultralytics и рамки rich (RF-DETR) — без переноса и без зазоров между строками; длинное — прокрутка */
  line-height: 1.25;
  white-space: pre;
  overflow-wrap: normal;
  tab-size: 4;
}
.dxc-logbox:not(.live) .dxc-log {
  height: auto;
  max-height: 340px;
}
.dxc-log:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.dxc-log-empty {
  color: var(--muted);
  font-style: italic;
}
.dxc-ln.own {
  color: var(--ink);
  font-weight: 700;
  background: color-mix(in srgb, var(--warning) 22%, transparent);
}
.dxc-ln.own-src {
  color: var(--ink);
  background: color-mix(in srgb, var(--warning) 22%, transparent);
}
.dxc-ln.exc {
  color: var(--bad-ink);
  font-weight: 700;
}
.dxc-logwrap > summary {
  margin-bottom: 8px;
}

/* ошибка: где в коде */
.dxc-tb {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bad-soft);
}
.dxc-tb > * {
  margin: 0;
  min-width: 0;
}
.dxc-tb-where {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}
.dxc-tb-src {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--code-bg);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dxc-tb-exc {
  color: var(--bad-ink);
  font-weight: 700;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.dxc-srv {
  margin-top: 4px !important;
}
.dxc-srv.mono {
  font-size: 13px;
}
.dxc-srv.pre {
  white-space: pre-wrap;
}

/* обучение завершилось */
.dxc-train-done {
  display: grid;
  gap: 14px;
}
.dxc-ok {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--good-soft);
}
.dxc-ok .verdict-ico {
  flex: none;
  background: var(--good-ink);
}
.dxc-ok-text {
  display: grid;
  gap: 2px;
  flex: 1 1 220px;
  min-width: 0;
}
.dxc-ok-text b {
  font-size: 16.5px;
}
.dxc-ok-text span {
  font-size: 13.5px;
}
.dxc-arts {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
}
.dxc-arts li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.dxc-arts li.total {
  border-bottom: 0;
  color: var(--muted);
}
.dxc-art-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.dxc-art-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}
.dxc-art-size {
  margin-left: auto;
  white-space: nowrap;
}

/* история: вид запуска */
.dxc-kind {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--muted);
}
.dxc-kind .ico {
  width: 13px;
  height: 13px;
}
.dxc-kind-train {
  background: var(--accent-soft);
  color: var(--accent);
}
.dxc-kind-infer {
  background: var(--good-soft);
  color: var(--good-ink);
}
.dxc-old-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.dx-hist-res.dxc-warn {
  color: var(--warn-ink);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .dxc.dx-train {
    grid-template-columns: minmax(0, 1fr);
  }
  .dxc-editor .editor-host .CodeMirror {
    height: clamp(340px, 60vh, 720px);
  }
}
@media (max-width: 640px) {
  .dxc-files {
    padding: 6px 6px 0;
  }
  .dxc-file {
    flex: 1 1 0;
    justify-content: center;
    padding: 8px 6px 9px;
  }
  .dxc-file .ico {
    display: none;
  }
  .dxc-file-role,
  .dxc-sol .dxc-sol-long {
    display: none;
  }
  .dxc-sol .dxc-sol-short {
    display: inline;
  }
  .dxc-sol {
    padding: 4px 6px;
  }
  .dxc-editor .run-btn {
    min-width: 0;
  }
  .dxc-launch {
    padding: 10px;
  }
  .dxc-ready .dx-meter {
    flex-basis: 100%;
    max-width: none;
    order: 3;
  }
  .dxc-select {
    flex-basis: 100%;
    width: 100%;
  }
  .dxc-msg.show {
    margin: 10px 10px 0;
  }
  .dxc-editor .editor-host .CodeMirror {
    height: 52vh;
    font-size: 12.5px;
  }
  .dxc-help > summary {
    padding: 14px 16px;
  }
  .dxc-help-body {
    padding: 0 14px 16px;
  }
  /* таблица путей — карточками */
  .dxc-paths thead {
    display: none;
  }
  .dxc-paths tr {
    display: grid;
    gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }
  .dxc-paths td {
    padding: 0;
    border: 0;
  }
  .dxc-paths td:nth-child(-n + 2) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .dxc-paths td:first-child code {
    font-weight: 700;
  }
  .dxc-log {
    height: 240px;
    font-size: 12px;
  }
  .dxc-log-head {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .dxc-log-head .out-count {
    display: none;
  }
  .dx-hist-model {
    flex-wrap: wrap;
  }
  .dx-hist-model b {
    white-space: nowrap;
  }
  /* статус/результат — под названием, а не отдельной колонкой (длинный статус ошибки выталкивал значок) */
  .dx-hist-item {
    grid-template-columns: 22px minmax(0, 1fr);
    row-gap: 2px;
  }
  .dx-hist-res {
    grid-column: 2;
    justify-items: start;
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 4px;
  }
  .dxc-time-text {
    font-size: 19px;
  }
  .dxc-ok .btn {
    width: 100%;
  }
  .dxc-old-tag {
    white-space: normal;
  }
}

/* ---------------------------------------------------------------- узкие экраны */

@media (max-width: 1400px) {
  .dx-work {
    grid-template-columns: 172px minmax(0, 1fr) 268px;
  }
  .dx-thumbs {
    grid-template-columns: minmax(0, 1fr);
  }
  .dx-thumb::before {
    padding-top: 62%;
  }
}
@media (max-width: 1180px) {
  .detect-page .task-title-row {
    align-items: flex-start;
  }
  /* разметка: холст на всю ширину, превью — лентой под ним, панель — ниже */
  .dx-work {
    height: auto;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-areas: 'center right' 'left right';
    grid-template-rows: auto auto;
    align-items: start;
  }
  .dx-center {
    height: clamp(460px, calc(100dvh - 300px), 900px);
  }
  .dx-right {
    overflow: visible;
    max-height: none;
  }
  .dx-left {
    grid-template-rows: auto auto;
  }
  .dx-thumbs-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .dx-thumbs {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 104px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .dx-thumb::before {
    padding-top: 75%;
  }
  .dx-train {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 860px) {
  .dx-work {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'center' 'left' 'right';
  }
  .dx-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .dx-stats,
  .dx-bigs,
  .dx-quality {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .detect-page .task-head {
    margin-bottom: 10px;
  }
  .detect-page .task-title-row h1 {
    font-size: 22px;
  }
  .dx-tabs {
    flex: 1 1 100%;
  }
  .dx-tabs .seg-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 13px;
    text-align: center;
  }
  .dx-tabs .seg-num {
    display: none;
  }
  .dx-tab-note {
    font-size: 11.5px;
  }
  /* холст — почти во всю высоту экрана телефона, без боковых отступов карточки */
  .dx-work {
    gap: 10px;
  }
  .dx-center {
    height: calc(100dvh - 128px);
    min-height: 420px;
    max-height: 760px;
    margin: 0 -16px;
    border-radius: 0;
    box-shadow: 0 1px 0 var(--line), 0 -1px 0 var(--line);
  }
  .dx-stagebar {
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 6px;
  }
  .dx-palette {
    flex: 1 1 100%;
    flex-wrap: wrap;
    order: 2;
  }
  .dx-tools {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  .dx-tools-sep {
    display: none;
  }
  .dx-tool {
    width: 38px;
    height: 38px;
  }
  .dx-tool[aria-label='Клавиши и жесты'] {
    display: none;
  }
  .dx-cls {
    min-height: 38px;
    padding: 0 10px 0 8px;
  }
  .dx-cls kbd {
    display: none;
  }
  .dx-navbar {
    padding: 6px 8px;
    gap: 6px;
  }
  .dx-file {
    display: none;
  }
  .dx-done-next {
    flex: 1;
  }
  .dx-navbar .dx-save {
    flex: 1 1 100%;
    justify-content: center;
    font-size: 12.5px;
    order: 10;
  }
  .dx-navbar .spacer {
    display: none;
  }
  .dx-stage-hint {
    max-width: calc(100% - 24px);
    bottom: 40px;
  }
  .dx-left {
    margin: 0 -16px;
    border-radius: 0;
  }
  .dx-thumbs {
    grid-auto-columns: 88px;
  }
  .dx-ds-grid {
    gap: 12px;
  }
  .dx-ds-body {
    padding: 14px 14px 16px;
  }
  .dx-stats,
  .dx-bigs,
  .dx-quality {
    gap: 8px;
  }
  .dx-big.main b {
    font-size: 30px;
  }
  .dx-curves {
    grid-template-columns: minmax(0, 1fr);
  }
  .dx-preds {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dx-ap-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px 10px;
  }
  .dx-ap-val {
    grid-column: 1 / -1;
    font-size: 12.5px;
  }
  .dx-keys td:first-child {
    white-space: normal;
  }
}
@media (hover: none) {
  .dx-file {
    display: none;
  }
}
