:root {
  --bg: #0b1220;
  --panel: #0f1b33;
  --card: #122246;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --good: #22c55e;
  --bad: #ef4444;
  --shadow: 0 10px 25px rgba(0, 0, 0, .25);
  --radius: 16px;
  --max: 980px;
  font-synthesis-weight: none;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 20% 10%, rgba(56, 189, 248, .18), transparent 60%),
    radial-gradient(900px 600px at 80% 30%, rgba(34, 197, 94, .10), transparent 55%),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none
}

button,
input,
select {
  font: inherit
}

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(11, 18, 32, .65);
  border-bottom: 1px solid rgba(148, 163, 184, .18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  max-width: var(--max);
  margin: 0 auto;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: .2px
}

.brand .pill {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  width: max-content;
}

.pill #pill-xp {
  background: rgba(56, 189, 248, .12);
  border: 1px solid rgba(56, 189, 248, .35);
  color: #bae6fd;
  border-radius: 14px;
  text-align: center;
}

.nav {
  display: flex;
  gap: 8px;
  padding: 0 18px 14px;
  max-width: var(--max);
  margin: 0 auto;
}

.nav a {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(18, 34, 70, .55);
  border: 1px solid rgba(148, 163, 184, .18);
  color: var(--muted);
}

.nav a.active {
  color: var(--text);
  border-color: rgba(56, 189, 248, .45);
  background: rgba(56, 189, 248, .12);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.card {
  grid-column: span 12;
  background: rgba(18, 34, 70, .55);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 18px
}

.card .stats {
  display: flex;
  justify-content: space-around;
  gap: 20px;
}

.stats .stat {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 100%;
  gap: 3px;
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
  border-radius: 14px;
  padding: 10px;
}

.stat .stat-icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* color: #554BD9; */
}

.stat .stat-text {
  color: var(--muted);
  font-size: 14px;
}

.meta {
  color: var(--muted);
  font-size: 13px
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}

.controls input,
.controls select {
  width: inherit;
  background: rgba(15, 27, 51, .7);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}

.select-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.5rem;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
  pointer-events: none;
}

.controls input {
  min-width: 220px;
  flex: 1
}

.btn {
  background: rgba(56, 189, 248, .14);
  border: 1px solid rgba(56, 189, 248, .35);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.05)
}

.btn.secondary {
  background: rgba(148, 163, 184, .10);
  border-color: rgba(148, 163, 184, .22);
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .10);
  border: 1px solid rgba(148, 163, 184, .18);
  color: var(--muted);
  font-size: 12px;
}

.badge.good {
  background: rgba(34, 197, 94, .12);
  border-color: rgba(34, 197, 94, .25);
  color: #bbf7d0
}

.badge.accent {
  background: rgba(56, 189, 248, .12);
  border-color: rgba(56, 189, 248, .25);
  color: #bae6fd
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px
}

.module {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
  display: flex;
  justify-content: space-between;
  gap: 5px;
  align-items: flex-start;
}

.module .title {
  font-weight: 650;
  margin: 0
}

.module .desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px
}

.module .right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 60px;
  align-items: center
}

.progress {
  width: 84px;
  height: 15px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .14);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .16)
}

.progress>div {
  height: 100%;
  background: rgba(56, 189, 248, .85)
}

.phrases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px
}

@media (max-width: 720px) {
  .phrases {
    grid-template-columns: 1fr
  }
}

.phrase {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.phrase .en {
  font-weight: 650
}

.phrase .ru {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px
}

.star {
  cursor: pointer;
  user-select: none;
  opacity: .9
}

.star.on {
  color: var(--accent)
}

.quiz {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qprompt {
  font-size: 18px;
  font-weight: 700
}

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
  cursor: pointer;
}

.option:hover {
  filter: brightness(1.05)
}

.option.correct {
  border-color: rgba(34, 197, 94, .35);
  background: rgba(34, 197, 94, .12)
}

.option.wrong {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .10)
}

