:root {
  --cream: #f6efe1;
  --paper: #fbf6e9;
  --ink: #1a2238;
  --navy: #243059;
  --accent: #b22234;
  --muted: #6b6457;
}

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Lora', Georgia, serif;
  background-image:
    radial-gradient(circle at 10% 10%, rgba(0,0,0,0.02) 0, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0,0,0,0.025) 0, transparent 40%);
}

h1, h2, h3, .display {
  font-family: 'Playfair Display', 'Times New Roman', serif;
  letter-spacing: -0.01em;
}

.paper-card {
  background: var(--paper);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 4px 18px rgba(0,0,0,0.06);
}

.ink-link {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.ink-link:hover { color: var(--accent); }

.alpha-letter {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0,0,0,0.15);
  background: var(--paper);
  color: var(--ink);
  border-radius: 0.25rem;
  transition: all 0.15s ease;
}
.alpha-letter:hover { background: var(--ink); color: var(--paper); }
.alpha-letter.active { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.alpha-letter.empty { opacity: 0.35; }

.rank-badge {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 1.75rem;
  line-height: 1;
}
.rank-1 { color: #b8860b; } /* gold */
.rank-2 { color: #7d7d7d; } /* silver */
.rank-3 { color: #a0522d; } /* bronze */

.vote-btn {
  border: 1px solid rgba(0,0,0,0.2);
  background: var(--paper);
  color: var(--ink);
  padding: 0.35rem 0.7rem;
  border-radius: 0.3rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.vote-btn:hover { background: var(--ink); color: var(--paper); }
.vote-btn.active-up { background: #2c7a3e; color: white; border-color: #2c7a3e; }
.vote-btn.active-down { background: var(--accent); color: white; border-color: var(--accent); }

.btn-primary {
  background: var(--navy);
  color: var(--paper);
  font-family: 'Playfair Display', serif;
  padding: 0.6rem 1.2rem;
  border-radius: 0.3rem;
  border: 1px solid var(--navy);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--navy);
  padding: 0.5rem 1rem;
  border-radius: 0.3rem;
  cursor: pointer;
  font-family: 'Playfair Display', serif;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--navy); color: var(--paper); }

.input-field {
  background: var(--paper);
  border: 1px solid rgba(0,0,0,0.2);
  padding: 0.55rem 0.8rem;
  border-radius: 0.3rem;
  font-family: 'Lora', serif;
  width: 100%;
  color: var(--ink);
}
.input-field:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 2px rgba(36,48,89,0.15); }

textarea.input-field { resize: vertical; min-height: 5rem; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal-content {
  background: var(--paper);
  border-radius: 0.5rem;
  max-width: 32rem;
  width: 100%;
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.flag-tag {
  display: inline-block;
  background: rgba(178,34,52,0.12);
  color: var(--accent);
  border: 1px solid rgba(178,34,52,0.3);
  padding: 0.15rem 0.5rem;
  border-radius: 0.2rem;
  font-size: 0.75rem;
  margin: 0.1rem;
}

.source-tag {
  display: inline-block;
  background: rgba(36,48,89,0.08);
  color: var(--navy);
  border: 1px solid rgba(36,48,89,0.25);
  padding: 0.2rem 0.55rem;
  border-radius: 0.2rem;
  font-size: 0.78rem;
  font-style: italic;
  font-family: 'Lora', serif;
}

.divider-orn {
  text-align: center;
  color: var(--muted);
  margin: 1.5rem 0;
  font-family: 'Playfair Display', serif;
}

.word-entry {
  border-bottom: 1px dashed rgba(0,0,0,0.12);
  padding: 1rem 0;
}
.word-entry:last-child { border-bottom: none; }

.word-headword {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.75rem;
  color: var(--ink);
}

.definition-card {
  padding: 1rem;
  border-left: 3px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.4);
  margin-bottom: 0.75rem;
  border-radius: 0 0.3rem 0.3rem 0;
}
.definition-card.top { border-left-color: #b8860b; background: rgba(184,134,11,0.05); }

.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--navy); color: var(--paper);
  padding: 1rem 1.25rem; border-radius: 0.4rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  z-index: 100; max-width: 24rem;
  font-family: 'Lora', serif;
  animation: slidein 0.3s ease;
}
.toast.error { background: var(--accent); }
.toast.warn { background: #8a6d1f; }
@keyframes slidein { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
