/* ============================================================
   ТОПДОМ — конструктор дома
   ============================================================ */
.cfg { margin-top: var(--hdr); display: grid; grid-template-columns: minmax(0, 1fr) 430px; height: calc(100svh - var(--hdr)); min-height: 600px; border-bottom: 1px solid var(--line); }

/* ---------- сцена ---------- */
.cfg__stage { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 100%); isolation: isolate; }
.cfg__canvas { position: absolute; inset: 0; z-index: 1; cursor: grab; }
.cfg__canvas:active { cursor: grabbing; }
.cfg__stage.is-top .cfg__canvas { cursor: default; }
.cfg__canvas canvas { display: block; width: 100% !important; height: 100% !important; opacity: 0; transition: opacity 1s var(--ease); }
.cfg__stage.is-ready .cfg__canvas canvas { opacity: 1; }

/* фото комнаты за полупрозрачным домом */
.cfg-photo { position: absolute; inset: 0; z-index: 0; opacity: 0; transition: opacity .55s var(--ease); background: var(--dark); }
.cfg-photo.is-on { opacity: 1; }
.cfg-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.08); transition: opacity .6s var(--ease), transform 7s var(--ease); }
.cfg-photo img.is-on { opacity: 1; transform: scale(1); }
.cfg-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.05) 40%, rgba(0,0,0,.35)); }

