* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; font-family: "Segoe UI", -apple-system, Helvetica, Arial, sans-serif; font-size: 15px; }
body { display: flex; flex-direction: column; background: #e8eaed; }

/* ── Top bar (Pearson VUE dark blue) ── */
#topbar {
  background: #1a3a5c; color: #fff; height: 46px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px;
}
.tb-left { font-weight: 600; }
.tb-center { font-size: 14px; }
.tb-right { display: flex; align-items: center; gap: 8px; }
#timer { font-variant-numeric: tabular-nums; font-weight: 600; background: #0e2440; padding: 2px 8px; border-radius: 3px; }
#timer.low { color: #ffb3b3; }
.tb-btn {
  background: #2e598c; color: #fff; border: 1px solid #4a76a8;
  padding: 5px 10px; cursor: pointer; font-size: 13px; border-radius: 3px;
}
.tb-btn:hover { background: #3a6ba3; }
.tb-danger { background: #8c2e2e; border-color: #a84a4a; }
.tb-danger:hover { background: #a33a3a; }

/* ── Split panes ── */
#main { flex: 1; display: flex; min-height: 0; }
.pane { min-width: 220px; display: flex; flex-direction: column; min-height: 0; background: #fff; }
#pane-ref { flex: 0 0 50%; border-right: none; position: relative; }
#resource-overlay {
  position: absolute; inset: 0; z-index: 20; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(226, 232, 238, .75); overflow-y: auto;
}
#resource-overlay[hidden] { display: none; }
#resource-overlay #resource-manager { width: min(560px, 100%); margin: auto; box-shadow: 0 8px 30px rgba(26, 58, 92, .18); }
body.refs-locked #ref-toolbar, body.refs-locked #ref-body { filter: grayscale(1); opacity: .45; pointer-events: none; }
#pane-q { flex: 1; }
#divider { flex: 0 0 6px; background: #b0b8c0; cursor: col-resize; }
#divider:hover { background: #8a94a0; }
body.swapped #main { flex-direction: row-reverse; }

/* ── Reference pane ── */
#ref-toolbar {
  flex: 0 0 40px; display: flex; align-items: center; gap: 8px;
  background: #d5dbe1; padding: 0 8px; border-bottom: 1px solid #b0b8c0;
}
#ref-current {
  flex: 1; font-size: 13.5px; font-weight: 600; color: #333;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ref-zoom {
  display: inline-flex; align-items: stretch; flex: 0 0 auto; height: 29px;
  border: 1px solid #8795a3; border-radius: 4px; overflow: hidden; background: #fff;
}
#ref-zoom button, #ref-zoom select {
  border: 0; border-right: 1px solid #c3cbd2; background: #fff; color: #25384a;
  font: inherit; font-size: 13px; cursor: pointer;
}
#ref-zoom button { width: 31px; font-size: 19px; line-height: 1; }
#ref-zoom select { width: 88px; padding: 0 5px; outline: none; }
#ref-zoom button:last-child { border-right: 0; }
#ref-zoom button:hover:not(:disabled), #ref-zoom select:hover:not(:disabled) { background: #eaf1f8; }
#ref-zoom button:focus-visible, #ref-zoom select:focus-visible { outline: 2px solid #2e598c; outline-offset: -2px; }
#ref-zoom button:disabled, #ref-zoom select:disabled { color: #98a2ac; cursor: default; background: #eef1f3; }
#ref-body { flex: 1; display: flex; min-height: 0; }
#ref-tree {
  flex: 0 0 270px; overflow-y: auto; border-right: 1px solid #b0b8c0;
  background: #f2f4f6; padding: 6px 0; font-size: 13px;
}
body.tree-hidden #ref-tree { display: none; }
.tree-folder-label {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  cursor: pointer; font-weight: 600; color: #1a3a5c; user-select: none;
}
.tree-folder-label:hover { background: #e2e8ee; }
.tree-folder-label .caret { font-size: 10px; width: 10px; transition: transform .12s; }
.tree-folder.open > .tree-folder-label .caret { transform: rotate(90deg); }
.tree-files { display: none; }
.tree-folder.open > .tree-files { display: block; }
.tree-file {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 5px 10px 5px 30px; cursor: pointer; font-size: 12.5px; color: #333;
  line-height: 1.3; font-family: inherit;
}
.tree-file:hover { background: #e2e8ee; }
.tree-file.active { background: #1a3a5c; color: #fff; }
#ref-viewer { flex: 1; position: relative; min-width: 0; }
#ref-frame { width: 100%; height: 100%; border: none; }
#ref-empty { padding: 40px; color: #555; text-align: center; }
#ref-empty h3 { margin-bottom: 12px; }
#ref-empty p { margin-bottom: 10px; line-height: 1.5; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 3px; font-size: 13px; }

/* ── Question pane ── */
#exam-picker { padding: 40px; overflow-y: auto; }
#exam-picker h2 { margin-bottom: 16px; }
#resource-manager {
  border: 1px solid #9eb1c3; border-radius: 6px; padding: 16px; margin-bottom: 20px;
  background: #f5f9fc; transition: box-shadow .2s, border-color .2s;
}
#resource-manager.needs-attention { border-color: #b7791f; box-shadow: 0 0 0 4px rgba(183,121,31,.18); }
.resource-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.resource-head p { color: #1a3a5c; font-size: 14px; font-weight: 600; line-height: 1.45; }
#resource-badge {
  flex: 0 0 auto; border-radius: 999px; padding: 4px 9px; font-size: 12px;
  font-weight: 600; color: #7a4b00; background: #fff1cc;
}
#resource-badge.ready { color: #17652b; background: #dff3e4; }
#resource-summary { margin-top: 14px; font-weight: 600; font-size: 13.5px; }
#resource-progress { width: 100%; height: 12px; margin: 8px 0 4px; accent-color: #2e598c; }
#resource-storage, #resource-status { color: #677482; font-size: 12px; min-height: 17px; }
#resource-error { color: #8c2e2e; background: #fbe7e7; padding: 7px 9px; margin-top: 8px; border-radius: 3px; font-size: 12.5px; }
.resource-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.resource-actions .nav-btn { padding: 8px 14px; }
.resource-secondary, .resource-group-download {
  border: 1px solid #8d9baa; background: #fff; color: #263a4e; padding: 7px 11px;
  border-radius: 3px; cursor: pointer; font: inherit; font-size: 12.5px;
}
.resource-secondary:hover, .resource-group-download:hover { background: #eaf1f8; }
.resource-secondary:disabled, .resource-group-download:disabled { cursor: default; color: #7b8792; background: #edf0f2; }
.resource-details { margin-top: 12px; font-size: 12.5px; color: #445567; }
.resource-details summary { cursor: pointer; user-select: none; }
#resource-groups { margin-top: 8px; border-top: 1px solid #d2dbe3; }
.resource-group { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid #dce3e9; }
.resource-group-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.resource-group-info strong { color: #263a4e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resource-group-info span { color: #6d7883; }
.resource-group-download { padding: 5px 9px; }
.exam-card {
  border: 1px solid #b0b8c0; border-radius: 4px; padding: 14px 16px; margin-bottom: 10px;
  cursor: pointer; background: #f7f9fb;
}
.exam-card:hover { background: #eaf1f8; border-color: #1a3a5c; }
.exam-card .ec-title { font-weight: 600; }
.exam-card .ec-meta { font-size: 13px; color: #666; margin-top: 4px; }
.exam-card .ec-resume { color: #1a6c2e; font-size: 13px; font-weight: 600; }
.hint { font-size: 12.5px; color: #888; margin-top: 14px; }

#question-view { flex: 1; overflow-y: auto; padding: 24px 28px 72px; }
.sqrt-arg { border-top: 1px solid #000; padding-top: 1px; }
#q-flagbar { margin-bottom: 14px; font-size: 13.5px; color: #444; }
#q-header {
  text-align: center; font-weight: 700; font-size: 15px;
  font-family: Arial, Helvetica, sans-serif; margin-bottom: 18px;
}
#q-stem, #q-options, .rq-stem, .rq-sol, .rq-opts {
  font-family: "Times New Roman", Georgia, serif; font-size: 16px; color: #000;
}
#q-stem, #q-options { max-width: 660px; }
#q-stem { display: flex; gap: 18px; line-height: 1.25; margin-bottom: 24px; }
.q-stem-text .stem-indent { display: block; text-indent: 2.5em; margin-top: 1.25em; }
.q-stem-text .stem-indent + .stem-indent { margin-top: 0; }
#q-stem sub, #q-options sub, .rq-stem sub, .rq-sol sub,
#q-stem sup, #q-options sup, .rq-stem sup, .rq-sol sup { font-size: 0.72em; }
.frac {
  display: inline-flex; flex-direction: column; text-align: center;
  vertical-align: middle; margin: 0 2px; line-height: 1.05; text-indent: 0;
}
.frac .fr-n { border-bottom: 1px solid #000; padding: 0 3px; }
.frac .fr-d { padding: 1px 3px 0; }
.q-num { font-weight: 700; flex: 0 0 26px; }
.q-stem-text { flex: 1; white-space: pre-wrap; min-width: 0; }
#q-stem img { max-width: 100%; max-height: 430px; width: auto; margin: 14px 0 0 2.5em; border: 0; display: block; }
#q-options { margin-left: 34px; }
.opt {
  display: flex; gap: 14px; align-items: flex-start; padding: 3px 10px; margin-bottom: 6px;
  border: 1px solid transparent; border-radius: 3px; cursor: pointer; line-height: 1.25;
}
.opt:hover { background: #f0f4f8; }
.opt.selected { background: #e2edf8; border-color: #7aa5cc; }
.opt.struck .opt-text { text-decoration: line-through; color: #999; }
.opt input {
  appearance: none; -webkit-appearance: none; width: 11px; height: 11px;
  border: 1.25px solid #000; border-radius: 50%; margin-top: 5px; flex: 0 0 auto;
  background: #fff; cursor: pointer;
}
.opt input:checked { background: #000; box-shadow: inset 0 0 0 2px #fff; }
.opt .opt-letter { font-weight: 400; min-width: 30px; }
#q-hint { margin-top: 18px; }

#q-bottombar {
  flex: 0 0 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: #d5dbe1; border-top: 1px solid #b0b8c0;
}
.nav-btn {
  background: #1a3a5c; color: #fff; border: none; padding: 9px 22px;
  font-size: 14px; cursor: pointer; border-radius: 3px;
}
.nav-btn:hover { background: #2e598c; }
.nav-btn:disabled { background: #9aa4ae; cursor: default; }

/* ── Score view ── */
#score-view { flex: 1; overflow-y: auto; padding: 30px; }
#score-view h2 { margin-bottom: 8px; }
#score-view .score-big { font-size: 40px; font-weight: 700; margin: 12px 0; }
.review-q { border: 1px solid #ccc; border-radius: 4px; padding: 16px 18px; margin: 12px 0; max-width: 720px; }
.review-q.correct { border-left: 5px solid #2e8c46; }
.review-q.wrong { border-left: 5px solid #8c2e2e; }
.review-q.blank { border-left: 5px solid #b0972e; }
.review-q .rq-summary {
  cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.review-q .rq-summary::-webkit-details-marker { display: none; }
.review-q .rq-expand {
  margin-left: auto; font-size: 12px; color: #2e598c;
  border: 1px solid #9eb1c3; border-radius: 3px; padding: 3px 8px; background: #fff;
}
.review-q[open] .rq-expand { display: none; }
.review-q[open] .rq-summary { margin-bottom: 12px; }
.review-q .rq-stem { display: flex; gap: 18px; margin: 6px 0 8px; line-height: 1.25; }
.rq-img { max-height: 300px; display: block; margin: 12px 0 4px 2.5em; }
.rq-opts { margin: 10px 0 0 44px; }
.rq-opt { display: flex; gap: 12px; margin-bottom: 3px; line-height: 1.25; }
.rq-opt .opt-letter { min-width: 24px; }
.rq-opt-ans { background: #f2f8f4; }
.rq-mark { font-family: Arial, Helvetica, sans-serif; font-size: 12px; align-self: center; }
.rq-mark-ok { color: #2e8c46; }
.rq-mark-x { color: #8c2e2e; }
.review-q .rq-sol {
  font-size: 15px; color: #000; background: #f7f9fb; border-top: 1px solid #d5dbe1;
  padding: 12px 14px; margin-top: 14px; white-space: pre-wrap; line-height: 1.55;
}
.rq-sol-label {
  font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; color: #566575; margin-bottom: 8px;
}
#q-solution { margin: 20px 0 0 34px; max-width: 660px; }
.q-sol-details > summary {
  cursor: pointer; user-select: none; list-style: none; display: inline-block;
  font-family: Arial, Helvetica, sans-serif; font-size: 12.5px; color: #2e598c;
  border: 1px solid #9eb1c3; border-radius: 3px; padding: 4px 10px; background: #fff;
}
.q-sol-details > summary::-webkit-details-marker { display: none; }
.q-sol-details > summary:hover { background: #eaf1f8; }
.q-sol-details[open] > summary { margin-bottom: 10px; }
.q-sol-details .rq-sol {
  font-family: "Times New Roman", Georgia, serif; font-size: 15px; color: #000;
  background: #f7f9fb; border-top: 1px solid #d5dbe1; padding: 12px 14px;
  white-space: pre-wrap; line-height: 1.45;
}
.q-sol-details .rq-sol sub, .q-sol-details .rq-sol sup { font-size: 0.72em; }

/* ── Navigator modal ── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: #fff; border-radius: 6px; padding: 20px 24px; max-width: 640px; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 12px; }
.nav-legend { display: flex; gap: 18px; font-size: 13px; margin-bottom: 14px; }
.sw { display: inline-block; width: 13px; height: 13px; margin-right: 5px; border-radius: 2px; vertical-align: -2px; }
.sw-ans { background: #2e8c46; }
.sw-un { background: #cfd6dd; border: 1px solid #9aa4ae; }
.sw-flag { background: #e0a800; }
#nav-grid { display: grid; grid-template-columns: repeat(10, 44px); gap: 6px; }
.nav-cell {
  height: 34px; border: 1px solid #9aa4ae; border-radius: 3px; background: #cfd6dd;
  font-size: 13px; cursor: pointer; position: relative;
}
.nav-cell.answered { background: #2e8c46; color: #fff; border-color: #24703a; }
.nav-cell.flagged::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 8px; height: 8px;
  background: #e0a800; border-radius: 50%;
}
.nav-cell.current { outline: 3px solid #1a3a5c; }
.modal-actions { margin-top: 16px; text-align: right; }

/* ── Calculator ── */
#calc {
  position: fixed; top: 70px; right: 30px; width: 260px; background: #f2f4f6;
  border: 1px solid #9aa4ae; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 60;
}
#calc-head {
  background: #1a3a5c; color: #fff; padding: 6px 10px; font-size: 13px;
  cursor: move; display: flex; justify-content: space-between; border-radius: 5px 5px 0 0;
}
#calc-head button { background: none; border: none; color: #fff; cursor: pointer; font-size: 13px; }
#calc-display {
  width: calc(100% - 16px); margin: 8px; height: 36px; font-size: 20px; text-align: right;
  border: 1px solid #b0b8c0; padding: 0 8px; font-variant-numeric: tabular-nums; background: #fff;
}
#calc-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 0 8px 8px; }
#calc-keys button {
  height: 32px; font-size: 13.5px; border: 1px solid #b0b8c0; background: #fff;
  cursor: pointer; border-radius: 3px;
}
#calc-keys button:hover { background: #e2edf8; }
#calc-keys button.op { background: #dde3e9; }
