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

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
}

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;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(92vw, 520px);
  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;
}
.settings-btn { min-height: 44px; font-weight: 800; }

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,
.auth-card select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d8ccb4;
  border-radius: 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.class-hint { margin: 0 0 8px; color: #9a3412; font-size: 0.86rem; font-weight: 700; }
.class-add { display: flex; gap: 8px; align-items: center; }
.class-add input { flex: 1; }
.class-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.class-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.class-row input { flex: 1 1 140px; }
.class-row .ghost, .class-row .save { padding: 8px 10px; }

.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, 720px);
  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;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px 16px 14px;
}

.meaning {
  margin: 4px 0 0;
  text-align: center;
  font-weight: 800;
  font-size: clamp(1.45rem, 3.4vw, 1.9rem);
  line-height: 1.25;
}

.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: 8px 0 0;
  border: 0;
  border-top: 1px solid rgba(20, 24, 31, 0.14);
}

.cloze {
  margin: 0;
  text-align: center;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.35rem, 3.8vw, 1.75rem);
  line-height: 1.45;
  color: var(--ink);
}

.blank {
  display: inline-block;
  min-width: 5.2em;
  margin: 0 4px;
  padding: 0 8px 2px;
  border-bottom: 3px solid #0f766e;
  background: rgba(15, 118, 110, 0.08);
  border-radius: 6px 6px 0 0;
  font-family: Outfit, system-ui, sans-serif;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #0f766e;
}

#typing-answer {
  width: 100%;
  margin-top: 0;
  min-height: 48px;
  padding: 12px 14px;
  border: 2px solid #d8ccb4;
  border-radius: 14px;
  font: inherit;
  font-size: 1.05rem;
  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: 0;
}

.face-scroll {
  flex: 0 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  padding: 4px 0 0;
}

.card-status {
  flex: 0 0 auto;
  padding: 0 22px 14px;
}

.edit-card {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  min-height: 44px;
  padding: 0 12px 0 10px;
  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,
.photo-back {
  width: min(100%, 520px);
  aspect-ratio: 16 / 9;
  height: auto;
  flex: 0 0 auto;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #eceae4;
}

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

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

.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);
}

.target-word {
  font-style: normal;
  font-weight: 800;
  color: #0f766e;
  background: transparent;
}

.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,
.speak-sm {
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
}

.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;
  min-height: 64px;
  padding: 12px 6px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font: inherit;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.grade-key {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.grade-vi {
  font-weight: 700;
  font-size: 1.05rem;
}

.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;
}

.brand-mark,
.brand-mark:popover-open {
  position: fixed;
  inset: auto max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) auto;
  width: clamp(72px, 12vw, 104px);
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
  user-select: none;
  z-index: 2147483000;
  filter: drop-shadow(0 6px 14px rgba(20, 24, 31, 0.28));
}

body.is-studying .stage {
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
}

