@font-face { font-family: Lato; font-weight: 400; font-style: normal; font-display: swap; src: url("../assets/fonts/lato-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: Lato; font-weight: 700; font-style: normal; font-display: swap; src: url("../assets/fonts/lato-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: Lato; font-weight: 400; font-style: italic; font-display: swap; src: url("../assets/fonts/lato-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: Lato; font-weight: 700; font-style: italic; font-display: swap; src: url("../assets/fonts/lato-latin-700-italic.woff2") format("woff2"); }

:root {
  --accent: #5a4999;
  --ink: #161f26;
  --bar: #d8d8d8;
  --row-a: #e2e2e2;
  --row-b: #f2f1f6;
  --ok: #cdff9b;
  --part: #fffe99;
  --bad: #ff9899;
  --status: #ff0000;
  --text: #222222;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 Lato, Arial, sans-serif; color: var(--text); background: #fff; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border-radius: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main { flex: 1; min-height: 0; overflow: auto; overflow-x: hidden; }

/* Bands */
.band { flex: none; background: var(--accent); color: #fff; padding: 8px 16px; }
.band :focus-visible { outline-color: #fff; }
.bar { flex: none; background: var(--bar); padding: 8px 12px; display: flex; gap: 6px; align-items: center; }

/* Buttons */
.btn { font: 700 13px/1 Lato, Arial, sans-serif; min-height: 34px; padding: 0 14px; border: 0; background: var(--ink); color: #fff; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.accent { background: var(--accent); }
.btn.accent:focus-visible { outline-color: var(--ink); }
.btn.outline { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost { background: transparent; color: #fff; border: 1px solid #fff; }
.btn.next { min-width: 72px; }
.btn.fin { min-width: 144px; }
.btn svg { width: 14px; height: 14px; display: block; }
.btn.mini { min-height: 0; font-size: 11px; padding: 6px 10px; pointer-events: none; }
.sq { width: 28px; height: 28px; min-height: 0; padding: 0; background: var(--ink); border: 0; color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.sq svg { width: 16px; height: 16px; display: block; }
.sq.mini { pointer-events: none; width: 26px; height: 26px; }

/* Instructions */
.ins-h1 { font-size: 17px; font-weight: 700; }
.ins-h2 { font-size: 13px; }
.ins .main { padding: 14px 16px 20px; font-size: 13px; }
.ins h2 { font-size: 13px; margin: 0 0 12px; }
.ins ul { margin: 0 0 14px; padding-left: 22px; }
.ins li { margin: 0 0 1px; }
.ins table.icons { border-collapse: collapse; border: 1px solid #222; width: 100%; max-width: 980px; margin: 0 0 14px; }
.ins table.icons th { text-align: left; font-weight: 400; padding: 6px 8px; border-bottom: 1px solid #ddd; }
.ins table.icons td { padding: 10px 8px; vertical-align: middle; font-size: 13px; }
.ins table.icons td:first-child { width: 230px; }
.ins .icell { display: flex; gap: 8px; align-items: center; }
.ins .foot-r { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ins .resume { font-size: 13px; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; }
.ins .bar { padding: 14px 12px; }

/* Question screen */
.qh { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 50px; }
.qh-l { font-size: 18px; font-weight: 700; }
.qh-c { font-size: 13px; text-align: center; }
.qh-r { text-align: right; font-size: 13px; line-height: 1.25; }
.qbody { flex: 1; min-height: 0; display: flex; }
.qbody.obj { overflow: auto; overflow-x: hidden; display: block; padding: 10px 16px 18px; }
.qbody .c { overflow-wrap: anywhere; }
.tw { overflow-x: auto; max-width: 100%; }
.tw > table { margin-top: 0; }

.pane { min-width: 0; overflow: auto; padding: 12px 16px; }
.pane.left { flex: 0 0 calc(var(--split, 50%) - 3px); }
.pane.right { flex: 1 1 0; display: flex; flex-direction: column; }
.divider { flex: 0 0 6px; background: #ebebeb; border-left: 1px solid #d0d0d0; border-right: 1px solid #d0d0d0; cursor: col-resize; display: flex; align-items: center; justify-content: center; touch-action: none; }
.divider i { display: block; width: 0; height: 14px; border-left: 2px dotted #999; }
.hl-tools { display: flex; gap: 6px; margin-bottom: 10px; }
.scen .hl { background: #ffff66; }
.scen .st { text-decoration: line-through; }
.scen { user-select: text; }
.req-h { font-weight: 700; margin: 0 0 8px; }
.pane.right .req { margin-bottom: 12px; }
.edwrap { flex: 1 0 320px; display: flex; flex-direction: column; min-height: 320px; }

/* Objective parts */
.oq p { margin: 0 0 10px; }
.oq .qr { margin-bottom: 8px; }
.part { padding: 2px 0 6px; }
hr.part-rule { border: 0; border-top: 1px solid #c8c8c8; margin: 16px 0 12px; }
.mxw { overflow-x: auto; max-width: 100%; margin: 10px 0 8px; }
table.mx { border-collapse: collapse; }
table.mx th, table.mx td { padding: 0; text-align: center; font-size: 13px; }
table.mx thead th { font-weight: 700; padding: 4px 12px; border-left: 1px solid #555; min-width: 92px; white-space: nowrap; }
table.mx thead td { border: 0; }
table.mx tbody th { text-align: left; font-weight: 700; padding: 7px 14px 7px 10px; min-width: 240px; max-width: 360px; }
table.mx tbody td { border-left: 1px solid #555; height: 32px; }
table.mx tbody tr.b > * { background: var(--row-b); }
table.mx tbody tr.ok > * { background: var(--ok); }
table.mx tbody tr.bad > * { background: var(--bad); }
table.mx tbody tr:last-child td { border-bottom: 0; }
table.mx tfoot td { height: 28px; border-left: 1px solid #555; }
table.mx tfoot td:first-child { border-left: 0; }
.rd { position: relative; display: flex; align-items: center; justify-content: center; height: 32px; cursor: pointer; margin: 0; }
input[type=radio] { accent-color: var(--accent); margin: 0 4px; width: 15px; height: 15px; }
.chs { margin: 10px 0 8px; padding: 6px 8px; max-width: 760px; }
.chs.ok { background: var(--ok); }
.chs.bad { background: var(--bad); }
.opt { position: relative; display: flex; align-items: flex-start; gap: 4px; padding: 3px 0; cursor: pointer; }
.opt input { margin-top: 3px; flex: none; }
.opt > span { flex: 1; min-width: 0; }
.opt p { margin: 0; }
.total { margin: 0; font-weight: 700; }

/* Bottom toolbar */
.qbar { justify-content: flex-end; }
.qbar .tb { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex: 1; min-width: 0; }

/* Navigation table */
.nav .main, .fin-s .main { padding: 14px 16px 20px; }
table.navt { border-collapse: collapse; width: 100%; max-width: 420px; font-size: 14px; }
table.navt th { background: var(--row-a); text-align: left; font-weight: 700; padding: 9px 12px; }
table.navt th.fl, table.navt td.fl { text-align: right; }
table.navt td { padding: 8px 12px; }
table.navt tbody tr { cursor: pointer; }
table.navt tbody tr:nth-child(odd) { background: var(--row-b); }
table.navt tbody tr:nth-child(even) { background: var(--row-a); }
table.navt .stat { color: var(--status); font-weight: 700; }
table.navt td.fl svg { width: 18px; height: 18px; vertical-align: middle; }
table.navt .linkbtn { text-decoration: none; }
.navh { font-size: 18px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 34px; }
.navh .tm { font-size: 14px; font-weight: 400; }
.fin-s p.lead { margin: 0 0 12px; font-size: 13px; }
.fin-h1 { font-weight: 700; font-size: 16px; }
.fin-h2 { font-size: 13px; }
.bar.right { justify-content: flex-end; }

/* Results */
.res .main { padding: 14px 16px 40px; }
.res-in { max-width: 1100px; margin: 0 auto; }
.res h2.sec { color: var(--accent); font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.res h2.sec small { font-size: 12px; font-weight: 400; color: #777; margin-left: 4px; }
.res .expired { font-weight: 700; margin: 0 0 12px; }
table.ov { border-collapse: collapse; width: 100%; margin: 0 0 12px; }
table.ov th, table.ov td { text-align: left; padding: 8px 12px; font-size: 13px; vertical-align: top; }
table.ov th { width: 200px; font-weight: 700; }
table.ov tr:nth-child(odd) { background: var(--row-a); }
table.ov tr:nth-child(even) { background: var(--row-b); }
.res .btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.qa { margin: 0 0 1px; }
.qa-h { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: center; border: 0; border-bottom: 1px solid #b8b8b8; padding: 9px 12px; background: var(--row-a); cursor: pointer; text-align: left; font-size: 13px; }
.qa-h.ok { background: var(--ok); }
.qa-h.part { background: var(--part); }
.qa-h.bad { background: var(--bad); }
.qa-h .pm { display: inline-block; width: 14px; }
.qa-b { padding: 14px 8px 20px; border-bottom: 1px solid #b8b8b8; }
.qa-b h3 { font-size: 15px; margin: 18px 0 8px; }
.qa-b h3:first-child { margin-top: 0; }
.ans-box { border: 1px solid #bbb; padding: 10px; min-height: 40px; }
.mg { margin: 6px 0; }
.mrow { display: flex; align-items: flex-start; gap: 10px; padding: 6px 8px; cursor: pointer; }
.mrow:nth-child(odd) { background: var(--row-b); }
.mrow input { margin: 3px 0 0; flex: none; width: 16px; height: 16px; }
.mrow .mt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mrow .mk { flex: none; font-weight: 700; min-width: 28px; text-align: right; }
.yourmark { font-weight: 700; margin: 10px 0 0; }
.fb { margin-top: 18px; }
.fb .fbp { border-top: 1px solid #c8c8c8; padding-top: 8px; margin-top: 10px; }
.fb .fbp:first-of-type { border-top: 0; }
.qa-b table.grid { margin: 6px 0 10px; }

/* Notes */
.notes .nbody { display: grid; grid-template-columns: 240px minmax(0, 860px); gap: 32px; padding: 16px; align-items: start; }
.toc { position: sticky; top: 0; font-size: 13px; line-height: 1.35; max-height: calc(100vh - 80px); overflow: auto; }
.toc a { display: block; padding: 5px 0; color: var(--text); text-decoration: none; cursor: pointer; }
.toc a:hover { text-decoration: underline; }
.toc a.cur { font-weight: 700; }
.notes .c { font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.notes .c h2 { font-size: 20px; font-weight: 700; color: var(--accent); margin: 28px 0 10px; padding-top: 14px; border-top: 1px solid var(--bar); }
.notes .c h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.notes .c h3 { font-size: 16px; font-weight: 700; }
.notes .hdr { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.notes .hdr .acts { display: flex; gap: 8px; }
.notes .hdr .t { font-size: 18px; font-weight: 700; }

/* Tool windows */
#tools { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }
.win { position: absolute; pointer-events: auto; background: #fff; border: 1px solid #8a8a8a; box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column; font-size: 13px; }
.win.rs { resize: both; overflow: hidden; min-width: 220px; min-height: 160px; }
.wt { flex: none; background: var(--bar); height: 26px; padding: 0 6px 0 9px; display: flex; align-items: center; justify-content: space-between; cursor: move; user-select: none; touch-action: none; color: #444; }
.wx { width: 15px; height: 15px; border: 1px solid #999; background: #f4f4f4; padding: 0; font-size: 12px; line-height: 11px; color: #666; cursor: pointer; }
.wb { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.calc { width: 285px; padding: 12px 12px 12px; outline: 0; }
.calc .cd { border: 1px solid #aaa; background: #fff; text-align: right; padding: 0 8px; overflow: hidden; white-space: nowrap; }
.calc .cd.m { height: 42px; line-height: 40px; font-size: 20px; margin-bottom: 8px; }
.calc .cd.s { height: 28px; line-height: 26px; font-size: 12px; color: #555; margin-bottom: 8px; }
.calc .ck { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc .ck button { height: 33px; border: 1px solid #b4b4b4; background: #ececec; font-size: 13px; cursor: pointer; padding: 0; }
.calc .ck button.w2 { grid-column: span 2; }

.ruler { position: absolute; pointer-events: auto; background: #ffffe5; border: 1px solid #b9b98c; opacity: 0.75; height: 58px; cursor: move; touch-action: none; }
.ruler .wx { position: absolute; top: 3px; right: 4px; }

.npad { width: 270px; height: 330px; }
.npad .ed { flex: 1; min-height: 0; margin: 6px; }
.npad .ed-body { flex: 1; min-height: 0; overflow: auto; font-family: Lato, Arial, sans-serif; }

.sheetw { width: 700px; height: 520px; }
.sh { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; }
.sh-how { flex: none; margin: 8px 8px 0; border: 1px solid #d0d0d0; padding: 7px 10px; font-size: 12px; line-height: 1.35; }
.sh-fx { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px; }
.sh-ref { width: 84px; height: 24px; border: 1px solid #c4c4c4; padding: 0 6px; background: #fff; }
.sh .fx { font: italic 14px Georgia, serif; color: #3367b0; padding: 0 2px; }
.sh-bar { flex: 1; min-width: 0; height: 24px; border: 1px solid #c4c4c4; padding: 0 6px; }
.sh-grid { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid #c4c4c4; border-bottom: 1px solid #c4c4c4; outline: 0; position: relative; }
.sh-grid table { border-collapse: separate; border-spacing: 0; table-layout: fixed; user-select: none; }
.sh-grid th { position: sticky; top: 0; z-index: 2; background: #e6ebf3; border-right: 1px solid #c4cbd8; border-bottom: 1px solid #c4cbd8; font-weight: 400; height: 21px; font-size: 12px; padding: 0; }
.sh-grid th.rh { position: sticky; left: 0; top: auto; z-index: 1; width: 40px; min-width: 40px; }
.sh-grid th.corner { left: 0; z-index: 3; }
.sh-grid th.hs { background: #cfd8e8; font-weight: 700; }
.sh-grid td { height: 21px; padding: 0 4px; border-right: 1px solid #dde3ee; border-bottom: 1px solid #dde3ee; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: clip; position: relative; background: #fff; }
.sh-grid td.n { text-align: right; }
.sh-grid td.sel { background: #e4ecfa; }
.sh-grid td.act { background: #fff; outline: 2px solid #217346; outline-offset: -2px; }
.sh-grid td input.cin { position: absolute; inset: 0; width: 100%; height: 100%; border: 2px solid #217346; padding: 0 3px; font-size: 12px; background: #fff; outline: 0; }
.sh-status { flex: none; background: #e6ebf3; padding: 3px 10px; font-size: 12px; color: #444; }

/* Rich editor */
.ed { display: flex; flex-direction: column; flex: 1; min-height: 0; border: 1px solid #c4c4c4; background: #fff; }
.ed-tb { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 3px 4px; border-bottom: 1px solid #d4d4d4; background: #fff; position: relative; }
.ed-tb .tbb { min-width: 26px; height: 26px; padding: 0 4px; border: 0; background: transparent; color: #666; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 2px; font-size: 13px; }
.ed-tb .tbb:hover { background: #ececec; }
.ed-tb .tbb svg { width: 16px; height: 16px; display: block; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.ed-tb .tbb .caret { font-size: 9px; }
.ed-tb .sep { width: 1px; height: 20px; background: #d4d4d4; margin: 0 3px; }
.ed-tb .msg { font-size: 12px; color: #444; margin-left: 8px; }
.ed-body { flex: 1; min-height: 0; padding: 8px 10px; font: 14px/1.4 Verdana, Geneva, sans-serif; color: #222; outline: 0; overflow: auto; overflow-wrap: break-word; }
.ed-body p { margin: 0 0 10px; }
.ed-body h1 { font-size: 22px; margin: 0 0 10px; }
.ed-body h2 { font-size: 18px; margin: 0 0 10px; }
.ed-body h3 { font-size: 16px; margin: 0 0 10px; }
.ed-body table { border-collapse: collapse; margin: 4px 0 10px; }
.ed-body td, .ed-body th { border: 1px solid #999; padding: 4px 8px; min-width: 64px; vertical-align: top; overflow-wrap: normal; word-break: normal; }
.ed-body td:first-child, .ed-body th:first-child { min-width: 200px; }
.ed-body ul, .ed-body ol { margin: 0 0 10px; padding-left: 30px; }
.ans-box.ed-body { overflow: visible; }

.pop { position: fixed; z-index: 5000; background: #fff; border: 1px solid #aaa; box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.3); font: 13px Lato, Arial, sans-serif; color: var(--text); }
.pop .mi { display: block; width: 100%; text-align: left; padding: 6px 14px; border: 0; background: #fff; cursor: pointer; white-space: nowrap; }
.pop .mi:hover:not(:disabled) { background: #ececec; }
.pop .mi:disabled { color: #aaa; cursor: default; }
.pop hr { border: 0; border-top: 1px solid #ddd; margin: 3px 0; }
.pop .tg { padding: 8px 10px; }
.pop .tg .lab { font-size: 12px; margin-bottom: 6px; color: #444; }
.pop .tg .cells { display: grid; grid-template-columns: repeat(8, 18px); gap: 2px; }
.pop .tg .cells button { width: 18px; height: 18px; border: 1px solid #bbb; background: #fff; padding: 0; cursor: pointer; }
.pop .tg .cells button.on { background: #cfd8e8; border-color: #6a7fa8; }
.pop.sw { display: grid; grid-template-columns: repeat(8, 22px); gap: 3px; padding: 8px; }
.pop.sw button { width: 22px; height: 22px; border: 1px solid #aaa; padding: 0; cursor: pointer; }
.pop.chars { display: grid; grid-template-columns: repeat(8, 28px); gap: 2px; padding: 8px; }
.pop.chars button { width: 28px; height: 28px; border: 1px solid #ddd; background: #fff; cursor: pointer; font-size: 15px; padding: 0; }
.pop.chars button:hover { background: #ececec; }

/* Small screens */
@media (max-width: 759px) {
  body { font-size: 14px; }
  .btn { min-height: 40px; }
  .band { padding: 8px 12px; }
  .qh { grid-template-columns: 1fr auto; grid-template-areas: "l c" "r r"; gap: 2px 8px; font-size: 13px; min-height: 0; }
  .qh-l { grid-area: l; font-size: 18px; }
  .qh-c { grid-area: c; font-size: 13px; text-align: right; }
  .qh-r { grid-area: r; display: flex; justify-content: space-between; font-size: 13px; text-align: left; }
  .qbody.wr { display: block; overflow: auto; overflow-x: hidden; }
  .pane { overflow: visible; padding: 10px 12px; }
  .pane.left { flex: none; }
  .divider { display: none; }
  .edwrap { flex: none; height: 340px; }
  .qbody.obj { padding: 10px 12px 18px; }
  .qbar { padding: 8px; }
  .qbar .tb { justify-content: flex-start; overflow-x: auto; }
  .qbar .tb .btn { flex: none; }
  .qbar .tb .btn.next, .qbar .tb .btn.fin { margin-left: auto; position: sticky; right: 0; min-width: 72px; }
  .qbar .tb .btn.fin { min-width: 96px; }
  .ins .main { padding: 12px; }
  .ins table.icons td:first-child { width: 120px; }
  .ins .icell { flex-wrap: wrap; }
  .ins .bar { flex-wrap: wrap; padding: 10px 8px; }
  .ins .foot-r { margin-left: auto; }
  .nav .main, .fin-s .main { padding: 12px; }
  .res .main { padding: 12px 10px 30px; }
  table.ov th { width: 112px; }
  .notes .nbody { display: block; padding: 12px; }
  .toc { position: static; max-height: none; margin-bottom: 16px; border-bottom: 1px solid var(--bar); padding-bottom: 8px; }
  .win { left: 0 !important; top: 50% !important; width: 100% !important; height: 50% !important; max-width: none; resize: none; }
  .win.rs { resize: none; }
  .wt { cursor: default; }
  .calc { width: 100%; overflow: auto; }
  .sheetw, .npad { width: 100%; }
  /* Keep the row labels in view while the answer columns scroll sideways */
  table.mx tbody th { min-width: 150px; max-width: 170px; position: sticky; left: 0; z-index: 1; background: #fff; }
  table.mx thead td { position: sticky; left: 0; z-index: 1; background: #fff; }
  table.mx tbody tr.b > th { background: var(--row-b); }
  table.mx tbody tr.ok > th { background: var(--ok); }
  table.mx tbody tr.bad > th { background: var(--bad); }
  table.mx thead th { min-width: 78px; white-space: normal; }
  .ed-tb .tbb { min-width: 34px; height: 34px; }
}

@media print {
  html, body, #app, .screen, .main { height: auto !important; overflow: visible !important; display: block; }
  .bar, .band .btn, .toc, .noprint, #tools { display: none !important; }
  .band { background: #fff; color: #000; padding: 0; }
  .notes .nbody { display: block; padding: 0; }
  .qa-b[hidden] { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Saving notice and self-marking additions */
.notice { flex: none; background: var(--part); color: var(--text); padding: 6px 16px; font-size: 13px; }
.mrow.mdone { margin-top: 6px; font-weight: 700; }
.mnote { margin: 0 0 8px; }
@media (max-width: 759px) { .notice { padding: 6px 12px; } }
