:root {
  --bg: #0e1116;
  --card: #f6f1e8;
  --ink: #14181f;
  --muted: #6b645b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100%;
  background:
    radial-gradient(900px 520px at 50% 42%, #1b2430 0%, var(--bg) 62%);
  color: var(--ink);
  font-family: Outfit, system-ui, sans-serif;
}

.add-word,
.back-home,
.create-deck,
.remaining,
.reset-btn,
.save,
.ghost {
  font: inherit;
  cursor: pointer;
}

.back-home,
.add-word {
  position: fixed;
  top: 20px;
  z-index: 50;
  pointer-events: auto;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #f6f1e8;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
}

.back-home {
  left: 20px;
}

.add-word {
  left: 20px;
}

body.is-studying .add-word {
  left: 168px;
}

.user-chip {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(72vw, 420px);
  padding: 4px 6px 4px 4px;
  border-radius: 999px;
  background: rgba(246, 241, 232, 0.94);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.user-chip[hidden] {
  display: none !important;
}

.user-chip img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #d8ccb4;
}

.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 600;
}

.user-signout {
  padding: 6px 8px;
  font-size: 0.78rem;
}

body.is-signed-in .remaining {
  right: 300px;
}

.remaining {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(246, 241, 232, 0.92);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.reset-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 5;
  border: 0;
  background: transparent;
  color: rgba(246, 241, 232, 0.55);
  font-size: 0.82rem;
}

.reset-btn:hover {
  color: #f6f1e8;
}

#auth-container,
#app-content {
  min-height: 100%;
}

#auth-container {
  position: relative;
  z-index: 1;
}

#app-content {
  position: relative;
  z-index: 2;
}

body.is-signed-in #auth-container {
  display: none !important;
  visibility: hidden;
  pointer-events: none !important;
  z-index: 0;
}

.auth-screen {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(92vw, 420px);
  padding: 28px 24px;
  border-radius: 28px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 2.1rem;
  font-weight: 400;
}

