/* nes-demo — styled to the Excelerate student workspace design language.
   Tokens mirror question_workspace.css / qw_render.css (light theme, indigo→violet brand). */
:root {
  --brand-primary: #4f46e5;
  --brand-secondary: #7c3aed;
  --brand-light: #eef2ff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e3e6ee;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #16a34a;    --ok-bg: #f0fdf4;
  --warn: #ea580c;  --warn-bg: #fff7ed;
  --bad: #dc2626;   --bad-bg: #fef2f2;
  --info: #0369a1;  --info-bg: #eff6ff;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 12px 30px rgba(15, 23, 42, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 22px; }

/* ---------------- brand header ---------------- */
.brandbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brandbar .logo {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}
.brandbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.brandbar .tag { color: var(--muted); font-size: 13px; margin-top: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 30px;
}

.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------------- buttons ---------------- */
.btn {
  appearance: none; cursor: pointer; font-family: inherit;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff; font-weight: 600; font-size: 16px; border: 1px solid transparent;
  padding: 13px 20px; border-radius: 11px; width: 100%;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .22);
  transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px); }
.btn:disabled { filter: grayscale(.5) opacity(.55); cursor: not-allowed; box-shadow: none; }
.btn.secondary {
  background: var(--card); color: var(--brand-primary);
  border: 1px solid var(--line); box-shadow: none;
}
.btn.secondary:hover { background: var(--brand-light); border-color: var(--brand-primary); }
.btn.small { width: auto; padding: 9px 16px; font-size: 14px; }

/* ---------------- chips ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.chip .k { color: var(--muted); font-weight: 600; }
.chip.subject { background: var(--brand-light); border-color: rgba(79, 70, 229, .35); color: var(--brand-primary); }
.chip.topic   { background: var(--brand-light); border-color: rgba(124, 58, 237, .3); color: var(--brand-secondary); }
.chip.sub     { background: #fff; border-color: rgba(79, 70, 229, .35); color: var(--brand-primary); }
.chip.diff    { background: var(--warn-bg); border-color: rgba(234, 88, 12, .3); color: var(--warn); }
.chip.type    { background: #f8fafc; }

/* ---------------- spinners ---------------- */
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand-primary);
  animation: spin .8s linear infinite; margin: 0 auto;
}
.mini-spinner {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.hidden { display: none !important; }
input[type=file] { display: none; }

/* ---------------- mobile capture ---------------- */
.mobile { max-width: 520px; margin: 0 auto; padding: 20px 18px 40px; }
.code-box {
  margin: 16px 0; padding: 16px; border-radius: 14px; text-align: center;
  background: var(--brand-light); border: 1px dashed rgba(79, 70, 229, .4);
}
.code-box .label { color: var(--brand-primary); font-size: 12px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.code-box .code {
  font-size: 50px; font-weight: 800; letter-spacing: 8px; margin-top: 4px;
  color: var(--brand-primary);
}
.preview-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); margin-top: 14px; display: none; }
.status-line { margin-top: 16px; font-weight: 600; text-align: center; min-height: 24px; color: var(--ink); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0 4px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------------- desktop display ---------------- */
.enter-code { max-width: 560px; margin: 5vh auto 0; }
.enter-code input {
  width: 100%; font-size: 32px; font-weight: 800; letter-spacing: 10px; text-align: center;
  text-transform: uppercase; padding: 15px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); margin: 16px 0;
}
.enter-code input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 4px var(--brand-light); }

.result-head { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 16px; }
.result-head .head-actions { margin-left: auto; display: flex; gap: 10px; }