/* Сетка картинок (img_options) */
.opts-img {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.option--img {
  padding: 4px;
  border-radius: 14px;
  border: 3px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
  cursor: pointer;
  aspect-ratio: 1;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}

.option--img:hover {
  filter: brightness(1.08);
}

.option--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  pointer-events: none;
}

.option--img.correct {
  border-color: rgba(34, 197, 94, .7);
  background: rgba(34, 197, 94, .12);
}

.option--img.wrong {
  border-color: rgba(239, 68, 68, .7);
  background: rgba(239, 68, 68, .10);
}

.footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 28px 0 10px;
}

.kpi {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 760px) {
  .kpi {
    grid-template-columns: 1fr
  }
}

.kpi .tile {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
}

.kpi .num {
  font-size: 24px;
  font-weight: 800
}

.notice {
  margin-left: auto;
  display: none;
}

.notice.show {
  display: block
}

/* ---------- Auth (Supabase) ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input {
  background: rgba(15, 27, 51, .7);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toggle {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  user-select: none;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.alert {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .16);
  background: rgba(15, 27, 51, .55);
}

.alert.good {
  border-color: rgba(34, 197, 94, .25);
  background: rgba(34, 197, 94, .08);
}

.alert.bad {
  border-color: rgba(239, 68, 68, .25);
  background: rgba(239, 68, 68, .08);
}

/* ── Image phrases & quiz ─────────────────────────── */
.phrase-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  margin-right: 12px;
  flex-shrink: 0;
}

.qimg-wrap {
  text-align: center;
  margin-bottom: 16px;
}

.qimg {
  width: 100%;
  max-width: 340px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
  margin: 0 auto 8px;
}

.qimg-hint {
  font-size: 0.85rem;
  color: var(--c-meta, #888);
}

/* Admin image preview */
.admin-img-preview {
  margin-top: 8px;
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}


/* ── ordering ──────────────────────────────────── */
.ord-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.ord-grid--img {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.ord-item {
  padding: 12px 10px;
  border-radius: 12px;
  border: 2px solid rgba(148, 163, 184, .18);
  background: rgba(15, 27, 51, .55);
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: border-color .15s;
  user-select: none;
}

.ord-item:hover:not(.ord-picked) {
  border-color: rgba(148, 163, 184, .4);
  filter: brightness(1.05);
}

.ord-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.ord-label {
  font-size: 13px;
}

.ord-num {
  position: absolute;
  top: -11px;
  right: -11px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(15, 27, 51, .8);
}

.ord-picked {
  border-color: rgba(59, 130, 246, .45);
}

.ord-correct {
  border-color: rgba(34, 197, 94, .6) !important;
  background: rgba(34, 197, 94, .12) !important;
}

.ord-wrong {
  border-color: rgba(239, 68, 68, .55) !important;
  background: rgba(239, 68, 68, .1) !important;
}

/* ── fill_blanks ────────────────────────────────── */
.blank-text {
  line-height: 2.5;
  font-size: 15px;
  margin-top: 10px;
}

.blank-line {
  margin-bottom: 2px;
}

.blank-slot {
  display: inline-block;
  min-width: 80px;
  border-bottom: 2px solid rgba(148, 163, 184, .4);
  padding: 2px 8px;
  margin: 0 3px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted, #888);
  font-style: italic;
  transition: all .15s;
}

.blank-slot.blank-filled {
  background: rgba(59, 130, 246, .12);
  border-color: rgba(59, 130, 246, .5);
  color: inherit;
  font-style: normal;
  font-weight: 500;
}

.blank-slot.blank-correct {
  background: rgba(34, 197, 94, .15);
  border-color: rgba(34, 197, 94, .6);
  color: inherit;
  font-style: normal;
}

.blank-slot.blank-wrong {
  background: rgba(239, 68, 68, .1);
  border-color: rgba(239, 68, 68, .5);
  color: inherit;
  font-style: normal;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .1);
}

.word-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, .3);
  background: rgba(15, 27, 51, .6);
  cursor: pointer;
  font-size: 14px;
}

