:root {
  --cc-green: #12392d;
  --cc-green-dark: #0b2a21;
  --cc-green-mid: #1d5141;
  --cc-mint: #eaf3ef;
  --cc-white: #ffffff;
  --cc-soft: #f4f7f6;
  --cc-shell: #f7f2ee;
  --cc-ink: #202727;
  --cc-muted: #5d6966;
  --cc-line: #d9e0dd;
  --cc-danger: #a22b2b;
}


/* Mobile containment: keep the modal independent from theme-level box sizing. */
.chestnut-chat-modal,
.chestnut-chat-modal *,
.chestnut-chat-modal *::before,
.chestnut-chat-modal *::after {
  box-sizing: border-box;
}
.chestnut-chat-modal {
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  overscroll-behavior: contain;
}
.chestnut-chat-modal__dialog,
.chestnut-chat,
.chestnut-chat__head,
.chestnut-chat__layout,
.chestnut-chat__care,
.chestnut-chat__form,
.chestnut-chat__field {
  min-width: 0;
  max-width: 100%;
}
.chestnut-chat-modal__dialog,
.chestnut-chat {
  overflow-x: hidden;
}
.chestnut-chat__title,
.chestnut-chat__subtitle,
.chestnut-chat__service-line,
.chestnut-chat__care,
.chestnut-chat__form,
.chestnut-chat__consent,
.chestnut-chat__status,
.chestnut-chat__microcopy {
  overflow-wrap: anywhere;
  word-break: normal;
}
.chestnut-chat__input,
.chestnut-chat__select,
.chestnut-chat__submit {
  min-width: 0;
  max-width: 100%;
}
.chestnut-chat-modal[hidden] { display: none !important; }
.chestnut-chat-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  transition: opacity .18s ease;
}
.chestnut-chat-modal.is-open { opacity: 1; }
.chestnut-chat-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 26, 22, .70);
  backdrop-filter: blur(7px);
}
.chestnut-chat-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(860px, calc(100vw - 48px));
  max-width: 860px;
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--cc-white);
  border: 1px solid #cfd9d5;
  border-top: 5px solid var(--cc-green);
  box-shadow: 0 24px 70px rgba(8, 30, 23, .25);
  transform: translateY(10px);
  transition: transform .18s ease;
}
.chestnut-chat-modal.is-open .chestnut-chat-modal__dialog { transform: none; }
.chestnut-chat-modal__close {
  position: absolute;
  z-index: 4;
  right: 18px;
  top: 17px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--cc-line);
  border-radius: 2px;
  background: var(--cc-white);
  color: var(--cc-green-dark);
  font: 400 29px/1 Arial, sans-serif;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.chestnut-chat-modal__close:hover,
.chestnut-chat-modal__close:focus-visible {
  background: var(--cc-soft);
  border-color: #9fb2ab;
  outline: 0;
}
.chestnut-chat-modal-open { overflow: hidden !important; }

.chestnut-chat {
  color: var(--cc-ink);
  background: var(--cc-white);
  font-family: Inter, Arial, sans-serif;
}
.chestnut-chat__head {
  padding: 30px 82px 26px 32px;
  border-bottom: 1px solid var(--cc-line);
}
.chestnut-chat__service-line {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.3;
}
.chestnut-chat__service {
  color: var(--cc-green);
  font-weight: 800;
}
.chestnut-chat__service-meta {
  color: var(--cc-muted);
  padding-left: 14px;
  border-left: 1px solid var(--cc-line);
}
.chestnut-chat__title {
  margin: 0;
  max-width: 650px;
  color: #19332c;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(32px, 4.2vw, 43px);
  line-height: 1.08;
  letter-spacing: -.035em;
  font-weight: 600;
}
.chestnut-chat__subtitle {
  margin: 13px 0 0;
  max-width: 650px;
  color: #45524f;
  font-size: 15px;
  line-height: 1.55;
}

.chestnut-chat__layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 390px;
}
.chestnut-chat__care {
  background: var(--cc-soft);
  border-right: 1px solid var(--cc-line);
  padding: 28px 24px 30px 32px;
}
.chestnut-chat__care-label {
  margin: 0 0 10px;
  color: var(--cc-green-mid);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}
