/* Начинка главной: конвертер (auto-digitizer.js). Каркас — ../site.css. */

h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }


.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px 20px; }
.viewer { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: var(--toolbar-h); }
.zoom-val { color: var(--muted); font-size: 13px; min-width: 56px; font-variant-numeric: tabular-nums; }
.tb-label { font-size: 13px; color: var(--muted); margin-right: 2px; }

/* ---- кнопки ---- */
button, .btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px;
  padding: 8px 14px; min-height: 36px; font-weight: 500; line-height: 1.2; cursor: pointer;
  text-decoration: none; color: inherit; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; box-shadow: var(--shadow-1); transition: background .13s, border-color .13s, box-shadow .13s,
  transform .06s; }
button:hover:not(:disabled), .btn:hover:not([aria-disabled="true"]) { background: var(--btn-hover);
  border-color: var(--muted); }
button:active:not(:disabled), .btn:active:not([aria-disabled="true"]) { transform: translateY(1px);
  box-shadow: none; }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.primary:hover:not(:disabled), .btn.primary:hover:not([aria-disabled="true"]) { background: var(--accent-hover);
  border-color: var(--accent-hover); }
.icon-btn { border: 0; background: none; box-shadow: none; min-height: 32px; padding: 4px 8px;
  color: var(--muted); font-size: 16px; }
.icon-btn:hover:not(:disabled) { background: var(--btn-hover); color: var(--ink); }
.hot { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(178, 106, 0, .18); }


