:root {
  --bg-deep: #0a1628;
  --bg-mid: #12243f;
  --bg-soft: #e8f0fa;
  --bg-page: #f0f5fc;
  --card: rgba(255, 255, 255, 0.92);
  --card-solid: #ffffff;
  --text: #142033;
  --muted: #5a6d85;
  --line: rgba(20, 48, 88, 0.1);
  --primary: #0d4f9c;
  --primary-light: #1a6fd4;
  --primary-dark: #083a75;
  --accent: #e8a317;
  --accent-soft: #fff4d6;
  --danger: #c0392b;
  --success: #1a8f55;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 16px 48px rgba(10, 30, 60, 0.1);
  --shadow-lg: 0 24px 64px rgba(10, 30, 60, 0.14);
  --glass: blur(18px) saturate(1.2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

.survey-body {
  font-family: "Noto Sans Thai", "Segoe UI", sans-serif;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  background: var(--bg-page);
}

/* ── Ambient background ── */
.survey-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    linear-gradient(165deg, #dce9f8 0%, #f0f5fc 38%, #faf6ee 100%);
}

.survey-bg-mesh {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image:
    radial-gradient(circle at 20% 15%, rgba(13, 79, 156, 0.08) 0%, transparent 42%),
    radial-gradient(circle at 85% 75%, rgba(232, 163, 23, 0.1) 0%, transparent 38%),
    linear-gradient(rgba(13, 79, 156, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 79, 156, 0.03) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

.survey-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: orb-drift 22s ease-in-out infinite;
}

.survey-bg-orb--1 {
  width: 420px;
  height: 420px;
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(26, 111, 212, 0.35), transparent 70%);
}

.survey-bg-orb--2 {
  width: 360px;
  height: 360px;
  bottom: 10%;
  left: -100px;
  background: radial-gradient(circle, rgba(232, 163, 23, 0.28), transparent 70%);
  animation-delay: -8s;
  animation-duration: 28s;
}

.survey-bg-orb--3 {
  width: 280px;
  height: 280px;
  top: 45%;
  right: 10%;
  background: radial-gradient(circle, rgba(13, 79, 156, 0.2), transparent 70%);
  animation-delay: -14s;
  animation-duration: 32s;
}

@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -18px) scale(1.05); }
  66% { transform: translate(-16px, 12px) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  .survey-bg-orb { animation: none; }
}

/* ── Layout ── */
.page {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 140px;
}

.page.narrow { max-width: 520px; padding-top: 48px; }

/* ── Hero ── */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  border-radius: calc(var(--radius) + 6px);
  padding: 28px 28px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-lg);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 50%),
    linear-gradient(145deg, #0a3d7a 0%, #0d4f9c 45%, #1565c0 100%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.hero-content {
  flex: 1;
  min-width: 0;
}

.hero-logo-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  min-width: 120px;
}

.hero-logo {
  display: block;
  width: auto;
  height: clamp(88px, 15vw, 118px);
  max-width: 100%;
  object-fit: contain;
}

.hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -15%;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 65%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #f5c842, var(--accent));
}

.hero-badge {
  display: none;
}

.hero-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(22px, 4.5vw, 32px);
  font-weight: 700;
  line-height: 1.25;
  max-width: 28ch;
}

.hero-sub {
  margin: 0 0 18px;
  opacity: 0.9;
  font-size: 15px;
  max-width: 36ch;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
}

/* ── Cards ── */
.card {
  background: var(--card);
  backdrop-filter: var(--glass);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card--section {
  border-top: 3px solid transparent;
}

.card--blue { border-top-color: var(--primary-light); }
.card--gold { border-top-color: var(--accent); }
.card--sign { border-top-color: var(--success); }
.card--meta { border-top-color: #7b8fa8; }

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.section-num {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.card--gold .section-num {
  background: linear-gradient(135deg, #c8870a, var(--accent));
}

.card--sign .section-num {
  background: linear-gradient(135deg, #157a42, var(--success));
}

.card h2 {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}

.lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  padding: 12px 14px;
  background: rgba(13, 79, 156, 0.05);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary-light);
}

.muted { color: var(--muted); font-size: 14px; }

/* ── Form fields ── */
.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field span { font-size: 13px; font-weight: 600; color: #2a3d55; }
.field em { color: var(--danger); font-style: normal; }

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  background: var(--card-solid);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26, 111, 212, 0.15);
}

/* ── Choices ── */
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.choice-row.compact .choice { font-size: 13px; padding: 8px 12px; }

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card-solid);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  user-select: none;
}

.choice:hover {
  border-color: rgba(13, 79, 156, 0.25);
  background: #f5f9ff;
}

