:root {
  --bg: #f0ece4;
  --bg-card: #ffffff;
  --bg-card-hover: #faf9f7;
  --bg-card-active: #f7f5f1;
  --text: #2c2825;
  --text-secondary: #5c5650;
  --text-muted: #84796e;
  --text-faint: #a69d93;
  --accent: #1a1a1a;
  --border: #ddd7ce;
  --border-light: #e8e3db;
  --heading: 'Lora', Georgia, serif;
  --body: 'Libre Franklin', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --bg-card: #242120;
    --bg-card-hover: #2c2927;
    --bg-card-active: #302d2a;
    --text: #e8e2d9;
    --text-secondary: #b5aea5;
    --text-muted: #8a8279;
    --text-faint: #6b6460;
    --accent: #e8e2d9;
    --border: #3a3633;
    --border-light: #322f2c;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: var(--body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  max-width: 680px;
  margin: 0 auto;
  padding: 4.5rem 2rem 2.5rem;
  text-align: center;
}
.header-label {
  font-family: var(--body);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.header-title {
  font-family: var(--heading);
  font-size: clamp(2.2rem, 5.5vw, 3.5rem);
  font-weight: 400;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
}
.header-title a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.15s;
}
.header-title a:hover { opacity: 0.7; }
.header-sub {
  font-family: var(--body);
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.65;
  font-weight: 400;
  max-width: 420px;
  margin: 0 auto;
}
.header-sub em {
  font-style: normal;
  font-weight: 500;
  color: var(--text);
}

/* Controls */
.controls {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 2rem 1.25rem;
}
.search-wrap {
  position: relative;
  margin-bottom: 0.75rem;
}
.search-input {
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 400;
  padding: 0.65rem 2.2rem 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  outline: none;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--text-muted); }
.search-input::placeholder { color: var(--text-faint); }
.search-x {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 1.2rem;
  line-height: 1;
  display: none;
  padding: 2px;
}
.search-x.on { display: block; }
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}
.controls-btns {
  display: flex;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  line-height: 1.4;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
  color: var(--text);
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

/* Cards */
.main {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
}
.card-list {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.town-card {
  padding: 1.75rem 2rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}
.town-card:last-child { border-bottom: none; }
.town-card:hover { background: var(--bg-card-hover); }
.town-card.active { background: var(--bg-card-active); }

.town-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.town-name {
  font-family: var(--heading);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.share-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--body);
  font-size: 0.72rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
  white-space: nowrap;
}
.share-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}
.share-btn svg {
  width: 14px;
  height: 14px;
}
.town-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.3rem;
  letter-spacing: 0.01em;
}
.town-acronym {
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--text);
  font-weight: 400;
  margin-top: 0.85rem;
}
.acr-lead { font-weight: 600; }
.acr-dim { color: var(--text-muted); }
.acr-paren { color: var(--text-muted); }
.town-note {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.85rem;
  line-height: 1.55;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}
.town-card.active .town-note {
  max-height: 200px;
  opacity: 1;
}

/* Empty state */
.empty {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  padding: 3.5rem 2rem;
  text-align: center;
}
.empty-title {
  font-family: var(--heading);
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-weight: 400;
}
.empty-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Submit form */
.submit-form, .submit-done {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  padding: 2.5rem 2rem;
}
.submit-done { text-align: center; }
.done-title {
  font-family: var(--heading);
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 0.4rem;
  font-weight: 400;
}
.done-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.form-title {
  font-family: var(--heading);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.form-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.field input, .field textarea {
  font-family: var(--body);
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
  font-weight: 400;
}
.field input:focus, .field textarea:focus { border-color: var(--text-muted); }
.field textarea { resize: vertical; }
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.form-actions .btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
}

/* Single town page */
.single-nav {
  margin-top: 1.5rem;
  text-align: center;
}

/* Footer */
.footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  border-top: 1px solid var(--border-light);
}
.footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

/* Responsive */
@media (max-width: 600px) {
  .header { padding: 3rem 1.25rem 2rem; }
  .controls { padding: 0 1.25rem 1rem; }
  .main { padding: 0 1.25rem 3rem; }
  .town-card { padding: 1.5rem 1.25rem; }
  .town-name { font-size: 1.35rem; }
  .controls-bar { flex-wrap: wrap; gap: 0.5rem; }
}
