﻿/* ============================================
   Bambinos Teacher Training - Design System
   Brand: white + Bambinos blue (#3777FF)
   ============================================ */

:root {
  --blue: #3777ff;
  --blue-dk: #1e5ce8;
  --blue-lt: #5b94ff;
  --blue-soft: #e8efff;
  --blue-ghost: #f5f8ff;
  --navy: #0b1b4d;
  --ink: #1b2547;
  --slate: #64748b;
  --slate-lt: #94a3b8;
  --border: #e2e9f7;
  --border-strong: #c9d8f8;
  --white: #ffffff;
  --bg: #f7f9fe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --yellow: #d97706;
  --yellow-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(11, 27, 77, 0.05);
  --shadow-md: 0 1px 2px rgba(11, 27, 77, 0.05), 0 10px 30px -14px rgba(30, 92, 232, 0.25);
  --shadow-lg: 0 2px 4px rgba(11, 27, 77, 0.06), 0 24px 48px -20px rgba(30, 92, 232, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
}

/* Subtle brand-tinted backdrop */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(1100px 550px at 80% -8%, rgba(55, 119, 255, 0.075), transparent 60%),
    radial-gradient(800px 500px at -10% 40%, rgba(55, 119, 255, 0.05), transparent 55%),
    var(--bg);
}

.container { max-width: 920px; margin: 0 auto; padding: 0 20px 72px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  margin: 0 -20px 32px;
  padding-left: 20px;
  padding-right: 20px;
  background: rgba(247, 249, 254, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--white);
  background: var(--blue);
  box-shadow: 0 6px 16px -6px rgba(30, 92, 232, 0.55);
}

.brand h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy);
  line-height: 1.15;
}
.brand h1 .dot-live { color: var(--blue); }
.brand .sub { color: var(--slate); font-size: 12px; font-weight: 500; }

.topbar .user { color: var(--slate); font-size: 13.5px; display: flex; gap: 12px; align-items: center; }
.topbar .user b { color: var(--navy); font-weight: 600; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  background: var(--blue);
  color: var(--white);
  border: 0;
  border-radius: 12px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(30, 92, 232, 0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
button:hover { background: var(--blue-dk); transform: translateY(-1px); box-shadow: 0 12px 24px -10px rgba(30, 92, 232, 0.6); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

button.ghost {
  background: var(--white);
  color: var(--slate);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
button.ghost:hover { color: var(--navy); border-color: var(--blue-lt); }

button.danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #fecaca;
  box-shadow: none;
}
button.danger:hover { background: var(--red); color: var(--white); border-color: var(--red); }

button.sm { padding: 7px 13px; font-size: 12.5px; border-radius: 9px; }

.link {
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
  background: none;
  border: 0;
  font-size: 13px;
  padding: 0;
  font-weight: 500;
  box-shadow: none;
}
.link:hover {
  text-decoration: underline;
  transform: none;
  box-shadow: none;
  background: none;
  color: var(--blue-dk);
}

/* ---------- Inputs ---------- */
input, textarea, select {
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--slate-lt); }
input:hover:not(:focus), textarea:hover:not(:focus), select:hover:not(:focus) { border-color: var(--blue-lt); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(55, 119, 255, 0.14);
}
label { font-size: 12.5px; color: var(--slate); display: block; margin: 14px 0 6px; font-weight: 600; letter-spacing: 0.02em; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow-md);
  overflow-x: auto; /* tables inside cards scroll horizontally on small screens */
}

.center-card {
  max-width: 430px;
  margin: 8vh auto 0;
  text-align: center;
  padding: 40px 36px;
  position: relative;
  overflow: hidden;
}
.center-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--blue);
}
.center-card .logo-badge {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: var(--white);
  background: var(--blue);
  box-shadow: 0 14px 30px -10px rgba(30, 92, 232, 0.6);
}
.center-card h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--navy); margin-bottom: 8px; }
.center-card p { color: var(--slate); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }

.error-msg { color: var(--red); font-size: 13px; font-weight: 600; margin-top: 10px; min-height: 16px; }

/* Auth forms - clean vertical rhythm between field, error text and button */
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.auth-form input { padding: 13px 16px; font-size: 15px; }
.auth-form button { padding: 13px 20px; font-size: 15px; }
.auth-form .error-msg { margin: -6px 0 0; min-height: 0; }

/* ---------- Progress ---------- */
.progress-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-sm);
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--slate);
  font-weight: 500;
  margin-bottom: 12px;
}
.progress-info strong { color: var(--navy); font-weight: 700; }
.progress-bar {
  height: 10px;
  background: var(--blue-soft);
  border-radius: 8px;
  overflow: hidden;
}
.progress-bar > div {
  height: 100%;
  background: var(--blue);
  border-radius: 8px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Video list (album grid) ---------- */
.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.video-item {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.video-item:hover:not(.locked) {
  border-color: var(--blue-lt);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.video-item.locked { opacity: 0.65; cursor: not-allowed; background: var(--blue-ghost); }
.video-thumb img { transition: transform 0.35s ease; }
.video-item:hover:not(.locked) .video-thumb img { transform: scale(1.05); }
.video-item:hover:not(.locked) .thumb-play::before { transform: scale(1.08); }
.thumb-play::before { transition: transform 0.2s ease; }

.video-num {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-soft);
  color: var(--blue-dk);
  font-weight: 800;
  font-size: 16px;
}
.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--navy);
}
.video-thumb .badge {
  position: absolute;
  top: 10px;
  right: 10px;
}
.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-item.locked .video-thumb img { filter: grayscale(0.6); opacity: 0.55; }
.thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 27, 77, 0.18);
  transition: background 0.15s;
}
.video-item:hover:not(.locked) .thumb-play { background: rgba(11, 27, 77, 0.32); }
.thumb-play::before {
  content: '';
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.thumb-play::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-38%, -50%);
  border-left: 13px solid var(--blue);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}
