:root {
  --purple: #7c3aed;
  --pink: #ec4899;
  --orange: #fb923c;
  --yellow: #fbbf24;
  --green: #10b981;
  --ink: #2d1b4e;
  --muted: #6b6285;
  --card-bg: #ffffff;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #fdf2ff 0%, #fef6e4 50%, #eafff3 100%);
  background-attachment: fixed;
}

h1, h2 {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
}

a {
  color: var(--purple);
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* Topbar */
.topbar {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(124, 58, 237, 0.12);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
  color: var(--ink);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.95rem;
}

.topnav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.topnav a:hover {
  color: var(--purple);
}

.topnav-user {
  color: var(--ink);
  font-weight: 600;
}

/* Flash messages */
.flash-stack {
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #e0e7ff; color: #3730a3; }

/* Login */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 90vh;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.15);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-emoji {
  font-size: 2.5rem;
  margin-bottom: 4px;
}

/* Hero */
.hero {
  text-align: center;
  margin: 20px 0 28px;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro {
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

/* Subject counters */
.subject-counters {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.subject-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 24px;
  border-radius: 999px;
  font-weight: 700;
  color: white;
}

.subject-pill.subject-a { background: linear-gradient(135deg, var(--purple), #a78bfa); }
.subject-pill.subject-b { background: linear-gradient(135deg, var(--pink), #f9a8d4); }

.subject-count {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.9;
}

/* Letter grid */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 12px;
}

.letter-tile {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px 8px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.letter-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.18);
}

.letter-tile-empty {
  opacity: 0.55;
}

.letter-char {
  display: block;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
}

.letter-count {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Letter detail page */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  text-decoration: none;
  font-weight: 600;
  color: var(--muted);
}

.letter-header {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.letter-header-char {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 3rem;
  background: linear-gradient(90deg, var(--purple), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.letter-header-counts {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

/* Cards */
.add-line-card, .admin-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.08);
  margin-bottom: 24px;
}

.add-line-card h2, .admin-card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

form label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin: 14px 0 6px;
  color: var(--ink);
}

form label:first-of-type {
  margin-top: 0;
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e3d9f7;
  font-family: inherit;
  font-size: 1rem;
  background: #fbfaff;
}

input:focus, textarea:focus {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

.subject-choice {
  display: flex;
  gap: 16px;
  margin: 6px 0 12px;
}

.subject-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0;
}

.subject-radio input {
  width: auto;
}

/* Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white;
  margin-top: 16px;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background: #f1edfe;
  color: var(--purple);
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-small {
  padding: 7px 14px;
  font-size: 0.82rem;
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 20px;
}

/* Line list */
.line-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.line-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.07);
}

.line-text {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.line-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}

.line-subject {
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
}

.line-subject.subject-a { background: var(--purple); }
.line-subject.subject-b { background: var(--pink); }

.line-author {
  font-weight: 600;
}

.vote-form {
  margin-left: auto;
}

.vote-btn {
  border: 1px solid #e3d9f7;
  background: #fbfaff;
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.vote-btn-active {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: white;
  border-color: transparent;
}

/* Admin tables */
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.user-table th, .user-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #f0ebfc;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.user-actions form {
  margin: 0;
}

.badge {
  background: #ede9fe;
  color: var(--purple);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.password-row {
  display: flex;
  gap: 8px;
}

.password-row input {
  flex: 1;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600 !important;
  margin-top: 16px !important;
}

.checkbox-row input {
  width: auto;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .two-cols {
    grid-template-columns: 1fr;
  }
  .letter-header-char {
    font-size: 2.2rem;
  }
}
