/*
 * Custom form step 1 — approved mobile profile composition.
 * This file loads after the shared content shell so the layout follows the
 * 480px content container even when an external browser viewport is wider.
 */

body.gx-app[data-page-id="custom_form"][data-form-step="1"] {
  --profile-bg: var(--gx-ui-page, #fcfcf8);
  --profile-surface: var(--gx-ui-surface, #ffffff);
  --profile-ink: var(--gx-ui-text, #211f1b);
  --profile-muted: var(--gx-ui-muted, #625f58);
  --profile-accent: var(--gx-ui-primary, #4c6331);
  --profile-accent-hover: var(--gx-ui-primary-hover, #405329);
  --profile-accent-soft: var(--gx-ui-soft, #e7eddf);
  --profile-border: var(--gx-ui-border, #cfd7c7);
  --profile-disabled: var(--gx-ui-disabled-bg, #f4f5f0);
  --profile-error: var(--gx-ui-error, #9b382d);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-page {
  width: 100%;
  min-height: calc(100dvh - var(--gx-content-header-top-min, 78px));
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) calc(34px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  background: var(--profile-bg);
  box-sizing: border-box;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-stepper-row,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .form-stepper {
  display: none;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] {
  width: 100%;
  max-width: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-section-heading {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  min-height: 58px;
  padding: 0 44px;
  text-align: center;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-section-heading h2 {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  color: var(--profile-ink);
  font-family: var(--gx-content-header-font, "Noto Serif TC", "Songti TC", serif);
  font-size: clamp(26px, 6.8cqi, 30px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-section-heading > span {
  grid-column: 1;
  grid-row: 2;
  margin-top: 4px;
  color: var(--profile-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-home-return:not([hidden]) {
  position: absolute;
  z-index: 1;
  top: -6px;
  left: 0;
  grid-column: auto;
  grid-row: auto;
  justify-self: auto;
  align-self: auto;
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  margin: 0;
  border: 0;
  border-radius: 12px;
  padding: 0;
  place-items: center;
  background: transparent;
  color: var(--profile-accent);
  box-shadow: none;
  cursor: pointer;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-home-return svg {
  width: 23px;
  height: 23px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-home-return:hover {
  background: var(--profile-accent-soft);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-home-return:focus-visible {
  outline: 3px solid var(--gx-ui-focus, rgba(76, 99, 49, 0.3));
  outline-offset: 1px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-sections {
  display: grid;
  gap: 0;
  margin-top: 24px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section {
  display: grid;
  gap: 20px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-identity-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
  min-width: 0;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-time-row,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-location-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-location-row {
  gap: 20px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .choice-field {
  display: grid;
  min-width: 0;
  gap: 9px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field > span,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .choice-field legend {
  color: var(--profile-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field b,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .choice-field legend b {
  margin-left: 5px;
  color: var(--profile-accent);
  font-size: 12px;
  font-weight: 700;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field input,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field select,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .lunar-date-grid select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 52px;
  min-height: 52px;
  border: 1px solid var(--profile-border);
  border-radius: 14px;
  padding: 0 14px;
  background: var(--profile-surface);
  color: var(--profile-ink);
  box-shadow: none;
  font: inherit;
  font-size: 16px;
  line-height: normal;
  outline: none;
  box-sizing: border-box;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field select,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .lunar-date-grid select {
  padding-right: 34px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-native, .birth-region-native, .birth-city-native, .lunar-date-native)[hidden] {
  display: none;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-picker, .birth-region-picker, .birth-city-picker, .lunar-date-picker) {
  position: relative;
  z-index: 1;
  min-width: 0;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-picker, .birth-region-picker, .birth-city-picker, .lunar-date-picker).is-open {
  z-index: 70;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-trigger, .birth-region-trigger, .birth-city-trigger, .lunar-date-trigger) {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  width: 100%;
  min-width: 0;
  height: 52px;
  min-height: 52px;
  align-items: center;
  border: 1px solid var(--profile-border);
  border-radius: 14px;
  padding: 0 38px 0 14px;
  background-color: var(--profile-surface);
  background-image: url("/gx-customer-assets/assets/icons/chevron-down-lucide.svg?v=2ae54e4d23ce4464899f");
  background-position: right 14px center;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  color: var(--profile-ink);
  box-shadow: none;
  font: inherit;
  font-size: 16px;
  line-height: normal;
  text-align: left;
  outline: none;
  box-sizing: border-box;
  cursor: pointer;
  touch-action: manipulation;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-trigger, .birth-region-trigger, .birth-city-trigger, .lunar-date-trigger) span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-trigger, .birth-region-trigger, .birth-city-trigger, .lunar-date-trigger):disabled {
  border-color: var(--gx-ui-disabled-border, #dde0d8);
  background-color: var(--profile-disabled);
  color: var(--gx-ui-disabled-text, #7c7c75);
  cursor: not-allowed;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-picker, .birth-region-picker, .birth-city-picker, .lunar-date-picker).is-open :is(.gender-trigger, .birth-region-trigger, .birth-city-trigger, .lunar-date-trigger),
body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-trigger, .birth-region-trigger, .birth-city-trigger, .lunar-date-trigger):focus-visible {
  border-color: var(--profile-accent);
  box-shadow: 0 0 0 3px rgba(var(--gx-ui-primary-rgb, 76, 99, 49), 0.16);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-trigger, .birth-region-trigger, .birth-city-trigger, .lunar-date-trigger)[aria-invalid="true"] {
  border-color: var(--profile-error);
  box-shadow: 0 0 0 3px rgba(var(--gx-ui-shadow-rgb, 155, 56, 45), 0.1);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-menu, .birth-region-menu, .birth-city-menu, .lunar-date-menu) {
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  top: calc(100% + 8px);
  max-height: min(280px, calc(100dvh - 144px));
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--profile-border);
  border-radius: 14px;
  background: var(--profile-surface);
  box-shadow: 0 16px 38px rgba(var(--gx-ui-shadow-rgb, 44, 52, 35), 0.18);
  box-sizing: border-box;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-menu, .birth-region-menu, .birth-city-menu, .lunar-date-menu)[hidden] {
  display: none;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-option, .birth-region-option, .birth-city-option, .lunar-date-option) {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  background: transparent;
  color: var(--profile-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  text-align: left;
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-option, .birth-region-option, .birth-city-option, .lunar-date-option):hover,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-option, .birth-region-option, .birth-city-option, .lunar-date-option):focus-visible {
  background: var(--profile-accent-soft);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.gender-option, .birth-region-option, .birth-city-option, .lunar-date-option).is-selected {
  background: var(--profile-accent);
  color: #ffffff;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.lunar-date-trigger, .lunar-date-option) {
  font-variant-numeric: tabular-nums;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field input::placeholder {
  color: var(--gx-ui-muted, #77766f);
  opacity: 1;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field input:focus-visible,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field select:focus-visible,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .lunar-date-grid select:focus-visible {
  border-color: var(--profile-accent);
  box-shadow: 0 0 0 3px rgba(var(--gx-ui-primary-rgb, 76, 99, 49), 0.16);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section :is(input, select)[aria-invalid="true"] {
  border-color: var(--profile-error);
  box-shadow: 0 0 0 3px rgba(var(--gx-ui-shadow-rgb, 155, 56, 45), 0.1);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field input:disabled,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-section .field select:disabled {
  border-color: var(--gx-ui-disabled-border, #dde0d8);
  background: var(--profile-disabled);
  color: var(--gx-ui-disabled-text, #7c7c75);
  opacity: 1;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .native-datetime-control {
  display: block;
  width: 100%;
  min-width: 0;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .native-datetime-control input {
  width: 100%;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .calendar-type-options,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .loop-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .calendar-type-card,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .loop-card {
  position: relative;
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--profile-border);
  border-radius: 14px;
  background: var(--profile-surface);
  color: var(--profile-ink);
  box-shadow: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.calendar-type-card, .loop-card).is-selected {
  border-color: var(--profile-accent);
  background: var(--profile-accent-soft);
  color: var(--gx-ui-selected-text, #26331a);
  box-shadow: none;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.calendar-type-card, .loop-card):focus-within {
  outline: 3px solid var(--gx-ui-focus, rgba(76, 99, 49, 0.26));
  outline-offset: 2px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .lunar-date-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.8fr 0.8fr;
  gap: 8px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-time-row .check-row {
  display: inline-flex;
  width: fit-content;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--profile-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-time-row .check-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--profile-accent);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-time-row .check-row input:focus-visible {
  outline: 3px solid var(--gx-ui-focus, rgba(76, 99, 49, 0.28));
  outline-offset: 3px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .field-label-row button {
  min-height: 44px;
  margin: -10px 0;
  border-radius: 10px;
  color: var(--profile-accent);
  font-size: 12px;
  font-weight: 700;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .field-label-row button:hover {
  background: var(--profile-accent-soft);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .unit-input em {
  color: var(--profile-accent);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .wrist-field small,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-loop-field .helper-text,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .lunar-date-field small {
  margin: 0;
  color: var(--profile-muted);
  font-size: 12px;
  line-height: 1.55;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-field-error,
body.gx-app[data-page-id="custom_form"][data-form-step="1"] .wrist-field-error {
  min-height: 0;
  margin: 0;
  color: var(--profile-error);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] :is(.step-one-field-error, .wrist-field-error):empty {
  display: none;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-date-error {
  margin-top: -12px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-loop-field {
  margin-top: 0;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-error:empty {
  display: none;
  min-height: 0;
  margin: 0;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-actions {
  margin-top: 24px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-primary {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 17px;
  background: var(--profile-accent);
  color: #ffffff;
  box-shadow: none;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-primary:hover {
  background: var(--profile-accent-hover);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-primary:active {
  transform: translateY(1px);
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-primary:focus-visible {
  outline: 3px solid var(--gx-ui-focus, rgba(76, 99, 49, 0.32));
  outline-offset: 3px;
}

body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-privacy {
  margin: 13px 8px 0;
  color: var(--profile-muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

@container gx-content-shell (max-width: 359px) {
  body.gx-app[data-page-id="custom_form"][data-form-step="1"] .custom-form-page {
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
  }

  body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-section-heading {
    padding-right: 40px;
    padding-left: 40px;
  }

  body.gx-app[data-page-id="custom_form"][data-form-step="1"] [data-form-panel="1"] .form-section-heading h2 {
    font-size: 24px;
  }

  body.gx-app[data-page-id="custom_form"][data-form-step="1"] .step-one-identity-row,
  body.gx-app[data-page-id="custom_form"][data-form-step="1"] .calendar-type-options,
  body.gx-app[data-page-id="custom_form"][data-form-step="1"] .loop-options {
    gap: 8px;
  }
}

.custom-form .birth-place-editable {
  display: flex;
  position: relative;
  gap: 0;
}
.custom-form .birth-place-editable > input {
  width: 100%;
  min-width: 0;
  padding-right: 52px;
}
.custom-form .birth-place-editable > button {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px !important;
  min-width: 48px !important;
  height: 100%;
  padding: 0 !important;
  border: 0 !important;
  background-color: transparent !important;
  box-shadow: none !important;
}
.custom-form .birth-place-editable > button > span { display: none; }

@media (prefers-reduced-motion: reduce) {
  body.gx-app[data-page-id="custom_form"][data-form-step="1"] *,
  body.gx-app[data-page-id="custom_form"][data-form-step="1"] *::before,
  body.gx-app[data-page-id="custom_form"][data-form-step="1"] *::after {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}