.thumb-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(11, 27, 77, 0.35);
}
.thumb-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Placeholder cards for unreleased lessons */
.video-item.placeholder {
  cursor: default;
  opacity: 0.75;
}
.video-item.placeholder:hover { transform: none; box-shadow: var(--shadow-sm); }
.placeholder-thumb {
  background: var(--blue-ghost);
  border-bottom: 1px dashed var(--blue-lt);
}
.placeholder-thumb .thumb-lock { opacity: 0.5; }
.video-item.placeholder .video-info h3 { color: var(--slate-lt); }
.video-item.placeholder .video-info p { color: var(--slate-lt); }

/* All-modules-complete banner */
.all-done {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--green);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.all-done-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 14px -4px rgba(22, 163, 74, 0.45);
}
.all-done-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 3px;
}
.all-done-sub {
  font-size: 13px;
  color: var(--slate);
  line-height: 1.5;
}

.video-info { padding: 14px 16px 16px; }
.video-info h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-info p { color: var(--slate); font-size: 12.5px; margin-top: 5px; }

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge.locked { background: var(--blue-ghost); color: var(--slate-lt); border: 1px solid var(--border); }
.badge.unlocked { background: var(--blue); color: var(--white); box-shadow: 0 4px 10px -4px rgba(55, 119, 255, 0.6); }
.badge.watched { background: var(--yellow-soft); color: var(--yellow); border: 1px solid #fde68a; }
.badge.passed { background: var(--green); color: var(--white); }

/* ---------- Admin video list (rows) ---------- */
.admin-video-list { display: flex; flex-direction: column; gap: 12px; }
.admin-video-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.admin-video-item:hover { border-color: var(--blue-lt); box-shadow: var(--shadow-md); }
.admin-video-item .video-info { padding: 0; flex: 1; min-width: 0; }

/* ---------- Watch view ---------- */
.player-wrap {
  position: relative;
  padding-top: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--navy);
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
}
.player-wrap iframe, .player-wrap #yt-player { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.player-wrap { margin-bottom: 0; }
.player-shell { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); margin-bottom: 20px; background: var(--navy); }
.player-shell:fullscreen { border-radius: 0; display: flex; flex-direction: column; }
.player-shell:fullscreen .player-wrap { flex: 1; padding-top: 0; }
.player-ctrls {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #0b1f3a; color: #fff; user-select: none;
}
.pl-btn {
  background: none; border: 0; color: #fff; cursor: pointer;
  font-size: 15px; padding: 4px 8px; border-radius: 6px; width: auto; box-shadow: none;
}
.pl-btn:hover { background: rgba(255,255,255,.15); }
.pl-progress {
  position: relative;
  flex: 1; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,.25);
}
.pl-progress-fill { height: 100%; width: 0; border-radius: 3px; background: var(--accent, #e63946); transition: width .4s linear; }
.pl-time { font-size: 12px; color: rgba(255,255,255,.85); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pl-vol { width: 80px; accent-color: #fff; margin: 0; box-shadow: none; }
.pl-big {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: rgba(0,0,0,.18);
}
.pl-big span {
  width: 76px; height: 76px; border-radius: 50%;
  background: rgba(11,31,58,.88); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; padding-left: 7px;
  box-shadow: 0 4px 20px rgba(0,0,0,.45);
  transition: transform .15s ease, background .15s ease;
}
.pl-big:hover span { transform: scale(1.08); background: var(--blue, #2563eb); }
#pl-qual-cur { font-size: 10px; opacity: .8; margin-left: 3px; }
.pl-menu {
  position: absolute; right: 10px; bottom: 44px; z-index: 30;
  background: #0b1f3a; border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px; padding: 4px; min-width: 100px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.pl-menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: rgba(255,255,255,.9); padding: 7px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13px; box-shadow: none;
}
.pl-menu button:hover { background: rgba(255,255,255,.12); }
.pl-menu button.sel { color: #ffd166; font-weight: 600; }
.pl-menu button.sel::before { content: '✓ '; }
@media (max-width: 560px) {
  .pl-vol { display: none; }
  .pl-time { font-size: 11px; }
}
.watch-actions { display: flex; gap: 14px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.watch-hint { color: var(--slate); font-size: 13.5px; }

/* ---------- Mini chessboard (lichess/chess.com style) ---------- */
.mini-board {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid var(--navy);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  --sq-lt: #e6f0ff;
  --sq-dk: #5aa5ff;
}
.mini-board .board-arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}
.mini-board .sq {
  position: relative;
  min-width: 0;
  min-height: 0;
}
.mini-board .sq.lt { background: var(--sq-lt); }
.mini-board .sq.dk { background: var(--sq-dk); }
.mini-board .sq.hl::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 215, 0, 0.45);
  box-shadow: inset 0 0 0 3px rgba(217, 119, 6, 0.9);
}
.mini-board .sq img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6%;
  display: block;
  z-index: 1;
  pointer-events: none;
}
.mini-board .coord {
  position: absolute;
  font-size: clamp(6px, 1.2vw, 9px);
  font-weight: 800;
  z-index: 2;
  pointer-events: none;
  line-height: 1;
}
.mini-board .sq.lt .coord { color: rgba(11, 27, 77, 0.6); }
.mini-board .sq.dk .coord { color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.mini-board .coord.rank { top: 2px; left: 3px; }
.mini-board .coord.file { bottom: 1px; right: 3px; }

/* ---------- Board editor ---------- */
.bedit { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin-top: 10px; }
.bedit-tools {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  align-items: center;
}
.bedit-tools button {
  width: 40px;
  height: 40px;
  padding: 4px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bedit-tools button img { width: 28px; height: 28px; pointer-events: none; }
.bedit-tools button:hover { background: var(--blue-ghost); border-color: var(--blue-lt); transform: none; box-shadow: none; }
.bedit-tools button.active {
  background: var(--blue-soft);
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(55, 119, 255, 0.18);
}
.bedit-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-lt);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.bedit-marks { gap: 6px; }
.bedit-marks button.bedit-mark {
  width: auto;
  height: 36px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  gap: 5px;
}
.bedit-marks button.bedit-mark.active {
  background: var(--yellow-soft);
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.18);
}
.bedit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bedit-board { max-width: 320px; touch-action: none; user-select: none; -webkit-user-select: none; }
.bedit-board .sq { cursor: pointer; }
.bedit-board .sq:has(> img) { cursor: grab; }
.bedit-board .sq:hover { outline: 2px solid rgba(11, 27, 77, 0.25); outline-offset: -2px; }
.bedit-board .sq.pend {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
  z-index: 1;
}
/* drag & drop editing - lichess style */
.bedit-board .sq.drop-target {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
  z-index: 1;
}
.bedit-board .sq.drag-src img { opacity: 0.3; }
.drag-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 8px rgba(11, 27, 77, 0.4));
}
.bedit-tools button:has(img) { cursor: grab; touch-action: none; }
.bedit-turn {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bedit-turn button {
  height: 30px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
}
.bedit-turn button.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}
.bedit-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--slate-lt);
}
.board-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.board-toggle input { accent-color: var(--blue); width: 15px; height: 15px; margin: 0; }