/* подписи комнат */
.cfg-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.rl { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; padding: 5px 10px 6px; border-radius: 12px; background: rgba(255, 255, 255, .9); color: var(--ink); box-shadow: 0 4px 18px rgba(0, 0, 0, .08); opacity: 0; transition: opacity .45s var(--ease), background .3s, color .3s; line-height: 1.15; }
.rl b { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: -.01em; }
.rl span { display: block; font-size: 11.5px; color: var(--ink-2); margin-top: 1px; transition: color .3s; }
.rl.is-tight { padding: 3px 7px 4px; border-radius: 9px; }
.rl.is-tight b { font-size: 10.5px; }
.rl.is-tight span { font-size: 10px; }
.rl.is-tiny b { display: none; }
.cfg__stage.is-top .rl { opacity: 1; transition-delay: .55s; }
.cfg__stage.is-top.is-hovering .rl { transition-delay: 0s; opacity: .28; }
.cfg__stage.is-top.is-hovering .rl.is-hot { opacity: 1; background: var(--acc); color: #fff; box-shadow: 0 8px 26px rgba(0,0,0,.25); }
.rl.is-hot span { color: rgba(255,255,255,.85); }
.rl.is-hot b { display: block; }

/* оверлеи */
.cfg-ov { position: absolute; z-index: 4; }
.cfg-ov--tl { top: 18px; left: 18px; }
.cfg-ov--tr { top: 18px; right: 18px; }
.cfg-ov--bl { left: 24px; bottom: 22px; pointer-events: none; transition: opacity .4s, transform .5s var(--ease); }
.cfg__stage.is-hovering .cfg-ov--bl { opacity: 0; transform: translateY(10px); }
.cfg-title .kicker, .cfg-title h1 { transition: opacity .4s; }
.cfg__stage.is-top .cfg-title .kicker, .cfg__stage.is-top .cfg-title h1 { display: none; }
.cfg__stage.is-top .cfg-title .cfg-big b { font-size: clamp(30px, 2.6vw, 44px); }
.cfg-ov--tl .seg { background: rgba(255,255,255,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.cfg-ov--tl .seg button { height: 44px; padding: 0 20px; display: inline-flex; align-items: center; gap: 8px; }
.cfg-ov--tl .seg svg { width: 18px; height: 18px; }
.cfg-hint { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; background: rgba(255,255,255,.82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.cfg-hint i { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); animation: hintPulse 1.8s ease-in-out infinite; }
@keyframes hintPulse { 50% { transform: scale(1.6); opacity: .5; } }
.cfg-hint .h-top { display: none; }
.cfg__stage.is-top .cfg-hint .h-top { display: inline; }
.cfg__stage.is-top .cfg-hint .h-side { display: none; }
.cfg__stage.is-hovering .cfg-hint { opacity: 0; }
.cfg-title .kicker { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.cfg-title h1 { font-size: clamp(28px, 3vw, 46px); font-weight: 300; letter-spacing: -.04em; line-height: 1.05; margin-top: 4px; }
.cfg-title .cfg-big { display: flex; align-items: baseline; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.cfg-title .cfg-big b { font-size: clamp(40px, 4.6vw, 76px); font-weight: 200; letter-spacing: -.05em; line-height: 1; color: var(--acc-t); }
html:not(.g1):not(.gp) .cfg-title .cfg-big b { color: var(--ink); }
.cfg-title .cfg-big span { font-size: 14px; color: var(--ink-2); font-weight: 500; }

/* подпись фото комнаты */
.cfg-cap { position: absolute; z-index: 5; left: 20px; bottom: 20px; max-width: min(440px, calc(100% - 40px)); padding: 16px 52px 16px 20px; border-radius: 18px; background: #fff; color: var(--ink); box-shadow: 0 16px 50px rgba(0,0,0,.25); opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .4s var(--ease), transform .5s var(--ease); }
.cfg__stage.is-hovering .cfg-cap { opacity: 1; transform: none; pointer-events: auto; }
.cfg-cap b { display: block; font-size: 20px; font-weight: 400; letter-spacing: -.02em; }
.cfg-cap span { display: block; font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.cfg-cap button { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; background: var(--paper); font-size: 20px; line-height: 1; display: grid; place-items: center; }
@media (hover: hover) and (pointer: fine) { .cfg-cap button { display: none; } .cfg-cap { padding-right: 20px; } }

.cfg__stage.no-webgl .cfg__canvas { display: grid; place-items: center; }
.cfg-fallback { width: min(640px, 90%); color: var(--ink); text-align: center; }
.cfg-fallback svg { width: 100%; height: auto; }
.cfg-fallback p { margin-top: 12px; color: var(--ink-3); font-size: 14px; }

/* ---------- панель ---------- */
.cfg__panel { background: #fff; border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; padding: 22px 26px 28px; display: flex; flex-direction: column; gap: 22px; scrollbar-width: thin; }
.cfg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cfg-head .kicker { color: var(--ink-3); font-size: 13px; font-weight: 500; }
.cfg-head h2 { font-size: 30px; font-weight: 300; letter-spacing: -.04em; line-height: 1.05; margin-top: 2px; }
.cfg-src { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.cfg-chip { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--acc-l); color: var(--acc-t); font-size: 12.5px; font-weight: 600; }
html:not(.g1):not(.gp) .cfg-chip { color: var(--ink); }
.cfg-stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); margin: 0; }
.cfg-stats div { padding: 12px 10px 12px 0; }
.cfg-stats div + div { padding-left: 10px; border-left: 1px solid var(--line); }
.cfg-stats dt { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.cfg-stats dd { margin: 2px 0 0; font-size: 30px; font-weight: 200; letter-spacing: -.04em; line-height: 1; }
.is-pulse { animation: pulse .6s var(--ease); }
@keyframes pulse { 30% { transform: scale(1.08); color: var(--acc-t); } }
.cfg-block { display: grid; gap: 10px; }
.cfg-lab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 600; font-size: 14px; }
.cfg-lab span { font-weight: 400; font-size: 12.5px; color: var(--ink-3); }
.cfg-lab output { font-weight: 300; font-size: 22px; letter-spacing: -.03em; }
.cfg-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
#floorNote.is-pulse { animation: noteFlash .9s var(--ease); }
@keyframes noteFlash { 30% { color: var(--acc-t); transform: translateX(4px); } }
#bedTabs button { font-size: 16px; font-weight: 600; }

/* площадь с отсечками */
.area { position: relative; padding: 14px 0 26px; }
.area input[type="range"] { position: relative; z-index: 2; display: block; height: 4px; background: linear-gradient(90deg, var(--acc) var(--p, 0%), var(--line) var(--p, 0%)); }
.area input[type="range"]::-webkit-slider-thumb { background: var(--acc); }
.area input[type="range"]::-moz-range-thumb { background: var(--acc); }
.area__ticks { position: absolute; left: 12px; right: 12px; top: 0; bottom: 0; }
.tick { position: absolute; top: 3px; width: 2px; height: 8px; margin-left: -1px; border-radius: 2px; background: var(--line); }
.tick.is-on { background: var(--ink-3); height: 10px; top: 2px; }
.tick.is-cur { background: var(--acc); }
.tick-lab { position: absolute; bottom: 0; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 2px 4px; border-radius: 6px; transition: color .2s, background .2s; }
.tick-lab:hover { color: var(--ink); background: var(--paper); }
.tick-lab.is-cur { color: var(--acc-t); }
html:not(.g1):not(.gp) .tick-lab.is-cur { color: var(--ink); }
#areaWrap.is-blocked { animation: shake .45s; }
#areaWrap.is-blocked .cfg-note { color: var(--acc-t); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* образцы цвета */
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.swatches--sm { grid-template-columns: repeat(3, 1fr); }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 14px; border: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--ink-2); transition: border-color .25s, background .25s, transform .3s var(--ease); }
.swatch i { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); position: relative; overflow: hidden; }
.swatch i::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 5px, rgba(255,255,255,.28) 5px 6px); }
.swatches--sm .swatch i::after { background: repeating-linear-gradient(0deg, transparent 0 6px, rgba(0,0,0,.25) 6px 7px); }
.swatch:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.swatch.is-active { border-color: var(--acc); background: var(--acc-l); color: var(--ink); box-shadow: inset 0 0 0 1px var(--acc); }

/* переключатель */
.cfg-switch { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 14px; cursor: pointer; user-select: none; }
.cfg-switch input { position: absolute; opacity: 0; pointer-events: none; }
.cfg-switch span { width: 46px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background .25s; flex: none; }
.cfg-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: transform .3s var(--ease); }
.cfg-switch input:checked + span { background: var(--acc); }
.cfg-switch input:checked + span::after { transform: translateX(20px); }
.cfg-switch input:focus-visible + span { outline: 2px solid var(--acc); outline-offset: 2px; }
.cfg-switch small { font-weight: 400; color: var(--ink-3); margin-left: auto; font-size: 12.5px; }

/* экспликация */
.rooms { display: grid; gap: 0; border-top: 1px solid var(--line); }
.rooms li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; border-radius: 8px; transition: background .2s, padding .3s var(--ease); }
.rooms li b { font-weight: 500; font-variant-numeric: tabular-nums; }
.rooms li:hover, .rooms li.is-hot { background: var(--acc-l); padding-left: 12px; }
.rooms li:focus-visible { outline: 2px solid var(--acc); }
.sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); }
.sw--kitchen { background: var(--pl-k); } .sw--bed, .sw--office { background: var(--pl-b); } .sw--bath { background: var(--pl-w); }
.sw--boiler, .sw--pantry, .sw--wardrobe { background: var(--pl-t); } .sw--hall, .sw--entry { background: var(--pl-h); }

