﻿/* ============================================
   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: 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; }

/* ---------- 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;
  -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%; }
.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; }
.bedit-board .sq { cursor: pointer; }
.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;
}
.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; }
.sort-arrow {
  display: inline-block;
  width: 12px;
  margin-left: 4px;
  font-size: 9px;
  color: var(--blue);
  vertical-align: 2px;
}

/* Prevent layout shift from scrollbar toggling + pin action column */
html { scrollbar-gutter: stable; }
table td:last-child { width: 1%; white-space: nowrap; }
.admin-container { max-width: 1180px; }

/* ============================================
   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; }
}