.auth-lead,
.auth-setup {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.auth-lead {
  margin: 0 0 20px;
}

.auth-card label {
  display: block;
  margin: 10px 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.password-field {
  overflow: hidden;
}

.auth-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d8ccb4;
  border-radius: 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.auth-actions {
  display: flex;
  justify-content: stretch;
  gap: 10px;
  margin-top: 16px;
}

.auth-actions .save,
.auth-actions .ghost {
  flex: 1;
}

.auth-error {
  margin: 0 0 8px;
  color: #b42318;
  font-size: 0.88rem;
  font-weight: 500;
}

.auth-setup {
  margin: 16px 0 0;
}

.auth-setup code {
  font-size: 0.85em;
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px 96px;
}

.deck {
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.deck[hidden],
.remaining[hidden],
.status[hidden],
.home[hidden],
.study-view[hidden],
.back-home[hidden],
.home-empty[hidden] {
  display: none !important;
}

.home {
  width: min(92vw, 960px);
  justify-self: center;
  align-self: start;
  padding-top: 48px;
}

.home-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  color: #f6f1e8;
}

.home-kicker {
  margin: 0 0 4px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.home-header h1 {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
}

.create-deck {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: #f6f1e8;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}

.dashboard {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  align-items: center;
  margin-bottom: 22px;
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(246, 241, 232, 0.08);
  color: #f6f1e8;
  box-shadow: inset 0 0 0 1px rgba(246, 241, 232, 0.1);
}

.dash-streak,
.dash-mastery {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-mastery {
  margin-left: 0;
}

.dash-fire {
  font-size: 1.85rem;
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(196, 93, 74, 0.35));
}

.dash-value {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.dash-label {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.68;
}

.dash-calendar {
  display: flex;
  flex: 1 1 100%;
  gap: 6px;
  order: 3;
}

.dash-day {
  flex: 1;
  min-width: 0;
  height: 38px;
  border-radius: 10px;
  background: rgba(246, 241, 232, 0.08);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.5;
}

.dash-day.is-done {
  background: rgba(196, 93, 74, 0.28);
  color: #f6c7a1;
  opacity: 1;
}

.dash-day.is-today {
  box-shadow: 0 0 0 1px rgba(246, 241, 232, 0.38);
  opacity: 1;
}

.dash-ring {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 50%;
  background: conic-gradient(#3e9a67 calc(var(--p) * 1%), rgba(246, 241, 232, 0.12) 0);
  display: grid;
  place-items: center;
}

.dash-ring-inner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #151b22;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.dash-mastery-copy {
  min-width: 0;
}

.dash-bar {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(246, 241, 232, 0.12);
  overflow: hidden;
}

.dash-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2d7a4f, #6bc48e);
}

@media (max-width: 720px) {
  .dash-mastery {
    margin-left: 0;
  }
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.deck-tile {
  appearance: none;
  width: 100%;
  min-height: 148px;
  padding: 20px 18px;
  border: 0;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deck-tile:hover {
  filter: brightness(1.04);
  transform: translateY(-2px);
}

.deck-tile-name {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.55rem;
  line-height: 1.2;
}

.deck-tile-due {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #2d7a4f;
}

.deck-tile-due.is-zero {
  color: var(--muted);
}

.deck-tile-total {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--muted);
}

.home-empty {
  margin: 12px 0 0;
  color: rgba(246, 241, 232, 0.72);
  font-size: 1.05rem;
  line-height: 1.5;
}

.card {
  width: 100%;
  height: min(72vh, 580px);
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1400px;
  -webkit-tap-highlight-color: transparent;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.22, 0.9, 0.28, 1);
}

.deck.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 32px;
  background: var(--card);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    0 2px 0 rgba(255, 255, 255, 0.35) inset;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.face-front {
  display: flex;
  flex-direction: column;
  padding: 18px 18px 22px;
}

.meaning {
  margin: 14px 0 10px;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.meaning-line {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  margin: 12px 0 0;
}

.face-back .meaning-back {
  margin: 0;
  flex: 1;
  text-align: left;
  color: var(--ink);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.45;
}

.card-divider {
  width: 100%;
  margin: 16px 0 4px;
  border: 0;
  border-top: 1px solid rgba(20, 24, 31, 0.14);
}

.cloze {
  margin: 0 0 16px;
  text-align: center;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.2rem, 3.6vw, 1.5rem);
  line-height: 1.5;
  color: var(--ink);
}

.blank {
  display: inline-block;
  min-width: 4.2em;
  margin: 0 2px;
  padding: 0 6px;
  border-bottom: 2px solid var(--ink);
  font-family: Outfit, system-ui, sans-serif;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#typing-answer {
  width: 100%;
  margin-top: auto;
  padding: 12px 14px;
  border: 1px solid #d8ccb4;
  border-radius: 14px;
  font: inherit;
  text-align: center;
  background: #fff;
  color: var(--ink);
}

#typing-answer:focus {
  outline: 2px solid #234236;
  outline-offset: 2px;
}

.typed-wrong {
  margin: 0 0 4px;
  text-align: center;
  color: #b42318;
  font-size: 0.92rem;
  font-weight: 600;
}

.status {
  margin: 0;
  max-width: 16ch;
  text-align: center;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.25;
  color: #f6f1e8;
}

.modal {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 24px;
  padding: 24px;
  background: #f6f1e8;
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.modal[open] {
  display: flex;
  flex-direction: column;
}

.modal::backdrop {
  background: rgba(8, 10, 14, 0.72);
}

.modal h2 {
  margin: 0 0 8px;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.7rem;
}

.modal label {
  display: block;
  margin: 12px 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.modal input,
.modal select,
.modal textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d8ccb4;
  border-radius: 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.modal select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #6b645b 50%),
    linear-gradient(135deg, #6b645b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.modal textarea {
  min-height: 132px;
  resize: vertical;
}

.import-status {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.ghost,
.save {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
}

.ghost {
  background: transparent;
  color: var(--muted);
}

.save {
  background: #234236;
  color: #f6f1e8;
  font-weight: 600;
}

.face-back {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  padding: 18px 18px 24px;
}

.edit-card {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  height: 30px;
  padding: 0 10px 0 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 24, 31, 0.38);
  color: #f6f1e8;
  opacity: 0.55;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.edit-card svg {
  width: 14px;
  height: 14px;
}

.edit-card:hover,
.edit-card:focus-visible {
  opacity: 0.92;
  background: rgba(20, 24, 31, 0.55);
}

.edit-card:focus-visible {
  outline: 2px solid #f6f1e8;
  outline-offset: 2px;
}

.photo {
  height: 42%;
  flex: 0 0 42%;
  border-radius: 20px;
  overflow: hidden;
  background: #163039;
}

.photo-back {
  height: 28%;
  flex: 0 0 28%;
}

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.quotes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.quote-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.flag {
  flex: 0 0 1.4em;
  line-height: 1.45;
  font-size: 1.15rem;
  text-align: center;
}

.word-back {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.03em;
  color: var(--ink);
}

.word-back.is-correct {
  color: #2d7a4f;
}

.ipa {
  margin: 6px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.example {
  margin: 0;
  flex: 1;
  text-align: left;
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.05rem, 3vw, 1.28rem);
  line-height: 1.45;
  color: var(--ink);
}

.example-vi {
  font-style: normal;
  color: #3f4a3d;
}

.speak {
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: #234236;
  color: #f6f1e8;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.speak-lg {
  width: 48px;
  height: 48px;
}

.speak-sm {
  width: 32px;
  height: 32px;
}

.speak svg {
  width: 58%;
  height: 58%;
  fill: currentColor;
}

.speak:hover {
  filter: brightness(1.08);
}

.grades {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease,
    visibility 0.45s ease;
}

.deck.is-flipped .grades {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0.38s;
}

.grade {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 6px 11px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font: inherit;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.grade-vi {
  font-weight: 600;
  font-size: 0.95rem;
}

.grade-en {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.82;
}

.interval-time {
  display: block;
  margin-top: 4px;
  font-size: 0.75em;
  opacity: 0.8;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.grade.again {
  background: linear-gradient(180deg, #c45d4a, #a43d32);
}

.grade.hard {
  background: linear-gradient(180deg, #d29a46, #b47828);
}

.grade.good {
  background: linear-gradient(180deg, #3e9a67, #2d7a4f);
}

.grade.easy {
  background: linear-gradient(180deg, #3d86b8, #2b6a96);
}

.grade:hover {
  filter: brightness(1.06);
}

.grade:focus-visible {
  outline: 2px solid #f6f1e8;
  outline-offset: 3px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(92vw, 360px);
  padding: 12px 16px;
  border-radius: 14px;
  background: #f6f1e8;
  color: #14181f;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .card-inner,
  .grades,
  .toast {
    transition: none;
  }
}

/* ===== Phân quyền giáo viên / học viên ===== */
[hidden] {
  display: none !important;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.deck-tile-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.deck-tile-action {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.deck-tile-action.is-danger {
  color: #b3261e;
}

.modal.modal-wide {
  width: min(960px, 94vw);
}

.students-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 65vh;
  overflow: auto;
}

.student-card h3 {
  margin: 0 0 4px;
}

.student-meta {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.student-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.student-table th,
.student-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  text-align: left;
}

/* =====================================================================
   BRIGHT THEME v35 — cheerful, motivating redesign (overrides above)
   ===================================================================== */
:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7280;
  --sun: #fbbf24;
  --coral: #fb7185;
  --teal: #14b8a6;
  --sky: #38bdf8;
  --grape: #a78bfa;
  --brand: #0d9488;
  --brand-dark: #0f766e;
  --shadow: 0 14px 34px rgba(31, 42, 68, 0.12);
  --shadow-lg: 0 24px 60px rgba(31, 42, 68, 0.16);
  --font-head: "Baloo 2", "Nunito", system-ui, sans-serif;
}

body {
  background:
    url("assets/blob-bg.svg") center / cover fixed no-repeat,
    linear-gradient(160deg, #fff7d6 0%, #ffe8e3 45%, #dff7f3 100%) fixed;
  color: var(--ink);
  font-family: Nunito, system-ui, sans-serif;
}

/* ---- Buttons ---- */
.save {
  background: linear-gradient(135deg, var(--coral), #f97316);
  color: #fff;
  font-weight: 800;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(249, 115, 22, 0.3);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s;
}
.save:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(249, 115, 22, 0.38); }
.save:active { transform: translateY(0) scale(0.98); }
.ghost { color: var(--brand-dark); font-weight: 700; border-radius: 14px; transition: background 0.18s; }
.ghost:hover { background: rgba(20, 184, 166, 0.12); }

.back-home,
.add-word,
.create-deck {
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.back-home::before { content: "← "; }
.create-deck { background: linear-gradient(135deg, var(--teal), var(--sky)); color: #fff; padding: 11px 18px; }
#teacher-dashboard-btn { background: linear-gradient(135deg, var(--grape), #f472b6); }
.back-home:hover, .add-word:hover, .create-deck:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.user-chip { background: rgba(255, 255, 255, 0.95); box-shadow: var(--shadow); }
.user-chip img { background: var(--sun); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--sun); }
.user-signout { padding: 6px 10px; }
.remaining { background: linear-gradient(135deg, var(--sun), #fb923c); color: #fff; box-shadow: var(--shadow); font-weight: 800; }
.reset-btn { color: rgba(31, 42, 68, 0.4); }
.reset-btn:hover { color: var(--coral); }

/* ---- Login ---- */
.auth-screen {
  grid-template-columns: minmax(0, 420px) minmax(0, 420px);
  justify-content: center;
  align-items: center;
  gap: 40px;
}
.auth-hero { text-align: center; color: var(--ink); animation: floatIn 0.7s ease both; }
.auth-mascot { width: min(240px, 60vw); height: auto; animation: bob 3.2s ease-in-out infinite; filter: drop-shadow(0 16px 20px rgba(13, 148, 136, 0.25)); }
.auth-bubble {
  position: relative;
  display: inline-block;
  margin: 10px auto 18px;
  padding: 12px 18px;
  border-radius: 20px;
  background: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
}
.auth-bubble::before {
  content: ""; position: absolute; top: -10px; left: 50%; margin-left: -10px;
  border: 10px solid transparent; border-top: 0; border-bottom-color: #fff;
}
.auth-perks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; text-align: left; max-width: 300px; margin-inline: auto; }
.auth-perks li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.7); font-weight: 700; font-size: 0.95rem;
}
.auth-perks img { width: 28px; height: 28px; }
.auth-card {
  position: relative;
  background: #fff;
  border-radius: 32px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  border-top: 8px solid transparent;
  background-image: linear-gradient(#fff, #fff), linear-gradient(90deg, var(--sun), var(--coral), var(--teal), var(--sky));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  animation: floatIn 0.7s 0.1s ease both;
}
.auth-card .home-kicker { color: var(--brand); opacity: 1; font-weight: 800; }
.auth-card h1 { font-family: var(--font-head); font-weight: 800; font-size: 2.2rem; line-height: 1.15; color: var(--ink); }
.auth-card input,
.modal input, .modal select, .modal textarea,
#typing-answer {
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.auth-card input:focus,
.modal input:focus, .modal select:focus, .modal textarea:focus,
#typing-answer:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.18);
}
.forgot-link { float: right; margin-top: 6px; font-size: 0.82em; color: var(--brand-dark); font-weight: 700; text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }
.auth-actions .save, .auth-actions .ghost { padding: 12px 14px; font-size: 1rem; }
.auth-actions .ghost { border: 2px solid rgba(20, 184, 166, 0.35); }

/* ---- Home hero ---- */
.home { padding-top: 72px; }
.home-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
  padding: 26px 28px;
  border-radius: 30px;
  background: linear-gradient(120deg, #14b8a6 0%, #38bdf8 55%, #a78bfa 100%);
  color: #fff;
  box-shadow: 0 20px 44px rgba(56, 189, 248, 0.32);
  overflow: hidden;
  animation: floatIn 0.6s ease both;
}
.home-hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.12);
}
.home-hero-copy { flex: 1; min-width: 0; position: relative; z-index: 1; }
.home-hero-art { width: clamp(140px, 26vw, 260px); flex: 0 0 auto; position: relative; z-index: 1; animation: bob 4s ease-in-out infinite; }
.hero-greeting { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; }
.hero-sub { margin: 4px 0 14px; font-weight: 600; opacity: 0.95; }
.today-progress { max-width: 460px; }
.today-bar { height: 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.today-bar span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #fde047, #fbbf24, #fb923c);
  transition: width 1s cubic-bezier(0.22, 0.9, 0.28, 1);
  box-shadow: 0 0 12px rgba(253, 224, 71, 0.8);
}
.today-label { margin: 8px 0 0; font-weight: 800; font-size: 0.95rem; }
.hero-quote {
  margin: 14px 0 0; padding: 10px 14px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.18); font-weight: 700; max-width: 520px;
}
.hero-quote small { display: block; margin-top: 2px; font-weight: 600; opacity: 0.85; font-style: italic; }
.hero-quote.is-in { animation: fadeUp 0.6s ease both; }

.home-header { color: var(--ink); margin-bottom: 18px; }
.home-kicker { color: var(--brand); opacity: 1; font-weight: 800; }
.home-header h1 { font-family: var(--font-head); font-weight: 800; color: var(--ink); }

/* ---- Dashboard ---- */
.dashboard { background: #fff; color: var(--ink); box-shadow: var(--shadow); border-radius: 26px; padding: 18px 20px; }
.dash-fire { width: 46px; height: 46px; animation: flicker 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
.dash-value { font-family: var(--font-head); font-size: 1.35rem; font-weight: 800; }
#streak-count { color: #f97316; }
.dash-label { opacity: 1; color: var(--muted); font-weight: 600; }
.dash-day { background: #f3f4f6; color: var(--muted); opacity: 1; border-radius: 12px; font-weight: 800; }
.dash-day.is-done { background: linear-gradient(135deg, #fde047, #fb923c); color: #fff; }
.dash-day.is-done::after { content: "🔥"; font-size: 0.8rem; }
.dash-day.is-today { box-shadow: 0 0 0 2px var(--coral); }
.dash-ring { background: conic-gradient(var(--teal) calc(var(--p) * 1%), #e5e7eb 0); width: 64px; height: 64px; flex-basis: 64px; }
.dash-ring-inner { background: #fff; width: 48px; height: 48px; color: var(--brand-dark); font-size: 0.82rem; }
.dash-bar { background: #e5e7eb; height: 8px; }
.dash-bar span { background: linear-gradient(90deg, var(--teal), var(--sky)); }

/* ---- Deck tiles ---- */
.deck-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.deck-tile {
  --c1: #fde68a; --c2: #fb923c;
  position: relative;
  padding: 0 18px 18px;
  min-height: 190px;
  background: #fff;
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.22s;
  animation: fadeUp 0.5s ease both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.deck-tile::before {
  content: attr(data-emoji);
  display: flex; align-items: center; justify-content: flex-end;
  margin: 0 -18px 4px; padding: 0 18px; height: 72px;
  font-size: 2.6rem;
  background:
    radial-gradient(circle at 15% 120%, rgba(255, 255, 255, 0.45) 0 40px, transparent 41px),
    radial-gradient(circle at 45% -30%, rgba(255, 255, 255, 0.3) 0 34px, transparent 35px),
    linear-gradient(120deg, var(--c1), var(--c2));
}
.deck-tile[data-cover="1"] { --c1: #99f6e4; --c2: #14b8a6; }
.deck-tile[data-cover="2"] { --c1: #bae6fd; --c2: #3b82f6; }
.deck-tile[data-cover="3"] { --c1: #fecdd3; --c2: #f43f5e; }
.deck-tile[data-cover="4"] { --c1: #ddd6fe; --c2: #8b5cf6; }
.deck-tile[data-cover="5"] { --c1: #bbf7d0; --c2: #22c55e; }
.deck-tile:hover { transform: translateY(-6px) rotate(-0.6deg); box-shadow: var(--shadow-lg); filter: none; }
.deck-tile:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.deck-tile-name { font-family: var(--font-head); font-weight: 800; font-size: 1.45rem; }
.deck-tile-due {
  align-self: flex-start; padding: 4px 10px; border-radius: 999px;
  background: #ffedd5; color: #c2410c; font-weight: 800; font-size: 0.85rem;
}
.deck-tile-due:not(.is-zero)::before { content: "⏰ "; }
.deck-tile-due.is-zero { background: #dcfce7; color: #15803d; }
.deck-tile-due.is-zero::before { content: "✅ "; }
.deck-tile-total { font-weight: 700; }
.deck-tile-action { border-color: #e5e7eb; font-weight: 700; }
.deck-tile-action:hover { background: #f3f4f6; }

.home-empty {
  padding: 24px; border-radius: 26px; background: #fff; box-shadow: var(--shadow);
  color: var(--muted); text-align: center; font-weight: 700;
}
.home-empty::before {
  content: ""; display: block; width: 200px; height: 150px; margin: 0 auto 8px;
  background: url("assets/empty-books.svg") center / contain no-repeat;
}

/* ---- Study card ---- */
.face { background: #fff; border-radius: 32px; box-shadow: var(--shadow-lg); }
.face-front { outline: none; border: 4px solid transparent; background-image: linear-gradient(#fff, #fff), linear-gradient(135deg, var(--sun), var(--coral), var(--sky)); background-origin: border-box; background-clip: padding-box, border-box; }
.face-back { border: 4px solid transparent; background-image: linear-gradient(#fff, #fff), linear-gradient(135deg, var(--teal), var(--sky), var(--grape)); background-origin: border-box; background-clip: padding-box, border-box; }
.photo { background: linear-gradient(135deg, #fef3c7, #ccfbf1); border-radius: 22px; }
.meaning { font-family: var(--font-head); font-size: 1.35rem; color: var(--ink); }
.cloze, .word-back, .example { font-family: var(--font-head); }
.cloze { font-weight: 600; }
.blank { font-family: Nunito, sans-serif; color: var(--coral); border-bottom: 3px dashed var(--coral); }
.word-back { font-weight: 800; letter-spacing: 0; color: var(--brand-dark); }
.word-back.is-correct { color: #16a34a; animation: pop 0.5s ease; }
.example { font-style: normal; font-weight: 500; }
.speak { background: linear-gradient(135deg, var(--teal), var(--sky)); box-shadow: 0 6px 14px rgba(20, 184, 166, 0.35); transition: transform 0.15s; }
.speak:hover { transform: scale(1.08); }
.typed-wrong { color: #e11d48; }
.edit-card { background: rgba(31, 42, 68, 0.5); }
.deck:not(.is-flipped) .card:hover .face-front { box-shadow: 0 30px 70px rgba(251, 113, 133, 0.25); }

.grade { border-radius: 18px; transition: transform 0.18s cubic-bezier(0.3, 1.5, 0.5, 1); }
.grade:hover { transform: translateY(-3px) scale(1.03); }
.grade.again { background: linear-gradient(180deg, #fb7185, #e11d48); }
.grade.hard { background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.grade.good { background: linear-gradient(180deg, #2dd4bf, #0d9488); }
.grade.easy { background: linear-gradient(180deg, #7dd3fc, #0284c7); }

.status { font-family: var(--font-head); font-weight: 800; color: var(--ink); max-width: 18ch; }
.status-art { display: block; width: clamp(140px, 30vw, 200px); height: auto; margin: 0 auto 12px; animation: bob 3s ease-in-out infinite; }
#done { color: var(--brand-dark); }

/* ---- Modals & toast ---- */
.modal { background: #fff; border-radius: 28px; box-shadow: var(--shadow-lg); border-top: 8px solid var(--teal); }
.modal::backdrop { background: rgba(31, 42, 68, 0.45); backdrop-filter: blur(3px); }
.modal h2 { font-family: var(--font-head); font-weight: 800; color: var(--ink); }
.toast { background: var(--ink); color: #fff; font-weight: 700; border-radius: 16px; }
.student-card { padding: 14px 16px; border-radius: 18px; background: #f8fafc; }

/* ---- Confetti ---- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 2000; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px;
  animation: confettiFall 3s ease-in forwards;
}

/* ---- Animations ---- */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes floatIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08) rotate(2deg); } }
@keyframes confettiFall {
  to { transform: translate(var(--x, 0), 105vh) rotate(var(--r, 360deg)); opacity: 0.9; }
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .auth-screen { grid-template-columns: minmax(0, 440px); gap: 8px; padding-top: 20px; }
  .auth-mascot { width: 130px; }
  .auth-bubble { font-size: 0.95rem; margin-bottom: 4px; }
  .auth-perks { display: none; }
}
@media (max-width: 640px) {
  .home { padding-top: 76px; }
  .home-hero { flex-direction: column-reverse; align-items: stretch; text-align: left; padding: 20px; }
  .home-hero-art { width: 120px; align-self: flex-end; margin: -6px 0 -40px; }
  .auth-card { padding: 26px 20px; }
  .auth-card h1 { font-size: 1.8rem; }
  .deck-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .deck-tile { min-height: 170px; padding: 0 14px 14px; }
  .deck-tile::before { margin: 0 -14px 4px; height: 58px; font-size: 2rem; }
  .deck-tile-name { font-size: 1.15rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.auth-screen { min-height: 100vh; }
.user-signout { white-space: nowrap; }
@media (max-width: 640px) {
  .home-hero-art { position: absolute; top: 10px; right: 8px; width: 84px; margin: 0; }
  .hero-greeting { padding-right: 76px; font-size: 1.5rem; }
  .user-chip span { max-width: 34vw; }
}

/* ---- v36: Quên mật khẩu + Quản lý người dùng ---- */
.forgot-row { margin: -4px 0 8px; text-align: right; }
.forgot-link { float: none; margin: 0; padding: 4px 2px; background: none; border: 0; cursor: pointer; font-family: inherit; }
.forgot-link:focus-visible { outline: 2px solid var(--brand); border-radius: 6px; }
.forgot-msg { margin: 4px 0 8px; padding: 10px 12px; border-radius: 14px; font-size: 0.9rem; font-weight: 600; line-height: 1.45; }
.forgot-msg.ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.forgot-msg.err { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.save:disabled, .ghost:disabled, .user-act:disabled { opacity: 0.55; cursor: not-allowed; }
.users-toolbar { display: flex; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.users-toolbar input { flex: 1 1 220px; margin: 0 !important; }
.users-toolbar select { flex: 0 0 190px; width: auto !important; margin: 0 !important; }
.users-table-wrap { max-height: 58vh; overflow: auto; border-radius: 16px; border: 1px solid #e2e8f0; }
.users-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.users-table th { position: sticky; top: 0; background: #f0fdfa; color: var(--brand-dark); text-align: left; padding: 8px; font-weight: 800; }
.users-table td { padding: 8px; border-top: 1px solid #eef2f7; vertical-align: top; }
.users-table .u-name { font-weight: 800; }
.users-table .u-email { color: var(--muted); font-size: 0.8rem; word-break: break-all; }
.u-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
.u-badge.active { background: #dcfce7; color: #15803d; }
.u-badge.blocked { background: #fef3c7; color: #b45309; }
.u-badge.deleted { background: #ffe4e6; color: #be123c; }
.u-badge.teacher { background: #e0f2fe; color: #0369a1; }
.u-badge.student { background: #f1f5f9; color: #475569; }
.u-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.user-act { padding: 4px 9px; border-radius: 10px; border: 1px solid #cbd5e1; background: #fff; font: inherit; font-size: 0.76rem; font-weight: 700; cursor: pointer; color: var(--ink); }
.user-act:hover { background: #f8fafc; }
.user-act.warn { border-color: #fcd34d; color: #b45309; }
.user-act.danger { border-color: #fda4af; color: #be123c; }
.user-act.ok { border-color: #86efac; color: #15803d; }
.users-note { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.users-note a { color: var(--brand-dark); font-weight: 700; }

/* AI TTS loading */
.tts-loading { opacity: 0.6; pointer-events: none; animation: tts-pulse 0.9s ease-in-out infinite; }
@keyframes tts-pulse { 50% { transform: scale(0.92); } }
.voice-caption { margin: 8px 0 0; font-size: 0.82rem; font-weight: 800; }
.voice-caption.is-ai { color: #0f766e; }
.voice-caption.is-browser { color: #b45309; }
.speak.is-browser { box-shadow: inset 0 0 0 2px #f59e0b; }
