* {
  box-sizing: border-box;
}

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2937;
  background: #f4f7fb;
  font-synthesis: none;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 32rem),
    #f4f7fb;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.app-header {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.intro {
  max-width: 720px;
  margin-bottom: 0;
  color: #64748b;
  line-height: 1.65;
}

.card {
  margin-bottom: 20px;
  padding: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.06);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading-actions {
  flex-wrap: wrap;
}

.step {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 800;
}

.section-copy {
  margin: -8px 0 20px;
  color: #64748b;
  font-size: 0.92rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-full {
  grid-column: 1 / -1;
}

label,
.choice-label {
  color: #334155;
  font-size: 0.9rem;
  font-weight: 700;
}

small {
  color: #94a3b8;
  font-size: 0.78rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input,
select {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  padding: 13px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

input:invalid:not(:placeholder-shown),
select:invalid:focus {
  border-color: #dc2626;
}

.choice-block {
  margin-bottom: 22px;
}

.choice-label {
  display: block;
  margin-bottom: 10px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
}

.choice input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.positions {
  display: grid;
  gap: 14px;
}

.position-card {
  padding: 18px;
  border: 1px solid #dbe3ee;
  border-radius: 16px;
  background: #f8fafc;
}

.position-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 12px;
  font-weight: 800;
}

.button-primary {
  background: #2563eb;
  color: white;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.button-primary:hover {
  background: #1d4ed8;
}

.button-secondary {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.button-secondary:hover,
.button-ghost:hover {
  background: #f1f5f9;
}

.button-ghost {
  background: transparent;
  color: #475569;
}

.icon-button {
  padding: 8px 10px;
  border-radius: 10px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.82rem;
  font-weight: 800;
}

.icon-button:hover {
  background: #fecaca;
}

.preview-card {
  overflow: hidden;
}

.xml-preview {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 18px;
  border-radius: 14px;
  background: #0f172a;
  color: #dbeafe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
}

.message-box {
  display: none;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 700;
}

.message-box.success,
.message-box.error {
  display: block;
}

.message-box.success {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.message-box.error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.action-bar {
  position: sticky;
  bottom: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 24px;
  }

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

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-full {
    grid-column: auto;
  }

  .section-heading,
  .position-header,
  .action-bar {
    align-items: stretch;
  }

  .section-heading,
  .position-header {
    flex-direction: column;
  }

  .action-bar {
    flex-direction: column-reverse;
  }

  .button {
    width: 100%;
  }
}
