@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600&display=swap");

:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #2a2520;
  --muted: #8d8379;
  --accent: #c58b36;
  --accent-dark: #a16b1f;
  --border: #efe4d5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Avenir Next", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.shell {
  min-height: 100vh;
  padding: 24px clamp(18px, 6vw, 90px);
  display: grid;
  gap: clamp(10px, 1.5vw, 14px);
  align-content: start;
}

.stage-bar {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-top: 16px;
  position: relative;
}

.stage-bar::before,
.stage-bar::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 4px;
  border-radius: 999px;
}

.stage-bar::before {
  right: 0;
  background: #f4e5d1;
}

.stage-bar::after {
  width: var(--progress, 0%);
  background: var(--accent);
  transition: width 0.25s ease;
}

.stage-back {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
}

.stage-back[disabled] {
  opacity: 0.4;
  cursor: default;
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 220px));
  gap: 32px;
}

.stage {
  display: grid;
  gap: 4px;
}

.stage__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #d8cbb7;
}

.stage__title {
  font-size: 14px;
  color: #cfc6be;
}

.stage.is-active .stage__label {
  color: var(--accent);
}

.stage.is-active .stage__title {
  color: #6f665f;
}

.stage.is-done .stage__label,
.stage.is-done .stage__title {
  color: #b8afa6;
}

.form-shell {
  width: 100%;
}

.step-layout {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 160px;
  align-items: start;
  gap: 40px;
  min-height: auto;
  justify-content: start;
}

.step-fields {
  display: grid;
  gap: 18px;
}

.step-question {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.step-question.is-hidden {
  display: none;
}

.steps {
  display: grid;
}

.form-step {
  display: none;
  animation: fadeSlide 0.25s ease;
}

.form-step.is-active {
  display: block;
}

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

.field__label {
  position: absolute;
  left: -9999px;
}

.chip-question {
  font-size: 13px;
  color: var(--muted);
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.chip-grid--inline {
  gap: 8px;
}

.chip {
  border: 1px solid #e2d7cc;
  background: #f6f3ef;
  color: #9a928a;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.chip--toggle {
  min-width: 48px;
  text-transform: none;
}

.chip.is-active,
.chip:focus {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

input,
select,
textarea {
  margin: 0;
  padding: 0 0 10px 0;
  border: none;
  border-bottom: 2px solid #e5d9cb;
  font-size: 24px;
  font-family: "Manrope", "Avenir Next", sans-serif;
  background: transparent;
  width: 100%;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: #c9c1b9;
}

select {
  color: var(--ink);
}

select:invalid {
  color: #c9c1b9;
}

select option {
  color: var(--ink);
}

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

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.field--amount .field__input {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid #e5d9cb;
  padding-bottom: 8px;
}

.field--amount .field__prefix {
  font-size: 26px;
  color: #b9b1a9;
}

.field--amount input {
  border-bottom: none;
  padding: 0;
  color: #b9b1a9;
}

.field--amount input:focus {
  color: var(--ink);
}

.field--amount-secondary .field__prefix {
  color: #b8b0a8;
}

.field--amount-secondary input {
  color: #b8b0a8;
}

.field__error {
  display: none;
  font-size: 12px;
  color: #e04838;
  margin-top: 6px;
}

.field__error.is-visible {
  display: block;
}

.info-block {
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.info-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #b7ada3;
}

.info-text {
  margin: 0;
  font-size: 13px;
  color: #c5bdb5;
  line-height: 1.5;
}

.info-block textarea {
  min-height: 140px;
}

.agreement {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #9c9288;
}

.agreement input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border: 1px solid #cfc6be;
  border-radius: 2px;
  margin: 0;
}

.step-action {
  display: grid;
  gap: 12px;
  justify-items: start;
  align-self: center;
}

button {
  border: none;
  padding: 12px 28px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: white;
  border-radius: 4px;
  min-width: 140px;
  text-align: center;
}

.primary:hover {
  background: var(--accent-dark);
}

.status {
  font-size: 13px;
  color: var(--muted);
}

.form-message {
  position: fixed;
  inset: 0;
  padding: 24px;
  background: rgba(255, 255, 255, 0.85);
  color: #9b4a1a;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  text-align: center;
  backdrop-filter: blur(4px);
  opacity: 1;
  transition: none;
}

.form-message.is-visible {
  display: flex;
}

.form-message.is-success {
  background: rgba(239, 247, 237, 0.85);
  border-color: transparent;
  color: #2f6a2d;
}

.form-message.is-error {
  background: rgba(254, 245, 232, 0.85);
  border-color: transparent;
  color: #9b4a1a;
}

.form-message__card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #efe4d5;
  padding: 28px 32px;
  display: grid;
  gap: 16px;
  align-items: center;
  max-width: min(520px, 90vw);
  box-shadow: 0 18px 40px rgba(32, 22, 9, 0.18);
  transform: none;
  transition: none;
  opacity: 1;
}

.form-message__close {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  letter-spacing: 0.08em;
}

.debug-output {
  margin-top: 18px;
  background: #1d1a17;
  color: #f5f1eb;
  padding: 14px;
  overflow-x: auto;
  font-size: 12px;
  border-radius: 6px;
  display: none;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .stage-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .step-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 16px;
  }

  input,
  select,
  textarea {
    font-size: 20px;
  }
}

@media (max-height: 760px) {
  .shell {
    padding: 14px clamp(14px, 4vw, 40px);
    gap: 12px;
  }

  .stage-bar {
    gap: 12px;
    padding-top: 8px;
  }

  .stage-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .stage__label {
    font-size: 10px;
    letter-spacing: 0.16em;
  }

  .stage__title {
    font-size: 12px;
  }

  .step-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
    justify-content: start;
    min-height: auto;
  }

  .chip-grid {
    gap: 8px;
  }

  .step-action {
    display: flex;
    justify-content: flex-start;
    padding: 0;
    border-top: none;
    position: static;
  }

  .step-action .primary {
    width: auto;
  }
}

.shell.is-compact {
  padding: 14px clamp(14px, 4vw, 40px);
  gap: 12px;
}

.shell.is-compact .stage-bar {
  gap: 12px;
  padding-top: 8px;
}

.shell.is-compact .stage-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.shell.is-compact .stage__label {
  font-size: 10px;
  letter-spacing: 0.16em;
}

.shell.is-compact .stage__title {
  font-size: 12px;
}

.shell.is-compact .step-layout {
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  justify-content: start;
  min-height: auto;
}

.shell.is-compact .step-fields {
  gap: 14px;
}

.shell.is-compact .step-question,
.shell.is-compact .chip-question {
  font-size: 12px;
}

.shell.is-compact .chip-grid {
  gap: 8px;
}

.shell.is-compact .chip {
  padding: 6px 10px;
  font-size: 11px;
}

.shell.is-compact input,
.shell.is-compact select,
.shell.is-compact textarea {
  font-size: 18px;
}

.shell.is-compact .step-action {
  display: flex;
  justify-content: flex-start;
  padding: 0;
  border-top: none;
  position: static;
}

.shell.is-compact .step-action .primary {
  width: auto;
}
