:root {
  --bg       : #0f1117;
  --surface  : #1a1d27;
  --surface2 : #23263a;
  --border   : #2e3250;
  --primary  : #5865f2;
  --success  : #3ba55d;
  --danger   : #ed4245;
  --warning  : #faa81a;
  --fav      : #f0a500;
  --text     : #e3e5e8;
  --text-muted: #8e9297;
  --radius   : 10px;
  --shadow   : 0 4px 24px rgba(0,0,0,.4);
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.navbar-brand { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.navbar-nav { display: flex; gap: 1.5rem; font-size: 0.9rem; }
.navbar-nav a { color: var(--text-muted); }
.navbar-nav a:hover { color: var(--text); text-decoration: none; }

/* ── Container ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;  /* bottom pad for sticky footer */
}

/* ── Buttons ── */
.btn {
  display: inline-block; padding: 0.55rem 1.2rem;
  border-radius: var(--radius); border: none; cursor: pointer;
  font-size: 0.9rem; font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.38; cursor: default; transform: none; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-warning   { background: var(--warning); color: #000; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-sm        { padding: 0.3rem 0.7rem; font-size: 0.8rem; border-radius: 7px; }
.btn-icon      { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0 0.3rem; }
.btn-fav-start { background: var(--fav); color: #000; padding: 0.55rem 1.2rem;
                 border-radius: var(--radius); border: none; cursor: pointer;
                 font-size: 0.9rem; font-weight: 700;
                 transition: opacity 0.15s, transform 0.1s; }
.btn-fav-start:hover { opacity: 0.88; transform: translateY(-1px); }

/* ── Auth pages ── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card h1 { color: var(--primary); margin-bottom: 0.25rem; }
.auth-card h2 { margin-bottom: 1.5rem; font-size: 1.1rem; color: var(--text-muted); }
.auth-card label {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.88rem; color: var(--text-muted); margin-bottom: 1rem;
}
.auth-card input {
  padding: 0.6rem 0.9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 0.95rem;
}
.auth-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.auth-card small { color: var(--text-muted); font-size: 0.78rem; }
.auth-card .btn { width: 100%; margin-top: 0.5rem; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.88rem; color: var(--text-muted); }
.error-msg {
  background: rgba(237,66,69,.15); border: 1px solid var(--danger);
  color: var(--danger); padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem;
}
.success-msg {
  background: rgba(59,165,93,.15); border: 1px solid var(--success);
  color: var(--success); padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem;
}
.info-msg { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.9rem; }

/* ── Mode grid ── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem; margin-bottom: 2.5rem;
}
.mode-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.mode-card-fav { border-color: var(--fav); }
.mode-card h2 { font-size: 1rem; margin-bottom: 0.5rem; }
.mode-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.mode-card select {
  width: 100%; padding: 0.5rem 0.7rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 0.88rem; margin-bottom: 0.75rem;
}
.badge-count {
  display: inline-block; background: var(--fav); color: #000;
  font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.4rem;
  border-radius: 10px; vertical-align: middle;
}

/* ── Progress tables ── */
.progress-section, .history-section { margin-bottom: 2rem; }
.progress-section h2, .history-section h2 { margin-bottom: 1rem; }
.progress-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.progress-table th, .progress-table td {
  padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); text-align: left;
}
.progress-table th { color: var(--text-muted); font-weight: 600; }
.wrong-count { color: var(--danger); font-weight: 700; }

/* ── Quiz header / nav ── */
.quiz-header { margin-bottom: 1rem; }

.quiz-nav {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem;
}
.quiz-nav-center {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
}
#quiz-counter {
  font-size: 0.88rem; color: var(--text-muted);
  cursor: pointer; text-decoration: underline dotted;
  user-select: none;
}
#quiz-counter:hover { color: var(--text); }

#jump-wrap {
  display: none; align-items: center; gap: 0.4rem;
}
#jump-input {
  width: 4.5rem; padding: 0.25rem 0.5rem;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: 0.88rem; text-align: center;
}

