:root {
  --bg-top: #dfe9f2;
  --bg-bottom: #f4f1ea;
  --ink: #1d2327;
  --ink-2: #5b6570;
  --line: rgba(29, 35, 39, 0.1);
  --glass: rgba(255, 255, 255, 0.86);
  --accent: #2F6FB2;          /* терракота фасада, RAL 2010 */
  --accent-ink: #ffffff;
  --free: #2e9e5b;
  --installment: #2f7fd8;
  --reserved: #e0a030;
  --sold: #c0463a;
  --unavailable: #9aa0a6;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(20, 30, 40, 0.14);
  --panel-w: 340px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; touch-action: none; }

/* ---------- загрузка ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  transition: opacity .5s;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-box { width: min(320px, 80vw); text-align: center; }
.loader-title { font-weight: 800; font-size: 22px; margin-bottom: 18px; }
.loader-bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.loader-text { margin-top: 12px; font-size: 13px; color: var(--ink-2); }

/* ---------- шапка и режимы ---------- */
.brand {
  position: fixed; top: 20px; left: 24px; z-index: 5; pointer-events: none;
  text-shadow: 0 1px 12px rgba(255, 255, 255, 0.8);
}
.brand-name { font-weight: 800; font-size: 24px; letter-spacing: -0.01em; }
.brand-sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