/* ---------- Quiz slides ---------- */
.quiz-body.with-board { display: flex; gap: 26px; align-items: flex-start; }
.quiz-body.with-board .quiz-main { flex: 1; min-width: 0; }
.qboard-preview { margin-top: 10px; }
[data-qbp] { max-width: 170px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.quiz-head .qnum { color: var(--slate); font-size: 13.5px; font-weight: 600; }
.quiz-dots { display: flex; gap: 6px; }
.quiz-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--blue-soft); transition: all 0.2s; }
.quiz-dots span.done { background: var(--green); }
.quiz-dots span.now { background: var(--blue); transform: scale(1.35); }

.question-text { font-size: 20px; font-weight: 700; line-height: 1.45; color: var(--navy); margin-bottom: 24px; letter-spacing: -0.01em; }

.options { display: flex; flex-direction: column; gap: 11px; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 15px 18px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  color: var(--ink);
  width: 100%;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.13s, background 0.13s, transform 0.13s, box-shadow 0.13s;
}
.option:hover {
  border-color: var(--blue-lt);
  background: var(--blue-ghost);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}
.option:hover .letter { background: var(--blue-lt); color: var(--white); }
.option .letter {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--blue-soft);
  color: var(--blue-dk);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  transition: all 0.13s;
}
.option.selected { border-color: var(--blue); background: var(--blue-ghost); box-shadow: 0 0 0 3px rgba(55, 119, 255, 0.15); }
.option.selected .letter { background: var(--blue); color: var(--white); }

/* ---------- Result ---------- */
.score-ring {
  --p: 0;
  width: 148px;
  height: 148px;
  margin: 14px auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.score-ring::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--border);
}
.score-ring span {
  position: relative;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--navy);
}
.score-ring.fail { background: conic-gradient(var(--red) calc(var(--p) * 1%), var(--red-soft) 0); }
.score-ring { background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--green-soft) 0); }

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-status { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.result-sub { color: var(--slate); font-size: 14px; margin-bottom: 22px; }

.review-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.review-item.right { border-left: 4px solid var(--green); }
.review-item.wrong { border-left: 4px solid var(--red); }
.review-item .rtext { font-weight: 700; font-size: 14.5px; color: var(--navy); margin-bottom: 8px; }
.review-item .ans { font-size: 13.5px; color: var(--slate); }
.review-item .ans.ok { color: var(--green); font-weight: 600; }
.review-item .ans.bad { color: var(--red); }

/* ---------- Tables & stats ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  color: var(--slate);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--blue-ghost);
}
th:first-child { border-radius: 10px 0 0 0; }
th:last-child { border-radius: 0 10px 0 0; }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--ink); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--blue-ghost); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-box::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--blue);
}
.stat-box .val { font-size: 30px; font-weight: 800; color: var(--navy); letter-spacing: -0.03em; }
.stat-box .lbl { color: var(--slate); font-size: 11.5px; margin-top: 5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* ---------- Admin ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 26px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  box-shadow: var(--shadow-sm);
  width: fit-content;
}
.tab {
  background: transparent;
  color: var(--slate);
  border: 0;
  border-radius: 10px;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.15s;
}
.tab:hover { color: var(--navy); background: var(--blue-ghost); transform: none; box-shadow: none; }
.tab.active {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 6px 14px -6px rgba(30, 92, 232, 0.55);
}

.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.q-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 12px;
  background: var(--blue-ghost);
}
.q-editor textarea { margin-bottom: 10px; background: var(--white); }
.q-editor .opt-row { display: flex; gap: 10px; align-items: center; margin-bottom: 7px; }
.q-editor .opt-row input[type="radio"] { width: auto; flex-shrink: 0; accent-color: var(--blue); }

.hidden { display: none !important; }
.muted { color: var(--slate); font-size: 13px; }
.section-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
  margin: 30px 0 14px;
  letter-spacing: -0.01em;
}

/* View fade-in */
#app > * { animation: fadeUp 0.3s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .card { padding: 22px; }
  .center-card { padding: 32px 24px; }
  .video-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .admin-video-item { padding: 13px 14px; flex-wrap: wrap; }
  .video-num { width: 40px; height: 40px; }
  .thumb-play::before { width: 30px; height: 30px; }
  .thumb-play::after { border-left-width: 10px; border-top-width: 7px; border-bottom-width: 7px; }
  .question-text { font-size: 17px; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 9px 8px; font-size: 12.5px; }
  .topbar .user { font-size: 12px; }
}

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 27, 77, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.16s ease;
  padding: 20px;
}
.modal-backdrop.show { opacity: 1; }
.modal-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(11, 27, 77, 0.3);
  padding: 26px;
  width: 100%;
  max-width: 400px;
  transform: translateY(10px) scale(0.97);
  transition: transform 0.16s ease;
}
.modal-backdrop.show .modal-card { transform: none; }
.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 8px;
}
.modal-msg {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 18px;
}
.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.modal-card input {
  width: 100%;
  margin-bottom: 6px;
}
.modal-err {
  color: var(--red);
  font-size: 12px;
  min-height: 16px;
  margin-bottom: 6px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions button { padding: 9px 20px; font-size: 13px; }

/* ---------- Leaderboard / teachers table ---------- */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover { color: var(--blue); }
.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  background: var(--blue-ghost);
  color: var(--slate);
}
.rank-num.r1 { background: #fef3c7; color: #b45309; box-shadow: inset 0 0 0 1.5px #f59e0b; }
.rank-num.r2 { background: #f1f5f9; color: #475569; box-shadow: inset 0 0 0 1.5px #94a3b8; }
.rank-num.r3 { background: #fed7aa; color: #9a3412; box-shadow: inset 0 0 0 1.5px #ea580c; }
tr.rank-top td { background: #f8fbff; }
td { white-space: nowrap; }
td:first-child, td:nth-child(2) { white-space: normal; }

/* Compact teachers table cells */
.sub-cell { font-size: 11.5px; color: var(--slate-lt); font-weight: 500; margin-top: 2px; }
.prog-cell { min-width: 110px; }
.prog-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--slate); font-weight: 600; margin-bottom: 4px; }
.mini-bar { height: 6px; background: var(--blue-soft); border-radius: 6px; overflow: hidden; }
.mini-bar > div { height: 100%; background: var(--blue); border-radius: 6px; }
.mod-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--blue-ghost);
  border: 1px solid var(--blue-lt);
  color: var(--blue);
  font-size: 11.5px;
  font-weight: 700;
}
.mod-chip.done { background: var(--green); border-color: var(--green); color: var(--white); }
td.actions { text-align: right; white-space: nowrap; }
.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  background: var(--blue-ghost);
  border: 1px solid var(--border);
  color: var(--slate);
  font-size: 13px;
  line-height: 1;
  box-shadow: none;
  margin-left: 6px;
  vertical-align: middle;
}
.icon-btn:hover { background: var(--blue); border-color: var(--blue); color: var(--white); transform: none; }
.icon-btn.danger { color: var(--red); }
.icon-btn.danger:hover { background: var(--red); border-color: var(--red); color: var(--white); }
.icon-btn svg { width: 14px; height: 14px; display: block; margin: auto; }
.sort-arrow {
  display: inline-block;
  width: 12px;
  margin-left: 4px;
  font-size: 9px;
  color: var(--blue);
  vertical-align: 2px;
}

