/* ============================================================
   PassDent design system — light, clean, indigo brand.
   Dark indigo sidebar over a soft light canvas; solid confident
   accent colour, generous spacing, no gimmicks.
   ============================================================ */

:root {
  /* Brand */
  --brand:      #5a4fd6;
  --brand-600:  #4c41c4;
  --brand-700:  #3f36a8;
  --brand-050:  #eeecfb;
  --brand-100:  #e2defa;

  /* Surfaces */
  --bg:         #f5f5fb;
  --card:       #ffffff;
  --sidebar:    #262444;   /* deep indigo */
  --sidebar-2:  #2f2c53;
  --line:       #e8e7f2;
  --line-2:     #f0eff7;

  /* Ink */
  --heading:    #1c1d33;
  --ink:        #1c1d33;   /* alias used by some inline template styles */
  --text:       #2c2e44;
  --muted:      #61657a;
  --faint:      #949aad;

  /* State */
  --correct:      #15a34a;
  --correct-bg:   #e5f7ec;
  --correct-line: #15a34a;
  --wrong:        #dc2626;
  --wrong-bg:     #fdecea;
  --wrong-line:   #dc2626;
  --amber:        #b45309;
  --amber-bg:     #fbeecd;

  --series-1:   #5a4fd6;

  --radius:     13px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(28,29,51,.05), 0 6px 20px rgba(28,29,51,.05);
  --shadow-lg:  0 10px 34px rgba(63,54,168,.14);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 { color: var(--heading); font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: 28px; margin: 0 0 20px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.mt0 { margin-top: 0; }

/* ---------- App shell ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px; flex-shrink: 0;
  background: var(--sidebar);
  color: #c9c8e0;
  padding: 20px 0 40px;
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 22px 4px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(150deg, #7d72f0, #5a4fd6);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.brand .name { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.brand .name span { color: #a99bff; }
.sidebar .tagline { padding: 0 22px 16px; margin: 8px 0 8px; font-size: 12px; color: #8983ad; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar h6 { margin: 22px 22px 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #7d78a0; font-weight: 700; }
.sidebar .nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 22px; color: #c3c1de; text-decoration: none; font-size: 14.5px; border-left: 3px solid transparent; transition: background .14s, color .14s; }
.sidebar .nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar .nav-item.active { background: rgba(125,114,240,.20); color: #fff; border-left-color: #a99bff; }
.sidebar .badge-count { background: #5a4fd6; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 8px; margin-left: auto; }

.main { flex: 1; padding: 36px 42px; max-width: 1180px; min-width: 0; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; margin-bottom: 24px; box-shadow: var(--shadow); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 22px; }
.messages li { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--brand-050); border: 1px solid var(--brand-100); color: #3a338f; font-size: 14.5px; }
.messages li.success { background: var(--correct-bg); border-color: #b6e6c6; color: #14532d; }
.messages li.error   { background: var(--wrong-bg); border-color: #f5c2bd; color: #8a1c14; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm); padding: 11px 22px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .14s, transform .04s, box-shadow .14s; box-shadow: 0 2px 8px rgba(90,79,214,.28); }
.btn:hover { background: var(--brand-600); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--heading); box-shadow: none; border: 1px solid var(--line); }
.btn.secondary:hover { background: #f6f6fc; border-color: #dcdaee; }
.btn.danger { background: var(--wrong); box-shadow: 0 2px 8px rgba(220,38,38,.25); }
.btn.danger:hover { background: #b91c1c; }
.btn.lg { padding: 14px 28px; font-size: 16px; }
.btn.ghost { background: transparent; color: var(--brand-600); border: 1px solid var(--brand-100); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-050); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Forms ---------- */
form p { margin: 0 0 16px; }
form label { display: block; font-weight: 600; margin-bottom: 5px; color: var(--heading); font-size: 14.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; max-width: 660px; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 15px; background: #fff; color: var(--text); transition: border-color .14s, box-shadow .14s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(90,79,214,.16); }
.helptext { color: var(--muted); font-size: 13px; display: block; margin-top: 3px; }
.errorlist { color: var(--wrong); list-style: none; padding: 0; margin: 5px 0; font-size: 14px; }
ul#id_mode, ul[id$="categories"], ul#id_correct_option { list-style: none; padding: 0; margin: 0; }
ul#id_mode li, ul[id$="categories"] li, ul#id_correct_option li { margin-bottom: 6px; }
ul#id_mode label, ul[id$="categories"] label, ul#id_correct_option label { font-weight: 400; display: inline; margin-left: 6px; color: var(--text); }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th, table.data td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data th { color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #faf9fe; }

.pill { display: inline-block; border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 600; }
.pill.approved { background: var(--correct-bg); color: #15803d; }
.pill.pending  { background: var(--amber-bg); color: var(--amber); }
.pill.rejected { background: var(--wrong-bg); color: #b91c1c; }
.pill.demo     { background: var(--brand-050); color: var(--brand-700); }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 18px; margin-bottom: 26px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.tile .tnum { font-size: 32px; font-weight: 800; color: var(--heading); letter-spacing: -0.02em; }
.tile .tlabel { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

/* ---------- Question / session ---------- */
.qlayout { display: flex; gap: 28px; align-items: flex-start; }
.qmain { flex: 1; min-width: 0; }
.qside { width: 300px; flex-shrink: 0; }

.qheader { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 10px; }
.qheader .qtitle { font-size: 15px; font-weight: 700; color: var(--heading); }
.navbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #eeedf6; color: var(--heading); text-decoration: none; font-size: 17px; border: none; cursor: pointer; transition: background .14s; }
.navbtn:hover { background: #e4e2f2; text-decoration: none; }
.navbtn.primary { background: var(--brand); color: #fff; }
.navbtn.primary:hover { background: var(--brand-600); }
.navbtn.disabled { opacity: .35; pointer-events: none; }

.stem { font-size: 17px; line-height: 1.65; margin-bottom: 24px; white-space: pre-line; color: var(--heading); }

.options { display: flex; flex-direction: column; gap: 9px; margin-bottom: 24px; }
.option { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); border-left: 5px solid #dcdaee; border-radius: var(--radius-sm); padding: 14px 16px; font: inherit; font-size: 15.5px; cursor: pointer; color: var(--text); transition: border-color .14s, background .14s; }
.option:hover { border-color: var(--brand); border-left-color: var(--brand); background: #f7f6fe; }
.option.answered { cursor: default; }
.option.answered:hover { border-color: var(--line); background: #fff; }
.option.correct { background: var(--correct-bg); border-color: var(--correct-line); border-left-color: var(--correct-line); }
.option.correct.answered:hover { background: var(--correct-bg); border-color: var(--correct-line); }
.option.chosen-wrong { background: var(--wrong-bg); border-color: var(--wrong-line); border-left-color: var(--wrong-line); }
.option.chosen-wrong.answered:hover { background: var(--wrong-bg); border-color: var(--wrong-line); }
.option .otext { flex: 1; }
.option .opct { background: #757a90; color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 2px 10px; flex-shrink: 0; }
.option.correct .opct { background: #15803d; }
.option.chosen-wrong .opct { background: #b91c1c; }

.explanation { background: #f2faf5; border: 1px solid #cbe8d5; border-left: 4px solid var(--correct); border-radius: var(--radius-sm); padding: 18px 22px; margin-bottom: 20px; white-space: pre-line; line-height: 1.65; }
.explanation h3 { margin-top: 0; }

.sidebox { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 19px; margin-bottom: 16px; box-shadow: var(--shadow); }
.sidebox h3 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.scorebox { background: linear-gradient(160deg, #ffffff, #f4f3fe); border-color: var(--brand-100); }
.scorebox .big { font-size: 32px; font-weight: 800; color: var(--heading); }
.score-line { display: flex; justify-content: space-between; font-size: 14.5px; padding: 4px 0; }
.tag { display: inline-block; background: var(--brand-050); color: var(--brand-700); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 500; margin: 0 6px 6px 0; }

/* Category reveal toggle */
.catbox { cursor: default; }
.catbox > summary { cursor: pointer; list-style: none; font-size: 14px; font-weight: 600; color: var(--brand-600); display: flex; align-items: center; gap: 7px; user-select: none; }
.catbox > summary::-webkit-details-marker { display: none; }
.catbox > summary::before { content: "\25B8"; font-size: 12px; transition: transform .14s; }
.catbox[open] > summary::before { transform: rotate(90deg); }
.catbox .cats { margin-top: 12px; }

.dots { display: flex; flex-wrap: wrap; gap: 7px; }
.dot { width: 31px; height: 31px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: #fff; text-decoration: none; }
.dot.right { background: var(--correct); }
.dot.wrong { background: var(--wrong); }
.dot.blank { background: #c2c0d6; color: #fff; }
.dot.current { outline: 2px solid var(--brand); outline-offset: 2px; }
.dot:hover { text-decoration: none; }

/* ---------- Performance histogram ---------- */
.viz-root { --viz-surface: #ffffff; }
.histo { display: flex; align-items: flex-end; gap: 2px; height: 190px; padding: 8px 0 0; position: relative; }
.histo .hbar { flex: 1; position: relative; display: flex; align-items: flex-end; height: 100%; }
.histo .hbar .fill { width: 100%; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; }
.histo .hbar.me::after { content: ""; position: absolute; left: 50%; top: -6px; bottom: -4px; width: 2px; background: var(--heading); }
.histo-axis { display: flex; gap: 2px; font-size: 11px; color: var(--muted); }
.histo-axis span { flex: 1; text-align: center; }
.hbar .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--heading); color: #fff; font-size: 12px; padding: 4px 9px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.hbar:hover .tip { display: block; }
.pctbar { background: #eceaf6; border-radius: 999px; height: 9px; overflow: hidden; }
.pctbar .in { height: 100%; background: var(--series-1); border-radius: 999px; }

.flagged { color: var(--wrong); }

.linkbtn { background: none; border: none; padding: 0; font: inherit; color: var(--wrong); cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: #b91c1c; }

/* ---------- Auth ---------- */
.authshell { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(1100px 460px at 50% -8%, var(--brand-050), var(--bg)); }
.authwrap { width: 100%; max-width: 440px; }
.authwrap .brand { justify-content: center; margin-bottom: 24px; }
.authwrap .brand .name, .topbar .brand .name { color: var(--heading); }
.authwrap .card { box-shadow: var(--shadow-lg); }

/* ---------- Landing ---------- */
.landing { max-width: none; padding: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 40px; max-width: 1120px; margin: 0 auto; }
.topbar .links { display: flex; align-items: center; gap: 10px; }
.hero { text-align: center; padding: 70px 24px 60px; max-width: 800px; margin: 0 auto; }
.hero .eyebrow { color: var(--brand-600); font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 16px; }
.hero h1 { font-size: 50px; line-height: 1.07; margin-bottom: 20px; }
.hero h1 span { color: var(--brand); }
.hero p.sub { font-size: 18px; color: var(--muted); max-width: 630px; margin: 0 auto 28px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .note { margin-top: 14px; font-size: 13.5px; color: var(--faint); }
.hero-stats { display: flex; gap: 48px; justify-content: center; flex-wrap: wrap; margin: 48px auto 0; }
.hero-stats .s .n { font-size: 32px; font-weight: 800; color: var(--heading); }
.hero-stats .s .l { font-size: 13px; color: var(--muted); }

.section { max-width: 1120px; margin: 0 auto; padding: 46px 40px; }

/* ---------- Discussion ---------- */
.sidebar .badge-count.alert { background: #e0483d; }

.discuss-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.discuss-head h2 { margin: 0; }

.comments { margin: 6px 0 22px; }
.no-comments { padding: 14px 0; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.comment:last-child { border-bottom: none; }
.comment-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.comment-author { font-weight: 600; color: var(--ink); }
.comment-time { color: var(--faint); }
.report-form { margin: 0 0 0 auto; }
.report-btn { background: none; border: none; padding: 0; font: inherit; font-size: 12.5px; color: var(--faint); cursor: pointer; }
.report-btn:hover { color: #b91c1c; }
.comment-body { font-size: 15px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; word-break: break-word; }

.emoji-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.emoji-bar .emoji { background: var(--brand-050); border: 1px solid var(--brand-100); border-radius: var(--radius-sm); padding: 3px 7px; font-size: 16px; line-height: 1; cursor: pointer; }
.emoji-bar .emoji:hover { background: var(--brand-100); }
.comment-form textarea { width: 100%; box-sizing: border-box; }
.comment-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.thread-closed { padding: 12px 0; }
.reported-body { margin: 6px 0; font-style: italic; color: var(--muted); }
.linkbtn.danger { color: #b91c1c; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .qlayout { flex-direction: column; }
  .qside { width: 100%; }
  .main { padding: 22px 18px; }
  .hero h1 { font-size: 36px; }
  .topbar, .section { padding-left: 20px; padding-right: 20px; }
}
