.scheme-full-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
}

.scheme-top-bar {
  min-height: 60px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.scheme-back-circle {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.scheme-back-circle:active {
  background: var(--surface-active);
}

.scheme-top-titles {
  min-width: 0;
  flex: 1;
}
.scheme-top-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.scheme-top-sub {
  font-size: 17px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scheme-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(156px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scheme-types-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Длинные названия типов не рвём посреди слова: кнопки переносятся целиком */
.scheme-types-grid .scheme-type-btn {
  flex: 1 1 150px;
}

.scheme-type-btn {
  min-height: 48px;
  padding: 6px 6px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.15;
  word-break: break-word;
  font-family: inherit;
}
.scheme-type-btn.active {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--accent-on);
  font-weight: 700;
}

.scheme-canvas-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scheme-canvas-caption {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
}

.scheme-svg-slot {
  position: relative;
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scheme-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scheme-slope-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scheme-mode-btn {
  min-height: 48px;
  padding: 6px 10px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.scheme-mode-btn.active {
  background: var(--sec-bg-tint);
  border-color: var(--sec-color);
  color: var(--sec-color);
  font-weight: 700;
}

.scheme-error-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--danger);
}

.scheme-hint-empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  padding: 16px;
  text-align: center;
  font-size: 17px;
  color: var(--text-muted);
}

.scheme-res-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scheme-res-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.scheme-res-card.main {
  border-color: var(--sec-border);
  background: var(--sec-bg-tint);
}
.scheme-res-lbl {
  font-size: 17px;
  color: var(--text-muted);
}
.scheme-res-val {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.scheme-res-card.main .scheme-res-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--sec-color);
}

.scheme-extra-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
}
.scheme-extra-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 17px;
  gap: 8px;
}
.scheme-extra-row:last-child {
  border-bottom: none;
}

.scheme-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10003;
}
.scheme-disclaimer {
  font-size: 17px;
  color: var(--text-muted);
  text-align: center;
}
.scheme-bottom-btns {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
}
.scheme-apply-btn {
  min-height: 54px;
  height: 54px;
}

.scheme-shapes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scheme-op-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scheme-op-add-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scheme-op-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scheme-op-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-input);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.scheme-op-item.is-selected {
  border: 1.5px solid var(--sec-color);
  background: var(--sec-bg-tint);
}

.scheme-op-walls-block {
  width: 100%;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scheme-op-walls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scheme-wall-chip {
  min-height: 48px;
  padding: 6px 12px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.scheme-wall-chip.active {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--accent-on);
  font-weight: 700;
}

.scheme-op-type-title {
  width: 100%;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.scheme-op-field {
  flex: 1;
  min-width: 72px;
}

.scheme-op-del-btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.scheme-op-del-btn:active {
  background: var(--danger-bg);
}

.scheme-target-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scheme-target-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: inherit;
}
.scheme-target-btn.active {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--accent-on);
  font-weight: 700;
}

/* Проём перетаскивается пальцем: прокрутку на нём отключаем заранее */
.scheme-opening {
  touch-action: none;
  cursor: grab;
}

