/* Начинка конструктора вышивки (editor.js). Каркас сайта — ../site.css: шапка и подвал сайта, палитра сайта.
   Конструктор всегда светлый (решение владельца 23.10.2026): своя палитра — переменные --ed-*, шрифт и фон —
   только у приложения (.ed-app), диалогов и меню; классы каркаса (.top, .brand, .logo, .site-*) здесь не использовать. */
:root {
  --ed-bg: #eceae6;
  --ed-panel: #faf9f7;
  --ed-line: #d6d2cb;
  --ed-text: #24221f;
  --ed-muted: #6f6a62;
  --ed-accent: #1f6feb;
  --ed-accent-soft: #dbe8ff;
  --ed-danger: #c62828;
  --ed-fabric: #fbfaf6;
  --ed-outside: #cfcbc4;
}
/* страница: шапка сайта + приложение — ровно в экран, подвал сайта — ниже прокрутки */
.ed-screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; flex: none; }
.ed-screen > .top { flex: none; }
.ed-app, .ed-page dialog, .ctx {
  font: 13px/1.35 system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ed-text);
}
.ed-app { flex: 1 1 auto; min-height: 0; background: var(--ed-bg); }
button, input, select { font: inherit; color: inherit; }
button {
  background: #fff; border: 1px solid var(--ed-line); border-radius: 5px; padding: 4px 9px; cursor: pointer;
}
button:hover { border-color: #aaa39a; }
button.primary { background: var(--ed-accent); color: #fff; border-color: var(--ed-accent); }
button.small { padding: 1px 6px; font-size: 12px; }
button:disabled { opacity: .45; cursor: default; }
input[type=number], input[type=text], input:not([type]), select {
  border: 1px solid var(--ed-line); border-radius: 4px; padding: 3px 5px; background: #fff;
}
input[type=number] { width: 5.5em; }
input[type=color] { width: 34px; height: 24px; padding: 0 2px; border: 1px solid var(--ed-line); border-radius: 4px; background: #fff; vertical-align: middle; }
.chk { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.muted { color: var(--ed-muted); }
.sp { flex: 1; }

.ed-app { display: grid; grid-template-rows: auto 1fr auto; }
.ed-bar {
  display: flex; gap: 10px; align-items: center; padding: 5px 10px; background: var(--ed-panel);
  border-bottom: 1px solid var(--ed-line); flex-wrap: wrap;
}
.ed-brand { font-weight: 600; margin-right: 6px; }
.ed-brand span { font-weight: 400; color: var(--ed-muted); font-size: 12px; margin-left: 4px; }
.grp { display: flex; gap: 3px; align-items: center; }
.ed-bar button { padding: 3px 8px; }

.main { display: grid; grid-template-columns: 74px 1fr 324px; min-height: 0; }
.tools { background: var(--ed-panel); border-right: 1px solid var(--ed-line); padding: 6px 5px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.tools hr { border: 0; border-top: 1px solid var(--ed-line); margin: 4px 2px; width: auto; }
.tools button {
  display: grid; grid-template-columns: 1fr; justify-items: center; padding: 4px 2px 3px; position: relative; border-color: transparent; background: transparent;
}
.tools button b { font-size: 18px; line-height: 20px; font-weight: 400; }
.tools button span { font-size: 10.5px; }
.tools button kbd { position: absolute; top: 1px; right: 3px; font: 9px/1 system-ui; color: var(--ed-muted); }
.tools button.on { background: var(--ed-accent-soft); border-color: var(--ed-accent); }
/* «Оставлять на листе» взведено: следующая линейка останется */
.tools button.armed::after { content: ""; position: absolute; left: 4px; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: #b00060; }

.stage { position: relative; display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.opts {
  display: flex; gap: 10px; align-items: center; padding: 5px 10px; background: #f3f1ee; border-bottom: 1px solid var(--ed-line);
  flex-wrap: wrap; min-height: 36px;
}
.opts .conn { display: inline-flex; gap: 10px; align-items: center; padding-left: 10px; border-left: 1px solid var(--ed-line); }
.opts .conn[hidden] { display: none; }
.opts input[type=range] { width: 90px; vertical-align: middle; }
.opts input[type=number] { width: 4.5em; }
.swatches { display: inline-flex; gap: 3px; }
.swatches i { width: 18px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); cursor: pointer; display: inline-block; }

#layers { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--ed-outside); }
#layers > svg, #layers > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#under, #gl { pointer-events: none; }
#cv { background: transparent; touch-action: none; user-select: none; }
#cv.tool-select { cursor: default; }
#cv.tool-node { cursor: default; }
#cv.tool-rect, #cv.tool-ellipse, #cv.tool-poly, #cv.tool-pen, #cv.tool-conn, #cv.tool-measure, #cv.tool-dir, #cv.tool-carve { cursor: crosshair; }
#cv.tool-bucket { cursor: cell; }
#cv.ruler-body { cursor: move; }
#cv.ruler-end { cursor: crosshair; }
#cv.pan { cursor: grab; }
#field { fill: var(--ed-fabric); }
#field-edge { fill: none; stroke: #8a847a; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
#grid-minor { stroke: #000; stroke-opacity: .06; stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }
#grid-major { stroke: #000; stroke-opacity: .14; stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }
#objs * { pointer-events: none; }
#overlay * { vector-effect: non-scaling-stroke; pointer-events: none; }
#overlay .selbox { fill: none; stroke: var(--ed-accent); stroke-width: 1; stroke-dasharray: 4 3; }
#overlay .selbox.one { stroke-opacity: .45; stroke-dasharray: 2 3; }
#overlay .selobj-bg { fill: none; stroke: #fff; stroke-width: 4; stroke-opacity: .85; fill-rule: evenodd; }
#overlay .selobj { fill: rgba(31, 111, 235, .08); stroke: var(--ed-accent); stroke-width: 2; fill-rule: evenodd; }
#overlay .hdl { fill: #fff; stroke: var(--ed-accent); stroke-width: 1.2; }
#overlay .rotl { stroke: var(--ed-accent); stroke-width: 1; }
#overlay .node { fill: #fff; stroke: #1b1b1b; stroke-width: 1.2; }
#overlay .node.smooth { fill: #fff; stroke: #0a7d3c; }
#overlay .node.on { fill: var(--ed-accent); stroke: var(--ed-accent); }
#overlay .hline { stroke: #7a7a7a; stroke-width: 1; }
#overlay .hdot { fill: #7a7a7a; stroke: #fff; stroke-width: 1; }
#overlay .pend { fill: none; stroke: var(--ed-accent); stroke-width: 1.5; }
#overlay .pend-w { fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: .35; }
#overlay .rubber { fill: none; stroke: var(--ed-accent); stroke-width: 1; stroke-dasharray: 5 4; }
#overlay .pt { fill: #fff; stroke: #b35400; stroke-width: 1.5; }
#overlay .pt.first { fill: #ffd8b0; }
#overlay .ptnum { fill: #b35400; font-weight: 600; font-family: system-ui, sans-serif; }
#overlay .marq { fill: rgba(31,111,235,.07); stroke: var(--ed-accent); stroke-width: 1; stroke-dasharray: 3 3; }
#overlay .arrow-bg { stroke: #000; stroke-opacity: .55; stroke-width: 4.5; stroke-linecap: round; fill: none; }
#overlay .arrow { stroke: #fff; stroke-width: 2; stroke-linecap: round; fill: none; }
#overlay .arrow-head { fill: #fff; stroke: #000; stroke-opacity: .55; stroke-width: 1; }
#overlay .rung { stroke: #fff; stroke-width: 2.5; }
#overlay .rung-bg { stroke: #000; stroke-opacity: .5; stroke-width: 4.5; }
#overlay .rung-end { fill: #fff; stroke: #000; stroke-width: 1; }
/* «Продвинутые настройки»: всё, кроме объекта, затенено (окно — по контуру объекта) */
/* линии тиснения: не шьются, по ним встают проколы рядов татами */
#overlay .carve-bg { fill: none; stroke: #fff; stroke-width: 4; stroke-opacity: .8; vector-effect: non-scaling-stroke; }
#overlay .carve { fill: none; stroke: #7b1fa2; stroke-width: 2; stroke-dasharray: 6 3; vector-effect: non-scaling-stroke; }
#overlay .carve.drawing { stroke: #d0007a; }
#overlay .carve.other { stroke-opacity: .55; }
#overlay .carve.off { stroke: #6d6d6d; stroke-opacity: .7; stroke-dasharray: 2 4; }
#overlay .carve-bg.off { stroke-opacity: .5; }
#overlay .carve-pt { fill: #fff; stroke: #7b1fa2; stroke-width: 1; }
/* направляющие (вытягиваются из линеек) */
#overlay .guide { stroke: #00a8e0; stroke-width: 1; vector-effect: non-scaling-stroke; shape-rendering: crispEdges; }
#overlay .guide.locked { stroke-dasharray: 6 3; }
#overlay .guide.drag { stroke: #e0006a; }
#cv.guide-x { cursor: col-resize; }
#cv.guide-y { cursor: row-resize; }
#overlay .adv-dim { fill: rgba(30, 26, 22, .55); stroke: none; pointer-events: none; }
#overlay .meas { stroke: #b00060; stroke-width: 1.5; }
/* размер шрифта задаёт атрибут font-size (в мм, пересчитан из пикселей экрана) — в CSS его не трогать */
#overlay .mlabel { fill: #b00060; font-weight: 600; font-family: system-ui, sans-serif; paint-order: stroke; stroke: #fff; stroke-width: 3; }
#overlay .snapc { fill: none; stroke: #d0007a; stroke-width: 2; }
#overlay .attr { fill: rgba(255,138,0,.06); stroke: #ff8a00; stroke-width: 1; stroke-dasharray: 3 3; }
#overlay .attr.hit { fill: rgba(255,138,0,.12); stroke-dasharray: none; }
#overlay .attr-pt { fill: #ff8a00; stroke: #fff; stroke-width: 1.5; }
#overlay .attr.hit.img { stroke: #0097a7; fill: rgba(0,151,167,.12); }
#overlay .attr-pt.img { fill: #0097a7; }
#edges-img { pointer-events: none; }
#overlay .bgbox { fill: none; stroke: #b35400; stroke-width: 1.5; stroke-dasharray: 6 3; }
#overlay .bghdl { fill: #fff; stroke: #b35400; stroke-width: 1.5; }
#overlay .bglabel { fill: #b35400; }

/* правая панель: каждый блок — отдельная карточка с заголовком-полосой */
.side { background: #e6e2dc; border-left: 1px solid var(--ed-line); display: flex; flex-direction: column; gap: 8px; padding: 8px; min-height: 0; overflow: hidden; }
.side section {
  background: #fff; border: 1px solid #d3cdc4; border-radius: 8px; box-shadow: 0 1px 2px rgba(60, 50, 40, .08);
  padding: 0 10px 8px; overflow-x: hidden; overflow-y: auto; flex: 0 1 auto; min-height: 0;
}
/* очередь шитья забирает остаток колонны; свёрнутые блоки — одна строка заголовка, место отдают развёрнутым */
.side section.grow { flex: 1 1 auto; min-height: 120px; }
.side section.collapsed { flex: none; min-height: 0; overflow: hidden; padding-bottom: 0; }
.side section.collapsed > :not(h3) { display: none !important; }
.side section.collapsed > h3 { margin-bottom: 0; border-bottom: 0; border-radius: 8px; }
.side h3 { cursor: pointer; user-select: none; }
.side h3 .fold { border: 0; background: none; padding: 0; width: 16px; min-width: 16px; font-size: 11px; line-height: 1;
  color: #5f584f; cursor: pointer; transition: transform .12s; }
.side h3 .fold:hover { color: var(--ed-text); }
.side h3 .fold:focus-visible { outline: 2px solid var(--ed-accent); outline-offset: 1px; border-radius: 3px; }
.side section.collapsed .fold { transform: rotate(-90deg); }
.side h3 {
  margin: 0 -10px 8px; padding: 7px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: #4a443c; background: #f4f1ec; border-bottom: 1px solid #e3ddd4; border-radius: 8px 8px 0 0;
  display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 1;
}
.h3btns { margin-left: auto; display: inline-flex; gap: 3px; text-transform: none; letter-spacing: 0; }
.prow { display: grid; grid-template-columns: 104px 1fr; gap: 6px; align-items: center; margin: 4px 0; }
.prow > span:first-child { color: var(--ed-muted); }
.prow .val { display: flex; gap: 6px; align-items: center; min-width: 0; }
.prow .val > input:not([type]), .prow .val > input[type=text], .prow .val > select { flex: 1 1 auto; min-width: 0; width: 100%; }
.prow .val > input[type=range] { flex: 1 1 auto; min-width: 50px; width: auto; }
.side input[type=number] { width: 4.8em; flex: 0 0 auto; }
.prow output { min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
.note { font-size: 12px; color: var(--ed-muted); margin: 4px 0; }
/* «Нитки»: объект, который считает движок (К4) */
/* «Нитки»: переходы между объектами по ответу движка (К5) */
#overlay .rt-jump { stroke: #2f5fd0; stroke-width: 1.2; stroke-dasharray: 5 4; fill: none; vector-effect: non-scaling-stroke; }
#overlay .rt-run { stroke: #2f5fd0; stroke-width: 1.2; fill: none; vector-effect: non-scaling-stroke; }
#overlay .rt-trim { fill: #b26a00; font-weight: 700; }
#overlay .rt-stop { fill: #fff; stroke: #c62828; stroke-width: 2; vector-effect: non-scaling-stroke; }
#overlay .rt-stop-t { fill: #c62828; }
#overlay .pt-in { fill: #2e7d32; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#overlay .pt-out { fill: #c62828; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#overlay .pt-in-t { fill: #2e7d32; }
#overlay .pt-out-t { fill: #c62828; }
.qtrans { font-size: 11px; color: #2f5fd0; padding: 0 6px 2px 34px; }
.qtrans.trim { color: #b26a00; }
.qtrans.stop { color: #c62828; }
.eng-pending { fill: none; stroke: #e08a00; stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.eng-pending-t { font-family: system-ui, sans-serif; font-weight: 500; fill: #8a8a8a; }
/* колёсико «обработка» над фигурой, которую считает движок */
.eng-spin { transform-origin: 0 0; animation: eng-spin .9s linear infinite; }
.eng-spin-bg { fill: none; stroke: #d6d2cc; stroke-width: 2; vector-effect: non-scaling-stroke; }
.eng-spin-fg { fill: none; stroke: #8a8a8a; stroke-width: 2; stroke-linecap: round; vector-effect: non-scaling-stroke; }
@keyframes eng-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .eng-spin { animation-duration: 2.5s; } }
#st-engine { color: #4a6a2a; }
/* разделы рецепта объекта в панели свойств: «Вид стежка», «Проколы», «Автоподложка»… */
.psub { margin: 10px 0 4px; padding-top: 6px; border-top: 1px solid #ebe6de; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: #6f6a62; }
#props > .psub:first-of-type { margin-top: 4px; padding-top: 0; border-top: 0; }
.note.warn { color: #9a4a00; }
.note.bad { color: var(--ed-danger); }
.pbtns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

#queue { display: flex; flex-direction: column; gap: 2px; }
.qrow { display: grid; grid-template-columns: 22px 16px 1fr 22px 22px 22px; gap: 5px; align-items: center; padding: 3px 4px; border-radius: 4px; cursor: pointer; border: 1px solid transparent; }
.qrow:hover { background: #f0ede8; }
.qrow.sel { background: var(--ed-accent-soft); border-color: #a9c6f5; }
.qrow.over { border-top: 2px solid var(--ed-accent); }
.qrow.nosew .qt { font-style: italic; color: var(--ed-muted); }
.qrow.hid { opacity: .5; }
.qrow .qn { color: var(--ed-muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; }
.qrow .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.3); }
.qrow .sw.none { background: repeating-linear-gradient(45deg, #fff 0 3px, #ccc 3px 5px); }
.qrow .qedit { width: 100%; padding: 1px 4px; }
.qrow .qt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qrow .qb { padding: 0; width: 22px; height: 20px; font-size: 11px; border-color: transparent; background: transparent; }
.qrow .qb:hover { border-color: var(--ed-line); }
.qsep { font-size: 11px; color: #9a4a00; padding: 1px 4px 1px 30px; border-top: 1px dashed #e0b080; margin-top: 2px; }
.qempty { color: var(--ed-muted); font-size: 12px; }

.status { display: flex; gap: 8px; align-items: center; padding: 4px 10px; background: var(--ed-panel); border-top: 1px solid var(--ed-line); font-size: 12px; white-space: nowrap; overflow: hidden; }
#st-hint { color: var(--ed-muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
#st-msg { color: #9a4a00; font-weight: 600; }
#st-pos, #st-zoom { font-variant-numeric: tabular-nums; }
#st-zoom { min-width: 3.5em; text-align: center; }
.status button { padding: 1px 8px; }

dialog { border: 1px solid var(--ed-line); border-radius: 10px; padding: 18px 22px; width: min(440px, 92vw); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(40,36,30,.45); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog p { margin: 0 0 12px; color: var(--ed-muted); }
dialog .row { display: grid; gap: 3px; margin-bottom: 10px; }
dialog .row input { width: 100%; padding: 6px 8px; font-size: 14px; }
dialog .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .row2s { grid-template-columns: 1fr 1fr auto; align-items: end; }
dialog .row2s #s-rot { margin-bottom: 10px; padding: 6px 10px; }
dialog .row select { width: 100%; padding: 6px 8px; font-size: 14px; }
dialog .btns { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
dialog .btns button { padding: 6px 14px; }

@media (max-width: 900px) {
  .main { grid-template-columns: 64px 1fr; }
  .side { display: none; }
}

/* контекстное меню */
.ctx {
  position: fixed; z-index: 50; min-width: 240px; max-height: calc(100vh - 8px); overflow-y: auto;
  background: #fff; border: 1px solid #cfc8bd; border-radius: 8px; box-shadow: 0 8px 28px rgba(40, 32, 24, .22); padding: 4px;
}
.ctx[hidden] { display: none; }
.ctx .citem {
  display: grid; grid-template-columns: 16px auto 1fr auto; align-items: center; gap: 6px; width: 100%;
  border: 0; background: transparent; padding: 5px 8px; border-radius: 5px; text-align: left; font-size: 13px;
}
.ctx .citem:hover:not(:disabled) { background: var(--ed-accent-soft); }
.ctx .citem:disabled { opacity: .4; }
.ctx .citem.danger { color: var(--ed-danger); }
.ctx .citem kbd { font: 11px system-ui; color: var(--ed-muted); }
.ctx .cchk { color: var(--ed-accent); font-weight: 700; text-align: center; }
.ctx .cswatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.3); display: inline-block; }
.ctx .citem:not(:has(.cswatch)) { grid-template-columns: 16px 1fr auto; }
.ctx .csep { height: 1px; background: #ebe6de; margin: 4px 6px; }
.ctx .chead { font-size: 11px; color: var(--ed-muted); text-transform: uppercase; letter-spacing: .04em; padding: 4px 8px 2px 30px; }
.prow .val > input.angrange { flex: 1 1 auto; }
#overlay .loose-label { fill: #b71c1c; }

/* вид «Нитки» */
.seg { display: inline-flex; border: 1px solid var(--ed-line); border-radius: 6px; overflow: hidden; margin-left: 6px; }
.seg button { border: 0; border-radius: 0; padding: 3px 10px; background: #fff; }
.seg button + button { border-left: 1px solid var(--ed-line); }
.seg button.on { background: var(--ed-accent); color: #fff; }
#objs .thread, #objs .thread-shadow, #objs .thread-hi { fill: none; stroke-linecap: round; }
#layers.view-thread #field { fill: #f3efe6; }
#layers.view-thread #grid-minor { display: none; }

/* окно разбора подложки */
#trace { width: min(480px, 94vw); }
#trace .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
#trace input[type=number] { width: 5em; }
#tr-result-title { font-weight: 600; color: var(--ed-text); }
#tr-result-body p { margin: 4px 0; color: var(--ed-text); }
.tr-stages { list-style: none; padding: 0; margin: 6px 0 12px; }
.tr-stages li { display: grid; grid-template-columns: 18px 1fr; column-gap: 6px; padding: 2px 0; color: var(--ed-muted); }
.tr-stages li::before { content: "○"; }
.tr-stages li.running { color: var(--ed-text); }
.tr-stages li.running::before { content: "◔"; color: var(--ed-accent); }
.tr-stages li.done::before { content: "✓"; color: #2e7d32; }
.tr-stages li.error::before { content: "✗"; color: var(--ed-danger); }
.tr-stages .st-s { grid-column: 2; font-size: 12px; color: var(--ed-muted); }

/* настройки конструктора */
.ed-bar .sp-left { margin-left: auto; }
#settings { width: min(520px, 94vw); }
#settings .set-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; margin: 10px 0 14px; }
#settings .set-name { font-weight: 600; }
#settings .set-lbl p { margin: 4px 0 0; }
#settings input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }

/* плеер симуляции (низ слева) */
.status .sim { display: inline-flex; align-items: center; gap: 4px; padding-right: 8px; margin-right: 4px; border-right: 1px solid var(--ed-line); flex-shrink: 0; }
.status .sim button { padding: 1px 7px; min-width: 28px; }
.status .sim button.on { background: var(--ed-accent); color: #fff; border-color: var(--ed-accent); }
.status .sim input[type=range] { width: 200px; }
.status .sim select { padding: 1px 2px; font-size: 12px; }
#sim-info { color: var(--ed-text); font-variant-numeric: tabular-nums; min-width: 9em; }
.qrow.simcur { background: #fff1d6; border-color: #e0a040; box-shadow: inset 3px 0 0 #e08a00; }
#overlay .simobj { fill: none; stroke: #e08a00; stroke-width: 2.5; stroke-dasharray: 6 3; }

/* «Продвинутый блок» — у правого края объекта в режиме «Продвинутые настройки» */
/* меню ПКМ в верхнем слое (popover): без умолчаний popover, своё положение */
#ctx[popover] { inset: auto; margin: 0; overflow: visible; }
/* окно «Описание» */
dialog.help-dlg { max-width: min(520px, calc(100vw - 32px)); }
dialog.help-dlg #help-b p { margin: 0 0 10px; line-height: 1.45; }
.adv { position: absolute; z-index: 5; width: 260px; max-height: calc(100% - 16px); overflow-y: auto; background: var(--ed-panel); border: 1px solid var(--ed-line);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 13px; }
.adv[hidden] { display: none; }
.adv-h { display: flex; gap: 6px; align-items: baseline; padding: 7px 8px 6px 10px; border-bottom: 1px solid var(--ed-line); }
.adv-h .adv-name { flex: 1; min-width: 0; color: var(--ed-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adv-h .adv-x { border: 0; background: transparent; padding: 0 4px; font-size: 18px; line-height: 1; }
.adv-b { padding: 4px 10px 10px; }
.adv-btns { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.adv-btns button.on { background: var(--ed-accent-soft); border-color: var(--ed-accent); }
/* слои линий тиснения */
.clayers { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.clrow { display: grid; grid-template-columns: 22px 18px 1fr auto 22px; gap: 4px; align-items: center; padding: 2px 4px; border-radius: 4px;
  border: 1px solid transparent; cursor: pointer; }
.clrow:hover { background: #f0ede8; }
.clrow.act { background: var(--ed-accent-soft); border-color: #a9c6f5; }
.clrow.off .clname { color: var(--ed-muted); text-decoration: line-through; }
.clrow .clname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clrow .clcnt { color: var(--ed-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.clrow .qb { padding: 0; width: 22px; height: 20px; font-size: 11px; border-color: transparent; background: transparent; }
.qrow .qadv.on { background: var(--ed-accent-soft); border-color: var(--ed-accent); }

/* слой подложки: список картинок */
.bglist { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px; max-height: 168px; overflow-y: auto; }
.bgrow { display: grid; grid-template-columns: 30px 1fr 22px 22px 22px 22px 22px; gap: 3px; align-items: center; padding: 2px 4px; border-radius: 4px;
  border: 1px solid transparent; cursor: pointer; }
.bgrow:hover { background: #f0ede8; }
.bgrow.act { background: var(--ed-accent-soft); border-color: #a9c6f5; }
.bgrow.hid { opacity: .55; }
.bgrow .bgthumb { width: 30px; height: 22px; object-fit: contain; background: #fff; border: 1px solid var(--ed-line); border-radius: 3px; }
.bgrow .bgname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bgrow .qb { padding: 0; width: 22px; height: 20px; font-size: 11px; border-color: transparent; background: transparent; }

/* линейки сверху и слева */
.rul { background: #f4f2ee; z-index: 4; box-sizing: border-box; }
#layers > canvas#rul-top { inset: 0 auto auto 20px; width: calc(100% - 20px); height: 20px; border-bottom: 1px solid #c9c4bb; cursor: row-resize; }
#layers > canvas#rul-left { inset: 20px auto auto 0; width: 20px; height: calc(100% - 20px); border-right: 1px solid #c9c4bb; cursor: col-resize; }
#rul-corner { position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-right: 1px solid #c9c4bb; border-bottom: 1px solid #c9c4bb;
  font: 9px/20px system-ui, sans-serif; color: #8a8378; text-align: center; user-select: none; cursor: default; }