.toast {
  position: fixed;
  right: 20px;
  bottom: calc(28px + clamp(72px, 12vw, 104px));
  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: #eceae4; border-radius: 18px; }
.photo.is-empty img,
.photo.is-broken img,
.photo.is-loading img,
.photo.is-mock img { display: none; }
.photo.is-empty,
.photo.is-broken,
.photo.is-loading,
.photo.is-mock { display: grid; place-items: center; color: #9a3412; font-weight: 800; text-align: center; padding: 12px; }
.photo.is-empty::after { content: "Chưa có ảnh Pixabay"; }
.photo.is-broken::after { content: "Ảnh không tải được"; }
.photo.is-loading::after { content: "Đang tìm ảnh…"; }
.photo.is-mock { color: #14532d; background: linear-gradient(160deg, #d9f99d, #86efac 45%, #38bdf8); }
.photo.is-mock::after { content: "Ảnh thành phố (mô phỏng)"; }
.meaning { font-family: var(--font-head); font-size: clamp(1.45rem, 3.4vw, 1.9rem); color: var(--ink); }
.cloze, .word-back, .example { font-family: var(--font-head); }
.cloze { font-weight: 600; }
.blank { font-family: Nunito, sans-serif; color: #0f766e; border-bottom: 3px solid #0f766e; background: rgba(15, 118, 110, 0.1); }
.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: 768px) {
  .photo, .photo-back { width: 100%; }
  .grades { gap: 8px; }
}
@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) {
  .brand-mark,
  .brand-mark:popover-open { width: 64px; }
  .auth-screen { align-items: start; padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
  .auth-mascot { width: 72px; }
  .auth-bubble { margin: 6px auto 0; padding: 8px 12px; }
  body.is-studying .stage { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
  .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: 18px 16px 16px; }
  .auth-card h1 { font-size: 1.55rem; }
  .auth-lead { margin-bottom: 8px; }
  .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; }
  .photo, .photo-back { width: 100%; }
  .grades { gap: 6px; margin-top: 10px; }
  .grade { min-height: 56px; padding: 8px 2px; }
  .grade-en { font-size: 0.62rem; }
}
@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-pending { color: #1d4e89; }
.voice-caption.is-browser { color: #b45309; }
.speak.is-browser { box-shadow: inset 0 0 0 2px #f59e0b; }
.example-vi.is-missing { color: #b45309; font-style: italic; }
.image-note, .repair-status { margin: 8px 0; color: #9a3412; font-size: 0.86rem; font-weight: 700; }
body:not(.is-verified-teacher) .card-status { display: none !important; }
.word-list-btn {
  position: fixed;
  top: 20px;
  left: 158px;
  z-index: 50;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #f6f1e8;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}
body.is-word-list .add-word { display: none !important; }
body.is-word-list .stage { padding-top: 72px; }
.word-list-back { position: fixed; top: 20px; left: 20px; z-index: 60; min-height: 44px; }
.deck-search {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 14px;
}
.deck-search input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: #fff;
  color: #14181f;
  font: inherit;
  box-shadow: var(--shadow);
}
.deck-search-count,
.deck-search-empty,
.deck-match-hint {
  margin: 0;
  color: #14181f;
  font-weight: 800;
}
.deck-search-empty { margin: 8px 0 16px; }
.deck-match-hint { color: var(--brand-dark); font-size: 0.88rem; font-weight: 700; }
.word-list-view {
  width: min(92vw, 880px);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #14181f;
}
.word-list-view[hidden] { display: none !important; }
.word-list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.word-list-head h1 { margin: 0; font-family: var(--font-head); font-size: clamp(1.6rem, 4vw, 2.2rem); }
.word-list-tools { display: flex; gap: 10px; align-items: center; }
.word-list-tools input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
}
.word-count { margin: 0; font-weight: 800; white-space: nowrap; color: #14181f; }
.word-list-note { margin: 0; color: #fde68a; font-weight: 700; }
.word-list-scroll {
  overflow: auto;
  min-height: 0;
  display: grid;
  gap: 10px;
  padding-bottom: 24px;
}
.word-row-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
}
.word-thumb {
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #eceae4;
}
.word-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.word-row-main { min-width: 0; }
.word-row-main h2 { margin: 0; font-size: 1.15rem; }
.word-row-main p { margin: 2px 0; }
.word-ipa { color: var(--muted); font-size: 0.85rem; }
.word-example { font-size: 0.92rem; }
.word-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.srs-badge { border-radius: 999px; padding: 3px 8px; font-size: 0.75rem; font-weight: 800; background: #e2e8f0; }
.srs-badge.is-due { background: #ffedd5; color: #9a3412; }
.srs-badge.is-new { background: #dbeafe; color: #1d4ed8; }
.srs-badge.is-later { background: #dcfce7; color: #166534; }
.word-actions { display: flex; gap: 6px; }
.word-actions button { min-height: 44px; }
@media (max-width: 700px) {
  .word-list-btn { display: none; }
  .word-row-card { grid-template-columns: 96px minmax(0, 1fr); }
  .word-thumb { width: 96px; }
}
@media (min-width: 701px) {
  body:not(.is-studying) .word-list-btn { display: none; }
}

.preview-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #14181f;
  color: #f6f1e8;
  font-size: 0.78rem;
  font-weight: 800;
}

/* Study screen fills the viewport. The picture shrinks before the words do. */
body.is-studying {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
body.is-studying #app-content {
  display: flex !important;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
body.is-studying .reset-btn { display: none; }
body.is-studying .stage {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  place-items: stretch;
  padding: 80px 8px calc(8px + clamp(68px, 7vw, 108px));
}
body.is-studying .study-view {
  width: min(100%, 1200px);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.is-studying .deck {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 6px;
}
body.is-studying .card {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
}
body.is-studying .card-inner,
body.is-studying .face {
  min-height: 0;
}
body.is-studying .face-front,
body.is-studying .face-back {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 8px 12px 8px;
  overflow: hidden;
}
body.is-studying .face-front {
  grid-template-rows: minmax(0, 1fr) auto auto auto;
}
body.is-studying .back-body {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
body.is-studying .photo-slot {
  container-type: size;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
body.is-studying .photo,
body.is-studying .photo-back {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  flex: 0 1 auto;
  margin: 0;
}
body.is-studying .word-back,
body.is-studying .meaning,
body.is-studying .cloze,
body.is-studying .example,
body.is-studying .example-vi,
body.is-studying .ipa,
body.is-studying .typed-wrong {
  overflow-wrap: anywhere;
  min-width: 0;
}
body.is-studying .word-back,
body.is-studying .meaning,
body.is-studying .cloze,
body.is-studying .example,
body.is-studying .example-vi,
body.is-studying .ipa,
body.is-studying .typed-wrong,
body.is-studying .blank,
body.is-studying #typing-answer {
  font-family: var(--card-font, inherit);
}
body.is-studying .cloze { font-family: var(--card-font, "Instrument Serif", Georgia, serif); }
body.is-studying .blank { font-family: var(--card-font, Outfit, system-ui, sans-serif); }
body.is-studying .word-back { font-size: clamp(calc(1.35rem * var(--card-scale, 1.2)), calc(3.6dvh * var(--card-scale, 1.2)), calc(2.8rem * var(--card-scale, 1.2))); line-height: 1.05; }
body.is-studying .meaning,
body.is-studying .face-front .meaning { font-size: clamp(calc(1.05rem * var(--card-scale, 1.2)), calc(2.5dvh * var(--card-scale, 1.2)), calc(1.85rem * var(--card-scale, 1.2))); line-height: 1.15; margin: 0; }
body.is-studying .cloze,
body.is-studying .example { font-size: clamp(calc(0.95rem * var(--card-scale, 1.2)), calc(2.05dvh * var(--card-scale, 1.2)), calc(1.45rem * var(--card-scale, 1.2))); line-height: 1.2; }
body.is-studying .example-vi { font-size: clamp(calc(0.9rem * var(--card-scale, 1.2)), calc(1.9dvh * var(--card-scale, 1.2)), calc(1.3rem * var(--card-scale, 1.2))); line-height: 1.2; }
body.is-studying .ipa { font-size: clamp(calc(0.8rem * var(--card-scale, 1.2)), calc(1.55dvh * var(--card-scale, 1.2)), calc(1.1rem * var(--card-scale, 1.2))); margin: 0; }
body.is-studying .typed-wrong { font-size: clamp(calc(0.78rem * var(--card-scale, 1.2)), calc(1.45dvh * var(--card-scale, 1.2)), calc(1rem * var(--card-scale, 1.2))); margin: 0; }
body.is-studying .quotes { gap: 4px; margin-top: 2px; }
body.is-studying .word-row { margin-top: 0; gap: 8px; }
body.is-studying .meaning-line { margin: 0; gap: 6px; }
body.is-studying .card-divider { margin: 4px 0 0; }
body.is-studying #typing-answer {
  min-height: 40px;
  padding: 8px 10px;
  font-size: clamp(calc(0.95rem * var(--card-scale, 1.2)), calc(2dvh * var(--card-scale, 1.2)), calc(1.25rem * var(--card-scale, 1.2)));
}
.settings-dialog { width: min(92vw, 560px); max-height: min(92dvh, 760px); overflow: hidden; }
.settings-scroll { overflow: auto; min-height: 0; }
.settings-dialog .settings-choice { display: inline-flex; width: auto; margin: 0; }
.settings-dialog fieldset { margin: 0 0 12px; padding: 0; border: 0; }
.settings-dialog legend { font-weight: 800; margin-bottom: 8px; }
.settings-lead { margin: 0 0 12px; }
.settings-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  color: #14181f;
  font-weight: 800;
  cursor: pointer;
}
.settings-choice input { width: auto; margin: 0; }
.settings-choice:has(input:checked) { background: #0f766e; color: #fff; }
.settings-preview {
  margin: 4px 0 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff;
  color: #14181f;
  font-family: var(--card-font, Nunito, system-ui, sans-serif);
}
.settings-preview p { margin: 0; }
.preview-kicker { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #0f766e; }
.preview-word { font-size: calc(1.35rem * var(--card-scale, 1.2)); font-weight: 800; }
.preview-ipa { font-size: calc(0.85rem * var(--card-scale, 1.2)); color: #6b645b; }
.preview-meaning { font-size: calc(1.15rem * var(--card-scale, 1.2)); font-weight: 800; }
.preview-example,
.preview-vi { font-size: calc(0.95rem * var(--card-scale, 1.2)); }
.settings-preview input {
  width: 100%;
  margin-top: 8px;
  min-height: 44px;
  font-family: inherit;
  font-size: calc(1rem * var(--card-scale, 1.2));
}
@media (max-height: 740px), (max-width: 500px) {
  body.is-studying .face-front,
  body.is-studying .face-back { padding: 4px 10px 4px; gap: 4px; }
  body.is-studying .word-back { font-size: clamp(calc(0.72rem * var(--card-scale, 1.2)), calc(1.9dvh * var(--card-scale, 1.2)), calc(1.7rem * var(--card-scale, 1.2))); }
  body.is-studying .meaning,
  body.is-studying .face-front .meaning { font-size: clamp(calc(0.7rem * var(--card-scale, 1.2)), calc(1.55dvh * var(--card-scale, 1.2)), calc(1.25rem * var(--card-scale, 1.2))); }
  body.is-studying .cloze,
  body.is-studying .example { font-size: clamp(calc(0.52rem * var(--card-scale, 1.2)), calc(1.18dvh * var(--card-scale, 1.2)), calc(1.05rem * var(--card-scale, 1.2))); line-height: 1.15; }
  body.is-studying .example-vi { font-size: clamp(calc(0.6rem * var(--card-scale, 1.2)), calc(1.2dvh * var(--card-scale, 1.2)), calc(0.98rem * var(--card-scale, 1.2))); line-height: 1.15; }
  body.is-studying .ipa { font-size: clamp(calc(0.58rem * var(--card-scale, 1.2)), calc(1.05dvh * var(--card-scale, 1.2)), calc(0.9rem * var(--card-scale, 1.2))); }
  body.is-studying #typing-answer { font-size: clamp(calc(0.62rem * var(--card-scale, 1.2)), calc(1.25dvh * var(--card-scale, 1.2)), calc(1rem * var(--card-scale, 1.2))); }
}
body.is-studying .grades { margin-top: 0; gap: 8px; }
body.is-studying .grade { min-height: 44px; padding: 6px 4px; }
body.is-studying .speak-lg,
body.is-studying .speak-sm { width: 44px; height: 44px; }
@media (max-width: 640px) {
  body.is-studying .stage { padding-top: 56px; padding-left: 8px; padding-right: 8px; }
  body.is-studying .grade-en { font-size: 0.6rem; }
}
@media (max-height: 700px) {
  body.is-studying .stage { padding-top: 80px; }
  body.is-studying .blank { min-width: 3.2em; letter-spacing: 0.04em; }
}
@media (max-width: 1100px) {
  body.is-studying .stage { padding-bottom: calc(10px + clamp(72px, 12vw, 104px)); }
}
@media (max-width: 700px) {
  .user-chip { max-width: calc(100vw - 16px); top: 8px; right: 8px; flex-wrap: wrap; }
  body.is-studying .stage { padding-top: 116px; }
  .settings-dialog { padding: 14px 14px 12px; max-height: calc(100dvh - 150px); }
  .settings-dialog h2 { margin-bottom: 4px; }
  .settings-lead { margin: 0 0 8px; }
  .settings-dialog fieldset { margin-bottom: 8px; }
  .settings-choices { gap: 6px; }
  .settings-choice { min-height: 40px; padding: 6px 10px; }
  .settings-preview { margin: 0 0 8px; padding: 8px 10px; }
  .preview-word { font-size: calc(1.15rem * var(--card-scale, 1.2)); }
  .preview-meaning { font-size: calc(1rem * var(--card-scale, 1.2)); }
  .preview-example, .preview-vi { font-size: calc(0.88rem * var(--card-scale, 1.2)); line-height: 1.2; }
  .settings-preview input { min-height: 40px; margin-top: 6px; }
}

.mobile-bar,
.mobile-menu,
.mobile-menu-backdrop { display: none; }
body:not(.is-teacher) #excel-import-btn { display: none !important; }
.word-list-head { flex-wrap: wrap; }
.modal-wide { width: min(96vw, 920px); }
.excel-preview-wrap { max-height: min(52dvh, 460px); overflow: auto; }
.excel-preview { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.excel-preview th, .excel-preview td { padding: 8px; text-align: left; vertical-align: top; border-bottom: 1px solid #e5e7eb; }
.excel-preview input { width: auto; min-height: 44px; }
.excel-row.is-duplicate { background: #fef3c7; }
.excel-row.is-invalid { background: #fee2e2; }
.excel-pick { display: inline-flex; align-items: center; min-height: 44px; }

@media (max-width: 767px) {
  body.is-signed-in .mobile-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    margin: 0;
    padding: 0 92px 0 8px;
    background: rgba(255, 247, 214, 0.96);
    box-shadow: 0 1px 0 rgba(20, 24, 31, 0.08);
  }
  .mobile-back,
  .mobile-menu-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    color: #14181f;
    font: inherit;
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
  }
  .mobile-menu-btn {
    position: fixed;
    top: 4px;
    right: 6px;
    z-index: 72;
  }
  .mobile-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
    font-size: 1rem;
    color: #14181f;
  }
  .mobile-menu-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 68;
    background: rgba(20, 24, 31, 0.28);
  }
  .mobile-menu:not([hidden]) {
    position: fixed;
    top: 52px;
    right: 8px;
    z-index: 73;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(280px, calc(100vw - 16px));
    margin: 0;
    padding: 12px;
    border-radius: 18px;
    background: #fff;
    color: #14181f;
    box-shadow: 0 16px 40px rgba(20, 24, 31, 0.2);
  }
  .mobile-menu-user {
    margin: 0 0 4px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-menu button {
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: #f6f1e8;
    color: #14181f;
    font: inherit;
    font-weight: 800;
    text-align: left;
    padding: 8px 12px;
    cursor: pointer;
  }
  body.is-signed-in .back-home,
  body.is-signed-in .add-word,
  body.is-signed-in .word-list-btn,
  body.is-signed-in .user-chip,
  body.is-signed-in .remaining,
  .word-list-back { display: none !important; }
  body.is-signed-in .brand-mark,
  body.is-signed-in .brand-mark:popover-open {
    width: 32px;
    height: auto;
    top: 8px;
    right: 54px;
    bottom: auto;
    left: auto;
    inset: 8px 54px auto auto;
  }
  body.is-signed-in .home,
  body.is-signed-in .word-list-view { padding-top: 8px; }
  body.is-signed-in .stage { padding-top: 56px; }
  body.is-studying,
  body.is-studying #app-content {
    height: 100dvh;
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
  }
  body.is-studying .stage {
    height: 100dvh;
    max-height: 100dvh;
    padding: 48px 6px 8px;
  }
  body.is-studying:has(.deck.is-flipped) .stage {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
  body.is-studying .study-view,
  body.is-studying .deck,
  body.is-studying .card {
    width: 100%;
    height: 100%;
    max-width: none;
  }
  body.is-studying .face-front,
  body.is-studying .face-back {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    padding: 4px 8px 4px;
    overflow: hidden;
  }
  body.is-studying .photo-slot {
    display: block;
    width: 100%;
    flex: 0 0 auto;
    container-type: normal;
  }
  body.is-studying .photo,
  body.is-studying .photo-back {
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 0;
  }
  body.is-studying .back-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    gap: 4px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  body.is-studying .word-back { font-size: calc(1.45rem * var(--card-scale, 1.2)); line-height: 1.15; text-align: left; }
  body.is-studying .meaning,
  body.is-studying .face-front .meaning { font-size: calc(1.12rem * var(--card-scale, 1.2)); line-height: 1.25; }
  body.is-studying .cloze,
  body.is-studying .example { font-size: calc(1.02rem * var(--card-scale, 1.2)); line-height: 1.3; }
  body.is-studying .example-vi { font-size: calc(0.96rem * var(--card-scale, 1.2)); line-height: 1.3; }
  body.is-studying .ipa { font-size: calc(0.9rem * var(--card-scale, 1.2)); text-align: left; }
  body.is-studying #typing-answer { font-size: calc(1.05rem * var(--card-scale, 1.2)); min-height: 44px; }
  body.is-studying .word-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    margin: 0;
  }
  body.is-studying .word-back { flex: 1 1 auto; min-width: 0; }
  body.is-studying .quote-line {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 8px;
    flex-wrap: nowrap;
  }
  body.is-studying .quote-line .flag { grid-column: 1; grid-row: 1; }
  body.is-studying .quote-line .example { grid-column: 2; grid-row: 1; flex: none; min-width: 0; }
  body.is-studying .quote-line .example-vi { grid-column: 1 / -1; }
  body.is-studying .quote-line .speak {
    grid-column: 3;
    grid-row: 1;
    margin: 0;
    align-self: start;
  }
  body.is-studying .edit-card {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    top: 6px;
    right: 6px;
    justify-content: center;
    opacity: 0.92;
  }
  body.is-studying .edit-card span { display: none; }
  body.is-studying .card-status { padding: 0; font-size: 0.75rem; }
  body.is-studying .grades {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 247, 214, 0.96);
    gap: 6px;
  }
  body.is-studying .grade { min-height: 52px; border-radius: 14px; }
  body.is-keyboard.is-studying,
  body.is-keyboard.is-studying #app-content,
  body.is-keyboard.is-studying .stage {
    height: var(--vv-height, 100dvh);
    max-height: var(--vv-height, 100dvh);
  }
  body.is-keyboard.is-studying .stage { padding-bottom: 8px; }
  body.is-keyboard.is-studying .face-front .photo-slot {
    flex: 0 1 88px;
    max-height: 88px;
    overflow: hidden;
  }
  body.is-keyboard.is-studying .face-front .photo {
    width: 100%;
    max-height: 88px;
    object-fit: contain;
  }
}
