*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
}

/* —— Шапка страницы —— */
.page-hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(135deg, #fffdf8 0%, #fff6e8 42%, #f3ead8 100%);
  border: 1px solid rgba(141, 110, 99, 0.22);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 12px 40px rgba(47, 42, 34, 0.08);
}

.page-hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -8%;
  width: min(52vw, 320px);
  height: min(52vw, 320px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 125, 50, 0.12) 0%, transparent 68%);
  pointer-events: none;
}

.page-hero::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #2e7d32 0%, #6d9f5c 38%, #8d6e63 100%);
  opacity: 0.85;
}

.page-hero__inner {
  position: relative;
  z-index: 1;
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.25rem, 3vw, 2.25rem);
}

.page-hero__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: clamp(1rem, 3vw, 2rem);
}

.page-hero__headline {
  flex: 1 1 280px;
  min-width: 0;
}

.page-hero__title {
  background: linear-gradient(120deg, #1b3d1c 0%, #2e7d32 45%, #4a3728 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@supports not (background-clip: text) {
  .page-hero__title {
    color: #2f2a22;
  }
}

.page-hero__logo-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  width: 200px;
  max-width: 200px;
}

.page-hero__logo {
  display: block;
  width: 200px;
  height: 200px;
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
}

.page-hero__phone-wrap {
  margin-top: 0.85rem;
}

.page-hero__phone {
  display: inline-flex;
  align-items: center;
  font-size: clamp(1.0625rem, 2.5vw, 1.25rem);
  font-weight: 800;
  color: #1b5e20;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}

.page-hero__phone:hover {
  color: #2e7d32;
  text-decoration: underline;
}

.page-hero__phone:focus-visible {
  outline: 3px solid rgba(46, 125, 50, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

.page-hero__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.page-hero__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
  color: #1b3d1c;
  background: rgba(232, 245, 233, 0.92);
  border: 1px solid rgba(46, 125, 50, 0.22);
  white-space: nowrap;
}

.page-hero__badge--tour {
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(46, 125, 50, 0.28);
}

.page-hero__badge--tour:hover {
  filter: brightness(1.05);
}

@media (max-width: 599px) {
  .page-hero__top {
    align-items: flex-start;
    gap: 0.75rem;
  }

  .page-hero__logo-wrap {
    width: 120px;
    max-width: 120px;
  }

  .page-hero__logo {
    width: 120px;
    height: 120px;
    max-width: 120px;
    max-height: 120px;
  }

  .page-hero__badges {
    margin-top: 0.85rem;
  }

  .page-hero__badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
  }
}

/* —— Онлайн-чат (виджет + плавающая кнопка) —— */
.chat-float-btn {
  position: fixed;
  z-index: 1400;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 56px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #2e7d32 0%, #1b5e20 100%);
  box-shadow: 0 6px 20px rgba(27, 94, 32, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-float-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(27, 94, 32, 0.5);
}

.chat-float-btn:focus-visible {
  outline: 3px solid rgba(46, 125, 50, 0.45);
  outline-offset: 2px;
}

.chat-widget {
  position: fixed;
  z-index: 1399;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  display: flex;
  flex-direction: column;
  width: min(100vw - 32px, 360px);
  max-height: min(520px, calc(100vh - 120px - env(safe-area-inset-bottom)));
  background: #fffaf2;
  border: 1px solid #e8decf;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(47, 42, 34, 0.18);
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.chat-widget--hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.chat-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(180deg, #fff9ee 0%, #f5ecd8 100%);
  border-bottom: 1px solid #e8decf;
}

.chat-widget__title {
  font-size: 15px;
  font-weight: 700;
  color: #2f2a22;
}

.chat-widget__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  color: #6a5e4d;
  background: transparent;
  cursor: pointer;
}

.chat-widget__close:hover {
  background: rgba(141, 110, 99, 0.12);
  color: #2f2a22;
}

.chat-widget__messages {
  flex: 1;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px;
  background: #fffcf7;
}

.chat-msg {
  max-width: 92%;
  margin-bottom: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg--user {
  margin-left: auto;
  background: #e8f5e9;
  color: #1b3d1f;
  border: 1px solid #c8e6c9;
}

.chat-msg--manager {
  margin-right: auto;
  background: #fff;
  color: #2f2a22;
  border: 1px solid #e8decf;
}

.chat-widget__form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid #e8decf;
  background: #fffaf2;
}

.chat-widget__input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d8ccb8;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: #2f2a22;
}

.chat-widget__input:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
}

.chat-widget__send {
  flex-shrink: 0;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: #2e7d32;
  cursor: pointer;
}

.chat-widget__send:hover {
  background: #1b5e20;
}

/* —— Мобильная панель итога (фаза 1) —— */
.mobile-summary-bar {
  position: fixed;
  z-index: 1300;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #fffdf8 0%, #fff6e8 100%);
  border-top: 1px solid rgba(141, 110, 99, 0.25);
  box-shadow: 0 -8px 28px rgba(47, 42, 34, 0.12);
}

.mobile-summary-bar__total-label {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6a5e4d;
}

.mobile-summary-bar__total-value {
  margin: 2px 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #2e7d32;
  line-height: 1.15;
  transition: color 0.25s ease, transform 0.25s ease;
}

