:root {
  --navy: #1a2456;
  --navy-soft: #2a3670;
  --gold: #c8a84b;
  --gold-soft: #e2c878;
  --ink: #1b1d23;
  --paper: #faf7ef;
  --rule: #d9d3bf;
  --band: #fcfaf3;
  --error: #b3261e;
  --success: #2f7d3a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- header ---------- */
.site-header {
  background: var(--navy);
  color: white;
  padding: 18px 16px;
  border-bottom: 4px solid var(--gold);
}
.site-header-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-header h1 {
  font-size: 1.2rem;
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}
.site-header .subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin: 0;
}
.brand-badge {
  flex: 0 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: bold;
  font-size: 1.4rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

/* ---------- progress bar ---------- */
.progress-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 239, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
  padding: 8px 16px;
}
.progress-bar-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--navy);
}
.progress-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--rule);
}
.progress-dot.filled {
  background: var(--gold);
  border-color: var(--navy);
}
.progress-label {
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- main layout ---------- */
.survey {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}
.intro {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 32px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.intro p { margin: 0 0 10px; }
.intro p:last-child { margin-bottom: 0; }
.intro .meta {
  font-size: 0.85rem;
  color: #555;
}

.section {
  margin-bottom: 44px;
}
.section-head {
  border-bottom: 2px solid var(--navy);
  margin-bottom: 18px;
  padding-bottom: 6px;
}
.section-head h2 {
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  margin: 0;
  font-weight: 700;
}
.section-head .section-sub {
  font-size: 0.85rem;
  color: #555;
  margin: 4px 0 0;
}

/* ---------- generic card ---------- */
.card {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 20px 22px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  margin-bottom: 18px;
}
.card-eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 700;
  margin: 0 0 6px;
}
.card-title {
  font-size: 1rem;
  margin: 0 0 14px;
  color: var(--ink);
}
.card .prompt {
  font-size: 0.88rem;
  color: #555;
  margin: 0 0 14px;
}

/* ---------- likert band ---------- */
.band-wrap { position: relative; padding-bottom: 26px; }
.band {
  position: relative;
  height: 56px;
  background: var(--band);
  border: 2px solid var(--navy);
  border-radius: 6px;
  cursor: crosshair;
  touch-action: manipulation;
  overflow: hidden;
  user-select: none;
}
.band-tick {
  position: absolute; top: 8px; bottom: 8px; width: 1px;
  background: var(--rule); pointer-events: none;
}
.band-tick.center { left: 50%; }
.band-tick.q1 { left: 25%; opacity: 0.5; }
.band-tick.q3 { left: 75%; opacity: 0.5; }
.band-labels {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between;
  padding: 4px 4px 0;
  font-size: 0.72rem; color: var(--navy); font-weight: 600;
  pointer-events: none;
}
.band-labels .center {
  position: absolute; left: 50%; transform: translateX(-50%);
}
.band .placeholder, .plane .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #9a967f; font-size: 0.85rem; font-style: italic;
  pointer-events: none; text-align: center; padding: 0 16px;
}
.band.has-dot .placeholder, .plane.has-dot .placeholder { display: none; }

.dot {
  position: absolute;
  width: 22px; height: 22px;
  margin-left: -11px; margin-top: -11px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--navy);
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  pointer-events: none;
}
.band .dot { top: 50%; }

/* ---------- coordinate plane ---------- */
.plane-grid {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  align-items: center;
  justify-items: center;
}
.axis-label {
  font-size: 0.78rem;
  color: var(--navy);
  text-align: center;
  font-weight: 600;
  line-height: 1.25;
}
.axis-label.top    { grid-area: 1 / 2 / 2 / 3; }
.axis-label.bottom { grid-area: 3 / 2 / 4 / 3; }
.axis-label.left   { grid-area: 2 / 1 / 3 / 2; writing-mode: vertical-rl; transform: rotate(180deg); max-height: 100%; }
.axis-label.right  { grid-area: 2 / 3 / 3 / 4; writing-mode: vertical-rl; max-height: 100%; }
.plane {
  grid-area: 2 / 2 / 3 / 3;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 380px;
  background: #fcfaf3;
  border: 2px solid var(--navy);
  border-radius: 4px;
  position: relative;
  cursor: crosshair;
  touch-action: manipulation;
  overflow: hidden;
  user-select: none;
}
.plane::before, .plane::after {
  content: "";
  position: absolute;
  background: var(--rule);
  pointer-events: none;
}
.plane::before { left: 0; right: 0; top: 50%; height: 1px; }
.plane::after  { top: 0; bottom: 0; left: 50%; width: 1px; }

