/* Студiя вишивки: стиль за схваленим прототипом (20.10). */
:root {
  --ink: #15171A; --ink-2: #3A404B; --muted: #5B6270; --line: #E2E5EA; --line-2: #C9CED8;
  --ground: #F4F5F7; --card: #FFFFFF; --accent: #2D4BD8; --accent-ink: #1F37A8; --accent-soft: #EEF1FD;
  --ok: #1E7B4A; --ok-soft: #E8F5EE; --warn: #8A5A00; --warn-soft: #FFF5DD; --bad: #B42318; --bad-soft: #FDECEA;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; }
a { color: var(--accent); } a:hover { color: var(--accent-ink); }
h1 { margin: 0; font-size: 28px; font-weight: 700; }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
p { margin: 0; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.nav { flex: 1 1 220px; max-width: 240px; min-width: 200px; padding: 24px 16px; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 24px; font-weight: 700; font-size: 17px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .grow { flex: 1 1 auto; }
.nav form button { width: 100%; min-height: 40px; border: 0; background: none; color: var(--muted); text-align: left; padding: 0 12px; cursor: pointer; border-radius: 10px; }
.nav form button:hover { background: var(--ground); }
.main { flex: 999 1 560px; min-width: 0; padding: 40px 48px; display: flex; justify-content: center; }
.col { width: 100%; max-width: 860px; display: flex; flex-direction: column; gap: 24px; }
.col.wide { max-width: 1200px; }
.lead { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 24px; }
.row { align-items: flex-start; }
.row > .card { flex: 1 1 300px; }

.styles { display: flex; flex-wrap: wrap; gap: 12px; }
.style { flex: 1 1 260px; text-align: left; padding: 18px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.style[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 17px; }
.style b { font-size: 16px; }
.style span { color: var(--muted); font-size: 14px; line-height: 1.45; }

.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px; border: 2px dashed var(--line-2); border-radius: 14px; cursor: pointer; text-align: center; padding: 20px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop small { color: var(--muted); }
.picked { display: flex; align-items: center; gap: 16px; }
.picked img { width: 96px; height: 96px; object-fit: contain; border-radius: 10px; background: var(--ground); border: 1px solid var(--line); }
.picked span { color: var(--muted); font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.fields > .field { flex: 1 1 160px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select { height: 44px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; background: var(--card); width: 100%; }
.fields { display: flex; flex-wrap: wrap; gap: 16px; }
.hint { font-size: 13px; color: var(--muted); }
.more { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-height: 32px; }

.btn { min-height: 52px; padding: 0 24px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn:hover { background: var(--accent-ink); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--card); color: var(--ink-2); border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--ground); color: var(--ink); }
.btn.soon { background: var(--card); color: var(--muted); border: 1px dashed var(--line-2); cursor: default; font-size: 14px; font-weight: 500; min-height: 44px; padding: 0 12px; text-align: center; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 12px 16px; }

.progress-wrap { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.progress-wrap img { flex: 0 1 280px; max-width: 100%; max-height: 360px; object-fit: contain; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.progress-wrap > div { flex: 1 1 320px; display: flex; flex-direction: column; gap: 20px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width .6s ease; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.steps li .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; }
.steps li.done { color: var(--ink); }
.steps li.done .dot { background: var(--accent); border-color: var(--accent); }
.steps li.done .dot::after { content: ""; width: 8px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now .dot { border-color: var(--accent); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.viewer { flex: 999 1 480px; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; background: var(--ground); border-radius: 10px; padding: 3px; }
.seg button { min-height: 38px; padding: 0 16px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chip { min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.stage { min-height: 480px; display: flex; align-items: center; justify-content: center; padding: 24px; background: #fff; }
.stage.checker { background-color: #fff; background-image: linear-gradient(45deg, #E8EBF0 25%, transparent 25%), linear-gradient(-45deg, #E8EBF0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #E8EBF0 75%), linear-gradient(-45deg, transparent 75%, #E8EBF0 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
.stage img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.stage { position: relative; }
.stage canvas.stage-gl { width: 100%; height: 70vh; display: block; touch-action: none; cursor: grab; }
.stage canvas.stage-gl[hidden] { display: none; }
.stage img.stage-under { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-height: 70vh; pointer-events: none; }
.stage .wait.small { position: absolute; left: 12px; top: 12px; font-size: 13px; color: var(--muted); }
.stage-zoom { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.stage-zoom .chip { background: var(--card); }
.stage .wait { color: var(--muted); }
.summary { flex: 1 1 300px; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.summary dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.summary dt { font-size: 13px; color: var(--muted); }
.summary dd { margin: 2px 0 0; font-weight: 700; font-size: 18px; }
.check { border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.check.ok { background: var(--ok-soft); color: var(--ok); }
.check.warn { background: var(--warn-soft); color: var(--warn); }
.check ul { margin: 6px 0 0; padding-left: 18px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette span { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }
.files { display: flex; flex-direction: column; }
.files a { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.files a:hover b { color: var(--accent); }
.files .ext { width: 40px; height: 40px; border-radius: 10px; background: var(--ground); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--ink-2); flex: 0 0 auto; text-transform: uppercase; }
.files small { display: block; color: var(--muted); font-size: 13px; }
.files .file-off { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); }
.card textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; resize: vertical; }
.two { display: flex; gap: 12px; } .two > * { flex: 1 1 0; }

.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.item:hover { border-color: var(--accent); color: var(--ink); }
.item .thumb { height: 170px; background: var(--ground); display: flex; align-items: center; justify-content: center; }
.item .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.item .meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.item .meta small { color: var(--muted); }
.badge { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.working { background: var(--accent-soft); color: var(--accent); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.empty { color: var(--muted); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; display: flex; flex-direction: column; gap: 20px; }

/* Редактор (#e/<id>) */
body.wide-view .main { padding: 24px; }
.editor { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.editor-bar .back { font-weight: 600; color: var(--ink-2); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.editor-body { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.editor-list { flex: 1 1 200px; max-width: 240px; max-height: 75vh; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.editor-head { font-weight: 600; padding: 4px 8px 8px; }
.editor-stage { font-size: 12px; color: var(--muted); padding: 8px 8px 2px; text-transform: uppercase; letter-spacing: .04em; }
.editor-item { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; font-size: 14px; }
.editor-item:hover { background: var(--ground); }
.editor-item[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.editor-item.gone .grow { text-decoration: line-through; color: var(--muted); }
.editor-item .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: 0 0 auto; }
.editor-item .grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-item small { color: var(--muted); font-size: 12px; font-weight: 400; }
.editor-canvas { flex: 999 1 420px; min-width: 0; background: #D3D5D9; border: 1px solid var(--line); border-radius: 14px; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.editor-canvas { position: relative; }
.editor-canvas svg { width: 100%; max-height: 75vh; display: block; position: relative; }
.editor-canvas canvas.editor-gl { position: absolute; display: none; pointer-events: none; }
.editor-canvas-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.editor-canvas-bar .seg button { padding: 0 14px; }
.editor-canvas-bar .seg button:disabled { opacity: .4; cursor: not-allowed; }
.editor-props { flex: 1 1 260px; max-width: 320px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.editor-group { display: flex; flex-direction: column; gap: 8px; }
.editor-label { font-size: 13px; font-weight: 600; }
.editor-props .seg { display: flex; } .editor-props .seg button { flex: 1 1 0; padding: 0 8px; }
.editor-props .seg button:disabled { opacity: .4; cursor: not-allowed; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.chip:disabled { opacity: .45; cursor: default; }

/* На одязi (#g/<id>) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.garment-canvas { background: #F7F8FA; }
.garment-canvas svg { width: 100%; max-height: 78vh; touch-action: none; }
.gsummary { margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.gsummary div { display: flex; justify-content: space-between; gap: 8px; }
.gsummary dt { color: var(--muted); } .gsummary dd { margin: 0; font-weight: 600; text-align: right; }
.field input[type=number] { height: 44px; }

@media (max-width: 720px) {
  .nav { max-width: none; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; } .nav .grow { display: none; }
  .main { padding: 24px 16px; }
  .stage { min-height: 300px; }
  .editor-list, .editor-props { max-width: none; }
  .editor-list { max-height: 220px; }
  body.wide-view .main { padding: 16px; }
}
.check .plan-source { margin-top: 6px; font-size: 13px; opacity: .85; }
.busy { margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); }
/* Редактор: цифри, шари, масштаб */
.editor-info { display: flex; flex-wrap: wrap; gap: 8px; }
.editor-stat { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-width: 96px; }
.editor-stat small { font-size: 12px; color: var(--muted); }
.editor-stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.editor-layers, .editor-zoom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.editor-layers .chip[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.editor-zoom { margin-left: auto; }
.editor-zoom .chip { min-width: 36px; }
.zoom-label { min-width: 48px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.editor-canvas svg { touch-action: none; cursor: grab; }
.editor-canvas-note { padding: 8px 12px; background: var(--card); border-top: 1px solid var(--line); }
.editor-travel { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; background: var(--card); border-top: 1px solid var(--line); }
.editor-travel[hidden] { display: none; }
.editor-row { display: flex; align-items: center; gap: 4px; }
.editor-row .editor-item { flex: 1 1 auto; min-width: 0; }
.editor-row .editor-item small { display: none; }
.editor-row .editor-item .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-row.drop { box-shadow: inset 0 2px 0 var(--accent, #2D4BD8); }
.chip.mini { min-width: 28px; padding: 0 6px; }
.editor-travel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; background: var(--ground); border-radius: 12px; }
.rating .stars { display: inline-flex; gap: 2px; }
.rating .star { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: #C9CED8; padding: 0 2px; }
.rating .star[aria-pressed="true"] { color: #D9A400; }
.rating input { flex: 1 1 200px; height: 36px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; }
/* «Дизайн 2» версія 2: статуси вузлів, бюджет, розміри в мм */
.d2-box { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--ground); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.d2-box details summary { cursor: pointer; color: var(--muted); }
.d2-nodes, .d2-geo, .d2-warn { margin: 6px 0 0; padding-left: 18px; }
.d2-nodes li.d2-failed, .d2-nodes li.d2-fallback { color: var(--warn); }
.d2-nodes li.d2-skipped { opacity: .7; }
.d2-warn li { color: var(--warn); }

/* Банер «сервіс оновлено» (version.js) */
.ver-banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px; max-width: min(900px, calc(100vw - 32px)); background: #15171A; color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.25); }
.ver-banner .btn { background: #fff; color: #15171A; border: 0; border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ver-banner .linkbtn { background: none; border: 0; color: #C9CED8; cursor: pointer; font-size: 13px; }
.field label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.field label.check input[type=checkbox] { width: 18px; height: 18px; min-height: 0; padding: 0; margin-top: 1px; flex: none; }
.d2-report { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #F7F8FB; border: 1px solid #E6E8EF; }
.d2-report .d2-verdict.ok strong { color: #127a3a; }
.d2-report .d2-verdict.bad strong { color: #b42318; }
.d2-report .d2-cost { font-weight: 600; }
.d2-report table.acc { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.d2-report table.acc th, .d2-report table.acc td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #E6E8EF; vertical-align: top; }
.d2-report table.acc tr.acc-fail td { background: #FEF3F2; }
.d2-report table.acc tr.acc-warn td { background: #FFFAEB; }

/* Власник 25.10 (правило 3): «не вистачає ниток» -- вибiр */
.threads-choice { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--card); color: var(--ink); border: 1px solid var(--warn); }
.threads-choice p { margin: 6px 0; }
.threads-choice ul { margin: 6px 0; padding-left: 18px; }
.threads-choice .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; border: 1px solid rgba(0,0,0,.2); }
.threads-choice .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
