:root {
  --ink: #302b26;
  --muted: #706b62;
  --paper: #f6efe5;
  --panel: #fffaf2;
  --sage: #687a5e;
  --terracotta: #a85f3c;
  --line: #d7c9b6;
  --danger: #9c392f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  background: #786044;
  color: #fffaf0;
}

.header-copy > p,
.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0.35rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 500;
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  color: #fffaf0;
  font-size: 0.78rem;
  font-weight: 700;
}

.auth {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
}

.cf-turnstile {
  min-height: 65px;
}

main {
  max-width: 1340px;
  margin: 0 auto;
  padding: 1.25rem;
}

.status {
  min-height: 1.4rem;
  color: var(--muted);
}

.panel {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.section-heading h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.eyebrow {
  color: var(--sage);
}

button,
input,
select,
textarea {
  max-width: 100%;
  border: 1px solid #c9b9a4;
  border-radius: 3px;
  padding: 0.5rem 0.58rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  border-color: var(--terracotta);
  background: var(--terracotta);
  color: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
}

button:hover {
  filter: brightness(0.94);
}

button.secondary {
  border-color: #a79378;
  background: transparent;
  color: #654f36;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.inline-form {
  display: flex;
  gap: 0.45rem;
}

.people-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.55rem;
}

.person-row {
  display: flex;
  gap: 0.35rem;
}

.person-row input {
  flex: 1;
  min-width: 0;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

#boundary-filter {
  margin-bottom: 0.25rem;
}

#region-boundaries,
#region-people {
  min-height: 9rem;
}

.help {
  margin: 0.55rem 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.active-toggle input {
  width: auto;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.preview-wrap {
  margin-top: 1rem;
}

.preview-wrap h3 {
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

#boundary-preview {
  height: 300px;
  border: 1px solid var(--line);
  background: #dfe4dc;
}

.regions-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.75rem;
}

.region-row {
  display: flex;
  flex-direction: column;
  padding: 0.8rem;
  border: 1px solid var(--line);
  background: #fff;
}

.region-row.inactive {
  opacity: 0.62;
}

.region-row h3 {
  margin-bottom: 0.35rem;
  font-size: 0.98rem;
}

.region-row p {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.region-row .people {
  color: var(--ink);
  font-weight: 700;
}

.region-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.55rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  header {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth {
    justify-content: flex-start;
  }

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

  .form-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .section-heading,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .person-row {
    flex-wrap: wrap;
  }
}