.readout {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #666;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-height: 1.2em;
  display: flex; align-items: center; gap: 8px;
}
.clear-btn {
  background: none;
  border: 1px solid var(--rule);
  color: #666;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}
.clear-btn:hover { background: #f0ece0; }

/* ---------- map ---------- */
.map-card { padding-bottom: 18px; }
#map {
  width: 100%;
  height: 60vh;
  min-height: 360px;
  max-height: 600px;
  border: 2px solid var(--navy);
  border-radius: 6px;
  background: #e8e3d2;
  margin-bottom: 12px;
}
.region-outline {
  fill: var(--navy);
  fill-opacity: 0.06;
  stroke: var(--navy);
  stroke-width: 2;
  stroke-opacity: 0.5;
}
.leaflet-popup-content { margin: 12px 14px; min-width: 220px; }
.leaflet-popup-content textarea {
  width: 100%; min-height: 70px;
  border: 1px solid var(--rule); border-radius: 4px;
  padding: 6px 8px; font: inherit; font-size: 0.9rem; resize: vertical;
}
.leaflet-popup-content .actions {
  display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end;
}
.leaflet-popup-content button {
  border: 1px solid var(--rule); background: white; color: var(--ink);
  padding: 4px 10px; border-radius: 3px; cursor: pointer;
  font: inherit; font-size: 0.85rem;
}
.leaflet-popup-content button.primary {
  background: var(--navy); color: white; border-color: var(--navy);
}
.leaflet-popup-content button.danger { color: #a33; }

.pin-list-head {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  font-weight: 700;
  margin: 0 0 8px;
}
.pin-list {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--rule); border-radius: 6px; background: white;
}
.pin-list li {
  display: flex; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}
.pin-list li:last-child { border-bottom: none; }
.pin-list li.empty {
  color: #888; font-style: italic; justify-content: center;
}
.pin-num {
  flex: 0 0 auto; width: 26px; height: 26px;
  border-radius: 50%; background: var(--gold);
  color: var(--navy); border: 2px solid var(--navy);
  font-size: 0.78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.pin-body { flex: 1 1 auto; min-width: 0; }
.pin-coord {
  font-size: 0.72rem; color: #888;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pin-comment { font-size: 0.92rem; margin-top: 2px; word-wrap: break-word; }
.pin-comment.empty { color: #999; font-style: italic; }
.pin-actions { flex: 0 0 auto; display: flex; gap: 6px; align-items: flex-start; }
.pin-actions button {
  border: 1px solid var(--rule); background: white; color: #666;
  padding: 3px 8px; border-radius: 3px; cursor: pointer;
  font: inherit; font-size: 0.78rem;
}
.pin-actions button:hover { background: #f0ece0; }

/* ---------- residence ---------- */
.residence-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 560px) {
  .residence-grid { grid-template-columns: 1fr 1fr; }
}
.residence-field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--navy);
  margin-bottom: 6px;
}
.residence-field label .req {
  color: var(--error);
  margin-left: 2px;
}
.residence-field select,
.residence-field input[type="text"] {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  background: white;
  color: var(--ink);
}
.residence-field select:focus,
.residence-field input[type="text"]:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--navy);
}

/* ---------- text fields ---------- */
.text-field {
  margin-bottom: 12px;
}
.text-field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--navy);
  margin-bottom: 6px;
}
.text-field textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  background: white;
  resize: vertical;
}
.text-field textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--navy);
}
.text-counter {
  font-size: 0.72rem;
  color: #888;
  text-align: right;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- submit ---------- */
.submit-section {
  margin-top: 32px;
  padding: 22px 24px;
  background: white;
  border: 2px solid var(--navy);
  border-radius: 8px;
  text-align: center;
}
.submit-section .turnstile-host {
  display: flex;
  justify-content: center;
  margin: 12px 0;
  min-height: 65px;
}
.submit-btn {
  background: var(--navy);
  color: white;
  border: none;
  padding: 14px 36px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.submit-btn:hover:not(:disabled) { background: var(--navy-soft); }
.submit-btn:disabled {
  background: #b8b39d;
  cursor: not-allowed;
}
.submit-help {
  font-size: 0.82rem;
  color: #666;
  margin: 8px 0 0;
}
.submit-error {
  margin-top: 12px;
  color: var(--error);
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.visible { opacity: 1; }

/* ---------- thanks ---------- */
.thanks-card {
  max-width: 520px;
  margin: 64px auto;
  padding: 36px 32px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.thanks-card h1 {
  color: var(--navy);
  font-size: 1.4rem;
  margin: 0 0 12px;
}
.thanks-card .checkmark {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: bold;
}
.thanks-card a {
  color: var(--navy);
}