.cfg-price { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 16px 18px; border-radius: 16px; background: var(--paper); font-size: 14px; }
.cfg-price span { color: var(--ink-2); }
.cfg-price b { font-weight: 500; text-align: right; }
.cfg-price::before { content: "Ориентировочная стоимость"; grid-column: 1 / -1; font-size: 12px; color: var(--ink-3); font-weight: 600; margin-bottom: 2px; }
.cfg-actions { display: grid; gap: 8px; margin-top: auto; }
.cfg-actions .btn { justify-content: space-between; width: 100%; }
.cfg-actions .btn--acc .btn__ic { background: #fff; color: var(--acc); }

/* ---------- все планировки ---------- */
.pg-row { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 26px 0; border-top: 1px solid var(--line); }
.pg-row:first-child { border-top: 1px solid var(--ink); }
.pg-row__h b { display: block; font-size: clamp(24px, 2.4vw, 36px); font-weight: 300; letter-spacing: -.035em; }
.pg-row__h span { font-size: 14px; color: var(--ink-3); }
.pg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pg-card { text-align: left; border-radius: var(--r-md); background: var(--paper); padding: 14px; display: flex; flex-direction: column; gap: 12px; transition: background .3s, box-shadow .3s, transform .4s var(--ease); color: var(--ink); }
.pg-card:hover { background: #fff; box-shadow: 0 16px 40px rgba(0,0,0,.08); transform: translateY(-3px); }
.pg-card.is-cur { background: #fff; box-shadow: inset 0 0 0 2px var(--acc); }
.pg-card__svg { aspect-ratio: 4 / 3; display: grid; place-items: center; color: #2a2a2a; }
.pg-card__svg svg { max-width: 100%; max-height: 100%; width: 100%; height: 100%; }
.pg-card__b b { display: block; font-size: 18px; font-weight: 500; letter-spacing: -.02em; }
.pg-card__b span { display: block; font-size: 14px; color: var(--ink-2); }
.pg-card__b small { display: block; font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* как это работает */
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.how__i { border-radius: var(--r-lg); background: #fff; padding: 26px; min-height: 230px; display: flex; flex-direction: column; transition: transform .4s var(--ease), box-shadow .3s; }
.how__i:hover { transform: translateY(-4px); box-shadow: 0 18px 44px rgba(0,0,0,.07); }
.how__i em { font-style: normal; font-size: 64px; font-weight: 200; letter-spacing: -.05em; line-height: 1; color: var(--acc-t); }
html:not(.g1):not(.gp) .how__i em { color: var(--ink); }
.how__i b { display: block; margin-top: auto; font-size: 20px; font-weight: 500; letter-spacing: -.02em; }
.how__i p { color: var(--ink-2); font-size: 14.5px; margin-top: 6px; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .cfg { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .cfg__stage { height: min(68svh, 640px); min-height: 420px; }
  .cfg__panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 22px var(--gutter) 30px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .cfg-head, .cfg-stats, .cfg-actions { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .cfg__panel { grid-template-columns: 1fr; }
  .cfg__stage { height: 64svh; min-height: 380px; }
  .cfg-ov--tl { top: 12px; left: 12px; right: 12px; }
  .cfg-ov--tl .seg { display: flex; }
  .cfg-ov--tl .seg button { flex: 1; justify-content: center; height: 42px; padding: 0 10px; font-size: 13.5px; }
  .cfg-ov--tr { top: 66px; right: auto; left: 12px; }
  .cfg-hint { height: 32px; font-size: 12px; padding: 0 12px; }
  .cfg-ov--bl { left: 14px; bottom: 12px; }
  .cfg-title h1 { display: none; }
  .cfg-title .cfg-big b { font-size: 40px; }
  .cfg-cap { left: 10px; right: 10px; bottom: 10px; max-width: none; padding: 12px 48px 12px 14px; }
  .cfg-cap b { font-size: 17px; }
  .cfg-cap span { font-size: 13px; }
  .cfg-stats dd { font-size: 26px; }
  .swatches { grid-template-columns: repeat(4, 1fr); }
  .pg-row { grid-template-columns: 1fr; gap: 12px; }
  .pg-list { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .pg-card { padding: 10px; }
  .pg-card__b b { font-size: 15px; }
  .pg-card__b span { font-size: 12.5px; }
  .pg-card__b small { display: none; }
  .how { grid-template-columns: 1fr; }
  .how__i { min-height: 0; }
  .how__i b { margin-top: 18px; }
}

/* ---------- загрузка 3D: пока скачивается модель, видно аккуратный индикатор ---------- */
.cfg__stage::after { content: "Строим 3D-модель дома…"; position: absolute; left: 50%; top: 50%; z-index: 3; transform: translate(-50%, -50%); padding: 14px 22px 14px 48px; border-radius: 999px; background: rgba(255,255,255,.9); font-size: 14px; font-weight: 500; color: var(--ink-2); box-shadow: 0 8px 30px rgba(0,0,0,.08); pointer-events: none; transition: opacity .5s; background-image: radial-gradient(circle at 26px 50%, var(--acc) 5px, transparent 6px); animation: cfgLoad 1.2s ease-in-out infinite; }
.cfg__stage.is-ready::after { opacity: 0; animation: none; }
@keyframes cfgLoad { 50% { background-size: 160% 160%; color: var(--ink); } }

/* телефон: кнопка «вернуться к дому», пока модель прокручена вверх */
.cfg-back { display: none; }
@media (max-width: 1100px) {
  .cfg-back { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 90; display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 20px 0 14px; border-radius: 999px; background: var(--acc); color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.25); transform: translate(-50%, 90px); opacity: 0; transition: transform .45s var(--ease), opacity .3s; pointer-events: none; white-space: nowrap; }
  .cfg-back svg { width: 18px; height: 18px; }
  .cfg-back.is-on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
  .cfg-back.is-on.is-pulse { animation: backPulse .6s var(--ease); }
}
@keyframes backPulse { 40% { transform: translate(-50%, 0) scale(1.08); } }

/* ---------- v2: читаемость текста слева снизу, телефон — панель сверху не перекрывает дом ---------- */
.cfg__stage .cfg-grad { position: absolute; left: 0; bottom: 0; z-index: 3; width: min(78%, 640px); height: 62%; pointer-events: none; background: radial-gradient(120% 100% at 0% 100%, rgba(255,255,255,.92) 0%, rgba(255,255,255,.7) 32%, rgba(255,255,255,0) 70%); transition: opacity .4s; }
.cfg__stage.is-hovering .cfg-grad { opacity: 0; }
.cfg-hint .h-tap { display: none; }
@media (hover: none) { .cfg-hint .h-top { display: none !important; } .cfg__stage.is-top .cfg-hint .h-tap { display: inline; } }
@media (max-width: 760px) {
  .cfg__canvas, .cfg-labels { top: 112px; bottom: 66px; }
  .cfg-ov--tl, .cfg-ov--tr { z-index: 6; }
  .cfg-ov--tr { left: 12px; right: 12px; }
  .cfg-hint { width: 100%; justify-content: center; }
  .cfg__stage .cfg-grad { width: 100%; height: 110px; background: linear-gradient(0deg, rgba(255,255,255,.85), rgba(255,255,255,0)); }
  .cfg-cap { pointer-events: none; }
  .cfg__stage.is-hovering .cfg-cap { pointer-events: auto; }
}