.modebar {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 4px; padding: 4px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.mode {
  border: 0; background: transparent; padding: 9px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; color: var(--ink-2);
}
.mode.active { background: var(--ink); color: #fff; }

/* ---------- панель ---------- */
.panel {
  position: fixed; top: 20px; right: 20px; bottom: 20px; width: var(--panel-w); z-index: 5;
  background: var(--glass); backdrop-filter: blur(14px); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.panel-handle { display: none; }
.panel-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.block { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.block-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 10px; }
.count { color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; padding: 6px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 6px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.floors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.floor-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 0;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.floor-btn b { font-size: 16px; }
.floor-btn small { font-size: 11px; color: var(--ink-2); }
.floor-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.floor-btn.active small { color: rgba(255, 255, 255, .85); }

.list-block { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 0; }
.list { overflow-y: auto; margin: 0 -8px; padding: 0 8px; flex: 1; }
.row {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 8px; border-radius: 10px;
}
.row:hover, .row.hover { background: rgba(200, 100, 60, 0.09); }
.row-num { font-weight: 800; font-size: 15px; }
.row-main { font-size: 13px; }
.row-main small { display: block; color: var(--ink-2); font-size: 12px; }
.row-price { font-size: 12px; font-weight: 700; text-align: right; }
.row-price .dot { margin-left: 6px; vertical-align: middle; }
.empty { color: var(--ink-2); font-size: 14px; padding: 12px 0; }

.hint {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(calc(-50% - var(--panel-w) / 2)); z-index: 4;
  background: var(--glass); backdrop-filter: blur(10px); padding: 9px 16px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2); box-shadow: var(--shadow); transition: opacity .4s;
  white-space: nowrap;
}
.hint.hide { opacity: 0; }

.fly-badge {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(calc(-50% - var(--panel-w) / 2)); z-index: 4;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center;
  background: rgba(29, 35, 39, 0.88); color: #fff; backdrop-filter: blur(10px);
  padding: 9px 16px; border-radius: 999px; font-size: 12px; box-shadow: var(--shadow);
}
.fly-badge[hidden] { display: none; }
.fly-badge b { color: #f2a37c; }
.fly-badge kbd {
  display: inline-block; min-width: 18px; padding: 1px 5px; margin-right: 3px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.25);
  font: 600 11px/1.4 "Manrope", system-ui, sans-serif; text-align: center;
}

/* ---------- подсказка ---------- */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; min-width: 190px;
  background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.45; transform: translate(16px, 16px);
}
.tooltip .t-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.tooltip .t-num { font-weight: 800; font-size: 16px; }
.tooltip .t-status { font-weight: 700; font-size: 12px; }
.tooltip .t-main { font-weight: 700; font-size: 15px; margin: 4px 0 2px; }
.tooltip .t-sub { color: var(--ink-2); }
.tooltip .t-cta { margin-top: 6px; font-size: 12px; color: var(--accent); font-weight: 700; }

/* ---------- карточка ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 26, 30, 0.45); backdrop-filter: blur(3px); }
.card {
  position: relative; width: min(1120px, 100%); height: min(720px, calc(100vh - 48px));
  background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr);
}
.card-close {
  position: absolute; top: 12px; right: 12px; z-index: 3; width: 38px; height: 38px;
  border-radius: 50%; border: 0; background: #f1f2f3; font-size: 24px; line-height: 1;
}
.gallery { background: #f6f6f4; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.gallery-main { position: relative; min-height: 0; overflow: hidden; }
.gallery-main img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-main.photo img { width: 100%; height: 100%; object-fit: cover; }
.gallery-main.plan { background: #fff; }
.gallery-main.plan img { inset: 20px 56px 44px; width: calc(100% - 112px); height: calc(100% - 64px); }
.g-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow); font-size: 26px; line-height: 1;
}
.g-nav.prev { left: 12px; } .g-nav.next { right: 12px; }
.g-caption {
  position: absolute; left: 12px; bottom: 12px; background: rgba(255, 255, 255, .92);
  padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
}
.gallery-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; background: #fff; border-top: 1px solid var(--line); }
.gallery-thumbs button {
  flex: 0 0 auto; width: 76px; height: 56px; border-radius: 8px; border: 2px solid transparent;
  padding: 0; overflow: hidden; background: #f3f3f3;
}
.gallery-thumbs button.active { border-color: var(--accent); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs .plan-thumb img { object-fit: contain; background: #fff; }

.info { padding: 32px 30px 28px; overflow-y: auto; }
.info-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.info h2 { margin: 10px 0 4px; font-size: 30px; letter-spacing: -0.02em; line-height: 1.1; }
.info-price { font-size: 20px; font-weight: 700; color: var(--accent); margin-bottom: 18px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 0 0 18px; }
.info-grid div { border-top: 1px solid var(--line); padding-top: 8px; }
.info-grid dt { font-size: 12px; color: var(--ink-2); }
.info-grid dd { margin: 2px 0 0; font-weight: 700; font-size: 16px; }
.info-note { font-size: 12px; color: var(--ink-2); margin-bottom: 18px; line-height: 1.5; }
.info-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 18px;
  font-weight: 700; font-size: 14px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- телефон ---------- */
@media (max-width: 820px) {
  :root { --panel-w: 0px; }
  .brand { top: 14px; left: 16px; }
  .brand-name { font-size: 19px; }
  .modebar { top: auto; bottom: calc(52vh + 12px); left: 16px; transform: none; }
  .mode { padding: 8px 13px; font-size: 13px; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 52vh; border-radius: 18px 18px 0 0; transition: height .3s; }
  .panel.collapsed { height: 64px; }
  body.panel-collapsed .modebar { bottom: 76px; }
  .panel-handle { display: block; border: 0; background: transparent; padding: 10px 0 4px; width: 100%; }
  .panel-handle span { display: block; width: 40px; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, .2); margin: 0 auto; }
  .block { padding: 12px 16px; }
  .hint, .fly-badge { display: none; }
  .modal { padding: 0; }
  .card { grid-template-columns: 1fr; height: 100%; border-radius: 0; overflow-y: auto; display: block; }
  .gallery { display: block; }
  .gallery-main { height: 46vh; }
  .gallery-main.plan img { inset: 12px 44px 40px; width: calc(100% - 88px); height: calc(100% - 52px); }
  .info { padding: 22px 18px 32px; overflow: visible; }
  .info h2 { font-size: 24px; }
}

/* embed on the REVION site: only the house and the hover tooltip */
html.embed body { background: transparent; }
html.embed .brand, html.embed .modebar, html.embed #panel, html.embed #hint, html.embed #fly-badge, html.embed .tooltip .t-cta { display: none !important; }
html.embed #loader { background: #0B1728; }
html.embed #loader .loader-title { color: #F5F7FA; }