/* ---------- In-video checkpoints ---------- */
.cp-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 15, 40, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.cp-card { max-width: 620px; width: 100%; margin: auto; }
.cp-dot {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 2px solid var(--navy);
  box-shadow: 0 0 0 1px rgba(255,255,255,.4); z-index: 2;
}
.cp-dot.done { background: var(--green, #22c55e); }
.cp-tag {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--blue);
  margin-bottom: 8px;
}
.cp-fb-ok { color: var(--green); font-weight: 700; margin: 14px 0 6px; font-size: 15px; }
.cp-fb-bad { color: var(--ink); margin: 14px 0 6px; font-size: 14px; line-height: 1.5; }
.cp-fb-bad b { color: var(--green); }
.option.correct { border-color: var(--green); background: #f0fdf4; }
.option.wrong { border-color: var(--red); background: #fef2f2; }

/* Pin action column */
table td:last-child { width: 1%; white-space: nowrap; }
.admin-container { max-width: 1180px; }

/* Compact results table - overflow scrolls inside the card, never the page */
.table-scroll { overflow-x: auto; }
.admin-table td { padding: 11px 12px; vertical-align: middle; }
.admin-table .sub-cell { white-space: normal; }
.admin-table .level-cell { width: 250px; min-width: 190px; white-space: normal; }
.admin-table .level-cell .lv-info { white-space: normal; }
.admin-table .level-cell .lv-name { white-space: nowrap; }
.admin-table .level-cell .lv-mod { white-space: normal; }
.admin-table .level-cell .sub-cell { margin-top: 4px; }

/* ============================================
   Responsive - tablets & phones
   ============================================ */

/* Faster taps on touch devices (no double-tap zoom delay) */
button, .option, .video-item { touch-action: manipulation; }

/* Tablets and small laptops */
@media (max-width: 900px) {
  .admin-container { max-width: 100%; }
  /* Quiz board stacks above the question (#qboard itself gets .mini-board) */
  .quiz-body.with-board { flex-direction: column; }
  .quiz-body.with-board #qboard { order: -1; align-self: center; margin-bottom: 18px; }
  #qboard.mini-board { max-width: 340px; }
  .bedit-tools { flex-wrap: wrap; }
  .table-toolbar { flex-wrap: wrap; }
}

/* Phones */
@media (max-width: 600px) {
  .container { padding: 0 14px 56px; }
  .topbar { margin: 0 -14px 24px; padding: 12px 14px; }
  .brand { gap: 9px; }
  .brand h1 { font-size: 16px; }
  .brand .sub { font-size: 11px; }
  .logo-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 20px; }
  .topbar .user { font-size: 12px; gap: 8px; }

  /* Prevent iOS auto-zoom on input focus */
  input, textarea, select { font-size: 16px; }

  .progress-wrap { padding: 16px 18px; margin-bottom: 20px; }
  .video-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  .watch-actions { flex-direction: column; align-items: stretch; }
  .watch-actions button { width: 100%; }
  .watch-hint { font-size: 13px; }

  .question-text { font-size: 16.5px; margin-bottom: 18px; }
  .option { padding: 13px 14px; font-size: 14px; gap: 11px; }
  .option .letter { width: 27px; height: 27px; font-size: 12px; }
  .quiz-head { margin-bottom: 16px; }
  #qboard.mini-board { max-width: 300px; }

  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
  .stat-box { padding: 14px; }
  .stat-box .val { font-size: 24px; }

  .card { padding: 20px 16px; }
  th, td { padding: 10px 10px; font-size: 12.5px; }

  .modal-card { padding: 20px; max-height: 90vh; overflow-y: auto; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions button { flex: 1; }

  .score-ring { width: 120px; height: 120px; }
  .score-ring span { font-size: 28px; }

  .bedit { max-width: 100%; }
  .bedit-board { max-width: 280px; margin: 0 auto; }

  .all-done { padding: 14px 16px; gap: 12px; }
  .all-done-icon { width: 36px; height: 36px; font-size: 17px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .video-list { grid-template-columns: 1fr 1fr; }
  .video-info h3 { font-size: 13px; }
  .video-info p { font-size: 11.5px; }
}


/* ==================== Assessment app ==================== */

.wfull { width: 100%; }
.small { font-size: 12px; }

.user-chip {
  background: var(--blue-soft); color: var(--blue-dk); border: 1px solid var(--border-str);
  font-weight: 700; font-size: 13px; padding: 7px 14px; border-radius: 999px;
}

.how-list { text-align: left; color: var(--slate); font-size: 13.5px; line-height: 1.9; padding-left: 20px; margin: 0 0 20px; }
.how-list b { color: var(--navy); }

/* --- Badges --- */
.badge-ok    { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.badge-err   { background: var(--red-soft);   color: var(--red);   border: 1px solid #fecaca; }
.badge-warn  { background: var(--yellow-soft);color: var(--yellow);border: 1px solid #fde68a; }
.badge-blue  { background: var(--blue); color: var(--white); box-shadow: 0 4px 10px -4px rgba(55,119,255,.6); }
.badge-dark  { background: var(--navy); color: var(--white); }
.badge-ghost { background: var(--blue-ghost); color: var(--slate); border: 1px solid var(--border); }
.badge.small, .badge.sm { font-size: 10.5px; padding: 3px 9px; }

.info-msg {
  background: var(--blue-ghost); border: 1px solid var(--border); color: var(--ink);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}

/* ============================================
   Student assessment - premium puzzle surface
   Board hero left, task rail right. Everything
   sizes to the viewport - no inner scrollbars.
   ============================================ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.pz-wrap { display: flex; justify-content: center; animation: rise .35s ease; }
.pz-main {
  display: flex; gap: 24px; align-items: flex-start;
  width: min(1140px, 100%);
}
.pz-board-col { flex: 0 0 auto; min-width: 0; }

/* Puzzle mode - lichess-style: near-full viewport width, board sizes to the
   screen height so the whole puzzle fits with no page scroll. */
.container.puzzle-mode { max-width: 1340px; padding-bottom: 18px; }
.container.puzzle-mode .topbar { margin-bottom: 10px; }
.container.puzzle-mode .pz-main { width: 100%; gap: 22px; }
.container.puzzle-mode .pz-board-col { flex: 1 1 auto; display: flex; justify-content: center; }
.container.puzzle-mode .pz-rail { flex: 0 0 360px; max-width: 360px; }
.container.puzzle-mode .pz-board-card { margin: 0; }

/* Compact the right rail in puzzle mode so the whole panel fits the
   viewport - denser cards and a tighter level-path ladder. */
@media (min-width: 961px) {
  .container.puzzle-mode .pz-rail {
    gap: 10px;
    max-height: calc(100dvh - 110px); overflow-y: auto;
  }
  .container.puzzle-mode .rail-card { padding: 13px 16px; border-radius: 14px; }
  .container.puzzle-mode .task-card .task-title { font-size: 15px; margin-bottom: 4px; }
  .container.puzzle-mode .task-card .task-sub { margin-bottom: 6px; }
  .container.puzzle-mode .task-desc { margin: 8px 0 2px; padding: 8px 11px; font-size: 12px; }
  .container.puzzle-mode .progress-card .progress-top { margin-bottom: 6px; }
  .container.puzzle-mode .progress-card .progress-bar { margin-bottom: 9px; }
  .container.puzzle-mode .progress-dots { gap: 4px; }
  .container.puzzle-mode .dot { width: 9px; height: 9px; }
  .container.puzzle-mode .lvl-path { padding: 11px 13px 9px; }
  .container.puzzle-mode .lp-head { margin-bottom: 6px; }
  .container.puzzle-mode .lp-row { padding: 4px 7px; gap: 8px; }
  .container.puzzle-mode .lp-icon { width: 20px; height: 20px; font-size: 10.5px; }
  .container.puzzle-mode .lp-info b { font-size: 12px; }
  .container.puzzle-mode .lp-info em { font-size: 11px; }
  .container.puzzle-mode .lp-info span { font-size: 10.5px; }
  .container.puzzle-mode .giveup-btn { padding: 10px; font-size: 12.5px; }
  .container.puzzle-mode .milestone { padding: 11px 14px; margin-bottom: 8px; }
}

.pz-board-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px;
  box-shadow: var(--shadow-lg);
  width: fit-content;
  margin: 0 auto;
}
.pz-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 2px 4px 12px;
}
.pz-num {
  font-size: 15px; font-weight: 800; color: var(--navy); letter-spacing: -0.01em;
}
.pz-num em { font-style: normal; font-weight: 600; color: var(--slate-lt); margin-left: 5px; font-size: 13px; }
.pz-meta-right { display: flex; align-items: center; gap: 8px; }

.side-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; text-transform: capitalize;
  padding: 5px 12px; border-radius: 999px;
}
.side-chip .side-dot { width: 11px; height: 11px; border-radius: 50%; }
.side-w { background: var(--blue-ghost); color: var(--navy); border: 1px solid var(--border); }
.side-w .side-dot { background: var(--white); border: 1.5px solid var(--slate-lt); }
.side-b { background: var(--navy); color: var(--white); }
.side-b .side-dot { background: #1b2547; border: 1.5px solid #4a5a8f; }

.timer-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; color: var(--slate);
  font-variant-numeric: tabular-nums;
  padding: 5px 12px; border-radius: 999px;
  background: var(--blue-ghost); border: 1px solid var(--border);
}
.timer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Board slot - sized to the viewport so nothing scrolls inside */
#board-slot { width: min(600px, calc(100dvh - 235px)); }
.container.puzzle-mode #board-slot { width: min(700px, calc(100dvh - 175px), calc(100vw - 450px)); }
.board-frame { width: 100%; border: 0; display: block; aspect-ratio: 1; border-radius: 12px; }
.board-retry {
  display: block; width: 100%; margin-top: 8px; padding: 12px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--white); color: var(--slate); font-weight: 700; cursor: pointer;
}
.board-retry:active { transform: scale(.99); }

/* --- Right rail --- */
.pz-rail { flex: 1 1 300px; min-width: 280px; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.rail-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.task-card { border-top: 3px solid var(--blue); }
.task-kicker {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .12em; color: var(--blue); margin-bottom: 7px;
}
.task-card .task-title { font-weight: 800; color: var(--navy); font-size: 16px; line-height: 1.35; margin-bottom: 5px; letter-spacing: -0.01em; }
.task-card .task-sub { font-size: 13px; color: var(--slate); margin-bottom: 10px; }
.task-card .task-sub b { color: var(--navy); }

.task-desc {
  margin: 10px 0 4px;
  padding: 10px 12px;
  background: var(--blue-ghost);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--navy);
}
.task-desc-tag {
  display: block; font-size: 9.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .1em; color: var(--blue); margin-bottom: 4px;
}
.task-tags { margin-top: 8px; }
.tag-chip {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--slate);
  background: var(--blue-ghost); border: 1px solid var(--border);
  padding: 4px 11px; border-radius: 999px;
}

/* Reserved-height feedback zone - banners appear inside it so the rail
   never reflows when feedback or a milestone shows up. */
.feedback { min-height: 50px; display: flex; flex-direction: column; justify-content: center; }
.feedback-banner { width: 100%;
  border-radius: 14px; padding: 13px 16px; font-weight: 700; font-size: 14px;
  animation: fbIn .25s ease;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-sm);
}
@keyframes fbIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.fb-ok   { background: var(--green-soft); color: #15803d; border: 1px solid #bbf7d0; }
.fb-err  { background: var(--red-soft);   color: var(--red);   border: 1px solid #fecaca; }
.fb-info { background: var(--blue-soft);  color: var(--blue-dk);border: 1px solid var(--border-strong); }
.feedback .wfull, .feedback button { margin-top: 10px; width: 100%; }

.progress-card .progress-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.progress-card .progress-label { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-lt); }
.progress-card .progress-pct { font-size: 13px; font-weight: 800; color: var(--blue); font-variant-numeric: tabular-nums; }
.progress-card .progress-bar { height: 7px; background: var(--blue-ghost); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress-card .progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue-lt), var(--blue)); border-radius: 99px; transition: width .4s; }
.progress-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border); transition: transform .15s; }
.dot:hover { transform: scale(1.25); }
.dot-ok { background: var(--green); }
.dot-err { background: var(--red); }
.dot-mistake { box-shadow: 0 0 0 2px var(--yellow-soft), 0 0 0 3px var(--yellow); }
.dot-current { background: var(--white); border: 2px solid var(--blue); }

