/* ==========================================================================
   SAT Studio — app UI
   Colors: navy + coral + teal. UI: Plus Jakarta Sans · Questions: Source Serif 4
   ========================================================================== */
:root {
  --coral: #ff6e58;
  --coral-deep: #d44d3d;
  --coral-rgb: 255 110 88;
  --teal-rgb: 96 189 193;
  --coral-soft: rgb(var(--coral-rgb) / .13);
  --teal: #60bdc1;
  --teal-soft: rgb(var(--teal-rgb) / .15);
  --ok: #3fbf8f;
  --warn: #f2b94b;
  --bad: #ff6e58;
  --ui: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --read: 'Source Serif 4', 'Georgia', serif;
  --radius: .75rem;
  --side-w: 248px;
}
[data-bs-theme="dark"] {
  --bg: #0e161c;
  --bg-2: #121d25;
  --surface: #16222b;
  --surface-2: #1c2a35;
  --ink: #e9eeee;
  --ink-soft: #93a3ad;
  --line: rgba(255, 255, 255, .08);
  --side-bg: #101920;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--ink-soft);
  --bs-tertiary-bg: var(--surface-2);
}
[data-bs-theme="light"] {
  --bg: #f3f4ef;
  --bg-2: #eaece5;
  --surface: #ffffff;
  --surface-2: #f4f5f0;
  --ink: #17212b;
  --ink-soft: #5b6a75;
  --line: rgba(23, 33, 43, .11);
  --side-bg: #17212b;
  --coral-deep: #c83d32;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--ink-soft);
}