.qcard { font-size: clamp(17px, 1.5vw, 21px); line-height: 1.6; }
.qcard .stem { margin-bottom: 16px; }
.opts { display: grid; gap: 10px; margin-top: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.opt .marker {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; color: var(--brand-primary); background: var(--brand-light);
}
.parts { margin-top: 14px; display: grid; gap: 14px; }
.part { border-left: 4px solid var(--brand-primary); padding: 4px 0 4px 16px; background: #f8fafc; border-radius: 0 10px 10px 0; }
.part .plabel { color: var(--brand-primary); font-weight: 700; margin-right: 8px; }
.part .part.nested, .part .parts .part { border-left-color: var(--info); background: #f0f9ff; }
.figure { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); margin: 12px 0; }

.stage { min-height: 56vh; display: grid; place-items: center; text-align: center; }
.stage .big { font-size: clamp(26px, 3.4vw, 40px); font-weight: 800; line-height: 1.15; color: var(--ink); letter-spacing: -.01em; }
.stage .sub { color: var(--muted); font-size: 17px; margin-top: 12px; }
.steps { display: flex; gap: 20px; justify-content: center; margin-top: 26px; color: var(--muted); flex-wrap: wrap; }
.steps .step { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.steps .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: #fff; font-size: 13px; }

/* ---------------- answer panel + evaluation ---------------- */
.answer-card { margin-top: 20px; }
.answer-card h3 { margin: 0 0 4px; font-size: 17px; }
.answer-card .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.ans-input {
  width: 100%; min-height: 96px; resize: vertical; font-family: inherit; font-size: 16px;
  padding: 13px 15px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.ans-input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 4px var(--brand-light); }
.ans-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.ans-actions .btn { width: auto; }
.ans-filename { color: var(--muted); font-size: 13px; }

.verdict {
  display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px;
  padding: 8px 15px; border-radius: 999px; border: 1px solid;
}
.verdict-icon { font-size: 17px; line-height: 1; }
.verdict.correct { background: var(--ok-bg); border-color: rgba(22, 163, 74, .35); color: var(--ok); }
.verdict.partial { background: var(--warn-bg); border-color: rgba(234, 88, 12, .35); color: var(--warn); }
.verdict.wrong   { background: var(--bad-bg); border-color: rgba(220, 38, 38, .35); color: var(--bad); }
.verdict.info    { background: var(--info-bg); border-color: rgba(3, 105, 161, .3); color: var(--info); }

.eval-body {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 15.5px; line-height: 1.7;
}
.answer-echo {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-top: 12px; font-size: 14.5px;
}
.answer-echo .k { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 3px; }

/* ---------------- student practice loop ---------------- */
.practice-card { margin-top: 20px; }
.practice-head { display: flex; align-items: center; gap: 12px; }
.practice-head h3 { margin: 0; font-size: 18px; }
.mode-pill {
  font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px;
  color: var(--brand-primary); background: var(--brand-light); border: 1px solid rgba(79, 70, 229, .3);
}
.practice-card .hint { color: var(--muted); font-size: 13.5px; margin: 6px 0 16px; }
.p-label { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 0 10px; }
.p-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.p-note { color: var(--muted); font-size: 13px; }

/* hint ladder */
.p-hints { margin-bottom: 18px; }
.hint-trail { display: grid; gap: 10px; margin-bottom: 12px; }
.hint-item {
  border: 1px solid rgba(79, 70, 229, .25); background: var(--brand-light);
  border-radius: 11px; padding: 12px 14px;
}
.hint-item .hint-rung { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-primary); margin-bottom: 4px; }
.hint-gate label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--ink); }