.chestnut-chat__care h3 {
  margin: 0 0 16px;
  color: #263b35;
  font-size: 19px;
  line-height: 1.25;
  font-weight: 750;
}
.chestnut-chat__care ul {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
}
.chestnut-chat__care li {
  position: relative;
  padding: 12px 0 12px 22px;
  border-top: 1px solid var(--cc-line);
  color: #465550;
  font-size: 13px;
  line-height: 1.45;
}
.chestnut-chat__care li:last-child { border-bottom: 1px solid var(--cc-line); }
.chestnut-chat__care li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 11px;
  color: var(--cc-green);
  font-weight: 800;
}
.chestnut-chat__care-note {
  margin: 0;
  color: var(--cc-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.chestnut-chat__form {
  margin: 0;
  padding: 28px 32px 30px;
}
.chestnut-chat__field { min-width: 0; }
.chestnut-chat__label {
  display: block;
  margin: 0 0 7px;
  color: #2d3b37;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 750;
}
.chestnut-chat__input,
.chestnut-chat__select {
  width: 100%;
  height: 54px;
  border: 1px solid #bfcac6;
  border-radius: 2px;
  background: #fff;
  color: var(--cc-ink);
  font: 500 15px/1 Inter, Arial, sans-serif;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.chestnut-chat__input { padding: 0 14px; }
.chestnut-chat__select { padding: 0 11px; }
.chestnut-chat__input::placeholder { color: #7b8581; opacity: 1; }
.chestnut-chat__input:focus,
.chestnut-chat__select:focus {
  border-color: var(--cc-green-mid);
  box-shadow: 0 0 0 3px rgba(29,81,65,.12);
}
.chestnut-chat__phone-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.chestnut-chat__consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 19px 0 0;
  color: #53605d;
  font-size: 12.5px;
  line-height: 1.45;
  cursor: pointer;
}
.chestnut-chat__consent input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--cc-green);
}
.chestnut-chat__consent a {
  color: var(--cc-green);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chestnut-chat__submit {
  width: 100%;
  min-height: 52px;
  margin-top: 21px;
  padding: 0 17px;
  border: 1px solid var(--cc-green);
  border-radius: 3px;
  background: var(--cc-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font: 750 14px/1 Inter, Arial, sans-serif;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.chestnut-chat__submit:hover:not(:disabled),
.chestnut-chat__submit:focus-visible:not(:disabled) {
  background: var(--cc-green-dark);
  border-color: var(--cc-green-dark);
  outline: 0;
}
.chestnut-chat__submit:disabled {
  opacity: .38;
  cursor: not-allowed;
}
.chestnut-chat__status {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.4;
}
.chestnut-chat__status[data-type="error"] { color: var(--cc-danger); }
.chestnut-chat__status[data-type="working"] { color: #5d6966; }
.chestnut-chat__status[data-type="success"] { color: #1f6b43; font-weight: 700; }
.chestnut-chat__microcopy {
  margin: 4px 0 0;
  color: #74807c;
  font-size: 11px;
  line-height: 1.45;
}
.chestnut-chat__hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

@media (max-width: 760px) {
  .chestnut-chat-modal {
    padding: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    align-items: end;
  }
  .chestnut-chat-modal__dialog {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - max(10px, env(safe-area-inset-bottom)));
    border-top-width: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .chestnut-chat-modal__close {
    top: 13px;
    right: 13px;
    width: 42px;
    height: 42px;
  }
  .chestnut-chat__head {
    padding: 22px 66px 20px 20px;
  }
  .chestnut-chat__service-line {
    display: block;
    margin-bottom: 8px;
  }
  .chestnut-chat__service-meta {
    display: block;
    border: 0;
    padding: 2px 0 0;
  }
  .chestnut-chat__title {
    font-size: clamp(29px, 8.3vw, 37px);
  }
  .chestnut-chat__subtitle { font-size: 14px; }
  .chestnut-chat__layout { grid-template-columns: 1fr; }
  .chestnut-chat__care {
    border-right: 0;
    border-bottom: 1px solid var(--cc-line);
    padding: 18px 20px;
  }
  .chestnut-chat__care h3 { margin-bottom: 10px; font-size: 17px; }
  .chestnut-chat__care ul {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
    margin-bottom: 0;
  }
  .chestnut-chat__care li {
    padding: 8px 0 8px 20px;
    font-size: 11.5px;
  }
  .chestnut-chat__care li:nth-child(3) { display: none; }
  .chestnut-chat__care-note { display: none; }
  .chestnut-chat__form { padding: 22px 20px 24px; }
  .chestnut-chat__phone-row { grid-template-columns: 112px minmax(0, 1fr); gap: 9px; }
  .chestnut-chat__input,
  .chestnut-chat__select { height: 50px; font-size: 14px; }
}

@media (max-width: 430px) {
  .chestnut-chat-modal {
    padding: 0;
    width: 100vw;
    max-width: 100vw;
  }
  .chestnut-chat-modal__dialog {
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .chestnut-chat__care { display: none; }
  .chestnut-chat__head {
    padding: max(18px, env(safe-area-inset-top)) 62px 17px 16px;
  }
  .chestnut-chat__title {
    font-size: clamp(27px, 8vw, 33px);
    line-height: 1.06;
  }
  .chestnut-chat__subtitle {
    font-size: 13.5px;
    line-height: 1.48;
  }
  .chestnut-chat__form {
    padding: 18px 16px max(22px, env(safe-area-inset-bottom));
  }
  .chestnut-chat__phone-row {
    grid-template-columns: minmax(92px, 108px) minmax(0, 1fr);
    gap: 8px;
  }
  .chestnut-chat__input,
  .chestnut-chat__select {
    width: 100%;
    max-width: 100%;
  }
  .chestnut-chat__consent {
    gap: 8px;
    font-size: 12px;
  }
  .chestnut-chat__submit {
    gap: 10px;
    padding-left: 14px;
    padding-right: 14px;
    font-size: 13px;
  }
  .chestnut-chat-modal__close {
    right: 10px;
    top: max(10px, env(safe-area-inset-top));
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 355px) {
  .chestnut-chat__phone-row {
    grid-template-columns: 1fr;
  }
  .chestnut-chat__head {
    padding-right: 58px;
  }
  .chestnut-chat__title {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chestnut-chat-modal,
  .chestnut-chat-modal__dialog,
  .chestnut-chat-modal__close,
  .chestnut-chat__submit,
  .chestnut-chat__input,
  .chestnut-chat__select { transition: none !important; }
}
