:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #6b7785;
  --line: #e3e8ef;
  --brand: #1f6feb;
  --brand-dark: #1659c4;
  --good: #1a8f4c;
  --good-bg: #e7f6ec;
  --bad: #d23c3c;
  --bad-bg: #fbeaea;
  --warn: #b8860b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,30,45,.08), 0 6px 24px rgba(20,30,45,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: #0f1b2d; color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.brand { font-weight: 700; font-size: 18px; cursor: pointer; letter-spacing: .2px; }
.nav { display: flex; gap: 6px; }
.navbtn {
  background: transparent; color: #cdd6e3; border: 0; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.navbtn:hover { background: rgba(255,255,255,.1); color: #fff; }

.app { max-width: 940px; margin: 0 auto; padding: 32px 20px 96px; }

/* paused-session banner (issue 27) — lives OUTSIDE #app so view renders never destroy it */
.suspended-banner {
  max-width: 940px; margin: 16px auto -16px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 14px;
}
.suspended-banner .sdetail { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* vertical rhythm — space the top-level blocks apart so nothing reads as cramped */
.app > .card, .app > .statrow { margin-bottom: 24px; }
.app > .card:last-child, .app > .statrow:last-child { margin-bottom: 0; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 16px; }

/* home */
.hero { padding: 30px 28px; }
.hero h1 { margin: 0 0 6px; font-size: 22px; }
.hero p { margin: 0; color: var(--muted); }

.statrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 22px 16px; text-align: center; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

.builder { padding: 28px; }
.builder .row { display: flex; flex-wrap: wrap; gap: 22px; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
select, input[type=number] {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: #fff; min-width: 150px;
}
/* hide the ugly native number-stepper — the field stays a clean box (type or arrow-key to change) */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 9px 16px; cursor: pointer; font-size: 14px; }
.seg button.active { background: var(--brand); color: #fff; }

.btn {
  border: 0; border-radius: 9px; padding: 11px 20px; font-size: 15px; font-weight: 600;
  cursor: pointer; background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #eef2f7; color: var(--ink); }
.btn.ghost:hover { background: #e2e8f1; }
.btn.small { padding: 7px 13px; font-size: 13px; }

.quick { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* question screen */
.qhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; margin-bottom: 14px; font-size: 14px; color: var(--muted);
}
.qhead .left { display: flex; gap: 16px; align-items: center; }
.qhead .right { display: flex; gap: 12px; align-items: center; }
.qhead .timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.langbtn { background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.5; }
.langbtn:hover { border-color: var(--brand); color: var(--brand); }
.progressbar { height: 4px; background: #e7ecf3; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.progressbar > i { display: block; height: 100%; background: var(--brand); }

.qcard { padding: 28px; }
.stem { font-size: 16.5px; line-height: 1.65; white-space: pre-wrap; margin-bottom: 22px; }

.options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff;
  transition: border-color .12s, background .12s;
}
.opt:hover { border-color: #c4d2e6; }
.opt.selected { border-color: var(--brand); background: #f3f8ff; }
.opt .key { font-weight: 700; width: 22px; flex: none; color: var(--muted); }
.opt .txt { flex: 1; }
.opt.correct { border-color: var(--good); background: var(--good-bg); }
.opt.incorrect { border-color: var(--bad); background: var(--bad-bg); }
.opt .mark { font-weight: 700; }
.opt.correct .mark { color: var(--good); }
.opt.incorrect .mark { color: var(--bad); }
.opt .pct { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
.opt .pctbar { position: relative; }
.opt.disabled { cursor: default; }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.spacer { flex: 1; }
.flagbtn { background: #fff; border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 14px; cursor: pointer; font-size: 14px; }
.flagbtn.on { border-color: var(--warn); color: var(--warn); background: #fff8e8; }

/* problem-report panel (shared markup; platform views restyle it) */
.reportpanel { margin-top: 12px; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; display: grid; gap: 8px; }
.reportpanel[hidden] { display: none; }   /* the author display beats the UA [hidden] rule */
.reportpanel textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 72px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 9px; font: inherit; }
:root[data-theme="dark"] .reportpanel textarea { background: #1b2431; color: var(--ink); border-color: var(--line); }

/* result + explanation */
.resultbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: 10px; margin: 18px 0;
  border-left: 5px solid var(--line);
}
.resultbar.correct { background: var(--good-bg); border-left-color: var(--good); }
.resultbar.incorrect { background: var(--bad-bg); border-left-color: var(--bad); }
.resultbar .verdict { font-weight: 700; font-size: 16px; }
.resultbar.correct .verdict { color: var(--good); }
.resultbar.incorrect .verdict { color: var(--bad); }
.resultbar .meta { color: var(--muted); font-size: 13px; }

.explanation { margin-top: 8px; }
.explanation h3 { font-size: 15px; margin: 18px 0 8px; }
.explanation p { white-space: pre-wrap; margin: 0 0 12px; line-height: 1.65; }
.explanation ul, .explanation ol { margin: 0 0 12px; padding-left: 24px; line-height: 1.65; }
.explanation li + li { margin-top: 6px; }
.explanation code { padding: 1px 5px; border-radius: 5px; background: #eef1f5; font: .92em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.eduobj { background: #f3f7fd; border: 1px solid #dbe7f7; border-radius: 10px; padding: 14px 16px; margin-top: 8px; }
.eduobj .t { font-weight: 700; margin-bottom: 6px; }

/* per-question tag chips (shown after answering) */
.qtags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.qtags-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.qtag { font-size: 13px; border-radius: 999px; padding: 3px 11px; border: 1px solid var(--line); line-height: 1.6; }
.qtag.topic { background: #e6effd; color: var(--brand); border-color: #cfe0fb; cursor: pointer; font-weight: 600; }
.qtag.topic:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.qtag.kw { background: #f4f6f9; color: var(--muted); }

.media { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.media figure { margin: 0; min-width: 0; max-width: 100%; }
/* show exhibits at (up to) their native size so text figures are readable; click to zoom further */
.media img, .media video { max-width: 100%; max-height: 72vh; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.media figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }

.tag { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #eef2f7; color: var(--muted); margin-right: 6px; }
.tag.warn { background: #fff8e8; color: var(--warn); }
.reviewnote { background: #fff8e8; border: 1px solid #f0e0b0; color: #8a6d1b; border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; font-size: 14px; }

/* summary */
.grid-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; margin-top: 14px; }
.gi { aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; border: 1.5px solid var(--line); }
.gi.correct { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.gi.incorrect { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.gi.skipped { background: #f0f0f0; color: var(--muted); }

/* stats */
.barlist { display: flex; flex-direction: column; gap: 12px; }
.barrow { display: grid; grid-template-columns: 180px 1fr 70px; align-items: center; gap: 12px; }
.barrow .name { font-size: 14px; }
.track { background: #eef2f7; height: 16px; border-radius: 8px; overflow: hidden; }
.track > i { display: block; height: 100%; background: linear-gradient(90deg, var(--bad), var(--warn) 55%, var(--good)); }
.barrow .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }

/* per-subject progress table */
.subjtable td { vertical-align: middle; }
.subjtable th:nth-child(2), .subjtable td:nth-child(2),
.subjtable th:nth-child(4), .subjtable td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; width: 70px; }
.covcell { display: flex; align-items: center; gap: 10px; }
.covcell .track { flex: 1; height: 10px; }
.covcell .track.cov > i { background: var(--brand); }
.covcell span { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); width: 38px; text-align: right; }

/* browse */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.pill.correct { background: var(--good-bg); color: var(--good); }
.pill.incorrect { background: var(--bad-bg); color: var(--bad); }
.pill.unused { background: #eef2f7; color: var(--muted); }

.browsebar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.browsebar select, .browsebar input { min-width: 0; }
.browsebar #bsearch { flex: 1; min-width: 120px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(8,12,20,.88); overflow: auto; z-index: 50; }
.lightbox.hidden { display: none; }
.lbwrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; box-sizing: border-box; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; cursor: zoom-in; }
.lightbox img.zoomed { max-width: none; max-height: none; width: 175vw; height: auto; border-radius: 0; cursor: zoom-out; }
.lightbox-close { position: fixed; top: 16px; right: 18px; background: rgba(255,255,255,.15); color: #fff; border: 0; font-size: 20px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; z-index: 51; }

@media (max-width: 640px) {
  .statrow { grid-template-columns: repeat(2, 1fr); }
  .barrow { grid-template-columns: 96px 1fr 52px; }
  .media img, .media video { max-width: 100%; }
  .app { padding: 16px 12px 80px; }
  .builder { padding: 16px; }
  .builder .row { gap: 12px; }
  .builder .field { width: 100%; }
  .builder select, .builder input[type=number] { width: 100%; }
  .builder .seg { width: 100%; }
  .builder .seg button { flex: 1; }
  .browsebar { flex-direction: column; }
  .browsebar select, .browsebar #bsearch { width: 100%; }
  .qcard { padding: 16px; }
  .qhead { flex-wrap: wrap; gap: 6px 12px; }
  .qhead .left { flex-wrap: wrap; gap: 6px 12px; }
  .opt { padding: 12px 13px; }
}

/* ---- utilities ---- */
[hidden] { display: none !important; } /* beat explicit display:flex on .nav/.userarea */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.btn.small.danger, .btn.ghost.danger { color: var(--bad); }
.btn.ghost.danger:hover { background: var(--bad-bg); }

/* ---- topbar user area ---- */
.userarea { display: flex; align-items: center; gap: 10px; }
.uname { color: #cdd6e3; font-size: 14px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- auth (login / signup) ---- */
.card.auth { max-width: 400px; margin: 7vh auto 0; padding: 34px 32px 30px; }
.authhead { text-align: center; }
.authlogo {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  background: linear-gradient(135deg, #e9f1ff, #d5e4ff);
  box-shadow: 0 6px 18px rgba(31,111,235,.20);
}
.card.auth h1 { margin: 0; font-size: 25px; letter-spacing: -.3px; }
.authsub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.authform { display: flex; flex-direction: column; gap: 14px; margin: 20px 0 0; }
.authform label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.authform input { padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; transition: border-color .12s, box-shadow .12s; }
.authform input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.15); }
.authform .btn { margin-top: 6px; }
.btn.block { width: 100%; text-align: center; }
.autherr { color: var(--bad); font-size: 14px; min-height: 18px; }
.auth-secret { position: relative; display: block; }
.auth-secret input { width: 100%; padding-right: 86px; box-sizing: border-box; }
.auth-reveal {
  position: absolute; top: 50%; right: 5px; min-height: 34px; padding: 4px 8px;
  transform: translateY(-50%); border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
}
.auth-reveal:hover, .auth-reveal:focus-visible { color: var(--ink); background: var(--bg); }
.auth-link { align-self: center; padding: 7px 4px; border: 0; background: transparent; color: var(--brand); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.authhint { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.authstatus { color: var(--good); font-size: 14px; line-height: 1.5; }
.authstatus:empty { display: none; }
.authactions { display: grid; gap: 8px; }

/* ---- admin (members) ---- */
.adminrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.adminInput { flex: 1; min-width: 200px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.adminlist { margin-top: 8px; }
.adminlist table { margin-top: 6px; }
.invitebox { margin: 14px 0 4px; padding: 12px 14px; background: var(--good-bg); border-radius: 10px; }
.invitelink { display: flex; gap: 8px; margin-top: 6px; }
.invitelink input { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.pill.pending { background: #fff4d6; color: var(--warn); }
.pill.used { background: #eef2f7; color: var(--muted); }
.pill.expired { background: var(--bad-bg); color: var(--bad); }
.pill.admin { background: #e6effd; color: var(--brand); }

/* ---- study a topic ---- */
.theme-builder { border-top: 3px solid var(--brand); }
/* live autocomplete dropdown under the topic field */
.ac-wrap { position: relative; flex: 1; min-width: 200px; }
.ac-wrap .adminInput { width: 100%; }
.ac-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; padding: 4px;
}
.ac-list[hidden] { display: none; }
.ac-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 7px; cursor: pointer; font-size: 14px;
}
.ac-item:hover, .ac-item.active { background: rgba(31,111,235,.10); }
.ac-item .cn { color: var(--muted); font-size: 11px; background: #eef2f7; padding: 0 7px; border-radius: 999px; flex: none; }
:root[data-theme="dark"] .ac-item:hover, :root[data-theme="dark"] .ac-item.active { background: rgba(76,141,255,.14); }
:root[data-theme="dark"] .ac-item .cn { background: #222c3a; }
.topicchips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.themeblock + .themeblock { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.qtag.topic .muted { margin-left: 4px; font-weight: 400; }
.qtag.topic:hover .muted { color: rgba(255,255,255,.8); }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--brand); background: #f5f9ff; }
.chip .cn { color: var(--muted); font-size: 11px; background: #eef2f7; padding: 0 6px; border-radius: 999px; }

/* themed-session study-plan overview (per-aspect question counts + steppers) */
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.plan-actions { display: flex; gap: 8px; }
.plan { display: flex; flex-direction: column; gap: 14px; }
.planrow { display: grid; grid-template-columns: 190px 1fr auto; align-items: center; gap: 16px; }
.planaspect { font-weight: 600; font-size: 14px; }
.planbar { background: #eef2f7; height: 12px; border-radius: 7px; overflow: hidden; }
.planbar > i { display: block; height: 100%; background: var(--brand); border-radius: 7px; transition: width .12s; }
:root[data-theme="dark"] .planbar { background: #222c3a; }
/* interactive slider (replaces the decorative planbar in the block builders) */
.planslider { width: 100%; min-width: 0; margin: 0; accent-color: var(--brand); cursor: pointer; }
/* editable count (overrides the global 150px-wide number input) */
input[type=number].stepnum {
  min-width: 0; width: 58px; padding: 5px 6px; text-align: center;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink);
}
input[type=number].stepnum:focus { border-color: var(--brand); outline: none; }
/* per-type stepper */
.stepper { display: inline-flex; align-items: center; gap: 7px; }
.stepbtn {
  width: 28px; height: 28px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 7px; cursor: pointer; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.stepbtn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.stepbtn:disabled { opacity: .35; cursor: not-allowed; }
.stepval { min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.stepmax { color: var(--muted); font-size: 12px; margin-left: -3px; }
:root[data-theme="dark"] .stepbtn { background: #1b2431; }
@media (max-width: 640px) {
  .planrow { grid-template-columns: 108px 1fr auto; gap: 10px; }
  .planaspect { font-size: 12.5px; }
  .stepper { gap: 5px; }
  .stepbtn { width: 26px; height: 26px; }
}

/* study-cycle breadcrumb on the question view */
.cyclebar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 2px 2px 14px; font-size: 13px;
}
.cyclebar .ctopic { font-weight: 600; color: var(--brand); }
.cyclebar .csep { color: var(--muted); }
.cyclebar .caspect { font-weight: 600; }
.cyclebar .cpos { color: var(--muted); font-size: 12px; }
.tag.theme { background: #e6effd; color: var(--brand); }

/* ---- topbar controls (theme + language) ---- */
.topctl { display: flex; gap: 6px; align-items: center; margin-left: 8px; }
.ctlbtn {
  background: rgba(255,255,255,.08); color: #cdd6e3; border: 0; width: 34px; height: 34px;
  border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
}
.ctlbtn:hover { background: rgba(255,255,255,.18); color: #fff; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 4px 8px; }
}

/* ---- SRS next-review chip (shown in the resultbar after answering) ---- */
.srsnext { font-size: 13px; color: var(--muted); background: rgba(31,111,235,.08); border-radius: 999px; padding: 3px 11px; }

/* ---- Mastery (Operação Mnemosyne) — subject dashboard panel + Progresso tab ---- */
.subjrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line); }
.subjrow:last-child { border-bottom: 0; }
.subjrow .name { font-weight: 600; }
.subjrow .meta { font-size: 12px; color: var(--muted); grid-column: 1; }
.subjrow .act { grid-row: 1 / span 2; grid-column: 2; }
.mbar { position: relative; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; grid-column: 1; margin: 2px 0; }
.mbar > span { position: relative; z-index: 1; display: block; height: 100%; border-radius: 999px; }
/* layered meter: cov = coverage (explicit tint/shade of the status hue — no alpha, stays clean on any surface);
   solid span = mastery. retention = how much of the cov segment is filled solid. */
.mbar > i.cov { position: absolute; top: 0; left: 0; height: 100%; border-radius: 999px; background: #c8d2e0; }
.st-review .mbar > i.cov { background: #e28585; }
.st-advance .mbar > i.cov { background: #7fabf0; }
.st-strong .mbar > i.cov { background: #72c496; }
.st-review .mbar > span { background: var(--bad); }
.st-advance .mbar > span { background: var(--brand); }
.st-strong .mbar > span { background: var(--good); }
.st-new .mbar > span { background: var(--muted); opacity: .5; }
:root[data-theme="dark"] .st-review .mbar > i.cov { background: #7a3b42; }
:root[data-theme="dark"] .st-advance .mbar > i.cov { background: #3a5a8f; }
:root[data-theme="dark"] .st-strong .mbar > i.cov { background: #2f6b48; }
.pill.review { background: var(--bad-bg); color: var(--bad); }
.pill.advance { background: rgba(31,111,235,.12); color: var(--brand); }
.pill.strong { background: var(--good-bg); color: var(--good); }
.pill.new { background: var(--line); color: var(--muted); }
.mastery-empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
/* topic drill-down under a subject row (Progresso) */
.subjwrap { border-bottom: 1px solid var(--line); }
.subjwrap:last-child { border-bottom: 0; }
.subjwrap .subjrow { border-bottom: 0; }
.topictoggle-row { margin: -4px 0 6px; }
.topictoggle { font-size: 12px; }
.topiclist { padding: 4px 0 10px 14px; border-left: 2px solid var(--line); margin: 0 0 8px 2px; }
.topicrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.topicrow:last-child { border-bottom: 0; }
.topicrow .tname { font-weight: 500; font-size: 14px; }
.topicrow .tmeta { font-size: 12px; color: var(--muted); grid-column: 1; }
.topicrow .mbar { grid-column: 1; height: 8px; margin: 1px 0; }
.topicrow .tacts { grid-row: 1 / span 3; grid-column: 2; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.topicrow .tacts .btn { width: 100%; }
.topicrow.st-review .tname { color: var(--bad); }
/* new-question slider revealed when review pool is chosen */
.newratio { margin: 12px 0 0; }
.newratio label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 6px; }
/* multi-subject block builder: repeatable subject + count rows */
.subjpick { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.subjpick .subjSel { flex: 1 1 auto; min-width: 0; }
.subjpick .subjCount { width: 90px; flex: 0 0 auto; }
.subjpick .rmSubj { flex: 0 0 auto; }
.subjpick .rmSubj:disabled { opacity: .35; cursor: default; }

/* ================= DARK THEME =================
   data-theme is set on <html> before first paint (index.html boot script).
   Tokens first, then overrides for every hardcoded light color. */
:root[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #161d27;
  --ink: #e6edf3;
  --muted: #93a1b3;
  --line: #2b3543;
  --brand: #4c8dff;
  --brand-dark: #6ba1ff;
  --good: #43c078;
  --good-bg: #12281b;
  --bad: #ef6a6a;
  --bad-bg: #2c1717;
  --warn: #d9a520;
  --shadow: 0 1px 3px rgba(0,0,0,.5), 0 6px 24px rgba(0,0,0,.35);
}
:root[data-theme="dark"] .topbar { background: #060b13; }
:root[data-theme="dark"] select,
:root[data-theme="dark"] input[type=number],
:root[data-theme="dark"] .seg button,
:root[data-theme="dark"] .opt,
:root[data-theme="dark"] .langbtn,
:root[data-theme="dark"] .flagbtn,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .adminInput,
:root[data-theme="dark"] .invitelink input,
:root[data-theme="dark"] .authform input,
:root[data-theme="dark"] .browsebar #bsearch { background: #1b2431; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .seg button.active { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .opt:hover { border-color: #3d5170; }
:root[data-theme="dark"] .opt.selected { border-color: var(--brand); background: #17233a; }
:root[data-theme="dark"] .opt.correct { background: var(--good-bg); }
:root[data-theme="dark"] .opt.incorrect { background: var(--bad-bg); }
:root[data-theme="dark"] .btn.ghost { background: #222c3a; color: var(--ink); }
:root[data-theme="dark"] .btn.ghost:hover { background: #2b3749; }
:root[data-theme="dark"] .progressbar { background: #222c3a; }
:root[data-theme="dark"] .track { background: #222c3a; }
:root[data-theme="dark"] .flagbtn.on { background: #2b2410; }
:root[data-theme="dark"] .eduobj { background: #14202f; border-color: #24344a; }
:root[data-theme="dark"] .qtag.topic { background: #16233a; border-color: #2a3d5c; }
:root[data-theme="dark"] .qtag.kw { background: #1b2431; color: var(--muted); }
:root[data-theme="dark"] .tag { background: #222c3a; color: var(--muted); }
:root[data-theme="dark"] .tag.warn { background: #2b2410; }
:root[data-theme="dark"] .tag.theme { background: #16233a; }
:root[data-theme="dark"] .reviewnote { background: #2b2410; border-color: #4a3d14; color: #d9b95c; }
:root[data-theme="dark"] .gi.skipped { background: #222c3a; color: var(--muted); }
:root[data-theme="dark"] .pill.unused, :root[data-theme="dark"] .pill.used { background: #222c3a; color: var(--muted); }
:root[data-theme="dark"] .pill.pending { background: #2b2410; color: var(--warn); }
:root[data-theme="dark"] .pill.admin { background: #16233a; color: var(--brand); }
:root[data-theme="dark"] .chip:hover { border-color: var(--brand); background: #17233a; }
:root[data-theme="dark"] .chip .cn { background: #222c3a; color: var(--muted); }
:root[data-theme="dark"] .authlogo { background: linear-gradient(135deg, #17233a, #101a2b); box-shadow: 0 6px 18px rgba(0,0,0,.5); }
:root[data-theme="dark"] .invitebox { background: var(--good-bg); }
:root[data-theme="dark"] .srsnext { background: rgba(76,141,255,.14); }

/* SRS agenda — reviews page (forecast + scheduled-question details). Token-driven: dark mode inherits via var(). */
.stat.statlink { cursor: pointer; transition: border-color .15s; }
.stat.statlink:hover { border-color: var(--brand); }

.forecast-nums { display: flex; flex-wrap: wrap; gap: 16px; font-size: 15px; margin-top: 2px; }
.forecast-nums .fnum { font-weight: 600; }
.forecast-nums .fnum.overdue { color: var(--bad); }
.forecast-nums .fnum.muted { color: var(--muted); font-weight: 400; }

.forecast-bars { display: flex; gap: 10px; margin-top: 16px; }
.forecast-bars .fb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.forecast-bars .fb .col { position: relative; width: 100%; max-width: 52px; height: 110px; display: flex; flex-direction: column; justify-content: flex-end; background: rgba(127,140,160,.12); border-radius: 8px; overflow: hidden; }
.forecast-bars .fb .bar { width: 100%; background: var(--brand); border-radius: 8px 8px 0 0; transition: height .2s; }
.forecast-bars .fb .col.overdue .bar { background: var(--bad); }
.forecast-bars .fb .cnt { position: absolute; top: 6px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; z-index: 1; }
.forecast-bars .fb .lbl { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* 30-day load projection: 31 slim columns, weekly labels only */
.forecast-bars.dense { gap: 2px; }
.forecast-bars.dense .fb { gap: 4px; }
.forecast-bars.dense .fb .col { max-width: none; height: 90px; border-radius: 3px; }
.forecast-bars.dense .fb .bar { border-radius: 3px 3px 0 0; }
.forecast-bars.dense .fb .cnt { font-size: 9px; top: 3px; }
.forecast-bars.dense .fb .lbl { font-size: 9px; }

.reviews-table .review-row.overdue .days { color: var(--bad); font-weight: 700; }
.reviews-table .review-row.today .days { color: var(--warn); font-weight: 600; }

/* SRS scope toggle + exclusion (reviews page) */
.scoperow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.srs-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.srs-seg .segbtn { border: none; background: transparent; color: var(--muted); padding: 6px 14px; font-size: 13px; cursor: pointer; }
.srs-seg .segbtn.on { background: var(--brand); color: #fff; font-weight: 600; }
.reviews-table .excl { padding: 2px 8px; }
.reviews-table.excluded .excludedrow td { color: var(--muted); }

/* ---- Flashcards (Operação Amadeus) ---- */
.cardface { text-align: center; padding: 34px 22px; font-size: 19px; line-height: 1.55; }
.clozegap { color: var(--brand); font-weight: 700; }
.clozeans { color: var(--good); }
.cardsep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.cardextra { margin-top: 12px; font-size: 15px; color: var(--muted); }
.gradebtns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gradebtn { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  padding: 12px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.gradebtn b { font-size: 15px; }
.gradebtn span { font-size: 12px; color: var(--muted); }
.gradebtn i { font-style: normal; font-size: 10px; color: var(--muted); opacity: .6; }
.gradebtn:hover { border-color: var(--brand); }
.g-again b { color: var(--bad); } .g-hard b { color: var(--warn); } .g-good b { color: var(--brand); } .g-easy b { color: var(--good); }
.actions.center { text-align: center; }
.kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.cardlist { margin: 0 0 10px 14px; }
.deckrow { align-items: center; }
@media (max-width: 640px) { .gradebtns { gap: 8px; } .cardface { font-size: 17px; padding: 24px 14px; } }

/* ---- macro-review offer card: quiet and dismissable. The left accent is the whole signal;
   no modal, no pulse. Wrap actions so the three buttons fit on phones. ---- */
.macro-review-alert { border-left: 4px solid var(--warn); padding: 16px 18px; }
.macro-review-alert .section-title { color: var(--warn); }
.macro-review-alert .actions { flex-wrap: wrap; margin-top: 10px; gap: 8px; }
:root[data-theme="dark"] .macro-review-alert { border-left-color: var(--warn); background: #1c2027; }
.macro-assessments { flex-wrap: wrap; gap: 10px; }
.macro-resources { display: grid; gap: 12px; }
.macro-resource { display: grid; gap: 3px; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 10px; color: inherit; text-decoration: none; }
.macro-resource:hover { border-color: var(--accent); }
.macro-resource span, .macro-resource small { color: var(--muted); font-size: .82rem; }
.macro-resource.is-unavailable { opacity: .62; }

/* ---- engine rebuild (2c): unified sessions, browse tree, contextual correction ---- */
.reviewadjustment { display: flex; align-items: center; margin: 10px 0 0; }
.adjustmentbtn { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.treetoggle { background: none; border: none; cursor: pointer; color: inherit; font-size: 12px; padding: 0 6px 0 0; }
.treespacer { display: inline-block; width: 18px; }
.browse-node .tname { display: flex; align-items: center; gap: 2px; }
