/* Tamaye Tutoring Homework Portal */
:root {
  --navy: #16233B;
  --navy-2: #24365A;
  --ivory: #F7F4ED;
  --ivory-2: #EFEAE0;
  --line: #E4DED0;
  --ink: #1F2937;
  --muted: #6B7280;
  --white: #FFFFFF;
  --ok: #1E7B4A;
  --ok-bg: #E7F4EC;
  --bad: #B42318;
  --bad-bg: #FDECEA;
  --fix: #9A6700;
  --fix-bg: #FFF4D6;
  --prog: #24548F;
  --prog-bg: #E5EEF9;
  /* Bluebook-style runner */
  --bb-blue: #324DC7;
  --bb-blue-dark: #2338A0;
  --bb-blue-soft: #E8ECFB;
  --bb-gray: #F0F1F3;
  --bb-border: #1F1F1F;
  --bb-flag: #C13145;
  --font-ui: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-brand: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --font-q: "Noto Serif", Georgia, "Times New Roman", serif;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--ivory);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.in-runner { background: var(--white); overflow: hidden; }
body.resizing { cursor: col-resize; user-select: none; }
button { font-family: inherit; font-size: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Menlo, Consolas, monospace; }
.tex-fallback { font-family: Menlo, Consolas, monospace; font-size: .9em; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 6px; padding: 10px 18px;
  font-weight: 600; font-size: 15px; cursor: pointer; line-height: 1.2;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--navy-2); }
.btn-ghost { background: transparent; color: var(--navy); border-color: #CFC7B6; }
.btn-ghost:hover:not(:disabled) { background: var(--ivory-2); }
.btn-outline { background: var(--white); color: var(--bb-blue); border: 1.5px solid var(--bb-blue); border-radius: 999px; }
.btn-outline:hover { background: var(--bb-blue-soft); }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-small { padding: 6px 10px; font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--navy); text-decoration: underline; cursor: pointer; padding: 0; font-weight: 500; }
.icon-btn { background: none; border: 0; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid #7C9CF5; outline-offset: 2px; }

/* ---------------- Brand pages ---------------- */
.brand-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--ivory);
}
.wordmark { font-family: var(--font-brand); font-size: 21px; color: var(--navy); text-decoration: none; letter-spacing: .01em; }
.brand-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.code-chip { font-family: Menlo, Consolas, monospace; font-size: 13px; background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; color: var(--navy); letter-spacing: .04em; }
.code-chip.big { display: inline-block; font-size: 22px; padding: 10px 22px; margin: 6px 0 4px; }

.page { max-width: 1040px; margin: 0 auto; padding: 44px 28px 120px; }
.page.narrow { max-width: 680px; }
.page.center { text-align: center; }
.display { font-family: var(--font-brand); font-weight: 400; color: var(--navy); font-size: 38px; line-height: 1.2; margin: 0 0 14px; letter-spacing: -.005em; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.lede { font-size: 18px; color: #3B4352; margin: 0 0 24px; }
.actions { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }
.page.center .actions { justify-content: center; }
.small-note { color: var(--muted); font-size: 13px; margin-top: 16px; }
.narrow-only { display: none; }
.setup-warning { margin-top: 24px; padding: 12px 16px; border-radius: 6px; background: var(--fix-bg); color: var(--fix); font-weight: 500; }

.loading { text-align: center; padding: 80px 0; color: var(--muted); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--navy); margin: 0 auto 16px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Entry */
.entry .display { font-size: 44px; }
.code-form { display: flex; gap: 10px; }
.code-input {
  flex: 1; min-width: 0; font-family: Menlo, Consolas, monospace; font-size: 22px; letter-spacing: .08em;
  padding: 12px 16px; border: 1.5px solid #CFC7B6; border-radius: 8px; background: var(--white); color: var(--navy);
}
.code-input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22,35,59,.12); }
.form-error { color: var(--bad); min-height: 1.4em; margin: 10px 0 0; font-weight: 500; }
.entry-notes { margin-top: 36px; display: grid; gap: 12px; }
.entry-notes > div { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; font-size: 15px; }
.entry-notes strong { color: var(--navy); }