.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-width: 0; position: relative; }
.as-is { font-weight: 400; color: var(--muted); font-size: 12px; }
/* над картинками курсор — красный крестик, как указатель-двойник (.twin); hotspot в центре */
:root { --cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M1 12h22M12 1v22' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M1 12h22M12 1v22' stroke='%23e0262b' stroke-width='2'/%3E%3C/svg%3E") 12 12, crosshair; }
.scroll { cursor: default; }
.scroll.pannable, .scroll.pannable.dragging, .canvas.sized { cursor: var(--cross); }
.notice-box, .proc-box { cursor: default; }
.canvas img.orig { position: absolute; display: block; max-width: none; -webkit-user-drag: none; user-select: none; }
.pane-head { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.file-name { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-foot { padding: 8px 12px; border-top: 1px solid var(--line); min-height: 44px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.scroll { height: min(62vh, 560px); overflow: auto; background:
  linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 20px 20px,
  linear-gradient(90deg, var(--grid) 1px, var(--canvas) 1px) 0 0 / 20px 20px; }
.canvas { position: relative; margin: auto; min-height: 100%; }
.canvas.sized { min-height: 0; }
/* жест колесом: растягивается готовая картинка, без перерисовки SVG (см. flushZoom в auto-digitizer.js) */
.canvas.zooming { transform-origin: 0 0; will-change: transform; }
/* упрощённая модель, пока вид двигают (lodTouch в auto-digitizer.js): вместо SVG — растровая копия */
canvas.lod-img { display: none; }
.canvas.lod canvas.lod-img:not([hidden]), .canvas.refining canvas.lod-img:not([hidden]) { display: block; }
.canvas.lod #dst-layer, .canvas.lod #overlay-layer, .canvas.refining #overlay-layer { visibility: hidden; }
.pend { visibility: hidden; }

/* указатель-двойник: где курсор на одной картинке — там крестик на другой (bindTwinPointer в auto-digitizer.js).
   Над холстом и сам курсор — такой же крестик (.own, системный скрыт): белый в режиме «разница» даёт цвет,
   обратный тому, что под ним, — на белом чёрный, на чёрном белый, крестик не теряется ни на каком фоне. */
.twin { position: absolute; width: 0; height: 0; z-index: 2; pointer-events: none; opacity: .75; mix-blend-mode: difference; }
.twin.own { opacity: 1; }
.twin::before, .twin::after { content: ""; position: absolute; background: #ffffff; }
.scroll.own-cross, .scroll.own-cross .canvas { cursor: none; }
/* рамка правого окна на левой картинке при слежении за иглой (placeViewFrame) — белая в режиме «разница» */
.view-frame { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; box-sizing: border-box;
  border: 2px solid #fff; border-radius: 2px; mix-blend-mode: difference; }
.view-frame[hidden] { display: none; }
/* прицел иглы в симуляции (placeReticle): кольцо, четыре штриха и точка — тоже белые в режиме «разница» */
.sim-ret { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 5; pointer-events: none;
  mix-blend-mode: difference; }
.sim-ret[hidden] { display: none; }
.sim-ret::before { content: ""; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px;
  border: 2px solid #fff; border-radius: 50%; box-sizing: border-box;
  background: radial-gradient(circle, #fff 0 1.8px, transparent 2.2px); }
.sim-ret::after { content: ""; position: absolute; left: -13px; top: -13px; width: 26px; height: 26px;
  background: linear-gradient(#fff, #fff) 0 12px / 10px 2px no-repeat, linear-gradient(#fff, #fff) 16px 12px / 10px 2px no-repeat,
    linear-gradient(#fff, #fff) 12px 0 / 2px 10px no-repeat, linear-gradient(#fff, #fff) 12px 16px / 2px 10px no-repeat; }
.twin::before { left: -11px; top: -1px; width: 22px; height: 2px; }
.twin::after { left: -1px; top: -11px; width: 2px; height: 22px; }

/* вид вышивки: Схема / Плотно / Как на ткани (setViewMode в auto-digitizer.js) */
.view-modes { display: inline-flex; align-items: center; gap: 8px; }
#pane-dst .pane-head { flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pane-head .seg button { border: 0; border-radius: 0; box-shadow: none; padding: 4px 10px; min-height: 0; }
.pane-head .seg button + button { border-left: 1px solid var(--line); }
.pane-head .seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
#fabric-color { width: 30px; height: 26px; padding: 0 2px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); cursor: pointer; }
#dst-scroll.v-cloth { background: var(--fabric, #f5f2ea); }   /* «Плотно» и «Как на ткани»: всё окно — ткань */
#dst-canvas.v-dense #dst-layer path.stitches { stroke-width: 0.38px; }   /* единица SVG здесь — мм */
#dst-canvas.v-fabric #dst-layer { visibility: hidden; }
canvas.fabric-view { position: absolute; left: 0; top: 0; pointer-events: none; }
.canvas.lod #dst-fabric { visibility: hidden; }
.simulating #dst-fabric { opacity: .13; }
/* рисование видеокартой (gl.js): холст размером с видимую часть окна, SVG и холст ткани скрыты */
canvas.gl-view { position: absolute; left: 0; top: 0; pointer-events: none; }
#dst-canvas.v-gl #dst-layer, #dst-canvas.v-gl #dst-fabric { visibility: hidden; }
/* левое окно на видеокарте: растровый оригинал — текстура, стежки поверх — из памяти видеокарты */
#src-canvas.l-gl #overlay-layer, #src-canvas.l-gl #overlay-lod { display: none; }
#src-canvas.l-tex #src-layer { visibility: hidden; }
#src-layer.zooming { transform-origin: 0 0; will-change: transform; }   /* SVG-оригинал при жесте колесом */
.gl-debug { position: absolute; right: 8px; bottom: 8px; z-index: 7; max-width: 340px; padding: 8px 10px;
  border-radius: 8px; background: rgba(20, 22, 28, .82); color: #f2f4f8; font: 12px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap; }
.gl-debug button { font: inherit; font-size: 12px; padding: 2px 8px; margin: 6px 6px 0 0; min-height: 0; }
.gl-debug details { margin-top: 6px; max-height: 40vh; overflow: auto; }
.gl-debug .gl-tune { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gl-debug .gl-tune input { width: 140px; }
/* копия при движении вида во время симуляции — так же притушена, как рисунок под ней: иначе на 2 с
   вместо прошитого на текущий момент виден весь готовый рисунок */
.simulating canvas.lod-img { opacity: .13; }
.layer, .layer svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay { opacity: .6; pointer-events: none; }
.hide-jumps .jumps { display: none; }
.dim path.stitches { opacity: .12; }
.dim path.stitches.hi { opacity: 1; }
/* наведение на плашку нитки (hoverChip): остальные цвета за 0,3 с почти прозрачные (95 %) и обратно */
#dst-layer path.stitches { transition: opacity .3s ease; }
.hovdim path.stitches { opacity: .05; }
#dst-scroll { transition: box-shadow .3s ease; }   /* контрастный фон под нитку цвета фона (hoverBack) */
.hovdim path.stitches.hov { opacity: 1; }

.drop { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; text-align: center; padding: 20px; color: #3a3a3e;
  border: 2px dashed var(--line); border-radius: 8px; margin: 10px; cursor: pointer;
  background: rgba(255, 255, 255, .55); transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--accent); background: rgba(255, 255, 255, .8); }
.drop.over { border-color: var(--accent); background: rgba(47, 95, 208, .06); }
.drop-title { font-weight: 600; font-size: 16px; }
.drop-sub { color: #6b6b70; }
.small { font-size: 12px; max-width: 280px; }
.placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #6b6b70; padding: 20px; text-align: center; }

/* сворачиваемые блоки под правым окном — как «Ход работы» и «Порядок шитья»; свёрнутый показывает сводку в заголовке */
.fold > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.fold[open] > summary { color: var(--ink); }
.fold-sum { font-weight: 400; margin-left: 2px; }
.fold[open] > summary .fold-sum { display: none; }
.fold-sum .danger { margin-left: 2px; }
.colors-block { border-top: 1px solid var(--line); padding: 6px 12px 8px; }
.colors-block[hidden] { display: none; }
.colors-block .legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px 0 6px; }
.colors-block .thread-pick { padding-top: 6px; border-top: 1px dashed var(--line); }
.sim-desc { display: flex; flex-direction: column; gap: 8px; }
.legend .chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 8px;
  border-radius: 999px; border: 1px solid var(--line); cursor: pointer; background: var(--panel); }
.legend .chip.on { border-color: var(--accent); }
.legend .sw { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }
.legend .thr { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.legend .thr .sw { border-radius: 3px; }
.legend .thr.far { color: var(--warn); }
.legend .chip.sel { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.legend .chip.picked .thr::after { content: "✎"; margin-left: 2px; color: var(--accent); }
.danger { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--err); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 17px; letter-spacing: .02em; }

/* окно цвета: плавающее поверх страницы, тянется за шапку (openThreadWin) */
.thr-win { position: fixed; z-index: 60; left: 24px; top: 80px; width: min(420px, calc(100vw - 16px));
  max-height: min(640px, calc(100vh - 16px)); display: flex; flex-direction: column; background: var(--panel);
  color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-3, 0 14px 40px rgba(0,0,0,.35)); }
.thr-win[hidden] { display: none; }
.tw-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line);
  cursor: move; user-select: none; touch-action: none; }
.thr-win.dragging { opacity: .92; }
.thr-win.dragging .tw-head { cursor: grabbing; }
.tw-grip { color: var(--muted); }
.tw-head b { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-body { padding: 10px 12px; overflow: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tw-danger { padding: 8px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.45;
  background: color-mix(in srgb, var(--err) 12%, transparent); border: 1px solid color-mix(in srgb, var(--err) 45%, transparent); }
.tw-danger[hidden] { display: none; }
.tw-now { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.thr-win .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); flex: none; }
.tw-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tw-row select { flex: 1; min-width: 0; }
.tw-tabs { align-self: flex-start; }
.tw-tabs button { border: 0; border-radius: 0; box-shadow: none; padding: 4px 12px; min-height: 0; }
.tw-tabs button + button { border-left: 1px solid var(--line); }
.tw-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.tw-pane[hidden] { display: none; }
#tw-q { width: 100%; margin-bottom: 8px; }
.tw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); align-content: start; grid-auto-rows: 30px; gap: 6px; height: 240px;
  overflow: auto; font-size: 12px; color: var(--muted); }
.tw-th { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 7px; min-height: 0; border: 1px solid var(--line);
  border-radius: 6px; background: none; box-shadow: none; font-size: 12px; color: var(--ink); cursor: pointer; }
.tw-th:hover { border-color: var(--accent); }
.tw-th.cur { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tw-th .c { font-weight: 600; }
.tw-th .d { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tw-th.far .d { color: var(--warn); }
#tw-color { width: 44px; height: 32px; padding: 0 2px; }
#tw-hex { width: 96px; font-family: ui-monospace, Consolas, monospace; }
.tw-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.tw-pal { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tw-pal button { width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.tw-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.tw-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.tw-hl { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-right: auto; }
.thread-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.thread-pick .thread-note { color: var(--muted); font-size: 12px; }

.side { display: flex; flex-direction: column; gap: 12px; }
/* правая колонка начинается вровень с окнами файла и DST: опускаем её на высоту строки масштаба + зазор .viewer */
@media (min-width: 1001px) { .side { margin-top: calc(var(--toolbar-h) + 10px); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 10px; }
input, select, textarea { background: var(--panel); color: var(--ink); }
.card input, .card select, .card textarea,
dialog input:not([type="checkbox"]), dialog select, dialog textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--panel); color: var(--ink);
  -webkit-appearance: none; appearance: none; }
.card select, dialog select {              /* своя стрелка: системная в тёмной теме рисуется чёрным */
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-size: 6px 6px, 6px 6px;
  background-position: right 15px center, right 9px center;
  background-repeat: no-repeat; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.size { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: end; }
.size label { margin-top: 0; }
.lock { padding-bottom: 8px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.play { width: 100%; margin-top: 10px; padding: 12px; font-size: 15px; font-weight: 600;
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  color: var(--accent-ink); border-color: var(--accent-hover); }
.play:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.wide { width: 100%; margin-top: 10px; }
dialog .metrics { margin-top: 10px; }
dialog .verdict { margin-top: 10px; }
dialog .row.end { margin-top: 16px; align-items: center; }
input:invalid:not(:placeholder-shown) { border-color: var(--err); }

/* дорожная карта обработки — поверх правого окна, фон слегка затенён */
.proc { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  padding: 12px; background: rgba(255, 255, 255, .55); pointer-events: none; }
.proc-box { pointer-events: auto; }
/* карты смотрят друг на друга: слева — к правому краю, справа — к левому */
#up-proc { justify-content: flex-end; }
#proc { justify-content: flex-start; }
@media (prefers-color-scheme: dark) { .proc { background: rgba(20, 20, 24, .5); } }
.proc-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16); max-width: min(420px, 94%); max-height: 94%; overflow: auto; }
.proc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700;
  margin-bottom: 10px; }
.proc-head button { border: 0; background: none; padding: 2px 6px; color: var(--muted); font-size: 15px; }
.proc-head button:hover { color: var(--ink); }
.stages { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; display: grid; grid-template-columns: 24px 1fr auto; gap: 2px 10px;
  align-items: start; padding-bottom: 10px; font-size: 14px; }
.stage:last-child { padding-bottom: 0; }
.stage::before { content: ""; position: absolute; left: 11px; top: 22px; bottom: 0; width: 2px;
  background: var(--line); }
.stage:last-child::before { display: none; }
.stage.done::before { background: var(--ok); }
.stage .ic { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel);
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 11px; line-height: 1; }
.stage.running .ic { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.stage.done .ic { border-color: var(--ok); background: var(--ok); }
.stage.done .ic::after { content: "✓"; }
.stage.error .ic { border-color: var(--err); background: var(--err); }
.stage.error .ic::after { content: "✕"; }
.stage .lb { line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage.done .lb, .stage:not(.running):not(.done):not(.error) .lb { color: var(--muted); }
.stage.running .lb { font-weight: 600; }
.stage .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; line-height: 20px; }
.stage .sum { grid-column: 2 / 4; color: var(--muted); font-size: 12px; line-height: 16px; height: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage.error .sum { color: var(--err); }
.stage .bar { grid-column: 2 / 4; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden;
  margin-top: 3px; }
.stage .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
/* высота строки постоянна: полоса всегда занимает место, просто не видна */
.stage:not(.running) .bar { visibility: hidden; }
.stage::before { top: 22px; }
.proc-sub { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.verdict { padding: 10px 12px; border-radius: 8px; font-weight: 600; margin-bottom: 10px; }
.verdict.auto { background: rgba(31, 138, 76, .12); color: var(--ok); }
.verdict.manual { background: rgba(178, 106, 0, .12); color: var(--warn); }
.verdict.error { background: rgba(192, 57, 43, .12); color: var(--err); }
.verdict ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; color: var(--ink); font-size: 13px; }
.metrics { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.metrics dt { color: var(--muted); }
.metrics dd { margin: 0; font-variant-numeric: tabular-nums; }
.notes { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.badge.stale { font-size: 12px; font-weight: 500; color: var(--warn); }
.msg { font-size: 13px; color: var(--muted); min-height: 18px; }
.msg.err { color: var(--err); }

.strategy-info { font-size: 12px; line-height: 1.4; margin-top: 6px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); }
.strategy-info p { margin: 0 0 4px; }
.strategy-info p:last-child { margin: 0; }
.strategy-info .pro b { color: var(--ok); }
.strategy-info .con b { color: var(--warn); }

/* уведомление о непригодном файле */
.notice { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; }
.notice-img { flex: 1; min-height: 0; width: 100%; object-fit: contain; opacity: .55; }
.notice-box { margin: 10px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--err);
  background: var(--panel); box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.notice-title { font-weight: 700; color: var(--err); margin-bottom: 4px; }
.notice-text { font-size: 13px; line-height: 1.45; }
.notice-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
/* вопрос «сгладить оттенки?» — не отказ, поэтому не красный */
.notice.ask .notice-box { border-color: var(--warn); }
.notice.ask .notice-title { color: var(--warn); }
.verdict.ask { background: rgba(178, 106, 0, .12); color: var(--warn); }
.verdict.ask .q-text { font-weight: 400; color: var(--ink); font-size: 13px; margin-top: 4px; line-height: 1.45; }
.q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.q-actions button { flex: 1 1 auto; }

/* порядок шитья блоков */
.order-block { border-top: 1px solid var(--line); padding: 8px 12px 12px; }
.order-block summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.order-block[open] summary { color: var(--ink); }
.order-map { border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); margin: 8px 0; }
.order-map svg { display: block; width: 100%; height: auto; }
.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px;
  max-height: 320px; overflow: auto; }
.order-list li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: start; font-size: 13px;
  padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.order-list li:hover, .order-list li.hi { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.order-map svg.hl .blk, .order-map svg.hl .lead, .order-map svg.hl .dot, .order-map svg.hl .num { opacity: .55; }
.order-map svg.hl .hi { opacity: 1; }
.order-map svg.hl .blk.hi { fill-opacity: 1; stroke: #111111; stroke-width: 2; vector-effect: non-scaling-stroke; }
.order-map svg.hl .num.hi { font-size: 1.2em; }
/* текущий отшиваемый блок — виден всегда, независимо от наведения */
.order-map svg .blk.cur { fill-opacity: 1; stroke: #111111; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.order-map svg .dot.cur { r: 1.6; }
.order-map svg .num.cur { font-size: 1.3em; }
.order-map svg.hl .cur { opacity: 1; }
.order-list li.cur { background: rgba(47, 95, 208, .12); box-shadow: inset 0 0 0 1px var(--accent); }
.order-map .blk, .order-map .lead, .order-map .dot, .order-map .num { transition: opacity .12s; }
.order-list .num { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
  text-shadow: 0 0 2px rgba(0,0,0,.5); }
.order-list .mv { font-weight: 600; }
.order-list .mv.trim, .order-list .mv.stop { color: var(--warn); }
.order-list .mv.travel { color: var(--accent); }
.order-list .why { color: var(--muted); }

/* симуляция отшива */
.pane-head button { font-size: 13px; padding: 4px 10px; font-weight: 500; }
.simulating #dst-layer { opacity: .13; }
.sim { pointer-events: none; }
.sim.ghost { opacity: .55; }   /* прицел-повторитель в левом окне: видно, но не спорит с оригиналом */
.sim-bar { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
#sim-details { display: flex; flex-direction: column; gap: 8px; }
.sim-main { font-weight: 600; }
.sim-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sim-controls button { padding: 6px 10px; min-height: 34px; }
.sim-controls button:not(.sim-main) { min-width: 38px; }
.sim-speed { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sim-follow { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer;
  white-space: nowrap; }
.sim-follow input { margin: 0; accent-color: var(--accent); }
.sim-speed select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--panel); }
#sim-exit { margin-left: auto; }
.sim-scrub { display: flex; align-items: center; gap: 10px; }
.sim-pos { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 92px;
  text-align: right; }
#sim-range { flex: 1; min-width: 0; height: 28px; margin: 0; cursor: grab; accent-color: var(--accent);
  -webkit-appearance: none; appearance: none; background: transparent; touch-action: none; }
#sim-range:active { cursor: grabbing; }
#sim-range::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--line); }
#sim-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }
#sim-range::-moz-range-track { height: 8px; border-radius: 4px; background: var(--line); }
#sim-range::-moz-range-progress { height: 8px; border-radius: 4px; background: var(--accent); opacity: .5; }
#sim-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }
.sim-dot.live { animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(.8); } to { transform: scale(1.25); } }
.sim-now { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column;
  gap: 3px; background: var(--bg); }
.sim-stage { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; min-height: 22px; }
.sim-group { margin-left: auto; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); }
.sim-obj { font-size: 13px; font-weight: 600; }
.sim-obj .d { font-weight: 400; color: var(--muted); }
.sim-why { font-size: 13px; line-height: 1.4; }
.sim-machine { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sim-machine .lbl { font-weight: 600; }
.sim-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); flex: none; }
.sim-dot.lock, .g-lock { --g: #7d3c98; }
.sim-dot.underlay, .g-underlay { --g: #a0703a; }
.sim-dot.top, .g-top { --g: #1f8a4c; }
.sim-dot.line, .g-line { --g: #138d90; }
.sim-dot.move, .g-move { --g: #2f5fd0; }
.sim-dot.machine, .g-machine { --g: #b26a00; }
.sim-dot.stop, .g-stop { --g: #c0392b; }
.sim-dot.done { --g: var(--ink); }
.sim-dot[class*=" "] { background: var(--g, var(--line)); }
.sim-log { font-size: 13px; }
.sim-log summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.sim-log ol { list-style: none; margin: 6px 0 0; padding: 0; max-height: 210px; overflow: auto;
  border: 1px solid var(--line); border-radius: 8px; position: relative; }
.sim-log li { display: grid; grid-template-columns: 34px 10px 1fr auto; gap: 6px; align-items: center;
  padding: 3px 8px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sim-log .blk-group { display: block; padding: 0; border-bottom: 1px solid var(--line); cursor: default; }
.sim-log .blk-group summary { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center;
  padding: 5px 8px; cursor: pointer; font-weight: 600; }
.sim-log .blk-group summary:hover { background: var(--bg); }
.sim-log .blk-group[data-cur="1"] > summary { background: rgba(47, 95, 208, .12); }
.sim-log .blk-group.done > summary { color: var(--muted); font-weight: 500; }
.sim-log .blk-num { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; text-shadow: 0 0 2px rgba(0,0,0,.5); }
.sim-log .blk-sum { color: var(--muted); font-weight: 400; font-size: 12px; }
.sim-log .steps { list-style: none; margin: 0; padding: 0 0 4px; background: var(--bg); }
.sim-log .steps li { border-bottom: 0; padding-left: 16px; }
.sim-log li:last-child { border-bottom: 0; }
.sim-log li:hover { background: var(--bg); }
.sim-log li.done { color: var(--muted); }
.sim-log li.cur { background: rgba(47, 95, 208, .12); font-weight: 600; color: var(--ink); }
.sim-log .n { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.sim-log .gd { width: 10px; height: 10px; border-radius: 50%; background: var(--g, var(--line)); }
.sim-log .o { color: var(--muted); font-weight: 400; }
.sim-log .c { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.sim-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 14px; margin: 0;
  font-size: 13px; }
.sim-stats div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--line); }
.sim-stats dt { color: var(--muted); }
.sim-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.sim-stats .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px;
  border: 1px solid rgba(0, 0, 0, .3); vertical-align: -1px; }

/* ---- модальные окна ---- */
dialog.modal { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink);
  padding: 0; max-width: 460px; width: calc(100% - 28px); max-height: 86vh; box-shadow: var(--shadow-3); }
dialog.modal::backdrop { background: rgba(10, 10, 14, .45); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-form { display: flex; flex-direction: column; max-height: 86vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 14px 16px 16px; overflow: auto; }
.modal-body > :first-child { margin-top: 0; }
.modal-body .lead { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
/* окно настроек: вкладки, секции, строка = подпись с пояснением слева, поле справа */
.tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--line);
  background: var(--bg); }
.tab { border: 0; border-radius: 0; background: none; min-height: 42px; padding: 0 14px;
  font-size: 14px; font-weight: 600; color: var(--muted); box-shadow: none;
  border-bottom: 2px solid transparent; }
.tab:hover { background: none; color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.tabpanel > .set-sec:first-child { padding-top: 14px; }

/* Вкладки лежат одна поверх другой в одной ячейке сетки, поэтому тело окна всегда высотой
   по самой длинной вкладке: при переключении высота модалки не меняется. Скрытая вкладка
   остаётся в потоке (место занимает), но не видна и не получает фокус. */
.settings { display: grid; align-items: start; }
.tabpanel { grid-area: 1 / 1; min-width: 0; }
.settings .tabpanel[hidden] { display: block !important; visibility: hidden; }


dialog.modal.wide-modal { max-width: 680px; }
.settings { padding: 0; }
.set-sec { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.set-sec:last-child { border-bottom: 0; }
.set-title { margin: 0 0 2px; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }
.set-lead { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 10px 18px;
  align-items: start; padding: 12px 0 0; }
.set-row + .set-row { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.set-lbl { min-width: 0; }
.set-name { display: block; margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.set-note { margin: 4px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.set-ctl { display: flex; justify-content: flex-end; padding-top: 1px; }
.set-ctl select { width: 100%; }
.range-ctl { align-items: center; gap: 10px; }
.range-ctl input[type=range] { flex: 1; min-width: 0; height: 28px; margin: 0; padding: 0; border: 0; background: none;
  box-shadow: none; accent-color: var(--accent); cursor: pointer; -webkit-appearance: none; appearance: none; }
.range-ctl input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line); }
.range-ctl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px;
  border-radius: 50%; background: var(--accent); border: 0; }
.range-ctl input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.range-ctl input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 0; }
.range-ctl input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.range-ctl output { flex: none; min-width: 48px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--ink); }
.set-fig { margin: 8px 0 0; }
.set-fig img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }
.set-fig figcaption { margin: 4px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.settings .strategy-info { margin: 12px 0 0; }

/* переключатель вместо системной галочки */
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 1px 0 0;
  width: 42px; height: 24px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; transition: background .15s, border-color .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: #ffffff; }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
  .set-row { grid-template-columns: 1fr; }
  .set-ctl { justify-content: flex-start; }
  .set-ctl select { width: 100%; }
}
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--line); background: var(--bg); border-radius: 0 0 13px 13px; }
.modal-foot .btn, .modal-foot button { min-width: 112px; }
dialog label { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; font-size: 13px;
  color: var(--muted); }
dialog label:first-child { margin-top: 0; }
.settings label.set-name { display: block; margin-top: 0; }
dialog select, dialog input, dialog textarea { font-size: 14px; color: var(--ink); }
@media (max-width: 520px) {
  .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .modal-foot .btn, .modal-foot button { width: 100%; }
}

/* Широкий экран: шапка и рабочая область — ровно в высоту экрана, ниже края уходит только подвал.
   main — высота экрана минус шапка (--head-h ставит auto-digitizer.js по её настоящей высоте); окна файла и DST
   занимают остаток колонки (основа 0, иначе холст с полями размером в окно растил бы окно) и сжимаются под то, что
   стоит под правым окном (плеер, легенда, нитки, порядок шитья); правая колонка прокручивается внутри себя.
   Левое окно не тянется само, а повторяет высоту правого (matchSrcPane в auto-digitizer.js). Левая карточка в высоте
   ряда не участвует (contain: size), а только растягивается по нему: иначе её подвал («Заменить файл» выше пустой
   легенды) поднимал ряд, правое окно росло, левое повторяло его — и страница росла без конца */
@media (min-width: 1001px) {
  body > main.layout { flex: none; box-sizing: border-box; height: calc(100vh - var(--head-h, 92px));
    height: calc(100dvh - var(--head-h, 92px)); min-height: 560px; grid-template-rows: minmax(0, 1fr); }
  .viewer, .side, .pane { min-height: 0; }
  .panes { flex: 1 1 0; min-height: 0; }
  .scroll { flex: 1 1 0; height: auto; min-height: 160px; }
  #pane-src { contain: size; }
  #src-scroll { flex: none; }
  #pane-dst { overflow-y: auto; }       /* на совсем низком экране — прокрутка внутри карточки, не под подвал */
  #pane-dst .order-block[open] { max-height: 34vh; overflow: auto; }
  .side { overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
}
@media (max-width: 720px) {
  .panes { grid-template-columns: 1fr; }
  .scroll { height: 46vh; }
}