.mobile-summary-bar__total-value--pulse {
  color: #1b5e20;
  transform: scale(1.03);
}

.mobile-summary-bar__actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

@media (min-width: 900px) {
  .mobile-summary-bar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-summary-bar__total-value {
    transition: none;
  }

  .calc-steps a {
    transition: none;
  }
}

@media (max-width: 899px) {
  .chat-float-btn {
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  }

  .chat-widget {
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 128px);
  }
}

@media (max-width: 480px) {
  .chat-widget {
    right: 12px;
    left: 12px;
    width: auto;
    max-height: min(55vh, 420px);
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 120px);
  }
}

/* —— Сетка блоков калькулятора (десктоп) —— */
@media (min-width: 900px) {
  .calc-blocks-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    column-gap: 12px;
    row-gap: 12px;
    align-items: start;
    grid-template-areas:
      "length gallery"
      "addons equipment"
      "addons summary"
      "addons lead";
  }

  .calc-blocks-layout__length {
    grid-area: length;
  }

  .calc-blocks-layout__gallery {
    grid-area: gallery;
  }

  .calc-blocks-layout__addons {
    grid-area: addons;
  }

  .calc-blocks-layout__equipment {
    grid-area: equipment;
  }

  .calc-blocks-layout__summary {
    grid-area: summary;
  }

  .calc-blocks-layout__lead {
    grid-area: lead;
  }
}

/* —— Футер —— */
.site-footer {
  margin-top: 8px;
  padding: 20px 0 24px;
  border-top: 1px solid rgba(141, 110, 99, 0.2);
  background: rgba(255, 253, 248, 0.72);
}

@media (max-width: 899px) {
  .site-footer {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.site-footer__link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #2e7d32;
  text-decoration: none;
  line-height: 1.45;
  transition: color 0.15s ease;
}

.site-footer__link:hover {
  color: #1b5e20;
  text-decoration: underline;
}

/* —— Юридические страницы —— */
.legal-page {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: #2f2a22;
  background: radial-gradient(circle at top, #faf4e9 0%, #f1e8d8 42%, #ebe3d4 100%);
  min-height: 100vh;
}

.legal-page__wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.legal-page__header {
  margin-bottom: 24px;
}

.legal-page__back {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #2e7d32;
  text-decoration: none;
}

.legal-page__back:hover {
  color: #1b5e20;
  text-decoration: underline;
}

.legal-page__title {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.legal-page__meta {
  margin: 0;
  font-size: 0.875rem;
  color: #6a5e4d;
}

.legal-page__content {
  padding: 24px;
  border-radius: 16px;
  background: #fffdf8;
  border: 1px solid rgba(141, 110, 99, 0.22);
  box-shadow: 0 8px 28px rgba(79, 63, 39, 0.08);
  font-size: 0.9375rem;
  line-height: 1.65;
}

.legal-page__content h2 {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.35;
  color: #2f2a22;
}

.legal-page__content h2:first-of-type {
  margin-top: 0;
}

.legal-page__content p {
  margin: 0 0 0.85rem;
}

.legal-page__content ul {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
}

.legal-page__content li {
  margin-bottom: 0.35rem;
}

.legal-page__content a {
  color: #2e7d32;
  font-weight: 600;
  text-decoration: none;
}

.legal-page__content a:hover {
  text-decoration: underline;
}

.legal-page__footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(141, 110, 99, 0.2);
  font-size: 0.8125rem;
  color: #6a5e4d;
  line-height: 1.55;
}

.legal-page__footer p {
  margin: 0 0 12px;
}

.legal-page__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.legal-page__nav a {
  color: #2e7d32;
  font-weight: 600;
  text-decoration: none;
}

.legal-page__nav a:hover {
  text-decoration: underline;
}

/* —— Онбординг «Как пользоваться» —— */
.calc-tour {
  position: fixed;
  inset: 0;
  z-index: 1400;
  pointer-events: none;
}

.calc-tour__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 14, 0.55);
  pointer-events: auto;
}

.calc-tour__backdrop--clear {
  background: transparent;
}

.calc-tour__highlight {
  position: absolute;
  border-radius: 16px;
  box-shadow:
    0 0 0 9999px rgba(20, 18, 14, 0.55),
    0 0 0 3px #2e7d32,
    0 12px 32px rgba(0, 0, 0, 0.25);
  background: transparent;
  pointer-events: none;
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
  z-index: 1;
}

.calc-tour__tooltip {
  position: absolute;
  z-index: 2;
  pointer-events: auto;
  padding: 14px 16px 12px;
  border-radius: 14px;
  background: #fffdf8;
  border: 1px solid rgba(141, 110, 99, 0.28);
  box-shadow: 0 16px 40px rgba(47, 42, 34, 0.22);
  max-width: calc(100vw - 32px);
}

.calc-tour__step {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2e7d32;
}

.calc-tour__title {
  margin: 0 0 6px;
  line-height: 1.3;
  color: #2f2a22;
}

.calc-tour__text {
  margin: 0 0 12px;
  line-height: 1.5;
  color: #6a5e4d;
}

.calc-tour__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
