/* мобильная адаптация: core — правки только для узких экранов (@media max-width) */
/* зона: шапка, #tabs/#subtabs, «Обзор», «Дом → Рендеры», лайтбокс */

/* ---------- сводка настроек и лист «Настройки сметы» — на всех ширинах (на десктопе лист — правая панель) ---------- */
.m-sum {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px 0 14px;
  border: 1px solid var(--rule2); border-radius: 12px; background: var(--paper); color: var(--ink); text-align: left;
  box-shadow: 0 1px 0 rgba(22,20,15,.03);
}
.m-sum[hidden] { display: none; }
.m-sum:active { background: var(--bg2); }
.m-sum-l { display: none; }
.m-sum-t { flex: 1; min-width: 0; padding: 6px 0; font-size: 14px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.m-chev { flex: none; width: 20px; height: 20px; color: var(--ink3); }

/* ---------- нижний лист ---------- */
html.m-lock, html.m-lock body { overflow: hidden; }
.m-sheet { position: fixed; inset: 0; z-index: 70; }
.m-sheet[hidden] { display: none; }
.m-sheet-bg { position: absolute; inset: 0; background: rgba(22,20,15,.42); opacity: 0; transition: opacity .25s ease; }
.m-sheet.open .m-sheet-bg { opacity: 1; }
.m-sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; background: var(--bg); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(22,20,15,.18);
  transform: translateY(102%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.m-sheet.open .m-sheet-panel { transform: translateY(0); }
.m-sheet-panel.drag { transition: none; }
.m-sheet-head { flex: none; padding: 8px var(--pad) 10px; touch-action: none; cursor: grab; border-bottom: 1px solid var(--rule); }
.m-grip { display: block; width: 40px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: var(--rule2); }
.m-sheet-head h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.1; letter-spacing: -.2px; }
.m-sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px var(--pad) 8px; }
.m-sheet-foot { flex: none; padding: 10px var(--pad) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: var(--bg); }
.m-done { width: 100%; min-height: 50px; border: 0; border-radius: 14px; background: var(--ink); color: var(--paper); font-size: 16px; font-weight: 500; }
.m-done:active { background: var(--ink2); }

/* группы настроек: варианты вертикально, во всю ширину */
.m-grp { padding: 16px 0 6px; }
.m-grp + .m-grp { border-top: 1px solid var(--rule); }
.m-grp[hidden] { display: none; }
.m-grp h3 { margin: 0 0 10px; font-size: 11.5px; font-weight: 500; letter-spacing: .7px; text-transform: uppercase; color: var(--ink3); }
.m-hint { margin: 8px 2px 4px; font-size: 13px; line-height: 1.45; color: var(--ink3); }
.m-hint[hidden], .m-hint:empty { display: none; }
.m-sheet .seg { display: flex !important; flex-direction: column; align-items: stretch; gap: 6px; padding: 0; background: none; box-shadow: none; border-radius: 0; }
.m-sheet .seg button, .m-list button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px;
  padding: 10px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper);
  color: var(--ink); font-size: 16px; font-weight: 400; line-height: 1.3; text-align: left; white-space: normal;
}
.m-sheet .seg button::after, .m-list button::after { content: ''; flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--rule2); }
.m-sheet .seg button.on, .m-sheet .seg.small button.on, .m-list button.on { background: var(--paper); color: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 500; }
.m-sheet .seg button.on::after, .m-list button.on::after { box-shadow: inset 0 0 0 6px var(--acc); }
.m-sheet .seg button[disabled] { opacity: .4; }
.m-sheet #crew .seg-l { display: none; }
.m-sheet .chk {
  display: flex; width: 100%; min-height: 52px; padding: 0 16px; justify-content: space-between; flex-direction: row-reverse;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); font-size: 16px; color: var(--ink);
}
.m-sheet .chk input { width: 44px; height: 26px; }
.m-sheet .chk input::after { width: 22px; height: 22px; }
.m-sheet .chk input:checked::after { transform: translateX(18px); }
.m-sheet .chk.dis { opacity: .6; }