.choice:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(135deg, #e8f2fc, #f0f7ff);
  color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(13, 79, 156, 0.12);
}

.choice input { accent-color: var(--primary); }

/* ── Checkboxes ── */
.check-group {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 0 0 14px;
  background: rgba(255,255,255,0.6);
}

.check-group legend {
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #2a3d55;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0;
  font-size: 14px;
  cursor: pointer;
}

.check input { margin-top: 3px; accent-color: var(--primary); }

/* ── Sub-panels ── */
.sub-panel {
  border-left: 4px solid var(--accent);
  padding: 4px 0 4px 16px;
  margin: 12px 0 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.repeat-list { display: grid; gap: 14px; }

.repeat-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: linear-gradient(180deg, #fafcff, #fff);
  box-shadow: 0 4px 16px rgba(10, 30, 60, 0.04);
}

.repeat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}

.repeat-head strong {
  font-size: 14px;
  color: var(--primary);
}

.wish-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.wish-list { display: grid; gap: 10px; }

.wish-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  transition: background 0.2s;
}

.wish-row:has(input:checked) {
  background: var(--accent-soft);
  border-color: rgba(232, 163, 23, 0.35);
}

.wish-check {
  margin: 0;
  font-weight: 600;
  font-size: 14px;
}

.wish-row input[type="text"] {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: #fff;
}

/* ── Confirm & signature ── */
.confirm-box {
  background: linear-gradient(135deg, #f0f7ff, #fafcff);
  border: 1.5px solid rgba(13, 79, 156, 0.12);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.65;
}

.sig-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sig-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: linear-gradient(180deg, #fff, #fafcff);
}

.sig-card h3 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sig-pad-wrap { margin-top: 10px; }

.sig-canvas {
  width: 100%;
  height: 180px;
  border: 2px dashed #a8bdd4;
  border-radius: var(--radius-sm);
  background:
    linear-gradient(#f8fafc 1px, transparent 1px) 0 0 / 100% 24px,
    #fff;
  touch-action: none;
  cursor: crosshair;
  transition: border-color 0.2s;
}

.sig-canvas:hover { border-color: var(--primary-light); }

.sig-actions { margin-top: 8px; }

/* ── Buttons ── */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 6px 20px rgba(13, 79, 156, 0.3);
}

.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 8px 28px rgba(13, 79, 156, 0.35);
}

.btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 16px;
  border-radius: 999px;
  pointer-events: auto;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  font-size: 14px;
}

.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid rgba(13, 79, 156, 0.2);
}

.btn.ghost:hover {
  background: #f0f7ff;
  border-color: var(--primary-light);
}

.btn.text {
  background: transparent;
  color: var(--danger);
  padding: 4px 8px;
  font-weight: 500;
}

/* ── Submit bar ── */
.submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin: 0 -16px;
  padding: 0 16px;
  pointer-events: none;
}

.submit-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 32px rgba(10, 30, 60, 0.1);
  pointer-events: none;
}

.submit-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}

/* ── Errors & success ── */
.form-error {
  background: #fff0ee;
  color: var(--danger);
  border: 1.5px solid #f5c6cb;
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  font-size: 14px;
}

.success-card {
  text-align: center;
  padding: 40px 28px;
  border-top: 3px solid var(--success);
}

.success-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8f7ee, #d4f0e0);
  color: var(--success);
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(26, 143, 85, 0.2);
}

.success-card h1 {
  margin: 0 0 10px;
  font-size: 24px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.admin-login .btn { width: 100%; margin-top: 8px; }

.footer {
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
}

.footer a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.footer a:hover {
  color: var(--primary);
  background: rgba(13, 79, 156, 0.06);
}

.hidden { display: none !important; }

/* ── Branch photos ── */
.photo-upload { margin-top: 8px; }

.photo-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 2px dashed rgba(18, 38, 58, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.photo-add-btn:hover {
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.92);
}

.photo-add-icon { font-size: 1.25rem; line-height: 1; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(18, 38, 58, 0.12);
  background: #fff;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(18, 38, 58, 0.72);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* ── Responsive ── */
@media (max-width: 760px) {
  .page { padding-bottom: 100px; }

  .hero { padding: 22px 18px 20px; }

  .hero-inner {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 16px;
  }

  .hero-logo-wrap {
    align-self: flex-end;
    min-width: 108px;
    padding: 10px 12px;
  }

  .hero-logo {
    height: 76px;
  }

  .grid.two,
  .sig-grid,
  .wish-row {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .submit-inner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .submit-hint { display: none; }

  .btn-submit { justify-content: center; width: 100%; }
}

@media (max-width: 400px) {
  .hero-tags { display: none; }
}
