:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --text: #1c2430;
  --muted: #5f6b7a;
  --line: #d5dbe3;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --warn: #b35c00;
  --fail: #c92a2a;
  --info: #1971c2;
  --note-bg: #fff4e0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181e;
    --surface: #1d232b;
    --surface-2: #232a33;
    --text: #e3e8ee;
    --muted: #9aa5b1;
    --line: #2e3742;
    --accent: #4c8dff;
    --accent-text: #0b1220;
    --danger: #ff8a80;
    --ok: #69db7c;
    --warn: #ffc078;
    --fail: #ff8a80;
    --info: #74c0fc;
    --note-bg: #3a2e1b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100%;
}
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; color: inherit; text-decoration: none; }
.brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user .who { font-size: 13px; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* --- список проектов --- */
.projects { width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.projects-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.projects-head .actions { margin: 0; }
.note { background: var(--note-bg); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.note.warn { color: var(--warn); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.cards[hidden] { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.thumb { display: block; width: 100%; aspect-ratio: 4 / 3; border: 0; padding: 0; background: var(--surface-2); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.card-body { padding: 10px 12px 12px; }
.card-body h3 { margin: 0 0 2px; font-size: 15px; overflow-wrap: anywhere; }
.card-body h3 a { color: inherit; text-decoration: none; }
.card-body p { margin: 0; font-size: 13px; }
.card-actions { display: flex; gap: 6px; margin-top: 10px; }
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 28px 16px; text-align: center; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dropzone p { margin: 4px 0; }
.intro { max-width: 720px; }
.upload-progress { display: grid; gap: 6px; margin-bottom: 12px; }
.upload-progress[hidden] { display: none; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* --- проект --- */
.project { flex: 1; min-height: 0; display: flex; }
.stage { position: relative; flex: 1; min-width: 0; background: var(--bg); }
.stage .view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); padding: 16px; text-align: center; }
.stage-empty[hidden] { display: none; }
.panel { width: 380px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 16px 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.back { text-decoration: none; }
.title-input { width: 100%; font-family: inherit; font-size: 17px; font-weight: 600; line-height: 1.3; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; margin: 6px 0 8px -6px; }
.title-input:hover, .title-input:focus { border-color: var(--line); background: var(--surface-2); }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: 0 -16px 12px; padding: 0 12px; overflow-x: auto; }
.tabs button { flex: 1 0 auto; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 8px 6px; border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.modebar { position: absolute; top: 12px; left: 12px; display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; z-index: 2; max-width: calc(100% - 24px); overflow-x: auto; }
.modebar button { border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.modebar button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.modebar button:disabled { opacity: .4; cursor: default; }
.legend { position: absolute; left: 12px; bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; display: grid; gap: 3px; z-index: 2; max-width: calc(100% - 24px); }
.legend[hidden], .jobbox[hidden], .faceinfo[hidden] { display: none; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }
.jobbox { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; z-index: 3; box-shadow: 0 6px 24px rgb(0 0 0 / .12); }
.faceinfo { position: absolute; right: 12px; bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; z-index: 2; max-width: 300px; display: grid; gap: 2px; }
.faceinfo .actions.compact { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }

/* инструменты просмотра: столбец кнопок справа и всплывающая панель */
.vtbar { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.vtbar .btn { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.vpanel { position: absolute; right: 112px; top: 12px; width: 290px; max-width: calc(100% - 136px); max-height: calc(100% - 24px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; font-size: 13px; z-index: 4; box-shadow: 0 6px 24px rgb(0 0 0 / .12); display: grid; gap: 8px; }
.vpanel[hidden] { display: none; }
.vpanel-head { display: flex; justify-content: space-between; align-items: center; }
.vpanel label { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.vpanel input[type=range] { flex: 1; min-width: 80px; }
.vpanel p { margin: 4px 0; }
.btn.close { min-width: 32px; padding: 0; font-size: 18px; line-height: 1; }
.vgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 4px; }
.seg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0; }
.mresult { min-height: 40px; }
.shots { display: grid; gap: 6px; }
.shot { display: grid; grid-template-columns: 72px 1fr auto; gap: 8px; align-items: center; }
.shot img { width: 72px; height: 48px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: block; }
.mlabel { position: absolute; transform: translate(-50%, -50%); background: #1c7ed6; color: #fff; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 6px; pointer-events: none; z-index: 2; white-space: nowrap; }
.mlabel[hidden] { display: none; }
.small { font-size: 12px; }

/* --- формы --- */
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > label { font-size: 13px; color: var(--muted); }
.field.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.field input:not([type=checkbox]), .field select, .dialog input {
  width: 100%; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit;
}
.help { color: var(--muted); font-size: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 4px; margin: 0 0 12px; }
legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-bottom: 8px; }
.add-machine { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 16px; }
.axis-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

dl.info { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 12px; font-size: 14px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.checks { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.check { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; font-size: 14px; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.check .badge { border: 0; color: #fff; font-weight: 600; padding: 1px 7px; margin-top: 1px; }
.check.ok .badge { background: var(--ok); }
.check.warn .badge { background: var(--warn); }
.check.fail .badge { background: var(--fail); }
.check.pending .badge { background: var(--muted); }
.check.info .badge { background: var(--info); }
@media (prefers-color-scheme: dark) { .check .badge { color: #111; } }

.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); width: min(400px, calc(100% - 32px)); padding: 20px; }
.dialog::backdrop { background: rgb(0 0 0 / .4); }
.form-error { color: var(--danger); font-size: 14px; }
.switch { font-size: 14px; margin: 4px 0 0; }

.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / .2); }
.toast.error { background: var(--danger); color: #fff; }
.notfound { padding: 40px 16px; text-align: center; }

.viewswitch { position: absolute; top: 12px; left: 12px; display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; z-index: 3; }
.viewswitch[hidden], .moldtools[hidden], .modebar[hidden] { display: none; }
.viewswitch button { border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.viewswitch button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.viewswitch:not([hidden]) ~ .modebar { top: 56px; }
.moldtools { position: absolute; left: 12px; bottom: 12px; margin: 0; display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; z-index: 2; max-width: calc(100% - 24px); }
.moldtools label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.moldtools input[type=range] { width: 120px; }
.moldtools > summary { color: var(--text); font-weight: 600; margin: 0; padding: 2px 0; }
.moldtools:not([open]) { padding: 4px 10px; }
.mrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.mrow[hidden], .moldtools .btn[hidden] { display: none; }
.btn.play { min-width: 32px; padding: 0; }
.phase { color: var(--accent); font-weight: 600; min-width: 9em; }
.stage.picking canvas { cursor: crosshair; }
details.components { margin: 12px 0; }
details.components summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.complist fieldset { margin: 8px 0; }
.comp { display: grid; grid-template-columns: auto 1fr auto auto; column-gap: 6px; align-items: center; padding: 2px 4px; font-size: 14px; border-radius: 6px; }
.comp.picked { background: var(--note-bg); }
.comp button.link { border: 0; background: none; color: var(--text); font: inherit; text-align: left; padding: 3px 0; cursor: pointer; }
.comp button.icon { border: 1px solid transparent; background: none; color: var(--muted); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.comp button.icon svg { width: 16px; height: 16px; }
.comp button.icon[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.comp button:disabled { cursor: default; opacity: .6; }
details.ctype { margin: 2px 0; }
details.ctype > summary { color: var(--text); font-size: 14px; margin: 0; padding: 3px 4px; }
details.ctype > .comp { margin-left: 18px; }

@media (max-width: 800px) {
  .project { flex-direction: column; }
  .moldtools { left: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  .vtbar { right: 8px; top: 8px; }
  .vtbar .btn.small { min-height: 30px; padding: 0 8px; font-size: 12px; }
  .vpanel { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-width: none; max-height: 46%; }
  .stage { flex: none; height: 56vh; min-height: 300px; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  #app { overflow-y: auto; }
  .faceinfo { top: 100px; bottom: auto; left: 8px; right: auto; max-width: calc(100% - 110px); }
  .modebar[hidden] ~ .faceinfo { top: 56px; }
  .legend { left: 8px; bottom: 8px; }
  .user .who { display: none; }
  .bar .badge { display: none; }
}

/* --- чертежи (этап 4) --- */
.sheets { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.sheet { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sheet .linklike { flex: 1; text-align: left; background: none; border: 0; padding: 0; color: var(--text); font: inherit; cursor: pointer; }
.sheet .linklike:hover b, .sheet .linklike:focus-visible b { color: var(--accent); }
.titleblock { margin: 12px 0; }
.titleblock summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.sheet-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--surface); color: var(--text); }
.sheet-dialog::backdrop { background: rgb(0 0 0 / .5); }
.sheet-dialog[open] { display: flex; flex-direction: column; }
.sheet-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sheet-bar .grow { flex: 1; }
.sheet-body { flex: 1; display: flex; min-height: 0; }
.sheet-scroll { flex: 1; overflow: auto; background: #e8e8e8; padding: 12px; touch-action: pan-x pan-y pinch-zoom; }
.sheet-holder { position: relative; width: 100%; margin: 0 auto; background: #fff; box-shadow: 0 1px 6px rgb(0 0 0 / .25); }
.sheet-img { display: block; width: 100%; height: auto; user-select: none; }
.sheet-over { position: absolute; inset: 0; width: 100%; height: 100%; }
.sheet-over .handle { fill: rgb(37 99 235 / .25); stroke: #2563eb; stroke-width: .5; cursor: move; touch-action: none; }
.sheet-over .handle.moved { fill: rgb(234 88 12 / .35); stroke: #ea580c; }
.sheet-over .handle.sel { fill: rgb(220 38 38 / .45); stroke: #dc2626; stroke-width: .8; }
.sheet-side { width: 320px; overflow: auto; padding: 12px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.sheet-side > * { flex-shrink: 0; }
.sheet-side textarea { min-height: 120px; width: 100%; font: inherit; font-size: 13px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; resize: vertical; }
.sheet-side .deleted { display: flex; flex-wrap: wrap; gap: 4px; }
.jobline .progress { margin-top: 4px; }
@media (max-width: 800px) {
  .sheet-body { flex-direction: column; }
  .sheet-scroll { flex: 1 1 60%; padding: 6px; }
  .sheet-side { width: auto; flex: 0 0 auto; max-height: 40dvh; border-left: 0; border-top: 1px solid var(--line); }
}

/* --- мини-CAD: дерево построения (этап 5) --- */
.cad { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 12px; }
.cad h3 { margin: 4px 0; font-size: 16px; }
.cad-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cad .actions.compact, .cad-editor .actions.compact { margin: 6px 0; gap: 6px; align-items: center; }
.cad select { min-height: 32px; }
.cad-tree { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 2px; }
.cad-item { border-radius: 8px; padding: 2px 4px; }
.cad-item.sel { background: var(--surface-2); outline: 1px solid var(--line); }
.cad-item.off .cad-name { opacity: .55; text-decoration: line-through; }
.cad-name { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; background: none; border: 0;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; padding: 2px 4px; }
.cad-icon { width: 22px; text-align: center; color: var(--accent); font-weight: 700; }
.cad-item.err .cad-icon { color: var(--danger); }
.badge.err { color: #fff; background: var(--danger); border-color: var(--danger); }
.cad-err { color: var(--danger); font-size: 13px; padding: 0 4px 4px 34px; }
.cad-bodies { margin: 8px 0; font-size: 14px; }
.cad-bodies summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.cad-body { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; margin: 6px 0; }
.cad-body input { min-width: 0; }
.cad-editor h3 { margin: 4px 0 10px; }
.cad-editor .inrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cad-editor .inrow input[type=text], .cad-editor .inrow select { flex: 1 1 140px; min-width: 0; min-height: 34px; }
.cad-editor .vec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 100%; }
.cad-editor .vec input { min-width: 0; }
.cad-refs { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 6px 10px; display: grid; gap: 4px; }
.cad-refs legend { font-size: 13px; color: var(--muted); }
label.cb { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 14px; margin-bottom: 6px; }

/* --- редактор эскиза --- */
body.sk-open { overflow: hidden; }
.sketcher { position: fixed; inset: 0; z-index: 50; background: var(--surface); display: grid;
  grid-template-rows: auto auto 1fr auto; color: var(--text); }
.sk-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.sk-title { font-size: 15px; }
.sk-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.sk-status { font-size: 13px; padding: 2px 10px; border-radius: 12px; border: 1px solid currentColor; }
.sk-status.under { color: var(--info); }
.sk-status.full { color: var(--ok); }
.sk-status.over, .sk-status.failed { color: var(--danger); }
.sk-bars { display: grid; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.sk-bar { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.sk-bar .btn { flex: 0 0 auto; }
.sk-stage { position: relative; min-height: 0; }
.sk-canvas { width: 100%; height: 100%; display: block; background: var(--surface); user-select: none; -webkit-user-select: none; }
.sk-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 6px 12px; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--line); min-height: 40px; }
.sk-param { display: flex; align-items: center; gap: 6px; color: var(--text); }
.sk-param input { width: 80px; min-height: 30px; }
.sk-value[hidden] { display: none; }
.sk-value { position: absolute; z-index: 2; display: flex; gap: 6px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.sk-value input[type=text] { width: 96px; min-height: 30px; }
.sk-value label { display: flex; gap: 4px; align-items: center; }
.sk-grid line { stroke: var(--line); stroke-width: 1; }
.sk-grid .sk-axis-x { stroke: #e0313188; stroke-width: 1.2; }
.sk-grid .sk-axis-y { stroke: #2b8a3e88; stroke-width: 1.2; }
.sk-scale { font-size: 11px; fill: var(--muted); }
.sk-ref line { stroke: var(--muted); stroke-width: 1.2; opacity: .55; }
.sk-curve { fill: none; stroke: var(--text); stroke-width: 2; }
.sk-curve.constr { stroke: var(--info); stroke-dasharray: 6 4; stroke-width: 1.4; }
.sk-curve.hover { stroke-width: 3; }
.sk-curve.sel, .sk-pt.sel { stroke: #f59f00; }
.sk-curve.bad, .sk-pt.bad { stroke: var(--danger); }
.sk-pt { fill: var(--surface); stroke: var(--text); stroke-width: 1.6; }
.sk-pt.center { fill: none; }
.sk-pt.hover { stroke-width: 3; }
.sk-pt.sel { fill: #f59f00; }
.sk-con text { font-size: 12px; fill: var(--accent); cursor: pointer; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.sk-con.bad text { fill: var(--danger); }
.sk-con.sel text { fill: #f59f00; font-weight: 700; }
.sk-con.ref text { fill: var(--muted); }
.sk-dimline { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.sk-preview { fill: none; stroke: #f59f00; stroke-width: 1.5; stroke-dasharray: 5 4; }
.sk-preview .faint { opacity: .4; }
@media (max-width: 800px) {
  .sk-top { padding: 6px 8px; }
  .sk-title { width: 100%; }
  .sk-actions { margin-left: 0; }
  .sk-bars { padding: 4px 8px; }
  .sk-hint { padding: 4px 8px; }
}

/* арматура (процесс D) на вкладке «Изделие» */
section.inserts { margin-top: 1rem; }
ul.inserts { list-style: none; padding: 0; margin: 0.4rem 0; }
ul.inserts li { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; padding: 0.25rem 0; border-bottom: 1px solid var(--line); }
ul.inserts li > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
section.inserts label.armpick { display: block; padding: 0.15rem 0; font-size: 14px; }

/* --- страницы «О сервисе», «Конфиденциальность» --- */
.page { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 16px 32px; }
.page h1 { font-size: 26px; margin-bottom: 12px; }
.page h2 { margin-top: 28px; }
.page .lead { font-size: 17px; }
.page li { margin: 6px 0; }
.page-foot { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); text-align: center; border-top: 1px solid var(--line); background: var(--surface); }
.projects .links { margin-top: 24px; text-align: center; }
.user .who.link { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline dotted; }

/* --- мини-CAD: панель команд (как CommandManager в SolidWorks) --- */
.cad-toolbar { display: grid; gap: 6px; margin: 8px 0 10px; }
.cad-group { --g: var(--muted); border: 1px solid var(--line); border-left: 3px solid var(--g); border-radius: 8px; padding: 4px 6px 6px; background: var(--surface); }
.cad-group.g-sketch { border-left-color: var(--accent); padding: 4px; }
.cad-group.g-boss { --g: var(--accent); }
.cad-group.g-cut { --g: var(--danger); }
.cad-group-title { font-size: 12px; color: var(--muted); margin: 0 0 4px 2px; }
.cad-group-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 4px; }
.cad-cmd { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 2px;
  border: 1px solid transparent; border-radius: 7px; background: none; color: var(--text); font: inherit; font-size: 12px; line-height: 1.15; text-align: center; cursor: pointer; }
.cad-cmd:hover, .cad-cmd:focus-visible { background: var(--surface-2); border-color: var(--line); }
.cad-cmd .cad-svg { color: var(--g, var(--accent)); display: inline-flex; }
.cad-group.g-sketch .cad-cmd { flex-direction: row; gap: 8px; min-height: 40px; width: 100%; font-size: 14px; font-weight: 600; color: var(--accent); }
.cad-group.g-sketch .cad-cmd .cad-svg { color: var(--accent); }
.cad-svg svg { display: block; }
.cad-icon { display: inline-flex; align-items: center; justify-content: center; }
.cad-item.cut .cad-icon { color: var(--danger); }
.cad-editor-title { display: flex; align-items: center; gap: 8px; }
.cad-editor-title .cad-svg { color: var(--accent); }
.cad-editor.cut .cad-editor-title .cad-svg { color: var(--danger); }
.cad-editor.cut { border-left: 3px solid var(--danger); padding-left: 8px; }

/* --- эскиз: поля ввода при рисовании, направляющие, привязка, цвет определённости --- */
.sk-sep { flex: 0 0 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.sk-bar select { flex: 0 0 auto; min-height: 32px; font-size: 13px; }
.sk-hud { position: absolute; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; max-width: calc(100% - 8px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; box-shadow: 0 4px 14px #0002; font-size: 13px; }
.sk-hud[hidden] { display: none; }
.sk-hud.coarse { left: 8px; right: 8px; bottom: 8px; }
.sk-hud-f { display: flex; align-items: center; gap: 4px; }
.sk-hud input { width: 76px; min-height: 30px; font: inherit; }
.sk-hud input::placeholder { color: var(--muted); }
.sk-hud input.locked { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sk-guide { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 4; opacity: .75; }
.sk-snap { fill: none; stroke: #f59f00; stroke-width: 1.6; }
.sk-canvas.under .sk-curve:not(.constr):not(.sel):not(.bad) { stroke: var(--info); }
.cad-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.cad-tabs button { border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 10px; cursor: pointer; }
.cad-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.cad-cmd { min-height: 48px; }
.cad-group-btns { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }

/* --- эскиз на плоскости / на детали --- */
.cad-where { font-weight: 600; margin: 4px 0 6px; }
.cad-planes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.cad-planes .btn { border-left-width: 3px; }
.cad-planes .pl-XY { border-left-color: #4c8dff; }
.cad-planes .pl-XZ { border-left-color: #2b8a3e; }
.cad-planes .pl-YZ { border-left-color: #e03131; }
.sk-stage.with-back { background: var(--surface); }
.sk-stage .sk-back { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; pointer-events: none; }
.sk-stage.with-back .sk-canvas { position: relative; z-index: 1; background: transparent; }