@media (min-width: 761px) {
  html.m-set .controls { display: contents; }
  html.m-set .top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px 22px; padding-top: 14px; padding-bottom: 14px; }
  html.m-set .brand p { max-width: 300px; white-space: normal; }
  @media (max-width: 1280px) { html.m-set .brand p { display: none; } }
  .m-sum { width: auto; max-width: 100%; justify-self: center; min-height: 46px; padding: 0 10px 0 18px; border-radius: 999px; }
  .m-sum-t { -webkit-line-clamp: 2; font-size: 14.5px; line-height: 1.35; }
  .m-sum { border-radius: 16px; padding-top: 4px; padding-bottom: 4px; }
  .m-sum-l { display: inline; flex: none; font-size: 12px; color: var(--acc); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; padding-left: 10px; border-left: 1px solid var(--rule); }
  .m-sum:hover { border-color: var(--ink); }
  html.m-set .hdr-total { border-left: 0; padding-left: 0; }
  .m-sheet-panel { left: auto; top: 0; right: 0; bottom: 0; width: min(480px, 94vw); max-height: none; border-radius: 18px 0 0 18px; transform: translateX(102%); box-shadow: -12px 0 40px rgba(22,20,15,.18); }
  .m-sheet.open .m-sheet-panel { transform: none; }
  .m-grip { display: none; }
  .m-sheet-head { cursor: default; padding-top: 18px; }
  .m-sheet .seg button, .m-list button { min-height: 42px; font-size: 15px; cursor: pointer; }
  .m-sheet .seg button:hover { border-color: var(--ink3); }
}

