:root {
  --mobile-nav-height: 72px;
  --mobile-fab-size: 52px;
}

body.mobile-mode {
  padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
}

body.mobile-mode [data-step-help-container],
body.mobile-mode .nav-steps-footer {
  display: none !important;
}

body.mobile-mode #mobileStepNav {
  display: flex;
}

body.mobile-mode .label-with-code {
  gap: 6px;
  flex-wrap: wrap;
}

body.mobile-mode .code-badge {
  font-size: 11px;
  padding: 4px 6px;
  gap: 2px;
  line-height: 1.1;
  flex-direction: column;
  align-items: center;
  text-align: center;
  white-space: normal;
  min-width: 48px;
  max-width: 60px;
}

#mobileStepNav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--color-nav-bg, #ffffff);
  border-top: 1px solid var(--color-nav-border, #e2e8f0);
  box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.12);
}

#mobileStepNav .mobile-step-nav__btn {
  flex: 1 1 0;
  min-height: 44px;
  border-radius: 14px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#mobileStepNav .mobile-step-nav__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#mobileStepNav .mobile-step-nav__btn--prev {
  background: var(--color-nav-prev-bg, #f8fafc);
  color: var(--color-nav-prev-text, #0f172a);
  border-color: var(--color-nav-prev-border, #e2e8f0);
}

#mobileStepNav .mobile-step-nav__btn--next {
  background: var(--color-nav-next-bg, #2563eb);
  color: var(--color-nav-next-text, #ffffff);
  border-color: var(--color-nav-next-border, #2563eb);
}

#mobileStepNav .mobile-step-nav__btn:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: none;
}

.mobile-help-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom));
  z-index: 60;
  display: none;
  align-items: flex-end;
  flex-direction: column;
  gap: 10px;
}

body.mobile-mode .mobile-help-fab {
  display: flex;
}

.mobile-help-fab__button {
  width: var(--mobile-fab-size);
  height: var(--mobile-fab-size);
  border-radius: 9999px;
  background: var(--color-nav-next-bg, #2563eb);
  color: #fff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.3);
}

.mobile-help-menu {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
  min-width: 200px;
}

.mobile-help-fab.is-open .mobile-help-menu {
  display: flex;
}

.mobile-help-menu button {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: var(--color-bg-alt, #f8fafc);
  color: var(--color-text, #0f172a);
  font-weight: 600;
}

.mobile-help-menu button:active {
  transform: translateY(1px);
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  header.hero-panel,
  header {
    padding: 1rem !important;
    margin-bottom: 1.5rem !important;
  }

  header .step-title,
  header .title {
    font-size: 1.5rem !important;
    line-height: 1.2 !important;
  }

  header .step-progress,
  header .body {
    font-size: 0.75rem !important;
  }

  .hero-panel img {
    height: 48px;
    margin-bottom: 0.75rem;
  }

  .surface-card,
  main {
    padding: 1rem !important;
  }

  .card-head {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .input,
  .select,
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (orientation: landscape) and (max-width: 1024px) {
  body.mobile-mode .surface-card .grid.mobile-landscape-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