/* Overview */
.facts { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 24px; }
.facts > div { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; min-width: 130px; }
.facts span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.facts strong { color: var(--navy); font-size: 17px; font-weight: 600; }
.section-list { list-style: none; padding: 0; margin: 0 0 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.section-list li { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.section-list li:last-child { border-bottom: 0; }
.sec-num { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none; }
.sec-title { font-weight: 600; color: var(--navy); }
.sec-meta { margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; }
.how { padding-left: 20px; margin: 0 0 8px; color: #3B4352; }
.how li { margin: 6px 0; }
.resume-note { background: var(--prog-bg); color: var(--prog); border-radius: 6px; padding: 10px 14px; font-weight: 500; }
.tags-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--navy); }

/* Toast + modal */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: var(--white); padding: 11px 18px; border-radius: 8px; font-weight: 500; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: opacity .2s, transform .2s; z-index: 80; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: #8A4B00; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.modal { background: var(--white); border-radius: 12px; max-width: 480px; width: 100%; padding: 26px 26px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 10px; font-size: 21px; color: var(--navy); font-family: var(--font-brand); font-weight: 400; }
.modal-body p { margin: 0 0 10px; color: #3B4352; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.help-list { padding-left: 18px; margin: 0; }
.help-list li { margin: 6px 0; }

/* ---------------- Runner: Bluebook-style ---------------- */
.runner { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--white); font-family: var(--font-ui); }
.bb-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 10px 24px; min-height: 72px; background: var(--white); }
.bb-head-left { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.bb-sec-title { font-weight: 700; font-size: 17px; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bb-dir-btn { background: none; border: 0; padding: 2px 0; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: #111; }
.bb-dir-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.bb-head-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bb-timer { font-size: 22px; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; min-height: 30px; color: #111; }
.bb-timer.hidden-time { visibility: hidden; }
.bb-timer.warn { color: var(--bad); }
.bb-hide { border: 1px solid #555; background: var(--white); border-radius: 999px; padding: 1px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }
.bb-head-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.bb-tool { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; color: #111; }
.bb-tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bb-tool:hover:not(:disabled) { background: var(--bb-gray); }
.bb-tool.on { background: var(--bb-blue-soft); color: var(--bb-blue-dark); }
.bb-tool:disabled { opacity: .35; cursor: not-allowed; }
.bb-more-wrap { position: relative; }
.bb-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--white); border: 1px solid #D6D8DD; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; min-width: 180px; z-index: 40; }
.bb-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.bb-menu button:hover { background: var(--bb-gray); }
.save-badge { font-size: 12px; color: var(--muted); margin-right: 8px; min-width: 70px; text-align: right; }
.save-badge.offline { color: var(--bad); font-weight: 600; }

/* Dashed rule, Bluebook-style */
.bb-dash { height: 3px; flex: none; background: repeating-linear-gradient(90deg, #1E2A44 0 14px, transparent 14px 20px, #6E7CA8 20px 34px, transparent 34px 40px); opacity: .85; }

.bb-dir-pop { position: absolute; top: 76px; left: 24px; z-index: 45; width: min(640px, calc(100vw - 48px)); max-height: 70vh; overflow: auto; background: var(--white); border: 1px solid #D6D8DD; border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.bb-dir-inner { padding: 22px 26px; }
.bb-dir-inner h2 { margin: 0 0 10px; font-size: 20px; }
.bb-dir-inner .right { text-align: right; margin-top: 14px; }
.bb-dir-text p { margin: 0 0 10px; font-family: var(--font-q); font-size: 16px; }

.bb-preview-bar { background: var(--fix-bg); color: var(--fix); padding: 8px 24px; font-size: 14px; }
.bb-preview-bar .link-btn { color: var(--fix); margin-left: 10px; }

.bb-body { flex: 1; display: flex; min-height: 0; position: relative; }
.bb-main { flex: 1; overflow: auto; min-width: 0; outline: none; }

/* Calculator panel */
.bb-calc { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid #D6D8DD; position: relative; background: var(--white); }
.bb-calc.wide { width: min(640px, 60vw); }
.bb-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; background: #2B2B2B; color: var(--white); font-size: 14px; }
.bb-panel-head .icon-btn { color: var(--white); }
.bb-panel-head .icon-btn:hover { background: rgba(255,255,255,.12); }
.bb-calc-host { flex: 1; min-height: 0; }
.bb-calc-msg { padding: 18px; color: var(--muted); font-size: 14px; }
.bb-resize { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 5; }
.bb-resize::after { content: ""; position: absolute; top: 50%; left: 2px; width: 4px; height: 40px; margin-top: -20px; border-radius: 2px; background: #B9BDC6; }

/* Reference panel */
.bb-ref { width: 440px; flex: none; display: flex; flex-direction: column; border-left: 1px solid #D6D8DD; background: var(--white); }
.bb-ref-body { flex: 1; overflow: auto; padding: 16px 18px 24px; }
.ref-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
.ref-fig { text-align: center; font-size: 13px; }
.ref-fig svg { width: 100%; max-width: 120px; height: auto; fill: none; stroke: #111; stroke-width: 1.4; }
.ref-fig svg text { fill: #111; stroke: none; font-family: var(--font-q); font-style: italic; font-size: 11px; }
.ref-fig svg .dash { stroke-dasharray: 4 3; }
.ref-fig svg .thin { stroke-width: 1; }
.ref-fig svg .dot { fill: #111; }
.ref-fig svg .dash-fill { stroke-dasharray: 4 3; fill: none; }
.ref-f { margin-top: 2px; min-height: 20px; }
.ref-facts { margin: 16px 0 0; padding-left: 18px; font-family: var(--font-q); font-size: 15px; }
.ref-facts li { margin: 6px 0; }

/* Footer */
.bb-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 12px 24px; min-height: 64px; background: var(--white); }
.bb-foot-left { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bb-qnav-btn { background: #111; color: var(--white); border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.bb-qnav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.bb-foot-right { display: flex; justify-content: flex-end; gap: 10px; }
.bb-btn { background: var(--bb-blue); color: var(--white); border: 0; border-radius: 999px; padding: 10px 26px; font-weight: 700; font-size: 15px; cursor: pointer; }
.bb-btn:hover:not(:disabled) { background: var(--bb-blue-dark); }
.bb-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Question navigator popover */
.bb-pop { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); background: var(--white); border: 1px solid #D6D8DD; border-radius: 14px; box-shadow: 0 16px 44px rgba(0,0,0,.22); padding: 18px 22px 20px; z-index: 50; }
.bb-pop::after { content: ""; position: absolute; bottom: -9px; left: 50%; margin-left: -9px; width: 16px; height: 16px; background: var(--white); border-right: 1px solid #D6D8DD; border-bottom: 1px solid #D6D8DD; transform: rotate(45deg); }
.bb-pop-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #E3E5E9; padding-bottom: 10px; margin-bottom: 12px; }
.bb-pop-foot { text-align: center; margin-top: 16px; }

.q-legend { display: flex; gap: 18px; justify-content: center; font-size: 13px; color: #333; margin-bottom: 14px; flex-wrap: wrap; }
.q-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.lg-box { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.lg-box.dashed { border: 1.5px dashed #555; }
.lg-pin svg, .lg-flag svg { width: 16px; height: 16px; }
.lg-pin svg { fill: none; stroke: #111; stroke-width: 2; }
.lg-flag svg { fill: var(--bb-flag); stroke: none; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 14px 10px; }
.q-cell {
  position: relative; height: 40px; border-radius: 6px; border: 1.5px dashed #555; background: var(--white);
  color: var(--bb-blue); font-weight: 700; font-size: 15px; cursor: pointer;
}
.q-cell.done { border: 1.5px solid var(--bb-blue); background: var(--bb-blue); color: var(--white); }
.q-cell:hover { box-shadow: 0 0 0 3px var(--bb-blue-soft); }
.q-cell .pin { position: absolute; top: -17px; left: 50%; margin-left: -8px; }
.q-cell .pin svg { width: 16px; height: 16px; fill: var(--white); stroke: #111; stroke-width: 2; }
.q-cell .mini-flag { position: absolute; top: -7px; right: -6px; }
.q-cell .mini-flag svg { width: 14px; height: 14px; fill: var(--bb-flag); stroke: var(--white); stroke-width: 1.2; }

/* Section intro + Check Your Work */
.bb-intro, .bb-check { max-width: 760px; margin: 0 auto; padding: 48px 28px 60px; }
.bb-intro h1, .bb-check h1 { font-size: 30px; margin: 0 0 12px; text-align: left; }
.bb-check h1 { text-align: center; }
.bb-check > p { text-align: center; margin: 4px 0; color: #333; }
.bb-intro-eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 6px; }
.bb-intro-facts { display: flex; gap: 10px; margin: 0 0 20px; }
.bb-intro-facts span { border: 1px solid #D6D8DD; border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 600; }
.bb-intro-facts .ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.bb-intro-facts .no { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.bb-intro-small { color: var(--muted); font-size: 14px; margin: 4px 0 24px; }
.bb-intro .btn-primary { background: var(--bb-blue); border-radius: 999px; }
.bb-intro .btn-primary:hover { background: var(--bb-blue-dark); }
.bb-check-card { margin-top: 26px; border: 1px solid #D6D8DD; border-radius: 12px; padding: 18px 22px 24px; box-shadow: 0 4px 18px rgba(0,0,0,.06); }
.bb-check-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid #E3E5E9; padding-bottom: 12px; margin-bottom: 18px; }
.bb-check-head .q-legend { margin: 0; }

/* Question layout */
.bb-q { min-height: 100%; }
.bb-q.single .bb-pane { max-width: 760px; margin: 0 auto; padding: 22px 28px 48px; }
.bb-q.split { display: flex; min-height: 100%; }
.bb-left { flex: 1 1 50%; overflow: auto; padding: 22px 30px 40px; background: var(--white); }
.bb-divider { width: 6px; flex: none; background: #E3E5E9; }
.bb-right { flex: 1 1 50%; overflow: auto; padding: 22px 30px 48px; }

.bb-qbar { display: flex; align-items: center; gap: 12px; background: var(--bb-gray); border-bottom: 2px dashed #9AA0AA; padding: 0 10px 0 0; min-height: 40px; margin-bottom: 18px; }
.bb-qnum { background: #111; color: var(--white); font-weight: 700; min-width: 34px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; font-size: 16px; }
.bb-flag { background: none; border: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; font-weight: 500; padding: 6px 4px; color: #111; }
.bb-flag svg { width: 18px; height: 18px; fill: none; stroke: #111; stroke-width: 1.7; }
.bb-flag.on { font-weight: 700; }
.bb-flag.on svg { fill: var(--bb-flag); stroke: var(--bb-flag); }
.bb-orig { font-size: 13px; color: var(--muted); }
.bb-abc { margin-left: auto; background: var(--white); border: 1.5px solid #111; border-radius: 6px; padding: 2px 8px; font-weight: 700; font-size: 13px; cursor: pointer; position: relative; }
.bb-abc span { text-decoration: line-through; text-decoration-thickness: 2px; }
.bb-abc.on { background: var(--bb-blue); border-color: var(--bb-blue); color: var(--white); }

.bb-qbody { font-family: var(--font-q); font-size: 17px; line-height: 1.6; color: #111; }
.bb-qbody p { margin: 0 0 12px; }
.bb-instr { font-style: italic; color: #333; }
.bb-stem { margin-bottom: 20px; }
.bb-stem .katex { font-size: 1.12em; }
.math-display { margin: 12px 0; overflow-x: auto; overflow-y: hidden; }
.q-figure { margin: 4px 0 18px; text-align: center; }
.q-figure img, .q-figure svg { max-width: 100%; height: auto; }
.plane { width: 320px; color: #111; }
.plane .pl-grid { stroke: #C9CCD2; stroke-width: .8; }
.plane .pl-axis { stroke: #111; stroke-width: 1.4; }
.plane .pl-line { stroke: #111; stroke-width: 2.2; }
.plane .pl-pt { fill: #111; }
.plane text { font-family: var(--font-q); font-size: 11px; fill: #111; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.plane .pl-name { font-style: italic; font-size: 13px; }

/* Answer choices */
.bb-choices { display: flex; flex-direction: column; gap: 12px; }
.bb-choice-row { display: flex; align-items: center; gap: 10px; }
.bb-choice {
  flex: 1; display: flex; align-items: center; gap: 14px; text-align: left; background: var(--white);
  border: 1.5px solid #3A3A3A; border-radius: 10px; padding: 10px 14px; min-height: 52px; cursor: pointer;
  font-family: var(--font-q); font-size: 17px; color: #111; position: relative;
}
.bb-choice:hover:not(:disabled) { border-color: var(--bb-blue); }
.bb-letter { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid #111; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-ui); font-weight: 700; font-size: 14px; }
.bb-choice-text .katex { font-size: 1.1em; }
.bb-choice-row.selected .bb-choice { border: 3px solid var(--bb-blue); padding: 8.5px 12.5px; }
.bb-choice-row.selected .bb-letter { background: var(--bb-blue); border-color: var(--bb-blue); color: var(--white); }
.bb-choice-row.crossed .bb-choice { color: #8A8F98; border-color: #B9BDC6; }
.bb-choice-row.crossed .bb-choice::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: #333; }
.bb-choice-row.crossed .bb-letter { border-color: #8A8F98; }
.bb-choice-row.first-try .bb-choice { cursor: not-allowed; }
.bb-choice-row.first-try .bb-choice::after { right: 104px; }
.first-tag { margin-left: auto; font-family: var(--font-ui); font-size: 12px; font-weight: 600; color: var(--bad); background: var(--bad-bg); border-radius: 999px; padding: 2px 10px; position: relative; z-index: 1; }
.bb-x { flex: none; width: 34px; height: 34px; border: 0; background: none; cursor: pointer; position: relative; }
.bb-x span { width: 26px; height: 26px; border: 1.5px solid #111; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.bb-x::after { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 2px; background: #111; }
.bb-undo { flex: none; background: none; border: 0; text-decoration: underline; font-family: var(--font-ui); font-weight: 700; cursor: pointer; font-size: 14px; width: 48px; }

/* Student-produced response */
.spr-dir { font-family: var(--font-q); font-size: 15px; line-height: 1.55; }
.spr-dir h2 { font-family: var(--font-ui); font-size: 16px; margin: 0 0 10px; }
.spr-dir ul { padding-left: 20px; margin: 0 0 16px; }
.spr-dir li { margin: 6px 0; }
.spr-ex { width: 100%; border-collapse: collapse; font-size: 14px; }
.spr-ex th, .spr-ex td { border: 1px solid #B9BDC6; padding: 6px 8px; text-align: center; vertical-align: middle; }
.spr-ex th { background: var(--bb-gray); font-family: var(--font-ui); font-size: 13px; }
.bb-spr { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.bb-spr-input { width: 170px; font-family: var(--font-q); font-size: 22px; padding: 8px 12px; border: 1.5px solid #3A3A3A; border-radius: 8px; border-bottom-width: 3px; }
.bb-spr-input:focus { outline: none; border-color: var(--bb-blue); }
.bb-suffix { font-family: var(--font-q); font-size: 22px; }
.bb-spr-preview { font-family: var(--font-ui); font-size: 14px; font-weight: 600; color: #333; }
.bb-spr-preview .katex { font-size: 1.25em; }
.retry-note { background: var(--bad-bg); color: var(--bad); border-radius: 6px; padding: 8px 12px; font-family: var(--font-ui); font-size: 14px; }

.pv-reveal { margin-top: 26px; border: 1px dashed var(--fix); border-radius: 8px; padding: 10px 14px; background: #FFFBEF; font-family: var(--font-ui); font-size: 15px; }
.pv-reveal summary { cursor: pointer; font-weight: 600; color: var(--fix); }
.pv-reveal .expl { font-family: var(--font-q); }

/* ---------------- Confidence pass ---------------- */
.conf { max-width: 860px; }
.conf-sec { font-family: var(--font-brand); font-weight: 400; color: var(--navy); font-size: 22px; margin: 28px 0 10px; }
.conf-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.conf-q { font-weight: 700; color: var(--navy); }
.conf-ans { font-family: var(--font-q); display: flex; align-items: center; gap: 10px; min-width: 0; overflow-x: auto; }
.ans-letter { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: var(--white); font-family: var(--font-ui); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.conf-btns { display: flex; gap: 6px; }
.conf-btn { border: 1.5px solid #CFC7B6; background: var(--white); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--navy); white-space: nowrap; }
.conf-btn:hover { border-color: var(--navy); }
.conf-btn.on[data-c="knew"] { background: var(--ok); border-color: var(--ok); color: var(--white); }
.conf-btn.on[data-c="unsure"] { background: #B7791F; border-color: #B7791F; color: var(--white); }
.conf-btn.on[data-c="guessed"] { background: var(--bad); border-color: var(--bad); color: var(--white); }
.conf-blank { margin-top: 18px; }
.sticky-foot { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(247,244,237,.96); border-top: 1px solid var(--line); backdrop-filter: blur(6px); z-index: 30; }
.sticky-inner { max-width: 860px; margin: 0 auto; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sticky-inner > span { font-weight: 600; color: var(--navy); }
.sticky-actions { display: flex; gap: 10px; }

/* ---------------- Review ---------------- */
.review .display { margin-bottom: 8px; }
.rv-title { font-family: var(--font-brand); font-weight: 400; color: var(--navy); font-size: 22px; margin: 6px 0 18px; }
.rv-title:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.stat span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.stat strong { display: block; font-family: var(--font-brand); font-weight: 400; color: var(--navy); font-size: 34px; line-height: 1.25; }
.stat em { font-style: normal; font-size: 13px; color: var(--muted); }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; color: var(--navy); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col > .card:only-child { grid-column: 1 / -1; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 50px; align-items: center; gap: 12px; margin: 8px 0; font-size: 15px; }
.bar-label { font-weight: 600; color: var(--navy); }
.bar { height: 10px; background: var(--ivory-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
.conf-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.conf-card { border-radius: 8px; padding: 10px 12px; background: var(--ivory); }
.conf-card span { display: block; font-size: 13px; font-weight: 600; }
.conf-card strong { display: block; font-size: 24px; font-family: var(--font-brand); font-weight: 400; }
.conf-card em { font-style: normal; font-size: 12px; color: var(--muted); }
.conf-card.knew span, .conf-card.knew strong { color: var(--ok); }
.conf-card.unsure span, .conf-card.unsure strong { color: #8A5A10; }
.conf-card.guessed span, .conf-card.guessed strong { color: var(--bad); }
.obs ul { margin: 0; padding-left: 20px; }
.obs li { margin: 6px 0; }
.tag-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-left: 4px solid var(--navy); }
.tag-banner h2 { margin-bottom: 4px; }
.tag-banner p { margin: 0; }
.tag-count { font-size: 15px; white-space: nowrap; color: var(--navy); }
.tag-count .check { color: var(--ok); font-weight: 700; }

.rv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 30px 0 12px; }
.rv-head h2 { font-family: var(--font-brand); font-weight: 400; color: var(--navy); font-size: 24px; margin: 0; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { border: 1px solid #CFC7B6; background: var(--white); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--navy); }
.filter.on { background: var(--navy); color: var(--white); border-color: var(--navy); }

.rv-item { background: var(--white); border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.rv-item.ok { border-left-color: var(--ok); }
.rv-item.bad, .rv-item.blank { border-left-color: var(--bad); }
.rv-item.fixed { border-left-color: #D69E2E; }
.rv-item-head { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: #FBFAF6; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rv-num { font-weight: 700; color: var(--navy); }
.rv-skill { color: var(--muted); font-size: 14px; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.rv-item-head .pill { margin-left: auto; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad, .pill.blank { background: var(--bad-bg); color: var(--bad); }
.pill.fixed { background: var(--fix-bg); color: var(--fix); }
.pill.prog { background: var(--prog-bg); color: var(--prog); }
.rv-body { padding: 16px 18px 14px; font-family: var(--font-q); font-size: 16px; }
.rv-body p { margin: 0 0 10px; }
.rv-stem { margin-bottom: 12px; }
.rv-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rv-choice { display: flex; align-items: center; gap: 12px; border: 1.5px solid #D6D8DD; border-radius: 8px; padding: 8px 12px; }
.rv-choice.correct { border-color: var(--ok); background: #F3FAF5; }
.rv-choice.correct .bb-letter { background: var(--ok); color: var(--white); border-color: var(--ok); }
.rv-choice.wrong { border-color: var(--bad); background: #FFF6F5; }
.rv-choice.wrong .bb-letter { background: var(--bad); color: var(--white); border-color: var(--bad); }
.mks { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mk { font-family: var(--font-ui); font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.mk-ok { background: var(--ok-bg); color: var(--ok); }
.mk-bad { background: var(--bad-bg); color: var(--bad); }
.mk-key { background: var(--ok); color: var(--white); }
.mk-x { background: #EEF0F3; color: #555; }
.rv-spr { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.rv-spr > div { border-radius: 8px; padding: 8px 14px; min-width: 130px; }
.rv-spr span { display: block; font-family: var(--font-ui); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.rv-spr strong { font-size: 20px; font-weight: 400; }
.rv-spr .ok { background: var(--ok-bg); color: var(--ok); }
.rv-spr .bad { background: var(--bad-bg); color: var(--bad); }
.rv-spr .key { background: #F3FAF5; color: var(--ok); border: 1.5px solid var(--ok); }
.rv-meta { font-family: var(--font-ui); font-size: 13px; color: var(--muted); margin: 6px 0 8px !important; }
.rv-expl { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.rv-expl summary { font-family: var(--font-ui); font-weight: 700; color: var(--navy); cursor: pointer; font-size: 14px; padding: 4px 0; }
.expl { padding: 6px 2px 2px; }
.expl ul { margin: 0 0 10px; padding-left: 22px; }
.rv-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: var(--ivory); border-radius: 8px; font-family: var(--font-ui); font-size: 14px; }
.rv-tags-q { font-weight: 600; color: var(--navy); margin-right: 4px; }
.tag-btn { border: 1.5px solid #CFC7B6; background: var(--white); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--navy); }
.tag-btn:hover { border-color: var(--navy); }
.tag-btn.on { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* Tutor tables */
.table-card { padding: 0; overflow: hidden; }
.table-card h2 { padding: 16px 20px 0; }
.table-wrap { overflow-x: auto; }
table.log { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.log th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--navy); color: var(--navy); white-space: nowrap; background: var(--white); }
table.log td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.log tr.hl td { background: var(--fix-bg); }
.tutor-list td { vertical-align: middle; }
.tutor-list td.mono { white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .bb-head { padding: 8px 12px; grid-template-columns: 1fr auto auto; }
  .bb-tool span { display: none; }
  .save-badge { display: none; }
  .bb-calc { position: absolute; z-index: 20; left: 0; top: 0; bottom: 0; width: min(420px, 92vw); box-shadow: 8px 0 24px rgba(0,0,0,.15); }
  .bb-calc.wide { width: 92vw; }
  .bb-ref { position: absolute; z-index: 20; right: 0; top: 0; bottom: 0; width: min(440px, 92vw); box-shadow: -8px 0 24px rgba(0,0,0,.15); }
  .bb-q.split { flex-direction: column; }
  .bb-divider { width: auto; height: 6px; }
  .bb-left { order: 2; }
  .bb-right, .bb-left { flex: none; overflow: visible; padding: 18px 16px 24px; }
  .bb-q.single .bb-pane { padding: 18px 16px 40px; }
  .bb-foot { padding: 10px 12px; grid-template-columns: auto 1fr auto; gap: 8px; }
  .bb-foot-left { display: none; }
  .bb-btn { padding: 9px 16px; }
  .two-col, .stats, .conf-cards { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .bb-sec-title { font-size: 14px; }
  .bb-dir-btn { font-size: 13px; }
  .bb-timer { font-size: 18px; min-height: 24px; }
  .bb-head-right { gap: 0; }
  .bb-tool { padding: 6px; }
  .page { padding: 28px 16px 120px; }
  .brand-bar { padding: 14px 16px; }
  .display, .entry .display { font-size: 30px; }
  .code-form { flex-direction: column; }
  .narrow-only { display: block; }
  .conf-row { grid-template-columns: 40px 1fr; }
  .conf-btns { grid-column: 1 / -1; }
  .conf-btn { flex: 1; padding: 6px 8px; }
  .sticky-inner { padding: 12px 16px; flex-direction: column; align-items: stretch; }
  .sticky-actions { justify-content: stretch; }
  .sticky-actions .btn { flex: 1; }
  .sec-meta { display: none; }
  .bar-row { grid-template-columns: 90px 1fr 44px; }
  .bb-qnav-btn { padding: 8px 10px; font-size: 13px; }
  .ref-grid { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .brand-bar .brand-right, .filters, .rv-tags button { display: none; }
  body { background: var(--white); }
  .rv-item { break-inside: avoid; }
}