.giveup-btn {
  background: var(--white); color: var(--slate);
  border: 1.5px dashed var(--border-strong); border-radius: 14px;
  padding: 12px; font-size: 13px; font-weight: 600;
  box-shadow: none; width: 100%;
}
.giveup-btn b { color: var(--navy); }
.giveup-btn:hover { border-color: var(--blue-lt); color: var(--navy); background: var(--blue-ghost); transform: none; box-shadow: none; }

/* --- Result card --- */
.result-card { max-width: 580px; }
.score-hero { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; }
.score-hero h2 { margin-bottom: 4px; }
.result-card .score-ring { width: 96px; height: 96px; flex-shrink: 0; }
.result-card .score-ring span { font-size: 23px; }

.level-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
  background: var(--blue-ghost); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
}
.level-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--slate-lt); }
.level-badge { font-weight: 800; font-size: 13px; padding: 6px 16px; border-radius: 999px; margin-left: auto; }
.lv-beg { background: var(--blue-soft); color: var(--blue-dk); border: 1px solid var(--border-strong); }
.lv-dev { background: var(--yellow-soft); color: var(--yellow); border: 1px solid #fde68a; }
.lv-int { background: var(--blue); color: var(--white); box-shadow: 0 6px 14px -6px rgba(30,92,232,.55); }
.lv-adv { background: var(--green); color: var(--white); box-shadow: 0 6px 14px -6px rgba(22,163,74,.5); }

/* Smart level chip (admin results table + student detail) */
.lv-chip { display: inline-flex; align-items: center; gap: 10px; text-align: left; }
.lv-num {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
  box-shadow: 0 4px 10px -4px rgba(11, 27, 77, 0.4);
}
.lv-info { display: flex; flex-direction: column; min-width: 0; }
.lv-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.lv-tag { margin-left: 6px; font-size: 10.5px; font-weight: 600; color: var(--slate-lt); }
.lv-mod {
  font-size: 11px; color: var(--slate-lt); line-height: 1.35; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 7px; margin-bottom: 18px; }
.result-cell {
  border-radius: 12px; padding: 8px 4px; text-align: center;
  border: 1px solid var(--border);
  transition: transform .15s ease;
}
.result-cell:hover { transform: translateY(-2px); }
.result-cell .rc-num { font-size: 10.5px; font-weight: 700; color: var(--slate-lt); }
.result-cell .rc-mark { font-size: 16px; font-weight: 800; line-height: 1.2; }
.result-cell .rc-sub { font-size: 9.5px; color: var(--yellow); font-weight: 700; }
.rc-ok { background: var(--green-soft); border-color: #bbf7d0; } .rc-ok .rc-mark { color: var(--green); }
.rc-err { background: var(--red-soft); border-color: #fecaca; }  .rc-err .rc-mark { color: var(--red); }
.result-foot { margin-bottom: 16px; }

/* --- Admin tables --- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th {
  text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--slate-lt); padding: 10px 10px 8px;
  border-bottom: 1.5px solid var(--border);
}
.admin-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:hover { background: var(--blue-ghost); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.detail-card { margin-top: 20px; }
.attempt-block { margin-bottom: 22px; }
.attempt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.progress-cells { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.progress-cells .prog-cell { min-width: 44px; }
.answers-detail .ans-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; font-size: 13px;
}
.ans-pos { font-weight: 800; color: var(--slate-lt); min-width: 30px; }
.ans-title { font-weight: 600; color: var(--navy); }
.ans-moves { flex-basis: 100%; }
.ans-board { width: 56px; height: 56px; margin-left: auto; }
.ans-board .mini-board { border-radius: 8px; }

/* --- Puzzle admin --- */
.padd-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 22px; }
@media (max-width: 760px) { .padd-grid { grid-template-columns: 1fr; } }
.padd-preview { width: 190px; margin-top: 10px; }
.padd-bedt { margin-top: 12px; }
.padd-grid label { display: block; }

.puzzle-item { align-items: center; }
.pz-board { width: 84px; height: 84px; flex-shrink: 0; }
.pz-board .mini-board { border-radius: 10px; }
.pz-info { flex: 1; min-width: 0; }
.pz-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.pz-sol { font-family: 'Consolas', 'Menlo', monospace; font-size: 12px; }
.pz-actions { flex-shrink: 0; }

textarea#pgn-text { margin: 10px 0; font-family: 'Consolas','Menlo',monospace; font-size: 12px; }

/* --- Intro steps --- */
.intro-card { max-width: 480px; }
.how-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; text-align: left; }
.how-step {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--blue-ghost); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.how-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  box-shadow: 0 4px 8px -3px rgba(30, 92, 232, .5);
}
.how-step b { display: block; font-size: 13.5px; color: var(--navy); margin-bottom: 1px; }
.how-step span:not(.how-num) { font-size: 12.5px; color: var(--slate); line-height: 1.45; }