html, body { min-height: 100%; }
body { font-family: var(--ui); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--coral); }
a:hover { color: var(--coral-deep); }
::selection { background: var(--coral); color: #fff; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, .display-title { font-family: var(--ui); font-weight: 800; letter-spacing: -.015em; }
.display-title { font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.15; margin: 0; }
h1 em, h2 em, h3 em, .display-title em { font-style: normal; color: var(--coral); }
.eyebrow { display: block; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.text-soft { color: var(--ink-soft) !important; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Sidebar layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 1030;
  display: flex; flex-direction: column; padding: 1.2rem .9rem;
  background: var(--side-bg); color: #dfe6e8; border-right: 1px solid rgba(255, 255, 255, .06);
}
.side-brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; padding: 0 .4rem; }
.side-brand:hover { color: inherit; }
.side-brand strong { display: block; font-weight: 800; font-size: 1.05rem; line-height: 1.1; }
.side-brand small { display: block; font-size: .72rem; color: #8fa0aa; }
.logo-box { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: .6rem; background: var(--coral); color: #fff; font-size: 1.15rem; flex: none; }
.side-label { margin: 1.8rem .6rem .5rem; font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6f828d; }
.side-nav { display: flex; flex-direction: column; gap: .2rem; }
.side-nav a {
  position: relative; display: flex; align-items: center; gap: .8rem; padding: .62rem .8rem; border-radius: .55rem;
  color: #b4c2c9; text-decoration: none; font-weight: 600; font-size: .92rem;
}
.side-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.side-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side-nav a.active { background: rgb(var(--coral-rgb) / .14); color: #fff; }
.side-nav a.active i { color: var(--coral); }
.side-nav a.active::before { content: ''; position: absolute; left: -.9rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--coral); }
.side-foot { margin-top: auto; display: grid; gap: .7rem; }
.side-user { display: flex; align-items: center; gap: .7rem; padding: .7rem; border-radius: .6rem; background: rgba(255, 255, 255, .04); }
.side-user strong { display: block; font-size: .9rem; color: #fff; }
.side-user small { display: block; font-size: .72rem; color: #8fa0aa; }
.side-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .5rem .7rem; border-radius: .5rem;
  border: 1px solid rgba(255, 255, 255, .1); background: transparent; color: #b4c2c9; font-size: .82rem; font-weight: 600; text-decoration: none;
}
.side-btn:hover { color: #fff; border-color: rgba(255, 255, 255, .25); }
.avatar { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem; background: var(--c, var(--coral)); color: #fff; font-weight: 800; font-size: .85rem; flex: none; }
.avatar.lg { width: 3rem; height: 3rem; font-size: 1.2rem; border-radius: .7rem; }
.avatar.sm { width: 1.6rem; height: 1.6rem; font-size: .75rem; border-radius: .4rem; }
/* Role avatars: one icon and colour per role (accent and teal follow the selected palette) */
.avatar.role-student { --c: var(--coral); }
.avatar.role-parent { --c: var(--teal); }
.avatar.role-admin { --c: #8b5cf6; }
.avatar > .bi { line-height: 1; }

.topbar, .tabbar { display: none; }
body.has-sidebar .app-main { margin-left: var(--side-w); }
.app-main { padding: 2rem 1rem 4rem; }
.app-main > .container-xl { max-width: 96rem; }
.icon-btn { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: .55rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

@media (max-width: 991.98px) {
  .sidebar { display: none; }
  body.has-sidebar .app-main { margin-left: 0; padding: 1.2rem .4rem 6rem; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1030;
    padding: .6rem 1rem; background: var(--side-bg); color: #fff;
  }
  .topbar .icon-btn { background: transparent; border-color: rgba(255, 255, 255, .12); color: #dfe6e8; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: var(--surface); border-top: 1px solid var(--line); padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem 0; color: var(--ink-soft); text-decoration: none; font-size: .68rem; font-weight: 600; border-radius: .5rem; }
  .tabbar a i { font-size: 1.2rem; }
  .tabbar a.active { color: var(--coral); }
}

/* ---------- Cards & surfaces ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.panel { padding: 1.3rem; }
.panel-title { font-size: .95rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.panel-title > i:first-child { color: var(--coral); }
.stat { padding: 1.1rem 1.2rem; }
.stat .label { font-size: .75rem; font-weight: 600; color: var(--ink-soft); }
.stat .value { font-size: 1.7rem; font-weight: 800; line-height: 1.15; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .78rem; color: var(--ink-soft); }
.hero-panel {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: clamp(1.4rem, 3vw, 2rem);
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--coral); color: var(--ink);
}
.hero-panel .text-soft { color: var(--ink-soft) !important; }
.hero-tile { padding: .9rem 1rem; border-radius: .6rem; background: var(--surface-2); text-align: left; }
.hero-tile .small { color: var(--ink-soft); font-weight: 600; }
.action-card {
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink); height: 100%;
  padding: 1.2rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.action-card:hover { border-color: var(--coral); color: var(--ink); background: var(--surface-2); }
.action-card .ic { width: 2.5rem; height: 2.5rem; border-radius: .55rem; display: grid; place-items: center; font-size: 1.15rem; background: var(--coral-soft); color: var(--coral); margin-bottom: .9rem; }
.action-card.teal .ic { background: var(--teal-soft); color: var(--teal); }

/* ---------- Buttons & forms ---------- */
.btn { font-weight: 700; border-radius: .55rem; padding: .55rem 1.1rem; }
.btn-sm { padding: .3rem .75rem; border-radius: .45rem; }
.btn-coral { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-coral:hover, .btn-coral:focus { background: var(--coral-deep); border-color: var(--coral-deep); color: #fff; }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--coral); color: var(--coral); background: var(--surface); }
.form-control, .form-select { background-color: var(--surface-2); border-color: var(--line); color: var(--ink); border-radius: .55rem; padding: .55rem .85rem; }
.form-control:focus, .form-select:focus { border-color: var(--coral); box-shadow: 0 0 0 .2rem var(--coral-soft); background-color: var(--surface-2); color: var(--ink); }
/* Password show/hide eye (added by app.js) */
.pw-wrap { position: relative; }
.pw-wrap .pw-input { padding-right: 2.75rem; }
.pw-wrap .pw-input.is-invalid { background-image: none; padding-right: 2.75rem; }
.pw-toggle { position: absolute; top: 0; right: 0; height: 100%; width: 2.6rem; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-soft); border-radius: 0 .55rem .55rem 0; }
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--coral); }
.pw-wrap .pw-input[type=text]:not(.pin-input) ~ .pw-toggle { color: var(--coral); }
.pw-wrap.no-toggle .pw-toggle { display: none; }
.pw-wrap.no-toggle .pw-input { padding-right: .85rem; }
/* Validation messages */
.invalid-feedback { color: var(--bad, #e5484d); font-size: .82rem; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--bad, #e5484d); }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { box-shadow: 0 0 0 .2rem rgb(229 72 77 / .2); }
.form-label { font-weight: 600; font-size: .85rem; }
.chip-group { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-group input { display: none; }
.chip-group label { padding: .38rem .8rem; border-radius: .45rem; border: 1px solid var(--line); cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--ink-soft); background: var(--surface); user-select: none; }
.chip-group input:checked + label { background: var(--coral-soft); border-color: var(--coral); color: var(--coral); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); color: var(--ink); }
.table > :not(caption) > * > * { border-color: var(--line); }
.badge-diff { font-size: .7rem; font-weight: 700; padding: .28em .6em; border-radius: .35rem; }
.badge-diff.E { background: rgba(63, 191, 143, .16); color: var(--ok); }
.badge-diff.M { background: rgba(242, 185, 75, .16); color: var(--warn); }
.badge-diff.H { background: var(--coral-soft); color: var(--coral); }
.badge-soft { background: var(--surface-2); color: var(--ink-soft); font-weight: 600; border-radius: .35rem; }
.badge-pretest { background: var(--teal-soft); color: var(--teal); border-radius: .35rem; font-weight: 700; }
.modal-content { border-radius: var(--radius); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--side-bg); color: #e9eeee; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: clamp(2rem, 3.5vw, 2.8rem); line-height: 1.1; }
.login-side ul { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .9rem; color: #b4c2c9; }
.login-side li i { color: var(--coral); margin-right: .6rem; }
.login-form { display: grid; place-items: center; padding: 2rem 1.2rem; }
.login-card { width: min(100%, 25rem); }
@media (max-width: 767.98px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 1.5rem; }
  .login-side ul { display: none; }
}
.profile-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .6rem; }
.profile-pick input { display: none; }
.profile-pick label {
  display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: .9rem .5rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: .6rem; background: var(--surface); font-weight: 700; font-size: .88rem;
}
.profile-pick input:checked + label { border-color: var(--coral); background: var(--coral-soft); }
.pin-input { letter-spacing: .6em; text-align: center; font-size: 1.4rem; font-weight: 800; }

/* ==========================================================================
   Question & answer reading styles (shared by practice + test)
   ========================================================================== */
.q-passage, .q-stem, .q-choice-text, .q-rationale {
  font-family: var(--read);
  font-size: 1.08rem;
  line-height: 1.68;
  font-optical-sizing: auto;
  color: var(--ink);
}
.q-passage p, .q-stem p, .q-rationale p { margin-bottom: .8em; }
.q-passage p:last-child, .q-stem p:last-child { margin-bottom: 0; }
.q-stem { font-weight: 500; }
.q-passage table, .q-stem table, .q-rationale table { width: auto; margin: .8rem 0; border-collapse: collapse; font-family: var(--ui); font-size: .92rem; }
.q-passage th, .q-passage td, .q-stem th, .q-stem td, .q-rationale td, .q-rationale th { border: 1px solid var(--line); padding: .35rem .7rem; }
.q-passage img, .q-stem img, .q-choice-text img, .q-rationale img { max-width: 100%; height: auto; }
/* College Board charts/figures are inline SVG drawn in black: scale them and give them a paper card */
.q-passage svg, .q-stem svg, .q-choice-text svg, .q-rationale svg { max-width: 100%; height: auto; }
.q-passage figure, .q-stem figure, .q-rationale figure { margin: .6rem 0 1rem; max-width: 100%; }
.q-passage figure.image, .q-stem figure.image, .q-rationale figure.image,
.q-passage figure.table, .q-stem figure.table { display: inline-block; }
[data-bs-theme="dark"] :is(.q-passage, .q-stem, .q-rationale, .q-choice-text) :is(figure.image, > svg, p > svg) {
  background: #fbfaf6; border-radius: .7rem; padding: .6rem; color: #111;
}
.q-passage .table-wrap, .q-stem .table-wrap { overflow-x: auto; }
[data-bs-theme="dark"] .q-passage img:not(.math-img), [data-bs-theme="dark"] .q-stem img:not(.math-img), [data-bs-theme="dark"] .q-rationale img:not(.math-img), [data-bs-theme="dark"] .q-choice-text img:not(.math-img) { background: #fff; border-radius: .5rem; padding: .4rem; }
[data-bs-theme="dark"] img.math-img { filter: invert(.92); }
.q-passage .underline, .q-stem .underline, .q-passage u { text-decoration: underline; text-underline-offset: 3px; }
.q-passage mark.hl { background: rgba(255, 214, 102, .55); color: inherit; padding: 0 1px; border-radius: 2px; }
.mjx-chtml { font-size: 108% !important; }
.sr-only, .sr-only-focusable { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.choice-list { display: grid; gap: .7rem; }
.choice-row { display: flex; align-items: stretch; gap: .5rem; }
.choice {
  flex: 1; display: flex; align-items: center; gap: .9rem; text-align: left;
  padding: .85rem 1rem; border: 2px solid var(--line); border-radius: .9rem;
  background: var(--surface); color: var(--ink); cursor: pointer; transition: border-color .12s, background .12s;
}
.choice:hover { border-color: rgb(var(--coral-rgb) / .55); }
.choice .letter {
  flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--ink-soft); font-family: var(--ui); font-weight: 800; font-size: .9rem;
}
.choice.selected { border-color: var(--coral); background: var(--coral-soft); }
.choice.selected .letter { background: var(--coral); border-color: var(--coral); color: #fff; }
.choice.correct { border-color: var(--ok); background: rgba(63, 191, 143, .12); }
.choice.correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--coral-soft); }
.choice.eliminated { opacity: .45; }
.choice.eliminated .q-choice-text { text-decoration: line-through; }
.eliminate-btn {
  flex: none; width: 2.4rem; border: 1px solid var(--line); border-radius: .7rem; background: transparent; color: var(--ink-soft);
  font-family: var(--ui); font-weight: 800; font-size: .78rem;
}
.eliminate-btn.on { color: var(--coral); border-color: var(--coral); }
.eliminate-btn span { text-decoration: line-through; }
.spr-box { max-width: 12rem; font-family: var(--ui); font-size: 1.3rem; font-weight: 700; text-align: center; }
.spr-preview { font-size: .9rem; color: var(--ink-soft); }
.spr-error { color: var(--bad); font-size: .85rem; }
.feedback { border-radius: var(--radius); padding: 1.2rem 1.4rem; border: 1px solid var(--line); background: var(--surface-2); }
.feedback.is-correct { border-color: rgba(63, 191, 143, .5); }
.feedback.is-wrong { border-color: rgb(var(--coral-rgb) / .5); }

/* ==========================================================================
   Test runner (Bluebook-style)
   ========================================================================== */
body.test-mode { overflow: hidden; }
.tr { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.tr-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem;
  padding: .55rem 1rem; border-bottom: 1px dashed var(--line); background: var(--bg-2);
}
.tr-title { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.tr-title small { display: block; color: var(--ink-soft); font-weight: 500; font-size: .78rem; }
.tr-timer { text-align: center; }
.tr-timer .time { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tr-timer .time.low { color: var(--coral); animation: pulse 1s infinite alternate; }
.tr-timer button { font-size: .72rem; padding: .1rem .6rem; }
@keyframes pulse { to { opacity: .55; } }
.tr-tools { display: flex; justify-content: flex-end; gap: .3rem; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: .1rem; border: 0; background: transparent;
  color: var(--ink); font-size: .7rem; font-weight: 600; padding: .25rem .55rem; border-radius: .6rem;
}
.tool-btn i { font-size: 1.15rem; }
.tool-btn:hover, .tool-btn.on { background: var(--surface-2); color: var(--coral); }
.tr-body { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.tr-body.no-passage { grid-template-columns: 1fr; }
.tr-body.no-passage .tr-left { display: none; }
.tr-body.no-passage .tr-right { max-width: 52rem; margin: 0 auto; width: 100%; }
.tr-left, .tr-right { overflow-y: auto; padding: 1.6rem clamp(1rem, 3vw, 2.6rem); }
.tr-left { border-right: 3px solid var(--line); }
.q-head {
  display: flex; align-items: center; gap: .6rem; padding: .3rem .3rem .3rem 0; margin-bottom: 1rem;
  background: var(--surface-2); border-radius: .6rem; border-bottom: 2px dashed var(--line);
}
.q-num { background: var(--ink); color: var(--bg); font-weight: 800; min-width: 2.2rem; text-align: center; padding: .35rem .5rem; border-radius: .6rem 0 0 .6rem; }
.mark-btn { border: 0; background: transparent; color: var(--ink); font-weight: 600; font-size: .88rem; }
.mark-btn.on i { color: var(--coral); }
.elim-toggle { margin-left: auto; border: 1px solid var(--line); background: transparent; color: var(--ink-soft); border-radius: .5rem; font-weight: 800; font-size: .78rem; padding: .15rem .5rem; }
.elim-toggle.on { color: var(--coral); border-color: var(--coral); }
.elim-toggle span { text-decoration: line-through; }
.tr-bottom {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem;
  padding: .6rem 1rem; border-top: 1px dashed var(--line); background: var(--bg-2);
}
.tr-bottom .who { font-weight: 700; font-size: .9rem; }
.nav-q-btn { background: var(--ink); color: var(--bg); border: 0; font-weight: 700; border-radius: .6rem; padding: .45rem 1rem; }
.tr-bottom .btns { display: flex; justify-content: flex-end; gap: .5rem; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: .5rem; }
.q-grid button {
  position: relative; height: 2.6rem; border: 2px dashed var(--ink-soft); background: transparent; color: var(--ink);
  font-weight: 800; border-radius: .5rem;
}
.q-grid button.answered { border: 2px solid var(--teal); background: var(--teal-soft); }
.q-grid button.current::after { content: ''; position: absolute; left: 50%; bottom: -.55rem; transform: translateX(-50%); color: var(--ink); width: .5rem; height: .5rem; background: var(--coral); border-radius: 50%; }
.q-grid button.flagged::before { content: '\F3CC'; font-family: 'bootstrap-icons'; position: absolute; top: -.6rem; right: -.4rem; color: var(--coral); font-size: .9rem; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: var(--ink-soft); }
.legend span::before { content: ''; display: inline-block; width: .8rem; height: .8rem; margin-right: .35rem; vertical-align: -1px; border-radius: 3px; }
.legend .l-cur::before { background: var(--coral); border-radius: 50%; }
.legend .l-un::before { border: 2px dashed var(--ink-soft); }
.legend .l-ans::before { border: 2px solid var(--teal); background: var(--teal-soft); }
.legend .l-flag::before { content: '\F3CC'; font-family: 'bootstrap-icons'; color: var(--coral); width: auto; height: auto; }

.calc-panel {
  position: fixed; top: 4.2rem; left: 1rem; z-index: 1050; width: min(30rem, calc(100vw - 2rem)); height: min(34rem, calc(100vh - 9rem));
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  display: none; flex-direction: column; overflow: hidden; resize: both;
}
.calc-panel.show { display: flex; }
@media (min-width: 1100px) {
  body.calc-open .tr-body.no-passage .tr-right { max-width: none; padding-left: calc(min(30rem, 40vw) + 2rem); }
}
.calc-panel .bar { display: flex; align-items: center; justify-content: space-between; padding: .45rem .8rem; background: var(--bg-2); cursor: move; font-weight: 700; font-size: .85rem; }
.calc-panel iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.ref-sheet { font-family: var(--ui); }
.ref-sheet .fig { border: 1px solid var(--line); border-radius: .8rem; padding: .8rem; text-align: center; font-size: .88rem; height: 100%; }
.ref-sheet svg { width: 100%; max-height: 90px; stroke: var(--ink); fill: none; stroke-width: 2; }
.ref-sheet svg text { fill: var(--ink); stroke: none; font-size: 13px; font-style: italic; }

.screen-center { position: fixed; inset: 0; display: grid; place-items: center; padding: 1.5rem; overflow-y: auto; }
.break-clock { font-size: clamp(3.5rem, 10vw, 6rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }

@media (max-width: 991.98px) {
  body.test-mode { overflow: auto; }
  .tr { position: static; min-height: 100vh; }
  .tr-top { position: sticky; top: 0; z-index: 10; grid-template-columns: 1fr auto; }
  .tr-title { display: none; }
  .tr-timer { text-align: left; }
  .tr-body { grid-template-columns: 1fr; }
  .tr-left { border-right: 0; border-bottom: 3px solid var(--line); }
  .tr-left, .tr-right { overflow: visible; padding: 1.1rem; }
  .tr-bottom { position: sticky; bottom: 0; grid-template-columns: auto 1fr; }
  .tr-bottom .who { display: none; }
  .tool-btn span { display: none; }
}

/* ==========================================================================
   Reports
   ========================================================================== */
.skill-bar { display: flex; gap: 3px; }
.skill-bar i { flex: 1; height: .55rem; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line); }
.skill-bar i.on { background: var(--coral); border-color: var(--coral); }
.acc-bar { height: .5rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.acc-bar > span { display: block; height: 100%; border-radius: 999px; }
.lvl-strong { background: var(--ok); color: var(--ok); }
.lvl-mid { background: var(--warn); color: var(--warn); }
.lvl-weak { background: var(--bad); color: var(--bad); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; }
.score-big { font-size: clamp(3rem, 9vw, 5rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: .3rem; }
.heatmap i { width: .85rem; height: .85rem; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.heatmap i.l1 { background: rgb(var(--coral-rgb) / .3); }
.heatmap i.l2 { background: rgb(var(--coral-rgb) / .55); }
.heatmap i.l3 { background: rgb(var(--coral-rgb) / .8); }
.heatmap i.l4 { background: var(--coral); }
.chart-box { position: relative; height: 260px; }
.kid-card { border-top: 4px solid var(--c, var(--coral)); }
.rec-item { display: flex; align-items: center; gap: .9rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.rec-item:last-child { border-bottom: 0; }

@media print {
  .sidebar, .topbar, .tabbar, .no-print, .btn { display: none !important; }
  body.has-sidebar .app-main { margin-left: 0; }
  body { background: #fff !important; color: #000 !important; }
  body::before { display: none; }
  .panel, .card { border-color: #ccc !important; break-inside: avoid; background: #fff !important; color: #000 !important; }
  .app-main { padding: 0; }
}

/* Wide College Board tables: scroll inside their column instead of overlapping */
.q-passage, .q-stem, .q-rationale { overflow-x: auto; }
.q-passage, .q-stem, .q-rationale, .q-choice-text { min-width: 0; overflow-wrap: break-word; }
#qPassage, #qQuestion, .tr-left, .tr-right { min-width: 0; }

/* ---------- Light / Dark segmented switch ---------- */
.theme-switch {
  position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; align-items: center;
  padding: 3px; border-radius: .6rem; border: 1px solid var(--line); background: var(--surface-2);
  isolation: isolate; min-width: 11rem;
}
.theme-switch .ts-knob {
  position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: .45rem; background: var(--coral); box-shadow: 0 2px 8px rgb(var(--coral-rgb) / .35);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
[data-bs-theme="dark"] .theme-switch .ts-knob { transform: translateX(100%); }
.theme-switch .ts-opt {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; background: transparent; padding: .42rem .7rem; border-radius: .45rem;
  font-size: .8rem; font-weight: 700; color: var(--ink-soft); transition: color .2s;
}
.theme-switch .ts-opt i { font-size: .9rem; }
.theme-switch .ts-opt:hover { color: var(--ink); }
[data-bs-theme="light"] .theme-switch [data-set-theme="light"],
[data-bs-theme="dark"] .theme-switch [data-set-theme="dark"] { color: #fff; }
.theme-switch.ts-compact { min-width: 0; }
.theme-switch.ts-compact .ts-opt { padding: .38rem .55rem; }
.theme-switch.ts-compact .ts-opt span { display: none; }
/* on the navy sidebar / top bar */
.theme-switch.ts-side { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .1); }
.theme-switch.ts-side .ts-opt { color: #93a3ad; }
.theme-switch.ts-side .ts-opt:hover { color: #fff; }
[data-bs-theme="light"] .theme-switch.ts-side [data-set-theme="light"],
[data-bs-theme="dark"] .theme-switch.ts-side [data-set-theme="dark"] { color: #fff; }

/* ---------- Official paper test questions (PDF crops) ---------- */
.q-crop { background: #fff; border-radius: var(--radius); padding: .9rem; border: 1px solid var(--line); overflow-x: auto; text-align: center; min-height: 6rem; }
.q-crop canvas { max-width: 100%; height: auto; display: inline-block; }
.q-crop-loading { color: #5b6a75; font-size: .9rem; padding: 2rem 0; }
.choice-list.letters-only { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-list.letters-only .choice-row { flex-direction: column; }
.choice-list.letters-only .choice { justify-content: center; padding: .7rem; }
.choice-list.letters-only .q-choice-text { display: none; }
.choice-list.letters-only .eliminate-btn { width: 100%; height: 1.9rem; }
.badge-paper { background: rgb(var(--teal-rgb) / .15); color: var(--teal); border-radius: .35rem; font-weight: 700; }

/* ---------- Personal-use disclaimer ---------- */
.app-footer {
  max-width: 76rem; margin: 3rem auto 0; padding: 1rem 1.2rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .6rem;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .78rem; line-height: 1.5;
}
.app-footer > i { color: var(--coral); }
.app-footer > span { flex: 1 1 18rem; }
.app-footer .btn-link { color: var(--coral); font-size: .78rem; font-weight: 700; text-decoration: none; }
.login-notice { margin-top: 1.2rem; padding: .8rem 1rem; border-radius: .6rem; border: 1px dashed var(--line); color: var(--ink-soft); font-size: .78rem; line-height: 1.5; }
.login-notice i { color: var(--coral); }
.login-notice .btn-link { color: var(--coral); font-size: .78rem; font-weight: 700; text-decoration: none; vertical-align: baseline; }

/* ==========================================================================
   Palette 2: Slate + Electric Blue  (html[data-palette="blue"])
   Default palette (Navy + Coral) needs no attribute.
   ========================================================================== */
html[data-palette="blue"] {
  --coral: #3b82f6;
  --coral-deep: #2563eb;
  --coral-rgb: 59 130 246;
  --teal: #22d3ee;
  --teal-rgb: 34 211 238;
  --ok: #34d399;
  --bad: #f87171;
}
html[data-palette="blue"][data-bs-theme="dark"] {
  --bg: #0f172a;
  --bg-2: #111a2e;
  --surface: #1a2438;
  --surface-2: #222d44;
  --ink: #e8edf5;
  --ink-soft: #94a3b8;
  --line: rgba(148, 163, 184, .14);
  --side-bg: #0b1222;
}
html[data-palette="blue"][data-bs-theme="light"] {
  --bg: #f5f7fb;
  --bg-2: #eaeef6;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --ink: #0f172a;
  --ink-soft: #526077;
  --line: rgba(15, 23, 42, .11);
  --side-bg: #0f172a;
  --coral: #2563eb;
  --coral-deep: #1d4ed8;
  --coral-rgb: 37 99 235;
  --teal: #0891b2;
  --teal-rgb: 8 145 178;
  --ok: #16a34a;
  --bad: #dc2626;
}

/* ---------- Palette selector ---------- */
.palette-switch { display: inline-flex; align-items: center; gap: .35rem; padding: 3px; border-radius: .6rem; border: 1px solid var(--line); background: var(--surface-2); }
.palette-switch button {
  width: 1.7rem; height: 1.7rem; border-radius: .45rem; border: 2px solid transparent; padding: 0; background: transparent;
  display: grid; place-items: center;
}
.palette-switch button span { display: block; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: linear-gradient(135deg, var(--sw-a) 50%, var(--sw-b) 50%); }
.palette-switch button:hover { border-color: var(--line); }
html:not([data-palette="blue"]) .palette-switch [data-set-palette="coral"],
html[data-palette="blue"] .palette-switch [data-set-palette="blue"] { border-color: var(--coral); }
.palette-switch.ts-side { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .1); }
.side-prefs { display: flex; gap: .5rem; align-items: stretch; }
.side-prefs .theme-switch { flex: 1; min-width: 0; }

/* ---------- Top-right toolbar (desktop) + account menu ---------- */
.page-toolbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; justify-content: flex-end;
  max-width: none; margin: -2rem -1rem 1.2rem; padding: .8rem 1.5rem .7rem;
  background: var(--bg);
}
.toolbar-controls { display: flex; align-items: center; gap: .5rem; }
.toolbar-divider { width: 1px; height: 1.6rem; background: var(--line); margin: 0 .2rem; }
.user-chip {
  display: inline-flex; align-items: center; gap: .55rem; padding: .25rem .65rem .25rem .25rem;
  border-radius: .6rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .88rem; line-height: 1;
}
.user-chip:hover { border-color: var(--coral); }
.user-chip .avatar { width: 1.9rem; height: 1.9rem; }
.user-chip-name { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-menu { background: var(--surface); border-color: var(--line); border-radius: .6rem; --bs-dropdown-link-color: var(--ink); --bs-dropdown-link-hover-bg: var(--surface-2); --bs-dropdown-link-hover-color: var(--ink); --bs-dropdown-header-color: var(--ink-soft); }
.topbar .user-chip { padding: .2rem; background: transparent; border-color: rgba(255, 255, 255, .12); }
.topbar .toolbar-controls { gap: .4rem; }
@media (max-width: 991.98px) {
  .page-toolbar { display: none; }
}
@media (max-width: 400px) {
  .topbar .topbar-name { display: none; }
  .topbar { padding: .55rem .7rem; }
}

/* ---------- Skill Analysis ---------- */
.min-w-0 { min-width: 0; }
.mastery { display: inline-block; font-size: .7rem; font-weight: 700; padding: .2em .6em; border-radius: .35rem; white-space: nowrap; }
.m-mastered { background: rgba(63, 191, 143, .16); color: var(--ok); }
.m-proficient { background: rgb(var(--teal-rgb) / .16); color: var(--teal); }
.m-developing { background: rgba(242, 185, 75, .16); color: var(--warn); }
.m-needs { background: rgb(var(--coral-rgb) / .16); color: var(--bad); }
.m-none { background: var(--surface-2); color: var(--ink-soft); }
.mdot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .35rem; padding: 0 !important; }
.mdot.m-mastered { background: var(--ok); } .mdot.m-proficient { background: var(--teal); } .mdot.m-developing { background: var(--warn); } .mdot.m-needs { background: var(--bad); } .mdot.m-none { background: var(--ink-soft); }
.improve-item { display: flex; align-items: flex-start; gap: .9rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.improve-item:last-of-type { border-bottom: 0; }
.improve-item .rank { flex: none; width: 1.9rem; height: 1.9rem; border-radius: .5rem; display: grid; place-items: center; font-weight: 800; background: var(--coral-soft); color: var(--coral); }
.dchip { display: inline-block; font-size: .7rem; font-weight: 700; padding: .15em .5em; border-radius: .35rem; background: var(--surface-2); color: var(--ink-soft); margin-right: .2rem; }
.dchip.lvl-strong { background: rgba(63, 191, 143, .16); color: var(--ok); }
.dchip.lvl-mid { background: rgba(242, 185, 75, .16); color: var(--warn); }
.dchip.lvl-weak { background: rgb(var(--coral-rgb) / .14); color: var(--bad); }
.trend { font-weight: 700; font-size: .8rem; white-space: nowrap; }
.trend.up { color: var(--ok); } .trend.down { color: var(--bad); } .trend.flat { color: var(--ink-soft); }
.txt-strong { color: var(--ok); } .txt-mid { color: var(--warn); } .txt-weak { color: var(--bad); }
.ring { --p: 0; flex: none; width: 3.6rem; height: 3.6rem; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--coral) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring span { width: 2.8rem; height: 2.8rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: .78rem; font-weight: 800; }
.chapter-kpis { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.chapter-kpis .k { font-size: .7rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.chapter-kpis .v { font-size: 1.15rem; font-weight: 800; }
.skill-table .insight { font-size: .74rem; max-width: 26rem; }
.quad-legend { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .8rem; }
@media (max-width: 575.98px) { .chapter-kpis { gap: .9rem; width: 100%; justify-content: space-between; } .quad-legend { grid-template-columns: 1fr; } }

/* ---------- Study plan ---------- */
.phase-track { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.phase { padding: .8rem .9rem; border-radius: .6rem; background: var(--surface-2); border: 1px solid var(--line); }
.phase.on { border-color: var(--coral); background: var(--coral-soft); }
.plan-days { display: grid; gap: .5rem; }
.plan-day { display: grid; grid-template-columns: 6rem 1fr; gap: .9rem; padding: .75rem .9rem; border-radius: .6rem; border: 1px solid var(--line); background: var(--surface-2); }
.plan-day.today { border-color: var(--coral); }
.plan-day.rest { opacity: .65; }
.pd-date span { display: block; font-size: .72rem; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pd-tasks { display: grid; gap: .5rem; }
.pd-task { display: flex; gap: .6rem; align-items: flex-start; }
.pd-task > i { color: var(--coral); margin-top: .1rem; }
.pd-task.k-test > i { color: var(--teal); }
.today-task { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.today-task:last-child { border-bottom: 0; }
.today-task:hover { color: var(--ink); }
.today-task .tick { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; }
.today-task.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.today-task.done .tt-title { text-decoration: line-through; color: var(--ink-soft); }
@media (max-width: 575.98px) {
  .phase-track { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-day { grid-template-columns: 1fr; gap: .4rem; }
}

/* ---------- Vocabulary ---------- */
.vcard-wrap { max-width: 40rem; margin: 0 auto; }
.vcard { padding: 1.6rem; min-height: 18rem; }
.v-word { font-family: var(--read); font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 600; text-align: center; margin: 1rem 0 1.2rem; }
.v-meaning { text-align: center; font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.v-example { font-family: var(--read); font-size: 1rem; line-height: 1.6; color: var(--ink-soft); padding: .9rem 1rem; border-left: 3px solid var(--coral); background: var(--surface-2); border-radius: 0; }
.v-example b { color: var(--ink); }
.v-actions { margin-top: 1.4rem; }

/* ---------- Study guides ---------- */
.guide-acc { --bs-accordion-bg: var(--surface); --bs-accordion-border-color: var(--line); --bs-accordion-color: var(--ink);
  --bs-accordion-btn-color: var(--ink); --bs-accordion-active-bg: var(--surface-2); --bs-accordion-active-color: var(--ink);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 .2rem var(--coral-soft); --bs-accordion-border-radius: var(--radius); --bs-accordion-inner-border-radius: var(--radius); }
.guide-acc .accordion-button { font-weight: 700; }
[data-bs-theme="dark"] .guide-acc .accordion-button::after { filter: invert(1) grayscale(1) brightness(1.6); }
.guide-body { font-size: .95rem; line-height: 1.7; }
.guide-body table { --bs-table-bg: transparent; color: var(--ink); }
.guide-body li { margin-bottom: .3rem; }

/* ---------- Badges ---------- */
.badge-card { display: flex; gap: .7rem; align-items: center; padding: .8rem; border-radius: .6rem; border: 1px dashed var(--line); background: var(--surface); height: 100%; opacity: .6; }
.badge-card.earned { border-style: solid; border-color: rgb(var(--coral-rgb) / .5); opacity: 1; }
.bc-ic { flex: none; width: 2.5rem; height: 2.5rem; border-radius: .6rem; display: grid; place-items: center; font-size: 1.2rem; background: var(--surface-2); color: var(--ink-soft); }
.badge-card.earned .bc-ic { background: var(--coral); color: #fff; }

/* ---------- Grouped sidebar + "More" menu ---------- */
.side-scroll { flex: 1; overflow-y: auto; margin: 0 -.4rem; padding: 0 .4rem; scrollbar-width: thin; }
.sidebar .side-label { margin: 1.3rem .6rem .4rem; }
.more-menu { height: auto !important; max-height: 80vh; background: var(--surface); color: var(--ink); border-radius: 1rem 1rem 0 0; }
.more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.more-grid a { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .8rem .3rem; border-radius: .7rem; background: var(--surface-2); color: var(--ink); text-decoration: none; font-size: .78rem; font-weight: 600; text-align: center; }
.more-grid a i { font-size: 1.3rem; color: var(--coral); }
.more-grid a.active { outline: 2px solid var(--coral); }
[data-bs-theme="dark"] .more-menu .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* ---------- Sign-in page tabs (Student / Parent / Admin) ---------- */
/* Segmented tabs (Accounts) */
.seg-tabs { display: inline-flex; flex-wrap: wrap; gap: .3rem; padding: 3px; border-radius: .6rem; border: 1px solid var(--line); background: var(--surface-2); }
.seg-tabs button { border: 0; background: transparent; padding: .45rem .9rem; border-radius: .45rem; font-weight: 700; font-size: .86rem; color: var(--ink-soft); display: inline-flex; align-items: center; gap: .4rem; }
.seg-tabs button:hover { color: var(--ink); }
.seg-tabs button.active { background: var(--coral); color: #fff; }
.seg-count { font-size: .72rem; min-width: 1.35rem; padding: .05rem .4rem; border-radius: 999px; background: rgb(var(--coral-rgb) / .14); color: var(--coral); text-align: center; }
.seg-tabs button.active .seg-count { background: rgba(255, 255, 255, .22); color: #fff; }
.search-box { position: relative; min-width: 16rem; }
.search-box i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--ink-soft); font-size: .85rem; pointer-events: none; }
.search-box input { padding-left: 2rem; }
@media (max-width: 575.98px) {
  .search-box { min-width: 0; width: 100%; }
  .seg-tabs { width: 100%; flex-wrap: nowrap; }
  .seg-tabs button { flex: 1; justify-content: center; padding: .45rem .3rem; font-size: .8rem; gap: .3rem; }
  .seg-tabs button > .bi { display: none; }
}
.accounts-table > thead > tr > th { font-weight: 600; padding: .75rem 1rem; white-space: nowrap; }
.accounts-table > tbody > tr > td { padding: .65rem 1rem; }
.accounts-table > tbody > tr:last-child > td { border-bottom: 0; }
.accounts-table > tbody > tr[data-search]:hover > td { background: var(--surface-2); }
/* Icon-only buttons */
.btn-icon { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .5rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .95rem; vertical-align: middle; }
.btn-icon:hover, .btn-icon:focus-visible { border-color: var(--coral); color: var(--coral); }
.btn-icon.danger { color: var(--bad); }
.btn-icon.danger:hover, .btn-icon.danger:focus-visible { border-color: var(--bad); background: rgb(229 72 77 / .08); color: var(--bad); }
.btn-icon + form, form + .btn-icon { margin-left: .3rem; }
.login-tabs { display: flex; gap: .35rem; padding: 3px; border-radius: .6rem; border: 1px solid var(--line); background: var(--surface-2); }
.login-tabs a { flex: 1; text-align: center; padding: .5rem .6rem; border-radius: .45rem; font-weight: 700; font-size: .86rem; color: var(--ink-soft); text-decoration: none; }
.login-tabs a:hover { color: var(--ink); }
.login-tabs a.active { background: var(--coral); color: #fff; }
