/* Mobile calculator-first rules keep the first editable controls above the fold. */
@media (max-width: 767px) {
  :root {
    --header-height: 54px !important;
  }

  .site-header {
    position: sticky;
    backdrop-filter: none !important;
  }

  body.home-page {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 24rem),
      var(--bg) !important;
  }

  body.home-page::before {
    display: none !important;
  }

  body.home-page :is(
    .site-header,
    .calculator-panel,
    .choice-option label,
    .wizard-choice label,
    .result-card,
    .result-highlight,
    .panel,
    .share-output
  ) {
    box-shadow: none !important;
  }

  body.home-page .site-header {
    background: var(--bg) !important;
  }

  .header-inner {
    min-height: auto !important;
    align-items: center !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.42rem !important;
    padding: 0.34rem 0 !important;
  }

  .logo {
    flex: 0 0 auto !important;
    gap: 0.42rem !important;
    max-width: 47vw !important;
    min-width: 0 !important;
  }

  .logo-mark {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
  }

  .logo-mark img {
    width: 30px !important;
    height: 30px !important;
  }

  .logo-title {
    display: block !important;
    max-width: 8.9rem !important;
    overflow: hidden !important;
    font-size: 0.93rem !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .site-nav {
    flex: 1 1 auto !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    width: auto !important;
    min-width: 0 !important;
    gap: 0.22rem !important;
    padding-bottom: 0 !important;
  }

  .site-nav a,
  .site-nav summary,
  .theme-toggle {
    min-height: 32px !important;
    padding: 0.34rem 0.48rem !important;
    font-size: 0.78rem !important;
  }

  .theme-toggle {
    display: none !important;
  }

  .hero-grid,
  .wood-hero-grid,
  .vinyl-hero-grid,
  .chain-hero-grid,
  .aluminum-hero-grid,
  .post-hero-grid,
  .cost-hero-grid,
  .privacy-hero-grid,
  .dog-hero-grid,
  .pool-hero-grid,
  .backyard-hero-grid,
  .wood-calculator-grid,
  .vinyl-calculator-grid,
  .chain-calculator-grid,
  .aluminum-calculator-grid,
  .post-calculator-grid,
  .cost-calculator-grid,
  .privacy-calculator-grid,
  .dog-calculator-grid,
  .pool-calculator-grid,
  .backyard-calculator-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.5rem !important;
  }

  .hero-grid > *,
  .wood-hero-grid > *,
  .vinyl-hero-grid > *,
  .chain-hero-grid > *,
  .aluminum-hero-grid > *,
  .post-hero-grid > *,
  .cost-hero-grid > *,
  .privacy-hero-grid > *,
  .dog-hero-grid > *,
  .pool-hero-grid > *,
  .backyard-hero-grid > *,
  #calculator > .container > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .breadcrumbs,
  .eyebrow,
  .cost-eyebrow,
  .privacy-eyebrow,
  .dog-eyebrow,
  .pool-eyebrow,
  .backyard-eyebrow,
  .chain-eyebrow,
  .aluminum-eyebrow,
  .wood-alert,
  .vinyl-alert,
  .chain-alert,
  .aluminum-alert,
  .post-alert,
  .wood-source-row,
  .vinyl-source-row,
  .wood-hero-list,
  .vinyl-hero-list,
  .chain-hero-list,
  .aluminum-hero-list,
  .post-hero-list,
  .wood-diagram-card,
  .vinyl-diagram-card,
  .chain-diagram-card,
  .aluminum-style-showcase,
  .post-diagram-card,
  .cost-visual-card,
  .privacy-visual-card,
  .dog-visual-card,
  .pool-visual-card,
  .backyard-summary-strip,
  #quick-numbers {
    display: none !important;
  }

  .wood-hero,
  .vinyl-hero,
  .chain-hero,
  .aluminum-hero,
  .post-hero,
  .cost-hero,
  .privacy-hero,
  .dog-hero,
  .pool-hero,
  .backyard-hero {
    padding: 0.42rem 0 0.16rem !important;
  }

  .hero h1,
  .page-hero h1,
  .wood-hero h1,
  .vinyl-hero h1,
  .chain-hero h1,
  .aluminum-hero h1,
  .post-hero h1,
  .cost-hero h1,
  .privacy-hero h1,
  .dog-hero h1,
  .pool-hero h1,
  .backyard-hero h1 {
    margin: 0 !important;
    max-width: 100% !important;
    font-size: clamp(1.48rem, 6.2vw, 1.95rem) !important;
    line-height: 1.06 !important;
    text-wrap: wrap !important;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .backyard-hero h1 {
    font-size: clamp(1.48rem, 6.4vw, 1.98rem) !important;
  }

  .wood-subtitle,
  .vinyl-subtitle,
  .chain-subtitle,
  .aluminum-subtitle,
  .post-subtitle,
  .cost-subtitle,
  .privacy-subtitle,
  .dog-subtitle,
  .pool-subtitle,
  .backyard-subtitle {
    display: none !important;
  }

  .wood-hero .reveal > p:not(.wood-subtitle),
  .vinyl-hero .reveal > p:not(.vinyl-subtitle),
  .chain-hero .reveal > p:not(.chain-subtitle),
  .aluminum-hero .reveal > p:not(.aluminum-subtitle),
  .post-hero .reveal > p:not(.post-subtitle),
  .cost-hero .reveal > p:not(.cost-subtitle),
  .privacy-hero .reveal > p:not(.privacy-subtitle),
  .dog-hero .reveal > p:not(.dog-subtitle),
  .pool-hero .reveal > p:not(.pool-subtitle) {
    display: none !important;
  }

  .wood-page .hero-actions,
  .vinyl-page .hero-actions,
  .chain-page .hero-actions,
  .aluminum-page .hero-actions,
  .post-page .hero-actions {
    display: none !important;
  }

  #calculator.section {
    padding: 0.12rem 0 2rem !important;
  }

  #calculator > .container > .section-heading {
    display: none !important;
  }

  #calculator .reveal,
  #calculator.reveal,
  #calculator [class*="calculator-grid"].reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  #calculator :is(
    .calculator-panel,
    .wood-tool-panel,
    .vinyl-tool-panel,
    .chain-tool-panel,
    .aluminum-tool-panel,
    .post-tool-panel,
    .cost-tool-panel,
    .privacy-tool-panel,
    .dog-tool-panel,
    .pool-tool-panel,
    .backyard-tool-panel
  ) {
    padding: 0.68rem !important;
    border-radius: 12px !important;
  }

  #calculator :is(
    .calculator-header,
    .wood-calculator-title,
    .vinyl-calculator-title,
    .chain-calculator-title,
    .aluminum-calculator-title,
    .post-calculator-title,
    .cost-tool-head,
    .privacy-tool-head,
    .dog-tool-head,
    .pool-tool-head,
    .backyard-tool-head
  ) {
    gap: 0.42rem !important;
    margin-bottom: 0.48rem !important;
  }

  #calculator :is(
    .calculator-panel h2,
    .wood-calculator-title h2,
    .vinyl-calculator-title h2,
    .chain-calculator-title h2,
    .aluminum-calculator-title h2,
    .post-calculator-title h2,
    .cost-tool-head h2,
    .privacy-tool-head h2,
    .dog-tool-head h2,
    .pool-tool-head h2,
    .backyard-tool-head h2
  ) {
    font-size: 1.14rem !important;
    line-height: 1.15 !important;
  }

  #calculator :is(
    .wood-fieldset,
    .vinyl-fieldset,
    .chain-fieldset,
    .aluminum-fieldset,
    .post-fieldset,
    .backyard-fieldset,
    .cost-step,
    .privacy-step,
    .dog-step,
    .pool-step
  ) {
    gap: 0.5rem !important;
    padding: 0.62rem !important;
    border-radius: 12px !important;
  }

  #calculator :is(
    .wood-form,
    .vinyl-form,
    .chain-form,
    .aluminum-form,
    .post-form,
    .wizard-panel,
    .expert-panel
  ) {
    gap: 0.58rem !important;
  }

  #calculator :is(
    .wood-choice-grid,
    .vinyl-choice-grid,
    .chain-choice-grid,
    .aluminum-choice-grid,
    .post-choice-grid,
    .post-choice-row,
    .cost-option-grid,
    .cost-material-choice,
    .cost-style-options,
    .privacy-option-grid,
    .privacy-material-choice,
    .privacy-style-options,
    .dog-option-grid,
    .dog-material-grid,
    .pool-option-grid,
    .pool-material-choice,
    .backyard-choice-grid,
    .backyard-material-grid,
    .backyard-install-grid,
    .backyard-input-grid,
    .backyard-input-grid.two
  ) {
    gap: 0.42rem !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #calculator :is(
    .wood-choice label,
    .vinyl-choice label,
    .chain-choice label,
    .aluminum-choice label,
    .post-choice label,
    .cost-option-grid button,
    .cost-material-choice button,
    .cost-style-options button,
    .privacy-option-grid button,
    .privacy-material-choice button,
    .privacy-style-options button,
    .dog-option-grid button,
    .dog-material-grid button,
    .pool-option-grid button,
    .pool-material-choice button,
    .backyard-choice-grid button,
    .backyard-material-grid button,
    .backyard-install-grid button
  ) {
    min-height: 44px !important;
    padding: 0.5rem 0.6rem !important;
    border-radius: 10px !important;
  }

  #calculator :is(input, select, textarea) {
    min-height: 44px !important;
  }

  #calculator :is(
    .wood-choice span,
    .vinyl-choice span,
    .chain-choice span,
    .aluminum-choice span,
    .post-choice span,
    .cost-option-grid button span,
    .cost-material-choice button span,
    .cost-style-options button span,
    .privacy-option-grid button span,
    .privacy-material-choice button span,
    .privacy-style-options button span,
    .privacy-style-options button small,
    .dog-option-grid button span,
    .dog-material-grid button span,
    .pool-option-grid button span,
    .pool-material-choice button span,
    .field-help,
    .wood-field-help,
    .vinyl-help,
    .chain-field-help,
    .aluminum-field-help,
    .post-field-help,
    .wood-small,
    .vinyl-small,
    .chain-small,
    .aluminum-small,
    .post-small
  ) {
    display: none !important;
  }

  #calculator :is(
    .wood-mode-switch,
    .vinyl-mode-switch,
    .chain-mode-switch,
    .aluminum-mode-switch,
    .post-mode-switch,
    .cost-mode-switch,
    .privacy-mode-switch,
    .dog-mode-switch,
    .pool-mode-switch,
    .wood-step-actions,
    .chain-step-actions,
    .aluminum-step-actions,
    .post-step-actions,
    .cost-step-nav,
    .privacy-step-nav,
    .pool-step-nav,
    .dog-segmented,
    .pool-segmented,
    .cost-segmented,
    .privacy-segmented
  ) {
    gap: 0.38rem !important;
  }

  #calculator :is(
    .wood-mode-switch button,
    .vinyl-mode-switch button,
    .chain-mode-switch button,
    .aluminum-mode-switch button,
    .post-mode-switch button,
    .cost-mode-switch button,
    .privacy-mode-switch button,
    .dog-mode-switch button,
    .pool-mode-switch button,
    .wood-step-actions button,
    .chain-step-actions button,
    .aluminum-step-actions button,
    .post-step-actions button,
    .cost-step-nav button,
    .privacy-step-nav button,
    .pool-step-nav button,
    .dog-segmented button,
    .pool-segmented button,
    .cost-segmented button,
    .privacy-segmented button
  ) {
    min-height: 38px !important;
    padding: 0.5rem 0.64rem !important;
    border-radius: 10px !important;
  }
}

@media (max-width: 767px) and (max-height: 740px) {
  .wood-subtitle,
  .vinyl-subtitle,
  .chain-subtitle,
  .aluminum-subtitle,
  .post-subtitle,
  .cost-subtitle,
  .privacy-subtitle,
  .dog-subtitle,
  .pool-subtitle,
  .backyard-subtitle {
    display: none !important;
  }
}