@media (max-width: 960px) {
  .pz-main { flex-direction: column; align-items: stretch; }
  .pz-board-col { align-self: center; width: 100%; }
  .pz-board-card { width: 100%; }
  #board-slot, .container.puzzle-mode #board-slot { width: 100%; max-width: 560px; margin: 0 auto; display: block; }
  .pz-rail { max-width: 560px; width: 100%; align-self: center; }
}

@media (max-width: 700px) {
  .score-hero { flex-direction: column; text-align: center; }
  .pz-main { gap: 14px; }
  .pz-board-card { padding: 10px; border-radius: 16px; }
  .pz-meta { flex-wrap: wrap; }
}

/* table fit fixes */
.admin-table .act-cell { text-align: center; }
.admin-table .act-cell .row-actions { display: flex; gap: 6px; flex-wrap: nowrap; justify-content: center; }
.admin-table td:nth-child(2) { white-space: nowrap; }
.level-badge { white-space: nowrap; color: var(--white); }

/* --- Level path (live ladder) --- */
.lvl-path { padding: 14px 16px 12px; }
.lp-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .07em; color: var(--slate-lt);
}
.lp-head b { color: var(--navy); font-size: 12px; }
.lp-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 10px;
}
.lp-row + .lp-row { margin-top: 2px; }
.lp-icon {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  background: var(--blue-ghost); color: var(--slate-lt);
  border: 1.5px solid var(--border);
}
.lp-crossed .lp-icon { background: var(--lc); border-color: var(--lc); color: var(--white); }
.lp-stopped .lp-icon { background: var(--red-soft); border-color: #fecaca; color: var(--red); }
.lp-current { background: var(--blue-ghost); border: 1px solid var(--border-strong); }
.lp-current .lp-icon { border-color: var(--blue); background: var(--blue-soft); }
.lp-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--blue);
  animation: lp-pulse 1.4s ease-out infinite;
}
@keyframes lp-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(55,119,255,.45); }
  70%  { box-shadow: 0 0 0 7px rgba(55,119,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(55,119,255,0); }
}
.lp-info { flex: 1; min-width: 0; }
.lp-info b { font-size: 12.5px; color: var(--navy); display: block; line-height: 1.25; }
.lp-info em { font-style: normal; font-weight: 600; color: var(--slate-lt); margin-left: 5px; font-size: 11.5px; }
.lp-info span { font-size: 11px; color: var(--slate-lt); }
.lp-locked { opacity: .55; }
.lp-range { font-size: 10px; font-weight: 700; color: var(--slate-lt); white-space: nowrap; }
.lp-crossed .lp-range, .lp-current .lp-range { color: var(--slate); }