/* Этап 3F-1: переключатель «2D | 3D» и объёмный макет */
.scheme-view-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.scheme-canvas-card.is-3d .scheme-2d-only {
  display: none;
}
.scheme-svg-slot[hidden],
.scheme-3d-box[hidden] {
  display: none;
}
.scheme-3d-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scheme-3d-slot {
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.scheme-3d-slot svg {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.scheme-3d-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.scheme-3d-rot-btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.scheme-3d-rot-btn:active {
  background: var(--surface-2);
}
.scheme-3d-hint {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  line-height: 1.3;
  color: var(--text-muted);
  text-align: center;
}

/* Редактор помещения на весь экран */
.scheme-editor-open-btn {
  width: 100%;
  min-height: 48px;
  font-size: 17px;
}
.scheme-editor {
  position: fixed;
  inset: 0;
  z-index: 10020;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.scheme-editor-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.scheme-editor-title {
  flex: 1;
  min-width: 0;
  font-size: 19px;
  font-weight: 700;
}
.scheme-editor-icon-btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.scheme-editor-icon-btn:active {
  background: var(--surface-2);
}
.scheme-editor-modes {
  display: flex;
  gap: 6px;
}
.scheme-editor-mode {
  min-width: 56px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.scheme-editor-mode.active {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--accent-on);
}
.scheme-editor-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.scheme-editor-canvas {
  width: 100%;
  transform-origin: center center;
  will-change: transform;
}
.scheme-editor-canvas svg {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.scheme-editor-zoom {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scheme-editor-tip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  font-size: 17px;
  line-height: 1.3;
  color: var(--text-muted);
  pointer-events: none;
}
.scheme-editor-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scheme-editor-panel[hidden] {
  display: none;
}
.scheme-editor-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.scheme-editor-panel-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
}
.scheme-editor-del {
  color: var(--danger);
  border-color: var(--danger);
}
.scheme-editor-del-btn {
  min-height: 48px;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--danger);
  background: var(--surface);
  color: var(--danger);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.scheme-editor-del-btn:active {
  background: var(--danger-bg);
}
.scheme-editor-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.scheme-editor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 17px;
  color: var(--text-muted);
  min-width: 0;
}
.scheme-editor-field span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scheme-editor-field .form-control {
  min-height: 48px;
  font-size: 17px;
  padding-left: 10px;
  padding-right: 10px;
}
.scheme-editor-walls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.scheme-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.scheme-editor-tool {
  flex: 1;
  min-width: 0;
  min-height: 54px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.scheme-editor-tool:active {
  background: var(--surface-2);
}
.scheme-editor-done {
  flex: 1.2;
  min-height: 54px;
  font-size: 17px;
}
.scheme-editor-fields-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Слой «Потолок» в редакторе помещения */
.scheme-editor-layers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 12px 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.scheme-editor-layer {
  min-height: 48px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.scheme-editor-layer.active {
  background: var(--accent-tint, var(--surface-2));
  border-color: var(--accent-fill);
  color: var(--accent-ink, var(--text));
  font-weight: 700;
}
.scheme-editor-layers + .scheme-editor-toolbar,
.scheme-editor-layers ~ .scheme-editor-toolbar {
  border-top: 0;
}
.scheme-editor-toolbar[hidden] {
  display: none;
}
.scheme-editor-toolbar-wrap {
  flex-wrap: wrap;
}
.scheme-editor-toolbar-wrap .scheme-editor-tool {
  flex: 1 1 40%;
}
.scheme-editor-toolbar-wrap .scheme-editor-done {
  flex: 1 1 100%;
}
.scheme-editor-fields-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.scheme-editor-dup {
  width: 100%;
  min-height: 48px;
  font-size: 17px;
}
.scheme-editor-niche-hint {
  font-size: 17px;
  color: var(--text-muted);
  line-height: 1.3;
}
.scheme-ceiling-summary {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scheme-ceiling-summary-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.scheme-ceiling-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 17px;
  color: var(--text-muted);
}
.scheme-ceiling-summary-row b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Комплектующие кровли в калькуляторе крыши */
.rs-parts-card {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rs-parts-title { font-family: var(--font-head); font-size: 19px; font-weight: 800; color: var(--text); }
.rs-parts-sub { font-size: 15px; color: var(--text-muted); }
.rs-parts-card .form-label { margin-top: 4px; }
.rs-parts-list { display: flex; flex-direction: column; }
.rs-parts-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 17px;
  color: var(--text);
}
.rs-parts-row:first-child { border-top: none; }
.rs-parts-row b { white-space: nowrap; font-weight: 700; }
.rs-parts-empty { font-size: 16px; color: var(--text-muted); padding: 6px 0; }
.rs-parts-btn { width: 100%; min-height: 52px; margin-top: 4px; }

/* Подпись «Пример», пока размеры дома не введены */
.rs-example-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--copper-tint);
  border: 1px solid var(--tile-ring);
  color: var(--copper-ink);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}

/* Плашка «Вид крыши»: выбранный вид с рисунком, по нажатию — сетка карточек */
.rk-pick {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}
.rk-head {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  text-align: left;
  cursor: pointer;
}
.rk-head-icon { flex-shrink: 0; display: inline-flex; }
.rk-head-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rk-head-label { font-size: 14px; color: var(--text-muted); }
.rk-head-name { font-family: var(--font-head); font-size: 19px; font-weight: 800; }
.rk-head-chev { flex-shrink: 0; color: var(--text-muted); display: inline-flex; transition: transform 0.2s ease; }
.rk-pick.is-open .rk-head-chev { transform: rotate(180deg); }
.rk-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px 10px 12px;
  border-top: 1px solid var(--border);
}
.rk-grid[hidden] { display: none; }
.rk-card {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}
.rk-card svg { width: 56px; height: 46px; }
.rk-card.active { border-color: var(--copper); background: var(--copper-tint); font-weight: 800; }
.rk-card:active { transform: scale(0.97); }
.rk-extras { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rk-extras .form-label { margin-top: 0; }
.rk-hint { margin-top: 4px; font-size: 14px; color: var(--text-muted); }
.rk-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--copper-tint);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}
