html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root {
  color-scheme: light;
  --bg: #f9fafb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --danger: #ef4444;
  --success: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: clip;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
}

.card {
  width: min(680px, 100%);
  max-width: 100%;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  overflow-x: hidden;
}

.draft-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid #fbbf24;
  background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 55%, #fffbeb 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 8px rgba(180, 83, 9, 0.07);
}

.draft-banner__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(251, 191, 36, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b45309;
}

.draft-banner__body {
  min-width: 0;
  flex: 1;
}

.draft-banner__title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
  color: #78350f;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.draft-banner__lead {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #92400e;
  line-height: 1.5;
}

.draft-banner__steps {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(251, 191, 36, 0.45);
  font-size: 13px;
  font-weight: 600;
  color: #78350f;
  line-height: 1.55;
}

.draft-banner__steps-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #b45309;
}

.draft-banner[hidden] {
  display: none !important;
}

.cover-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 12px;
  line-height: 0;
  background: #f3f4f6;
}

.form-cover {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
}

.header {
  min-width: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.progress {
  margin-top: 12px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.form-logo {
  display: block;
  max-width: 160px;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin-bottom: 10px;
  border-radius: 10px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.muted {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.form {
  margin-top: 20px;
  display: grid;
  gap: 14px;
}

.form.form--short {
  gap: 16px;
}

.form.form--long {
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field--spacious {
  gap: 14px;
}

.field--hidden-by-condition {
  display: none;
}

.field label {
  font-size: 13px;
  font-weight: 600;
}

.radio-group {
  display: grid;
  gap: 8px;
}

.radio-row,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.checkbox-group,
.rating-group {
  display: grid;
  gap: 8px;
}

.address-group {
  display: grid;
  gap: 8px;
}

.address-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.field--spacious .radio-group,
.field--spacious .checkbox-group,
.field--spacious .rating-group,
.field--spacious .address-group {
  gap: 12px;
}

.field--spacious .radio-row,
.field--spacious .checkbox-row,
.field--spacious .rating-row {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.field--spacious .address-row {
  gap: 12px;
}

.field--spacious input[type="file"] {
  padding-top: 13px;
  padding-bottom: 13px;
}

.field-section-title {
  margin: 6px 0 2px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.field-section-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.field-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.signature-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.signature-canvas {
  width: 100%;
  height: 130px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.signature-clear-btn,
.signature-upload-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
}

.signature-clear-btn {
  margin-top: 0;
  height: auto;
}

.signature-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.signature-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  cursor: pointer;
}

.signature-upload-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.signature-upload-preview {
  width: 100%;
  max-height: 96px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #f8fafc;
}

.required {
  color: var(--danger);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

/* Native radios/checkboxes must not use full-width text-field rules */
input[type="radio"],
input[type="checkbox"] {
  width: auto;
  max-width: none;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  accent-color: var(--primary);
}

select:invalid {
  color: var(--muted);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.submit-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.submit-row button {
  margin-top: 0;
  width: 100%;
}

button {
  margin-top: 8px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.form.form--short .submit-row {
  margin-top: 16px;
}

.form.form--medium .submit-row {
  margin-top: 10px;
}

.form.form--long .submit-row {
  margin-top: 6px;
}

button:disabled {
  opacity: 0.65;
  cursor: default;
}

.state {
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}

.state.error {
  color: var(--danger);
}

.state.success {
  color: var(--success);
}

.state.note {
  color: var(--muted);
}

.form-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.form-footer__inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.form-footer__logo {
  width: 18px;
  height: 18px;
  display: inline-block;
  object-fit: contain;
  flex-shrink: 0;
  vertical-align: middle;
}

.form-footer__link {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.form-footer__link:hover {
  color: var(--primary);
}

@media (max-width: 480px) {
  .page {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .card {
    padding: 18px 14px;
    border-radius: 14px;
  }

  h1 {
    font-size: clamp(1.35rem, 6.5vw, 28px);
    word-break: break-word;
  }

  .muted {
    font-size: 13px;
  }

  .address-row {
    grid-template-columns: 1fr;
  }

  .radio-row,
  .checkbox-row {
    align-items: flex-start;
    gap: 10px;
  }

  .field--spacious {
    gap: 12px;
  }

  .field--spacious .radio-group,
  .field--spacious .checkbox-group,
  .field--spacious .rating-group,
  .field--spacious .address-group {
    gap: 11px;
  }

  .field--spacious .radio-row,
  .field--spacious .checkbox-row,
  .field--spacious .rating-row {
    padding: 11px 12px;
  }

  .field--spacious .address-row {
    gap: 10px;
  }

  .field--spacious .signature-wrap {
    padding: 13px;
    gap: 12px;
  }

  input[type="radio"],
  input[type="checkbox"] {
    margin-top: 3px;
  }
}

@media (max-width: 420px) {
  .draft-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .draft-banner__icon {
    align-self: flex-start;
  }
}