/* --- Stage-checkpoint milestone --- */
.milestone {
  border-radius: 16px; padding: 14px 16px; margin-bottom: 12px;
  background: var(--white); border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  animation: ms-in .35s ease;
}
@keyframes ms-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.milestone.ms-ok { border-color: #bbf7d0; background: linear-gradient(180deg, #f0fdf4, var(--white)); }
.ms-tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--green); margin-bottom: 5px; }
.ms-dim .ms-tag { color: var(--slate-lt); }
.ms-text { font-size: 13px; color: var(--slate); line-height: 1.5; }
.ms-text b { color: var(--navy); }
.ms-finish {
  margin-top: 10px; width: 100%; padding: 8px;
  background: transparent; border: 1.5px dashed var(--border-strong);
  border-radius: 10px; color: var(--slate); font-size: 12px; font-weight: 600;
}
.ms-finish:hover { border-color: var(--blue-lt); color: var(--blue-dk); background: var(--blue-ghost); }

/* Slim milestone banner - lives inside the reserved feedback zone */
.ms-banner { font-size: 12.5px; font-weight: 600; padding: 10px 14px; }
.ms-banner b { color: var(--navy); }
.ms-banner.ms-dim { background: var(--blue-ghost); border-color: var(--border); color: var(--slate); }