#quiz-progress-bar-wrap {
  height: 5px; background: var(--surface2); border-radius: 3px;
}
#quiz-progress-bar {
  height: 100%; background: var(--primary); border-radius: 3px;
  transition: width 0.35s ease;
  width: 0%;
}

/* ── Quiz card ── */
.quiz-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow);
}
.quiz-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 0.75rem;
}
.quiz-section-label { font-size: 0.8rem; color: var(--primary); font-weight: 600; }

/* Favorite star */
.btn-fav {
  background: none; border: none; cursor: pointer;
  font-size: 1.5rem; color: var(--text-muted); line-height: 1;
  transition: color 0.15s, transform 0.1s;
  padding: 0; flex-shrink: 0;
}
.btn-fav:hover { transform: scale(1.2); }
.btn-fav.is-fav { color: var(--fav); }

/* Question image */
.q-img-wrap { margin-bottom: 1rem; }
.question-img { max-width: 100%; border-radius: 8px; }

.question-text { font-size: 1.05rem; margin-bottom: 1.25rem; line-height: 1.55; }

/* Extra images (pic_1…) — always shown */
.extra-images { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }
.extra-img {
  max-width: 320px; max-height: 240px; border-radius: 8px;
  border: 1px solid var(--border); cursor: zoom-in;
}

/* Options */
.options-list { display: flex; flex-direction: column; gap: 0.55rem; }
.option-btn {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); cursor: pointer;
  font-size: 0.93rem; text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: rgba(88,101,242,.1); }
.option-btn:disabled { cursor: default; }
.option-btn.correct { border-color: var(--success) !important; background: rgba(59,165,93,.15) !important; }
.option-btn.wrong   { border-color: var(--danger)  !important; background: rgba(237,66,69,.15) !important; }
.option-img { max-width: 110px; max-height: 70px; border-radius: 4px; flex-shrink: 0; }

/* Answer feedback */
.answer-feedback { margin-top: 1.5rem; }
.correct-text { color: var(--success); font-weight: 700; font-size: 1rem; }
.wrong-text   { color: var(--danger);  font-weight: 700; font-size: 1rem; }
.hint-buttons { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }

#hint-panel {
  margin-top: 0.75rem; padding: 1rem;
  background: var(--surface2); border-radius: 8px; border: 1px solid var(--border);
}
.hint-text { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }
.hint-img  { max-width: 100%; border-radius: 8px; margin-top: 0.75rem; }

.all-images-panel { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.all-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }

.btn-next-q { margin-top: 1rem; }

/* Row below card */
.quiz-actions-row { margin-top: 1rem; text-align: right; }

/* ── Sticky footer ── */
.quiz-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0.55rem 1.5rem;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

/* ── Result screen ── */
.quiz-result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3rem 2rem;
  text-align: center; box-shadow: var(--shadow);
}
.quiz-result h2 { font-size: 1.6rem; margin-bottom: 1rem; }
.quiz-result p  { font-size: 1.1rem; margin-bottom: 1.5rem; }
.quiz-result .btn { margin: 0.4rem; }

/* ── Admin ── */
.admin-section { margin-bottom: 2.5rem; }
.admin-section h2 { margin-bottom: 1rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th, .admin-table td {
  padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); text-align: left;
}
.admin-table th { color: var(--text-muted); }
.token-cell { font-family: monospace; font-size: 0.8rem; word-break: break-all; }
.row-disabled { opacity: 0.45; }
.badge-active { color: var(--success); font-weight: 600; }
.action-cell { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: flex-start; }

/* ── Misc ── */
h1    { font-size: 1.6rem; margin-bottom: 1.5rem; }
.muted   { color: var(--text-muted); font-size: 0.88rem; }
.centered { text-align: center; padding: 3rem; color: var(--text-muted); }