/* MCQ options as buttons */
.p-opts { display: grid; gap: 10px; margin-bottom: 16px; }
.p-opt {
  display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
  font-family: inherit; font-size: 16px; color: var(--ink); transition: border-color .12s, background .12s, box-shadow .12s;
}
.p-opt:hover { border-color: var(--brand-primary); background: var(--brand-light); }
.p-opt.selected { border-color: var(--brand-primary); background: var(--brand-light); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.p-opt.locked { pointer-events: none; opacity: .7; }
.p-opt .marker {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; color: var(--brand-primary); background: var(--brand-light);
}
.p-opt.selected .marker { color: #fff; background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary)); }

/* Socratic provocateur card */
.socratic-card {
  margin-top: 16px; padding: 16px 18px; border-radius: 13px;
  border: 1px solid rgba(124, 58, 237, .3);
  background: linear-gradient(180deg, #faf5ff, #fff);
}
.socratic-q .coach { display: block; font-weight: 700; color: var(--brand-secondary); font-size: 13px; margin-bottom: 6px; }
.socratic-card textarea { margin-top: 12px; }

/* reflection */
.p-reflect { margin-top: 16px; }
.reflect-card {
  padding: 16px 18px; border-radius: 13px; border: 1px dashed rgba(22, 163, 74, .4); background: var(--ok-bg);
}
.reflect-card .reflect-title { font-weight: 700; color: var(--ok); margin-bottom: 8px; }
.reflect-card label { display: block; font-weight: 600; margin-bottom: 8px; }
.reflect-done { padding: 14px 16px; border-radius: 12px; background: var(--ok-bg); border: 1px solid rgba(22, 163, 74, .35); color: var(--ok); font-weight: 600; }

/* mobile role picker */
.role-title { font-size: 18px; margin: 0 0 14px; text-align: center; }
.role-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  padding: 16px; margin-bottom: 12px; border-radius: 14px; border: 1px solid var(--line); background: #fff;
  font-family: inherit; color: var(--ink); transition: border-color .12s, box-shadow .12s, background .12s;
}
.role-btn:hover, .role-btn:active { border-color: var(--brand-primary); background: var(--brand-light); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.role-btn .role-emoji { font-size: 30px; flex: 0 0 auto; }
.role-btn .role-copy { display: flex; flex-direction: column; gap: 3px; }
.role-btn .role-copy b { font-size: 16px; }
.role-btn .role-copy small { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ---------------- study notes drawer ---------------- */
.drawer-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 92vw); z-index: 61;
  background: var(--card); box-shadow: -20px 0 60px rgba(15, 23, 42, .25);
  transform: translateX(100%); transition: transform .24s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.drawer-head .title { font-weight: 700; font-size: 17px; }
.drawer-head .x { margin-left: auto; border: 0; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.drawer-body { padding: 20px 24px; overflow-y: auto; line-height: 1.75; font-size: 15.5px; }
.drawer-body .loading { text-align: center; padding: 40px 0; color: var(--muted); }

/* ---------------- markdown (notes + feedback) ---------------- */
.md h1, .md h2, .md h3 { line-height: 1.3; margin: 20px 0 8px; font-weight: 700; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.06em; color: var(--brand-primary); }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0; padding-left: 22px; }
.md li { margin: 5px 0; }
.md code { background: #f1f5f9; padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.md strong { font-weight: 700; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md blockquote { border-left: 3px solid var(--brand-primary); margin: 12px 0; padding: 2px 14px; color: var(--muted); background: #f8fafc; }
.ai-note { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 12.5px; }

/* ================================================================
   PRODUCT DEMO — /demo pages
   ================================================================ */

/* form fields used in the add-question drawer and assess builder */
.field-label {
  display: block; font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.field-input {
  width: 100%; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-family: var(--font); font-size: 14px;
}
.field-input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px var(--brand-light); }

/* bank cards on /demo landing */
.demo-banks { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.bank-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfbff 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 28px 24px;
  display: flex; flex-direction: column; gap: 16px; cursor: pointer;
  transition: box-shadow .18s, border-color .18s, transform .12s;
  text-decoration: none; color: inherit; position: relative; overflow: hidden;
}
.bank-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  opacity: 1; transition: opacity .18s;
}
.bank-card:hover { border-color: var(--brand-primary); box-shadow: 0 8px 32px rgba(79,70,229,.12); transform: translateY(-3px); }
.bank-card:hover::before { opacity: 1; }
.bank-card__top { display: flex; align-items: center; gap: 16px; }
.bank-card__icon {
  width: 56px; height: 56px; border-radius: 14px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 28px;
}
.bank-card__body { flex: 1; min-width: 0; }
.bank-card__name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.bank-card__count { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.bank-card__arrow {
  color: var(--brand-primary); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; margin-top: auto;
  opacity: .7; transition: opacity .15s, transform .15s;
}
.bank-card:hover .bank-card__arrow { opacity: 1; transform: translateX(4px); }

/* question cards in the bank browser */
.qbank-card {
  margin-bottom: 20px; padding: 0; overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
  position: relative;
}
.qbank-card:hover { border-color: rgba(79,70,229,.3); box-shadow: 0 6px 24px rgba(79,70,229,.08); }
.qbank-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  opacity: .75;
  pointer-events: none;
}
.qbank-card__header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 18px 24px 14px; border-bottom: 1px solid var(--line); background: #f9fafb;
}
.qbank-card__number {
  font-size: 13px; font-weight: 800; letter-spacing: .04em;
  color: var(--brand-primary); flex: 0 0 auto;
  background: var(--brand-light); padding: 4px 10px; border-radius: 8px;
}
.qbank-card__badges { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.qbank-card__body { padding: 20px 24px; }
.qbank-card__body .stem { font-size: 15.5px; line-height: 1.7; }
.qbank-card__body .opts { margin-top: 14px; }
.qbank-card__footer {
  padding: 14px 24px 18px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  justify-content: flex-end;
}
.qbank-card__assess-btn {
  padding: 9px 18px !important; font-size: 13.5px !important;
  width: auto !important;
}
.qnum {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); flex: 0 0 auto;
}

/* bank toolbar */
.bank-toolbar { padding: 16px 20px; }

/* assessment builder picker */
.picker-row {
  display: flex; gap: 14px; align-items: flex-start; cursor: pointer; margin-bottom: 12px;
  padding: 16px; transition: border-color .12s, background .12s;
}
.picker-row input[type=checkbox] {
  display: block !important; /* override hidden rule */
  flex: 0 0 auto; width: 18px; height: 18px; margin-top: 3px;
  accent-color: var(--brand-primary); cursor: pointer;
}
.picker-row--selected { border-color: var(--brand-primary); background: var(--brand-light); }
.picker-row__head { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.picker-row__text { font-size: 14px; color: var(--ink); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.picker-row__body { flex: 1; min-width: 0; }

/* selected list in the assessment summary panel */
.selected-list { display: grid; gap: 8px; margin-top: 6px; max-height: 320px; overflow-y: auto; }
.selected-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; font-size: 13px;
}
.selected-item__num { color: var(--muted); font-weight: 700; flex: 0 0 auto; }
.selected-item__text { flex: 1; min-width: 0; }
.selected-item__remove {
  flex: 0 0 auto; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px;
}
.selected-item__remove:hover { color: var(--bad); }
.assess-summary { font-size: 13.5px; font-weight: 600; color: var(--muted); }

/* paper question blocks */
.paper-q { margin-bottom: 22px; }
.paper-q__head {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.paper-q__text { font-size: 16px; line-height: 1.65; }

/* ---------------- QR sheet ---------------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.qr-card { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 20px; text-align: center; box-shadow: var(--shadow); }
.qr-card h3 { margin: 0 0 10px; font-size: 20px; }
.qr-card .qimg { display: grid; place-items: center; min-height: 200px; }
.qr-card .hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .qr-card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}
