#sculpt-dialog {
  display: none;
  padding: 0;
  margin: auto;
  width: min(100%, 760px);
  max-width: calc(100% - 20px);
  height: min(93dvh, 850px);
  max-height: 100dvh;
  overflow: hidden;
  border: 1px solid var(--shop-border);
  background: var(--shop-bg);
}

#sculpt-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.sculpt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--shop-border);
}
.sculpt-header h2 { margin: 0; font-size: 1rem; text-align: center; }
.sculpt-header button { min-height: 44px; padding: 6px 10px; }
#sculpt-viewport { position: relative; overflow: hidden; }
#sculpt-viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#sculpt-viewport[data-orbit="true"] canvas { cursor: grab; }
.sculpt-controls {
  max-height: 53dvh;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--shop-panel);
  border-top: 1px solid var(--shop-border);
  padding: 8px 12px max(8px, env(safe-area-inset-bottom, 0px));
}
.sculpt-brushes, .sculpt-settings { display: grid; gap: 6px; }
.sculpt-brushes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sculpt-brushes button { min-height: 44px; padding: 4px 3px; font-size: .8rem; }
.sculpt-brushes button[aria-pressed="true"] { color: var(--shop-on-accent); background: var(--shop-accent); border-color: var(--shop-accent); }
.sculpt-settings { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.sculpt-settings label { min-width: 0; font-size: .8rem; font-weight: 650; }
.sculpt-settings output { float: right; font-variant-numeric: tabular-nums; color: var(--shop-muted); }
#sculpt-dialog .sculpt-settings input[type="range"] { display: block; width: 100%; min-height: 32px; margin: 0; padding: 0; border: 0; background: transparent; accent-color: var(--shop-accent); }
.sculpt-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sculpt-footer label { display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: .8rem; }
#sculpt-dialog #sculpt-mirror { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; }
.sculpt-history { display: flex; gap: 4px; }
.sculpt-history button { width: 44px; min-height: 44px; padding: 2px; font-size: 1rem; }
#sculpt-help, #sculpt-error { margin: 3px 0 0; color: var(--shop-muted); font-size: .78rem; }
#sculpt-error { color: #ffbf8d; }
.sculpt-cursor { position: absolute; pointer-events: none; transform: translate(-50%, -50%); border: 1px solid var(--shop-accent); border-radius: 50%; }

@media (max-width: 650px) {
  #sculpt-dialog { max-width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .sculpt-header { padding-top: max(6px, env(safe-area-inset-top, 0px)); }
}

#sculpt-tool-toggle { min-height: 44px; padding: 4px 10px; }
#sculpt-tool-toggle[aria-expanded=true] { border-color: var(--shop-accent); }
#sculpt-tool-menu { padding-top: 3px; }
#sculpt-tool-menu[hidden] { display: none; }
.sculpt-mirror-label { display: flex; align-items: center; gap: 6px; min-height: 40px; font-size: .8rem; }

/* ---------- Úprava sítě ---------- */
#mesh-edit-dialog {
  display: none; padding: 0; margin: auto; width: min(100%, 980px); max-width: calc(100% - 20px);
  height: min(94dvh, 900px); max-height: 100dvh; overflow: hidden;
  border: 1px solid var(--shop-border, #233042); background: var(--shop-bg, #0e131b); color: #e6edf6;
}
/* Telefon: hlavička, 3D plocha, lišta nástrojů (vodorovně), parametry. */
#mesh-edit-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: "head" "view" "rail" "ctrl"; }
.mesh-edit-header { grid-area: head; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "cancel title hist apply" "modes modes modes modes"; align-items: center; gap: 8px; }
#mesh-edit-cancel { grid-area: cancel; } .mesh-edit-header h2 { grid-area: title; margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mesh-edit-history { grid-area: hist; } #mesh-edit-apply { grid-area: apply; } .mesh-edit-modes { grid-area: modes; }
.mesh-edit-modes button { flex: 1; } .mesh-edit-modes kbd { display: none; }
html.pc .mesh-edit-header { display: flex; } html.pc .mesh-edit-header h2 { margin-right: auto; } html.pc .mesh-edit-modes button { flex: 0 0 auto; } html.pc .mesh-edit-modes kbd { display: inline; }
.mesh-edit-modes, .mesh-edit-history { display: flex; gap: 4px; }
.mesh-edit-modes button, .mesh-edit-history button { min-height: 34px; padding: 4px 10px; border-radius: 8px; font-size: 13px; }
.mesh-edit-modes button[aria-pressed="true"] { background: #3a2a14; color: #fdba74; border-color: #f97316; }
.mesh-edit-modes kbd, .mesh-edit-rail kbd { font: 10px ui-monospace, monospace; color: #64748b; margin-left: 3px; }
#mesh-edit-viewport { grid-area: view; position: relative; overflow: hidden; min-height: 200px; }
#mesh-edit-viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.mesh-edit-rail { grid-area: rail; display: flex; gap: 4px; overflow-x: auto; padding: 6px 10px; border-top: 1px solid var(--shop-border, #233042); }
.mesh-edit-rail button { display: flex; align-items: center; gap: 5px; min-height: 38px; padding: 4px 10px; font-size: 15px; border-radius: 8px; white-space: nowrap; }
.mesh-edit-rail button span { font-size: 12.5px; }
.mesh-edit-rail kbd { display: none; }
.mesh-edit-rail i { flex: 0 0 1px; background: #243246; margin: 4px 2px; }
.mesh-edit-controls { grid-area: ctrl; display: grid; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--shop-border, #233042); max-height: 34dvh; overflow: auto; }
.mesh-edit-group h3 { display: none; }
.mesh-edit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mesh-edit-row button { min-height: 38px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.mesh-edit-row button[aria-pressed="true"] { background: #133b3a; color: #5eead4; border-color: #2dd4bf; }
.mesh-edit-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #8d9bb0; margin: 0; }
.mesh-edit-inline input { width: 76px !important; min-height: 34px !important; padding: 4px 8px !important; }
#mesh-edit-info { font-size: 12px; }
#mesh-edit-error { margin: 0; }
.mesh-edit-status { display: none; }
.mesh-edit-hud { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 10px;
  background: #0e131bf0; border: 1px solid #f9731688; color: #e2e8f0; font-size: 13px; text-align: center; pointer-events: none; box-shadow: 0 10px 30px #0008; }
.mesh-edit-hud b { color: #fdba74; font-size: 15px; }
.mesh-edit-hud code { color: #5eead4; }
.mesh-edit-hud span { display: block; margin-top: 3px; font-size: 11px; color: #94a3b8; }
/* Transformace myší (G/R/S/E) mají smysl jen s myší; na dotyku zůstávají tlačítka a tažení prstem. */
@media (pointer: coarse) { #mesh-edit-dialog [data-mesh-modal], #mesh-edit-extrude-move { display: none; } }
@media (max-width: 650px) {
  #mesh-edit-dialog { width: 100%; max-width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .mesh-edit-row button { min-height: 40px; padding: 4px 8px; font-size: 12px; }
}
/* PC: jako režim úprav v Blenderu – nástroje vlevo, 3D uprostřed, parametry vpravo, nápověda dole. */
html.pc #mesh-edit-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border: 0; border-radius: 0; }
html.pc #mesh-edit-dialog[open] { grid-template-columns: 84px minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head head head" "rail view ctrl" "stat stat stat"; }
html.pc .mesh-edit-rail { flex-direction: column; overflow: auto; border-top: 0; border-right: 1px solid var(--shop-border, #233042); padding: 8px 6px; gap: 3px; }
html.pc .mesh-edit-rail button { flex-direction: column; gap: 1px; min-height: 54px; padding: 4px 2px; font-size: 18px; position: relative; }
html.pc .mesh-edit-rail button span { font-size: 11px; color: #cbd5e1; }
html.pc .mesh-edit-rail kbd { display: block; position: absolute; right: 4px; top: 3px; margin: 0; }
html.pc .mesh-edit-rail i { flex: 0 0 1px; height: 1px; margin: 5px 6px; }
html.pc .mesh-edit-controls { max-height: none; border-top: 0; border-left: 1px solid var(--shop-border, #233042); align-content: start; gap: 10px; padding: 12px; }
html.pc .mesh-edit-group { background: #121a26; border: 1px solid #1f2b3c; border-radius: 10px; padding: 10px; }
html.pc .mesh-edit-group h3 { display: block; margin: 0 0 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #64748b; }
html.pc .mesh-edit-row button { min-height: 32px; }
html.pc .mesh-edit-inline { width: 100%; justify-content: space-between; }
html.pc .mesh-edit-status { display: block; grid-area: stat; padding: 5px 14px; border-top: 1px solid var(--shop-border, #233042); font-size: 12px; color: #94a3b8; background: #0b1017; }
html.pc .mesh-edit-status b { color: #e2e8f0; }

/* Dialogy s 3D plochou: rozmazané pozadí (backdrop-filter) se při softwarovém GPU přepočítává
   s každým snímkem a tažení pak trhá. Pozadí jen ztmavíme. */
dialog:has(canvas)::backdrop,
#mesh-edit-dialog::backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(5, 8, 14, .88); }
/* Při otevřeném 3D dialogu vypnout všechna rozmazání na stránce za ním (každý snímek by je překresloval). */
html:has(dialog[open]:has(canvas)) * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