@media (max-width: 760px) {
  /* ---------- шапка ---------- */
  .top {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 10px var(--pad) 9px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  /* строка 1: бренд слева, итог справа */
  .brand { gap: 10px; padding-right: 156px; min-height: 36px; }
  .brand > div { min-width: 0; }
  .mark { width: 34px; height: 34px; font-size: 15px; }
  .brand h1 { font-size: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand p { display: none; }

  .hdr-total {
    position: absolute; top: max(10px, env(safe-area-inset-top)); right: var(--pad);
    height: 36px; max-width: 150px;
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px;
    border-left: 0; padding-left: 0; text-align: right;
  }
  .hdr-total span { font-size: 9.5px; letter-spacing: .5px; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .hdr-total b { font-size: 23px; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }

  /* строка 2: сводка текущего выбора → лист «Настройки сметы» (кнопку и лист создаёт m-menu.js) */
  html.m-menu .controls { display: contents; }


  /* ---------- навигация: разделы — нижняя панель ---------- */
  html.m-menu .tabs {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    margin: 0; padding: 0 0 env(safe-area-inset-bottom); overflow: visible;
    border-bottom: 0; border-top: 1px solid var(--rule);
    background: rgba(243,239,231,.96); box-shadow: 0 -4px 18px rgba(22,20,15,.05);
  }
  html.m-menu .tabs button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 0; min-height: 58px; padding: 6px 2px 7px; margin: 0; border: 0;
    font-size: 11px; font-weight: 500; letter-spacing: .1px; color: var(--ink3);
  }
  html.m-menu .tabs button.on { color: var(--ink); border: 0; }
  html.m-menu .tabs button.on::before { content: ''; position: absolute; top: -1px; left: 26%; right: 26%; height: 2px; border-radius: 0 0 2px 2px; background: var(--acc); }
  html.m-menu .tabs button.on .m-ico { color: var(--acc); }
  .m-ico { width: 23px; height: 23px; flex: none; }
  .m-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html.m-menu main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* подвкладки: компактная строка с текущей подвкладкой → лист со списком */
  html.m-menu .subtabs { display: none; }
  .m-subbar {
    position: sticky; top: 0; z-index: 15; padding: 6px var(--pad);
    background: rgba(243,239,231,.95); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rule);
  }
  .m-subbar[hidden] { display: none; }
  .m-subbtn { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 44px; padding: 0 2px; border: 0; background: none; text-align: left; align-items: center; }
  .m-sub-sec { flex: none; font-size: 10.5px; font-weight: 500; letter-spacing: .7px; text-transform: uppercase; color: var(--ink3); }
  .m-sub-cur { flex: 1; min-width: 0; font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-sub-n { flex: none; font-size: 12px; color: var(--ink3); font-variant-numeric: tabular-nums; }
  .m-list { display: flex; flex-direction: column; gap: 6px; padding: 14px 0 4px; }

  /* ---------- «Обзор» ---------- */
  main { padding-top: 16px; }
  #tab-overview .hero { height: 330px; border-radius: 16px; }
  #tab-overview .hero img { object-position: 58% 62%; }
  #tab-overview .hero::after { background: linear-gradient(180deg, rgba(14,12,9,0) 30%, rgba(14,12,9,.5) 62%, rgba(14,12,9,.82) 100%); }
  #tab-overview .hero-txt { left: 18px; right: 18px; bottom: 20px; }
  #tab-overview .hero-txt span { font-size: 11px; letter-spacing: 1.5px; }
  #tab-overview .hero-txt h2 { font-size: 31px; line-height: 1.02; margin: 8px 0 0; }

  #tab-overview .kpis { margin: 20px 0 4px; }
  .kpi .l { font-size: 10.5px; }
  .kpi .s { font-size: 13px; }

  #overview .section { font-size: 28px; margin: 38px 0 10px; }

  .ov-cards { grid-template-columns: 1fr; }
  .ov-cards .card, .ov-cards .card + .card, .ov-cards .card:nth-child(even) { padding: 16px 0 18px; border-left: 0; }
  .ov-cards .card h3 { font-size: 12px; margin-bottom: 8px; }
  .ov-cards .card .big { font-size: 40px; }
  .ov-cards .card p { font-size: 15px; line-height: 1.55; margin-top: 10px; }

  .ov-steps li { font-size: 15px; line-height: 1.6; padding: 16px 0 14px 40px; }
  .ov-steps li::before { font-size: 30px; top: 12px; }
  .ov-steps .linkish { display: inline-flex; align-items: center; min-height: 38px; margin: 2px 16px 0 0; font-size: 15px; }

  .ov-map { grid-template-columns: 1fr; }
  .ov-map > div, .ov-map > div + div { padding: 18px 0 8px; border-left: 0; gap: 0; align-items: stretch; }
  .ov-map h4 { font-size: 26px; }
  .ov-map p { font-size: 15px; margin: 2px 0 10px; }
  .ov-map .linkish {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 46px; padding: 0; font-size: 15px; border-top: 1px solid var(--rule);
  }
  .ov-map .linkish::after { content: '→'; color: var(--ink3); font-size: 16px; }

  /* ---------- «Дом → Рендеры» ---------- */
  .gallery { grid-template-columns: 1fr; gap: 22px; }
  .gallery img { border-radius: 12px; }
  .gallery figure:hover img { transform: none; }
  .gallery figcaption { font-size: 15px; padding-top: 9px; }
  #tab-renders .hint2 { font-size: 13px; line-height: 1.5; }

  /* ---------- лайтбокс: на весь экран, крупная кнопка закрытия ---------- */
  .lightbox { background: #0c0b09; height: 100vh; height: 100dvh; }
  .lightbox img { max-width: 100vw; max-height: calc(100dvh - 140px); }
  .lightbox button#lbclose {
    top: max(10px, env(safe-area-inset-top)); right: 10px;
    width: 48px; height: 48px; border-radius: 50%;
    display: grid; place-items: center; padding: 0 0 3px;
    font-size: 30px; line-height: 1;
    background: rgba(255,255,255,.14); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  .lightbox button#lbclose:active { background: rgba(255,255,255,.28); }
  .lbcap { bottom: max(18px, env(safe-area-inset-bottom)); font-size: 14px; line-height: 1.45; padding: 0 20px; }
}

@media (max-width: 420px) {
  .brand { padding-right: 140px; }
  .brand h1 { font-size: 21px; }
  .hdr-total { max-width: 136px; }
  .hdr-total b { font-size: 21px; }
  #tab-overview .hero { height: 300px; }
  #tab-overview .hero-txt h2 { font-size: 28px; }
  .kpi .v { font-size: 30px; }
  .ov-cards .card .big { font-size: 36px; }
}
.m-about { margin: -4px 2px 10px; font-size: 13px; line-height: 1.45; color: var(--ink2); }
/* вариант = название + пояснение под ним; кружок выбора справа */
.m-sheet .seg button { display: grid !important; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; row-gap: 3px; }
.m-sheet .seg button .b-t { grid-column: 1; }
.m-sheet .seg button .b-d { grid-column: 1; font-size: 12.5px; line-height: 1.4; color: var(--ink3); font-weight: 400; }
.m-sheet .seg button::after { grid-column: 2; grid-row: 1 / span 2; }
.m-sheet .seg button.on .b-d { color: var(--ink2); }
.b-d { display: none; }
.m-sheet .b-d { display: block; }