.word-chip:hover:not(.used) {
  filter: brightness(1.1);
}

.word-chip.used {
  opacity: .3;
  pointer-events: none;
}

/* ── word_order ─────────────────────────────────── */
.wo-answer {
  min-height: 52px;
  border-bottom: 2px solid rgba(148, 163, 184, .3);
  padding: 10px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  border-radius: 4px;
  transition: border-color .2s;
}

.wo-placeholder,
.spell-placeholder {
  font-size: 14px;
  color: var(--muted, #888);
  font-style: italic;
}

.wo-token {
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, .2);
  border: 1px solid rgba(59, 130, 246, .4);
  cursor: pointer;
  font-size: 14px;
}

.wo-token:hover {
  background: rgba(59, 130, 246, .3);
}

.wo-answer.wo-correct {
  border-color: rgba(34, 197, 94, .6);
  background: rgba(34, 197, 94, .06);
}

.wo-answer.wo-wrong {
  border-color: rgba(239, 68, 68, .5);
  background: rgba(239, 68, 68, .05);
}

.wo-correction {
  color: rgba(74, 222, 128, .9) !important;
  margin-top: 8px;
}

.word-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .1);
}

.word-tile {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, .3);
  background: rgba(15, 27, 51, .6);
  cursor: pointer;
  font-size: 14px;
}

.word-tile:hover:not(.used) {
  filter: brightness(1.1);
}

.word-tile.used {
  opacity: .25;
  pointer-events: none;
}

/* ── word_spelling ──────────────────────────────── */
.spell-prompt {
  margin: 10px 0 6px;
  font-size: 15px;
  color: var(--muted, #aaa);
}

.spell-answer {
  min-height: 52px;
  border-bottom: 2px solid rgba(148, 163, 184, .3);
  padding: 10px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-top: 6px;
  border-radius: 4px;
  transition: border-color .2s;
}

.spell-char {
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(59, 130, 246, .2);
  border: 1px solid rgba(59, 130, 246, .4);
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
}

.spell-char:hover {
  background: rgba(59, 130, 246, .3);
}

.spell-answer.spell-correct {
  border-color: rgba(34, 197, 94, .6);
  background: rgba(34, 197, 94, .06);
}

.spell-answer.spell-wrong {
  border-color: rgba(239, 68, 68, .5);
  background: rgba(239, 68, 68, .05);
}

.spell-correction {
  color: rgba(74, 222, 128, .9) !important;
  margin-top: 8px;
}

.letter-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .1);
}

.letter-tile {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, .3);
  background: rgba(15, 27, 51, .6);
  cursor: pointer;
  font-size: 19px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.letter-tile:hover:not(.used) {
  filter: brightness(1.1);
}

.letter-tile.used {
  opacity: .22;
  pointer-events: none;
}

/* ── badge earned / img opts labeled ────────────── */
.ex-badge-earned {
  font-size: 20px;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 215, 0, .1);
  border: 1px solid rgba(255, 215, 0, .3);
  margin: 12px 0;
}

.opts-img--labeled .option--img {
  aspect-ratio: auto;
  padding: 8px;
}

.opt-label {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-top: 6px;
}

/* ── Skeleton loader ──────────────────────────────── */
@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }

  100% {
    background-position: 400px 0;
  }
}

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg,
      rgba(148, 163, 184, .08) 25%,
      rgba(148, 163, 184, .18) 50%,
      rgba(148, 163, 184, .08) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

.skeleton-line {
  display: block;
}

.skeleton-module {
  padding: 16px 0;
  border-bottom: 1px solid rgba(148, 163, 184, .08);
}

.skeleton-module:last-child {
  border-bottom: none;
}