/* Crans-Montana V9 — dedicated mobile modal/wizard scrolling layer. */
@media (max-width: 620px) {
  /* Main DN8 modal: fixed shell + one intentional internal scroll region. */
  #enquiries:not([hidden]) {
    display: block;
    width: 100%;
    height: var(--dn8-mobile-height, 100dvh);
    max-height: var(--dn8-mobile-height, 100dvh);
    min-height: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  #enquiries > .wrap {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
  }

  #lead-wizard.wizard-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--dn8-mobile-height, 100dvh);
    max-height: var(--dn8-mobile-height, 100dvh);
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border-left: 0;
    border-right: 0;
  }

  #lead-wizard .wizard-head {
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
    gap: .45rem;
    padding: calc(.55rem + env(safe-area-inset-top)) 3.55rem .55rem var(--dn8-mobile-edge);
  }

  #lead-wizard .wizard-head .eyebrow {
    font-size: .55rem;
    line-height: 1.2;
  }

  #lead-wizard .wizard-head h3 {
    margin: .12rem 0 0;
    font-size: clamp(1.18rem, 5.8vw, 1.45rem);
    line-height: 1.02;
  }

  #lead-wizard .wizard-head p {
    display: none;
  }

  #lead-wizard .wizard-close {
    top: calc(.48rem + env(safe-area-inset-top));
    right: var(--dn8-mobile-edge);
    width: 40px;
    height: 40px;
  }

  #lead-wizard .wizard-layout {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  #lead-wizard .wizard-rail {
    flex: 0 0 auto;
    min-height: 0;
    padding: .32rem var(--dn8-mobile-edge) .42rem;
    overflow: hidden;
    border: 0;
    border-bottom: 1px solid rgba(201,164,1,.2);
  }

  #lead-wizard .wizard-progress-label,
  #lead-wizard .wizard-steps,
  #lead-wizard .wizard-summary {
    display: none;
  }

  #lead-wizard .wizard-progress-track {
    height: 5px;
    margin: 0;
  }

  #lead-wizard .wizard-main {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  #progressive-lead-form {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #wizard-error-summary:not([hidden]) {
    flex: 0 0 auto;
    max-height: 26%;
    margin: .45rem var(--dn8-mobile-edge) 0;
    overflow-y: auto;
  }

  #wizard-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    contain: layout paint;
    padding: .55rem max(var(--dn8-mobile-edge), env(safe-area-inset-right))
      calc(var(--dn8-mobile-nav-reserve) + env(safe-area-inset-bottom) + 1.25rem)
      max(var(--dn8-mobile-edge), env(safe-area-inset-left));
    scroll-padding-top: .5rem;
    scroll-padding-bottom: calc(var(--dn8-mobile-nav-reserve) + env(safe-area-inset-bottom) + 1rem);
  }

  #wizard-stage .wizard-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow: visible;
  }

  #wizard-stage .wizard-stage-heading {
    flex: 0 0 auto;
    margin: 0 0 .5rem;
  }

  #wizard-stage .wizard-stage-heading h4 {
    margin: 0;
    font-size: clamp(1.55rem, 7.8vw, 2.05rem);
    line-height: 1.02;
    text-align: left;
    overflow-wrap: anywhere;
  }

  #wizard-stage .wizard-quick-card {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    align-items: center;
    gap: .55rem;
    margin: 0 0 .65rem;
    padding: .5rem .6rem;
    font-size: .69rem;
    line-height: 1.3;
  }

  #wizard-stage .wizard-quick-card span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #wizard-stage .wizard-quick-card a {
    font-size: .7rem;
    white-space: nowrap;
  }

  #wizard-stage .wizard-fields,
  #wizard-stage .wizard-fields--contact {
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
    justify-content: flex-start;
    align-content: start;
    gap: .55rem;
    overflow: visible !important;
  }

  #wizard-stage .choice-carousel {
    min-height: 0;
    overflow: visible;
  }

  #wizard-stage .choice-grid,
  #wizard-stage .choice-grid.compact,
  #wizard-stage .asset-class-grid,
  #wizard-stage .checkbox-list {
    grid-template-columns: 1fr;
    gap: .5rem;
  }

  #wizard-stage .choice-card span {
    min-height: 52px;
    padding: .62rem .72rem;
    font-size: .88rem;
  }

  #wizard-stage .location-chips {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: .42rem;
    margin-top: .55rem;
  }

  #wizard-stage .location-chips button {
    min-height: 42px;
    padding: .45rem .5rem;
    font-size: .78rem;
  }

  #wizard-stage .wizard-field > input,
  #wizard-stage .wizard-field > textarea {
    font-size: 1rem;
  }

  #wizard-stage .wizard-other-detail,
  #wizard-stage .wizard-context-note textarea {
    max-height: none;
    resize: vertical !important;
  }

  #wizard-stage .wizard-context-note textarea {
    min-height: 96px;
  }

  /* Property context: full-but-tight on first step, compact thereafter. */
  #wizard-stage .wizard-context-banner {
    flex: 0 0 auto;
    gap: .22rem;
    margin: 0 0 .65rem;
    padding: .68rem .75rem;
  }

  #wizard-stage .wizard-context-banner span {
    font-size: .56rem;
    letter-spacing: .12em;
  }

  #wizard-stage .wizard-context-banner strong {
    font-size: .9rem;
    line-height: 1.24;
    overflow-wrap: anywhere;
  }

  #wizard-stage .wizard-context-banner .wizard-context-reassurance {
    margin: .05rem 0 0;
    font-size: .71rem;
    line-height: 1.35;
  }

  #wizard-stage .wizard-context-clear {
    margin-top: .05rem;
    padding: .2rem 0;
    font-size: .58rem;
  }

  #progressive-lead-form:not(.dn8-first-step) #wizard-stage .wizard-context-banner.context-property {
    gap: .12rem;
    margin-bottom: .5rem;
    padding: .48rem .62rem;
    border-left-width: 3px;
  }

  #progressive-lead-form:not(.dn8-first-step) #wizard-stage .wizard-context-banner.context-property span {
    font-size: .5rem;
  }

  #progressive-lead-form:not(.dn8-first-step) #wizard-stage .wizard-context-banner.context-property strong {
    font-size: .79rem;
    line-height: 1.2;
  }

  #progressive-lead-form:not(.dn8-first-step) #wizard-stage .wizard-context-banner.context-property .wizard-context-reassurance {
    font-size: .63rem;
    line-height: 1.25;
  }

  #progressive-lead-form:not(.dn8-first-step) #wizard-stage .wizard-context-banner.context-property .wizard-context-clear {
    font-size: .52rem;
  }

  /* Back/Next become a safe-area-aware action layer, never a mid-screen obstruction. */
  #progressive-lead-form .wizard-actions {
    position: absolute !important;
    inset: auto 0 0 0;
    z-index: 50;
    display: block;
    width: 100%;
    height: calc(var(--dn8-mobile-nav-reserve) + env(safe-area-inset-bottom));
    margin: 0;
    padding: 0;
    border: 0;
    background: linear-gradient(to top, #0f0f12 48%, rgba(15,15,18,.94) 72%, rgba(15,15,18,0));
    pointer-events: none;
  }

  #progressive-lead-form .wizard-actions .right-actions {
    display: contents;
  }

  #progressive-lead-form .wizard-actions .wizard-back,
  #progressive-lead-form .wizard-actions .wizard-continue {
    position: absolute !important;
    top: auto !important;
    bottom: calc(.55rem + env(safe-area-inset-bottom));
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    margin: 0 !important;
    transform: none !important;
    pointer-events: auto;
  }

  #progressive-lead-form .wizard-actions .wizard-back {
    left: max(.6rem, env(safe-area-inset-left));
  }

  #progressive-lead-form .wizard-actions .wizard-continue {
    right: max(.6rem, env(safe-area-inset-right));
  }

  #progressive-lead-form .wizard-status {
    position: absolute;
    left: 50%;
    bottom: calc(var(--dn8-mobile-nav-reserve) + env(safe-area-inset-bottom) + .35rem);
    width: min(calc(100% - 2rem), 560px);
    max-height: 28%;
    overflow-y: auto;
  }

  #lead-wizard .wizard-success {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.35rem var(--dn8-mobile-edge)
      calc(1.5rem + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Standalone Quick Submission gets the same viewport and reachability rules. */
  .quick-submission-page .quick-overlay {
    width: 100%;
    height: var(--dn8-mobile-height, 100dvh);
    min-height: 0;
    max-height: var(--dn8-mobile-height, 100dvh);
    padding: 0;
    overflow: hidden;
  }

  .quick-submission-page .quick-modal {
    width: 100%;
    height: var(--dn8-mobile-height, 100dvh);
    min-height: 0;
    max-height: var(--dn8-mobile-height, 100dvh);
    overflow: hidden;
    border-left: 0;
    border-right: 0;
  }

  .quick-submission-page .quick-header {
    flex: 0 0 auto;
    min-height: 62px;
    padding-top: calc(.45rem + env(safe-area-inset-top));
  }

  .quick-submission-page #quick-submission-form {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    padding: 0 var(--dn8-mobile-edge);
    overflow: hidden;
  }

  .quick-submission-page .quick-progress {
    flex: 0 0 auto;
    padding: .4rem 0;
  }

  .quick-submission-page .quick-context-banner {
    flex: 0 0 auto;
    gap: .16rem;
    margin: .05rem 0 .45rem;
    padding: .55rem .65rem;
  }

  .quick-submission-page .quick-context-banner strong {
    font-size: .82rem;
    line-height: 1.22;
  }

  .quick-submission-page .quick-context-banner p {
    font-size: .66rem;
    line-height: 1.3;
  }

  .quick-submission-page .form-stage:not([hidden]) {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    justify-content: flex-start;
    padding: .35rem .15rem
      calc(var(--dn8-mobile-nav-reserve) + env(safe-area-inset-bottom) + 1rem);
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scroll-padding-bottom: calc(var(--dn8-mobile-nav-reserve) + env(safe-area-inset-bottom) + .8rem);
  }

  .quick-submission-page .quick-arrow {
    position: fixed;
    top: auto;
    bottom: calc(.55rem + env(safe-area-inset-bottom));
    z-index: 80;
    width: 48px;
    height: 48px;
    transform: none;
  }

  .quick-submission-page .quick-back {
    left: max(.6rem, env(safe-area-inset-left));
  }

  .quick-submission-page .quick-next {
    right: max(.6rem, env(safe-area-inset-right));
  }

  .quick-submission-page .quick-success {
    flex: 1 1 auto;
    min-height: 0;
    display: block;
    padding: 1.25rem var(--dn8-mobile-edge)
      calc(1.5rem + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 360px) {
  #wizard-stage .wizard-stage-heading h4 {
    font-size: clamp(1.42rem, 7.4vw, 1.78rem);
  }

  #wizard-stage .wizard-quick-card {
    font-size: .64rem;
  }

  #wizard-stage .wizard-quick-card a {
    font-size: .66rem;
  }

  #wizard-stage .location-chips {
    grid-template-columns: 1fr;
  }
}