/* Permanent finish-early affordance (toggled .show when eligible) */
.finish-link {
  display: none; margin: -2px auto 0; padding: 4px 10px;
  background: none; border: 0; box-shadow: none;
  color: var(--slate-lt); font-size: 12px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.finish-link.show { display: block; }
.finish-link:hover { color: var(--blue-dk); transform: none; box-shadow: none; }

/* --- Placement card (final report) --- */
.result-kicker {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .09em; color: var(--blue); text-align: center; margin-bottom: 16px;
}
.place-card {
  border-radius: 16px; padding: 16px 18px; margin-bottom: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--lv) 10%, var(--white)), var(--white));
  border: 1.5px solid color-mix(in srgb, var(--lv) 30%, var(--white));
}
.place-eyebrow { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--slate-lt); margin-bottom: 6px; }
.place-level { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.place-emoji { font-size: 20px; }
.place-level b { font-size: 22px; color: var(--lv); }
.place-name { font-size: 14px; font-weight: 700; color: var(--navy); }
.place-module { font-size: 12.5px; color: var(--slate); margin-top: 6px; line-height: 1.5; }
.place-next {
  margin-top: 10px; font-size: 12.5px; color: var(--slate);
  border-top: 1px dashed color-mix(in srgb, var(--lv) 30%, var(--white));
  padding-top: 10px;
}
.place-next b { color: var(--lv); }

/* --- Stage breakdown (final report) --- */
.stage-report { margin-bottom: 18px; }
.stage-report-head {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--slate-lt); margin-bottom: 8px;
}
.stage-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 11px;
}
.stage-row + .stage-row { margin-top: 6px; }
.stage-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.stage-info { flex: 1; min-width: 0; }
.stage-info b { font-size: 12.5px; color: var(--navy); display: block; }
.stage-info span { font-size: 11px; color: var(--slate-lt); }
.stage-mark { font-size: 12.5px; font-weight: 800; color: var(--slate-lt); white-space: nowrap; }
.sr-ok { background: var(--green-soft); border-color: #bbf7d0; }
.sr-ok .stage-mark { color: var(--green); }
.sr-miss { background: var(--red-soft); border-color: #fecaca; }
.sr-miss .stage-mark { color: var(--red); }
.sr-idle { opacity: .6; }

/* --- Admin stage chips --- */
.stage-mini { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.stage-chip {
  font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  background: var(--blue-ghost); color: var(--slate-lt); border: 1px solid var(--border);
}
.sc-ok { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.sc-miss { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.sc-idle { opacity: .55; }

/* --- Report actions + print --- */
.result-actions { display: flex; gap: 10px; }
.result-actions .ghost { flex: 1; }

.print-head { display: none; }

@media print {
  @page { margin: 14mm; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { background: #fff !important; }
  .topbar, .result-actions, .result-foot { display: none !important; }
  .container { padding: 0; max-width: none; }
  .result-card {
    box-shadow: none !important; border: none; max-width: none;
    margin: 0; padding: 0; animation: none;
  }
  .print-head {
    display: block; text-align: center; margin-bottom: 18px;
    font-size: 15px; font-weight: 800; color: var(--navy);
    border-bottom: 2px solid var(--blue); padding-bottom: 10px;
  }
  .print-head span { display: block; font-size: 11.5px; font-weight: 600; color: var(--slate-lt); margin-top: 3px; }
  .result-kicker { margin-top: 2px; }
  .stage-row, .result-cell, .place-card { break-inside: avoid; }
}

/* ---------- Teacher console / demo sessions ---------- */
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.session-card { margin-top: 14px; }
.session-title { font-weight: 800; font-size: 15px; color: var(--navy); }
.session-link-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-code {
  font-size: 15px; font-weight: 800; letter-spacing: 1.5px;
  background: var(--blue-ghost); color: var(--navy);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px;
}
.results-mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-mini th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--slate-lt); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.results-mini td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.results-mini tr:last-child td { border-bottom: none; }
.lvl-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.lvl-module { font-size: 10.5px; color: var(--slate-lt); margin: 2px 0 0 15px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Clickable result rows -> per-student report (mirrors student/admin views) */
tr.result-row { cursor: pointer; }
tr.result-row:hover td { background: var(--bg); }
tr.result-row.open td { background: var(--bg); border-bottom: none; }
.row-caret { display: inline-block; margin-left: 7px; color: var(--slate-lt); font-size: 10px; transition: transform .18s; }
tr.result-row.open .row-caret { transform: rotate(90deg); }
tr.res-detail td { background: var(--bg); padding: 0 14px 14px; border-bottom: 1px solid var(--border); }
.res-detail-body { max-width: 640px; }
.rd-summary { font-size: 12.5px; color: var(--slate); margin: 4px 0 10px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.rd-place {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  border: 1px solid var(--border); border-left: 4px solid var(--lv, var(--border-strong));
  border-radius: 10px; padding: 8px 12px; background: var(--white);
}
.rd-place .place-emoji { font-size: 20px; }
.rd-place b { font-size: 13px; color: var(--navy); }
.res-detail-body .stage-report { margin-bottom: 12px; }
.res-ans-list { display: flex; flex-direction: column; gap: 4px; }
.res-ans {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  padding: 5px 9px; border-radius: 8px; border: 1px solid transparent;
}
.res-ans.ra-ok { background: var(--green-soft); border-color: #bbf7d0; }
.res-ans.ra-err { background: var(--red-soft); border-color: #fecaca; }
.ra-pos { font-weight: 800; color: var(--slate-lt); min-width: 24px; }
.ra-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.ra-title i { color: var(--slate-lt); font-weight: 400; font-size: 11px; }
.ra-lv { font-size: 10px; font-weight: 800; color: var(--slate-lt); }
.ra-mark { font-weight: 800; }
.ra-ok .ra-mark { color: var(--green); } .ra-err .ra-mark { color: var(--red); }
.ra-sub { font-size: 10px; color: var(--yellow); font-weight: 700; min-width: 40px; }
.ra-time { font-size: 11px; color: var(--slate-lt); min-width: 28px; text-align: right; }

#new-session-slot {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
#new-session-slot[hidden] { display: none; }
#new-session-slot input { flex: 1; min-width: 180px; }
#new-session-slot select { flex: 0 1 auto; }

/* --- Teacher: live solving radar --- */
.live-grid { margin: 12px 0 14px; }
.live-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  color: var(--slate); margin-bottom: 10px;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
.live-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 260px)); gap: 14px; }
.live-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 10px;
  background: var(--white); box-shadow: var(--shadow-sm);
  transition: opacity .3s;
}
.live-card.live-stale { opacity: .5; }
.live-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; margin-bottom: 8px; }
.live-card-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-card .mini-board { width: 100%; max-width: none; border-radius: 8px; }
.live-card .mini-board .coord { font-size: 7px; }
.live-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px; color: var(--slate-lt); margin-top: 8px; min-height: 16px;
}
.live-turn { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--slate); white-space: nowrap; }
.turn-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); flex-shrink: 0; }
.turn-dot.w { background: var(--white); }
.turn-dot.b { background: var(--ink); }
.live-meta { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.live-card-foot .mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; color: var(--ink); }
.live-miss { color: var(--red); font-weight: 700; }
.live-age { color: var(--slate-lt); }
