/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #fafafa;
  color: #111;
  min-height: 100vh;
}

/* Page layout modifiers (set via <body class="…">) */
body.center { display: flex; align-items: center; justify-content: center; }
body.practice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
body.practice.flash-correct { background: #d4edda; }
body.practice.flash-wrong   { background: #f8d7da; }
body.browse { padding: 3.2rem 1.5rem 4rem; }

kbd {
  font-family: inherit;
  background: #eee;
  border-radius: 3px;
  padding: 0 0.25rem;
}

/* ── User bar (practice + browse) ─────────────────────────────────────── */
.user-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: #aaa;
  background: #fafafa;
  z-index: 10;
}
.user-bar .who { color: #555; font-weight: 600; }
.user-bar a { color: #888; text-decoration: none; }
.user-bar a:hover { color: #333; }

/* Mark admins so their elevated access is obvious at a glance. */
.user-bar .badge-admin {
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a6d00;
  background: #fff3cd;
  border: 1px solid #ffe08a;
  border-radius: 999px;
  vertical-align: middle;
}
.user-bar a.admin-link { color: #8a6d00; font-weight: 600; }
.user-bar a.admin-link:hover { color: #6a5400; }
#voice-select {
  font-size: 0.75rem;
  color: #555;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 2px 4px;
  background: #fff;
  max-width: 180px;
}

/* ── Practice page ────────────────────────────────────────────────────── */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  max-width: 820px;
  padding: 3.5rem 1rem 1rem;
}

.sidebar { width: 150px; flex-shrink: 0; padding-top: 0.5rem; }
.sidebar-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #bbb;
  margin-bottom: 0.6rem;
}
.wrong-word {
  font-size: 0.82rem;
  padding: 0.28rem 0.55rem;
  border-radius: 5px;
  margin-bottom: 0.25rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  color: #555;
  transition: opacity 0.35s ease, transform 0.35s ease, background 0.2s;
}
.wrong-word.is-current {
  background: #fff8e1;
  border-color: #f5c542;
  color: #333;
  font-weight: 600;
}
.wrong-word.removing { opacity: 0; transform: translateX(-16px); pointer-events: none; }
.sidebar-empty { font-size: 0.78rem; color: #ccc; font-style: italic; }

.card { flex: 1; max-width: 520px; padding: 1rem 2rem 2rem; text-align: center; }

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: #666;
}
.level-label { font-weight: 600; font-size: 1rem; color: #333; }

.streak-dots { display: flex; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #ddd; transition: background 0.2s; }
.dot.on { background: #28a745; }
.dot.must-pass { background: #ff9800; animation: pulse-dot 0.9s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.4); opacity: 0.6; }
}

.level-picker {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.level-picker:empty { display: none; }
.level-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid #d5d5d5;
  border-radius: 16px;
  background: #fff;
  color: #666;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.level-btn:hover { background: #f0f0f0; }
.level-btn.active { background: #2a60b4; border-color: #2a60b4; color: #fff; font-weight: 600; }
.practice-note {
  font-size: 0.75rem;
  color: #e6a817;
  min-height: 1rem;
  margin-bottom: 0.6rem;
  text-align: center;
}
.practice-note:empty { margin-bottom: 0; }

.speaker-wrap { margin-bottom: 0.5rem; }
.speaker {
  font-size: 4rem;
  cursor: pointer;
  user-select: none;
  display: inline-block;
  transition: transform 0.1s;
}
.speaker:active { transform: scale(0.9); }
.review-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  margin-bottom: 0.4rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.review-badge.visible  { opacity: 1; }
.review-badge.retry    { color: #e6a817; background: #fff8e1; border: 1px solid #f5c542; }
.review-badge.mustpass { color: #c75000; background: #fff0e6; border: 1px solid #ff9800; }

.keyboard-hint { font-size: 0.8rem; color: #aaa; margin-bottom: 1.5rem; }

.hint-btns { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1.5rem; }
.hint-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 20px;
  cursor: pointer;
  background: #fff;
  color: #666;
  transition: background 0.1s, border-color 0.1s;
}
.hint-btn:hover { background: #f0f0f0; border-color: #aaa; }
.hint-btn.active { background: #e8f0fe; border-color: #4a80d4; color: #2a60b4; }

.hint-text {
  font-size: 0.9rem;
  color: #555;
  font-style: italic;
  min-height: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}

#answer {
  width: 100%;
  font-size: 1.6rem;
  padding: 0.6rem 1rem;
  border: 2px solid #ccc;
  border-radius: 10px;
  outline: none;
  text-align: center;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  background: #fff;
}
#answer:focus { border-color: #555; }

.feedback { font-size: 1.3rem; font-weight: 600; min-height: 2rem; letter-spacing: 0.03em; }
.feedback.correct { color: #28a745; }
.feedback.wrong   { color: #dc3545; }
.feedback.levelup { color: #007bff; }

.actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; justify-content: center; }
.action-btn {
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  color: #555;
}
.action-btn:hover { background: #f0f0f0; }

/* ── Maths page ───────────────────────────────────────────────────────── */
.maths .stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  font-size: 0.85rem;
  color: #777;
  margin-bottom: 1rem;
}
.maths .stats b { color: #2a60b4; font-size: 1.05rem; }
.maths .streak-count { font-weight: 600; color: #e6651a; font-size: 1rem; }
.maths .question {
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin: 0.4rem 0 1.4rem;
}
.maths .tier-picker { margin-bottom: 1rem; }

/* ── Browse page ──────────────────────────────────────────────────────── */
.wrap { max-width: 1100px; margin: 0 auto; }
.wrap h1 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.subtitle { color: #999; font-size: 0.85rem; margin-bottom: 2rem; }

.search-row { margin-bottom: 1.8rem; }
#search {
  width: 100%;
  max-width: 360px;
  font-size: 0.95rem;
  padding: 0.5rem 0.8rem;
  border: 2px solid #ccc;
  border-radius: 8px;
  outline: none;
}
#search:focus { border-color: #555; }

.level-block { margin-bottom: 2.2rem; }
.level-block.hidden { display: none; }
.level-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid #e6e6e6;
  padding-bottom: 0.3rem;
}
.level-head h2 { font-size: 1.05rem; }
.level-head .count { font-size: 0.8rem; color: #aaa; }

.word-grid { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.word-chip {
  position: relative;
  font-size: 0.85rem;
  padding: 0.22rem 0.55rem;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 5px;
  cursor: default;
  white-space: nowrap;
}
.word-chip:hover { background: #eef3fb; border-color: #b9cdee; }
.word-chip.hidden { display: none; }

.tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: 260px;
  background: #1f2430;
  color: #f2f2f2;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
  z-index: 20;
  white-space: normal;
  text-align: left;
}
.word-chip:hover .tip { opacity: 1; visibility: visible; }
.tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2430;
}
.tip .def { display: block; margin-bottom: 0.35rem; }
.tip .ex  { display: block; color: #b9c2d0; font-style: italic; }
.tip .none { color: #888; }
/* keep the first chip's tooltip from spilling off the left edge */
.word-grid > .word-chip:first-child .tip { left: 0; transform: none; }
.word-grid > .word-chip:first-child .tip::after { left: 20px; }

/* ── Login page ───────────────────────────────────────────────────────── */
.login-card { width: 100%; max-width: 420px; padding: 2.5rem 2rem; }
.login-card h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
.login-card .sub { color: #888; font-size: 0.95rem; margin-bottom: 1.5rem; }
.login-error {
  background: #f8d7da;
  color: #842029;
  border: 1px solid #f1aeb5;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.login-card form { display: flex; flex-direction: column; gap: 0.6rem; }
.login-card input {
  font-size: 1.1rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid #ccc;
  border-radius: 8px;
  outline: none;
}
.login-card input:focus { border-color: #555; }
.login-buttons { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.login-card button[type="submit"] {
  flex: 1;
  font-size: 1rem;
  padding: 0.55rem 1.2rem;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.login-card button[type="submit"]:hover { background: #333; }
.login-card button.secondary { background: #fff; color: #333; border: 1px solid #ccc; }
.login-card button.secondary:hover { background: #f0f0f0; }
.login-hint { margin-top: 1rem; font-size: 0.8rem; color: #888; line-height: 1.4; }

/* ── Admin: accounts page ─────────────────────────────────────────────── */
.admin .admin-notice {
  background: #e8f0fe; color: #2a60b4; border: 1px solid #c5d8f7;
  border-radius: 6px; padding: 0.5rem 0.8rem; font-size: 0.85rem; margin-bottom: 1rem;
}
.admin-create { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.admin-create input {
  font-size: 0.95rem; padding: 0.45rem 0.7rem;
  border: 2px solid #ccc; border-radius: 8px; outline: none;
}
.admin-create input:focus { border-color: #555; }
.admin-create button {
  padding: 0.45rem 1rem; border: none; border-radius: 8px;
  background: #2a60b4; color: #fff; cursor: pointer;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td {
  text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid #eee;
}
.admin-table th { font-size: 0.75rem; text-transform: uppercase; color: #999; letter-spacing: 0.05em; }
.admin-table .pending { color: #e6a817; }
.admin-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.admin-actions form { margin: 0; }
.admin-actions button {
  font-size: 0.78rem; padding: 0.25rem 0.6rem; border: 1px solid #ccc;
  border-radius: 6px; background: #fff; color: #555; cursor: pointer;
}
.admin-actions button:hover { background: #f0f0f0; }
.admin-actions button.danger { color: #c0392b; border-color: #e3b5af; }
.admin-actions button.danger:hover { background: #fdecea; }
