* {
  box-sizing: border-box;
}

:root {
  --red: #990000;
  --red-dark: #760000;
  --text: #151515;
  --muted: #666;
  --line: #dedede;
  --bg: #f5f5f6;
  --card: #ffffff;
  --soft-red: #fff4f4;
}

body {
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  width: 100%;
  min-height: 100vh;
  padding: 28px 18px 48px;
}

.form-card {
  width: min(1080px, 100%);
  margin: 0 auto;
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.10);
  overflow: hidden;
}

.top-line {
  height: 10px;
  background: var(--red);
}

.form-header {
  text-align: center;
  padding: 42px 28px 24px;
}

.form-header .eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-weight: 700;
}

.form-header h1 {
  margin: 0;
  color: var(--red);
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.25;
}

.form-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.section-card {
  margin: 20px 34px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.section-card h2 {
  margin: 0 0 20px;
  color: var(--red);
  font-size: 22px;
}

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

.section-heading h2 {
  margin-bottom: 0;
}

.copy-address-btn {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--red);
  border-radius: 6px;
  background: #fff;
  color: var(--red);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.copy-address-btn:hover,
.copy-address-btn:focus-visible {
  background: var(--soft-red);
}

.section-card h3 {
  margin: 18px 0 12px;
  font-size: 17px;
  color: #222;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  height: 44px;
  margin-top: 7px;
  padding: 10px 12px;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: #111;
}

select {
  cursor: pointer;
}

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

input[type="file"] {
  height: auto;
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(153, 0, 0, 0.15);
  border-color: var(--red);
}

input[list] {
  background-image: linear-gradient(45deg, transparent 50%, #777 50%),
    linear-gradient(135deg, #777 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:disabled,
input.is-disabled-by-choice {
  background: #f0f0f0;
  color: #999;
  cursor: not-allowed;
}

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

.grid.two {
  grid-template-columns: repeat(2, 1fr);
}

.grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.grid.four {
  grid-template-columns: repeat(4, 1fr);
}

.grid.six {
  grid-template-columns: repeat(6, 1fr);
}

.choice-box {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  padding: 15px;
  margin: 12px 0 16px;
  border: 1px solid #ead0d0;
  border-radius: 12px;
  background: var(--soft-red);
}

.choice-box p {
  width: 100%;
  margin: 0 0 4px;
  font-weight: 800;
  color: var(--red);
}

.choice-box label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}

.choice-box input[type="radio"],
.choice-box input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
}

.choice-box input[type="text"] {
  max-width: 340px;
  margin: 0;
}

.choice-box input[type="text"]:disabled {
  opacity: 0.65;
}

.sibling-grid {
  display: grid;
  grid-template-columns: 2fr 0.7fr 1fr 2fr;
  gap: 10px;
}

.hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.note {
  padding: 12px 14px;
  border-left: 5px solid var(--red);
  background: var(--soft-red);
  border-radius: 8px;
  color: #3a3a3a;
  line-height: 1.6;
}

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

.submit-area {
  margin: 28px 34px 34px;
}

.submit-area button {
  width: 100%;
  min-height: 58px;
  border: none;
  border-radius: 6px;
  background: var(--red);
  color: white;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s;
}

.submit-area button:hover {
  background: var(--red-dark);
}

.submit-area button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.action-row button {
  width: 100%;
}

.btn-preview {
  min-height: 58px;
  border: 1px solid var(--red) !important;
  border-radius: 6px;
  background: #ffffff !important;
  color: var(--red) !important;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s;
}

.btn-preview:hover {
  background: var(--soft-red) !important;
}

.btn-preview:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-message {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  font-weight: 700;
}

.form-message.success {
  color: #0b6b2b;
  background: #e8f8ee;
  border: 1px solid #b8e7c7;
}

.form-message.error {
  color: #9b0000;
  background: #fff0f0;
  border: 1px solid #f0bcbc;
}

@media (max-width: 900px) {
  .grid.two,
  .grid.three,
  .grid.four,
  .grid.six,
  .sibling-grid {
    grid-template-columns: 1fr;
  }

  .section-card,
  .submit-area {
    margin-left: 18px;
    margin-right: 18px;
  }

  .section-card {
    padding: 18px;
  }

  .choice-box {
    align-items: stretch;
  }

  .choice-box label {
    width: 100%;
  }

  .choice-box input[type="text"] {
    max-width: 100%;
  }

  .section-heading {
    align-items: stretch;
  }

  .copy-address-btn {
    width: 100%;
  }
}

.form-card [hidden] { display: none !important; }
.form-header .form-intro { font-size: 16px; color: var(--red); }
.form-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 34px 16px; }
.form-steps button { padding: 15px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: #fff; font: inherit; cursor: pointer; }
.form-steps button span { display: block; font-weight: 800; margin-bottom: 4px; }
.form-steps button[aria-current="step"] { background: var(--soft-red); border-color: var(--red); color: var(--red); }
.form-scope-note { margin: 0 34px 28px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.form-page-title { margin: 24px 34px 8px; color: var(--red); font-size: 21px; scroll-margin-top: 140px; }
.form-page-title:focus { outline: none; }
.step-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-bottom: 20px; }
.step-controls span { color: var(--muted); font-size: 14px; text-align: center; }
.submit-area .step-controls button { min-height: 44px; font-size: 16px; }
.attachment-preview { display: block; max-width: 100%; max-height: 240px; margin-top: 12px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; }
.form-card input[readonly] { background: #f5f5f5; color: #555; }
@media (max-width: 700px) {
  .form-steps { margin: 8px 18px 16px; gap: 6px; }
  .form-steps button { font-size: 12px; padding: 12px 6px; }
  .form-steps button span { font-size: 16px; }
  .form-page-title, .form-scope-note { margin-left: 18px; margin-right: 18px; }
  .step-controls { gap: 8px; }
}

@media (max-width: 700px) {
  .action-row {
    grid-template-columns: 1fr;
  }
}
