/* === Design Tokens === */
:root {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-border: #e2e8f0;
  --color-primary: #0d9488; /* teal-600 */
  --color-primary-hover: #0f766e;
  --color-primary-light: #ccfbf1;
  --color-error: #ef4444;
  --color-error-bg: #fef2f2;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --tap-min: 44px;
}

/* === Reset / Base === */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Page Shell === */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) calc(var(--space-xl) + 80px);
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}
.logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 4px 10px;
  border-radius: 999px;
}

/* === Sections === */
.section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}

/* === Fields === */
.field { margin-bottom: var(--space-md); }
.field:last-child { margin-bottom: 0; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.req { color: var(--color-error); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
input::placeholder,
textarea::placeholder { color: #94a3b8; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
/* Keep native dropdown arrow on iOS */
@supports (-webkit-touch-callout: none) {
  select { background-image: none; padding-right: 12px; }
}

textarea { resize: vertical; min-height: 80px; }
.hint {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 4px;
}
.error {
  display: block;
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 6px;
  min-height: 1.2em;
}

/* === Radio Group === */
.radio-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.radio-btn {
  position: relative;
  flex: 1 1 120px;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--color-surface);
  transition: border-color .15s ease, background .15s ease;
  font-weight: 500;
  font-size: 0.95rem;
  user-select: none;
}
.radio-btn input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.radio-btn:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: #0f766e;
}

/* === Checkbox === */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-text);
}
.checkbox-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  margin-top: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.checkbox-text strong { color: #0f766e; }

/* === Hidden === */
.hidden { display: none !important; }

/* === Sticky Submit === */
.sticky-submit {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-top: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
}
.submit-btn {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.submit-btn:active { transform: translateY(1px); }
.submit-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.btn-loader {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.submit-btn.is-loading .btn-text { opacity: .9; }
.submit-btn.is-loading .btn-loader { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.submit-meta {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* === Toast === */
.toast {
  position: fixed;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: #1e293b;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  transition: transform .25s ease;
  white-space: nowrap;
}
.toast.is-visible { transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--color-error); }
.toast.toast-success { background: var(--color-success); }

/* === Spacer to clear sticky bar === */
.spacer { height: 20px; }

/* === Success Page === */
.success-page .main { padding-bottom: var(--space-xl); }
.success-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: 1.8rem;
  font-weight: 700;
}
.success-title {
  margin: 0 0 var(--space-sm);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
}
.success-body {
  margin: 0 0 var(--space-lg);
  color: var(--color-text-secondary);
  font-size: 1rem;
  line-height: 1.55;
}
.success-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s ease, transform .1s ease;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); }

.success-meta {
  font-size: 0.85rem;
  color: #94a3b8;
}
.success-meta code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--color-text);
  font-size: 0.8rem;
}

/* === Responsive === */
@media (max-width: 480px) {
  .page { padding: var(--space-md) var(--space-sm) calc(var(--space-xl) + 120px); }
  .section { padding: var(--space-md); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .field-row .field { margin-bottom: var(--space-md); }
  .success-card { padding: var(--space-lg) var(--space-md); }
}

@media (min-width: 641px) {
  .sticky-submit {
    position: static;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: none;
    padding: 0;
    margin-top: var(--space-lg);
  }
  .submit-btn { border-radius: var(--radius); }
  .page { padding-bottom: var(--space-xl); }
}
