/* Student side: my tests, the test screen and the result.
   Ink blue + saffron (the brand), NTA's familiar palette colours for answer states, IBM Plex Sans for the interface and
   the paper's serif for questions. One strong element: the time bar that drains across the top during a test. */
:root {
  --ink: #14214a; --ink-2: #2b3a6b; --paper: #f4f6fb; --card: #ffffff; --line: #dde2ee; --muted: #5d6680;
  --brand: #14214a; --brand-2: #2b3a6b; --saffron: #e39b2d; --saffron-soft: #fdf3e3;
  --s-ans: #1f9d55; --s-not: #d64545; --s-rev: #6c3fb5; --s-nv: #e7eaf2;
  --ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}
body.st { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--paper); font-family: var(--ui); color: var(--ink); font-size: 15px; }
body.st button, body.st input, body.st select, body.st textarea { font-family: var(--ui); }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }

/* top bar */
.st-top { display: flex; align-items: center; gap: 14px; padding: 0 20px; height: 58px; background: var(--brand); color: #fff; flex: none; position: relative; }
.st-top .brand { font-family: "Times New Roman", serif; font-size: 20px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.st-top .who { color: #c4cde8; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-top .grow { flex: 1; }
.st-top .ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; }
.st-top .ghost:hover { background: rgba(255,255,255,.1); }
.timebar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--saffron); transition: width 1s linear; }
.timebar.low { background: var(--s-not); }
.clock { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.clock small { display: block; font-size: 11px; font-weight: 400; color: #c4cde8; letter-spacing: 0; text-align: right; }
.clock.low { color: #ffb4a8; }

.st-main { flex: 1; overflow: auto; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px 60px; }

/* buttons */
.b { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 9px 16px; font-size: 14.5px; font-weight: 500; cursor: pointer; }
.b:hover { border-color: #b6c0da; }
.b.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.b.primary:hover { background: var(--brand-2); }
.b.go { background: var(--s-ans); border-color: var(--s-ans); color: #fff; }
.b.go:hover { filter: brightness(1.06); }
.b.review { background: #f3eefb; border-color: #d8ccf0; color: var(--s-rev); }
.b:disabled { opacity: .45; cursor: default; }

/* my tests */
.hello { font-size: 26px; font-weight: 600; margin: 0 0 4px; }
.hello-sub { color: var(--muted); margin: 0 0 26px; }
.group-h { font-size: 15px; font-weight: 600; color: var(--muted); margin: 26px 0 10px; }
.live { background: #fff; border: 2px solid var(--s-ans); border-radius: 14px; padding: 20px 22px; display: grid; grid-template-columns: 1fr auto; gap: 14px 20px; align-items: center; margin-bottom: 12px; }
.live h3 { margin: 0 0 6px; font-size: 20px; }
.live .facts { color: var(--muted); font-size: 14.5px; }
.live .facts span { margin: 0 6px; color: #b5bdd2; }
.live .facts b { color: var(--ink); font-weight: 600; }
.live .closes { color: var(--s-not); font-size: 13.5px; margin-top: 8px; }
.live .b { font-size: 16px; padding: 12px 22px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--s-ans); margin-right: 6px; box-shadow: 0 0 0 4px #dff3e7; vertical-align: 2px; }
.trow { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; display: flex; gap: 16px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.trow .t { flex: 1; min-width: 200px; }
.trow h4 { margin: 0 0 3px; font-size: 16px; font-weight: 600; }
.trow .m { color: var(--muted); font-size: 13.5px; }
.score-chip { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; padding: 6px 12px; border-radius: 8px; background: var(--saffron-soft); color: #8a5300; }
.empty { background: #fff; border: 1px dashed #c8cfe0; border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); }

/* test screen */
.tx { display: grid; grid-template-columns: minmax(0, 1fr) 300px; height: 100%; }
.tx-q { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: #fff; }
.tx-scroll { flex: 1; overflow: auto; padding: 18px 28px 28px; }
.secs { display: flex; gap: 4px; padding: 10px 28px 0; border-bottom: 1px solid var(--line); background: #fafbfe; overflow-x: auto; flex: none; }
.secs button { border: 0; background: none; padding: 9px 14px 10px; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.secs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--saffron); }
.qhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.qhead .qn { font-size: 17px; font-weight: 600; }
.qhead .marks { font-size: 13px; color: var(--muted); }
.qhead .marks .p { color: var(--s-ans); font-weight: 600; } .qhead .marks .n { color: var(--s-not); font-weight: 600; }
.tx .qbody { font-size: 17.5px; line-height: 1.55; }
.choices { margin-top: 18px; display: grid; gap: 10px; }
.choice { display: flex; gap: 14px; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 16px; cursor: pointer; background: #fff; transition: border-color .12s, background .12s; }
.choice:hover { border-color: #aab6d6; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .key { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #b9c2da; display: grid; place-items: center; font-weight: 600; font-size: 14.5px; color: var(--ink-2); }
.choice.multi .key { border-radius: 8px; }
.choice.sel { border-color: var(--brand); background: #eef1fa; }
.choice.sel .key { background: var(--brand); border-color: var(--brand); color: #fff; }
.choice:has(input:focus-visible) { outline: 3px solid var(--saffron); outline-offset: 2px; }
.choice .qbody { font-size: 17px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.numin { font-size: 22px; padding: 10px 14px; width: 260px; max-width: 100%; border: 1.5px solid var(--line); border-radius: 10px; margin-top: 18px; font-variant-numeric: tabular-nums; }
.numin:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px #e3e8f6; }
textarea.numin { width: 100%; min-height: 140px; font-size: 16px; }
.mx { border-collapse: collapse; margin-top: 16px; }
.mx td, .mx th { border: 1px solid var(--line); padding: 8px 14px; text-align: center; }
.mx th { background: #f6f7fb; font-weight: 600; }
.mx input { width: 18px; height: 18px; }
.actions { flex: none; display: flex; gap: 8px; align-items: center; padding: 12px 28px; border-top: 1px solid var(--line); background: #fafbfe; flex-wrap: wrap; }
.actions .grow { flex: 1; }
.saved { font-size: 12.5px; color: var(--muted); margin-right: 6px; }

/* palette */
.pal { display: flex; flex-direction: column; background: var(--paper); min-height: 0; }
.pal-in { flex: 1; overflow: auto; padding: 16px; }
.counts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.counts div { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.counts b { min-width: 30px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; }
.c-ans { background: var(--s-ans); } .c-not { background: var(--s-not); } .c-rev { background: var(--s-rev); border-radius: 50% !important; } .c-nv { background: var(--s-nv); color: var(--ink) !important; }
.pal h5 { margin: 14px 0 8px; font-size: 13.5px; font-weight: 600; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, 42px); gap: 8px; }
.pgrid button { height: 40px; width: 42px; padding: 0; border-radius: 8px; border: 1px solid #cfd5e4; background: var(--s-nv); color: var(--ink); cursor: pointer; font-weight: 600; font-size: 13.5px; position: relative; font-variant-numeric: tabular-nums; }
.pgrid button.na { background: var(--s-not); color: #fff; border-color: var(--s-not); }
.pgrid button.an { background: var(--s-ans); color: #fff; border-color: var(--s-ans); }
.pgrid button.rv { background: var(--s-rev); color: #fff; border-color: var(--s-rev); border-radius: 50%; }
.pgrid button.rva::after { content: ""; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: #35d07f; border: 2px solid #fff; }
.pgrid button.cur { box-shadow: 0 0 0 3px var(--saffron); }
.pal-foot { flex: none; padding: 14px 16px; border-top: 1px solid var(--line); background: #fff; }
.pal-foot .b { width: 100%; padding: 12px; font-size: 15.5px; }
.pal-close, .pal-open { display: none; }

/* result */
.res-head { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; margin: 14px 0 18px; }
.ring { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; }
.ring > div { width: 104px; height: 104px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.ring b { font-size: 27px; font-variant-numeric: tabular-nums; line-height: 1; }
.ring span { font-size: 12.5px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 16px 20px; }
.stats div { font-size: 13px; color: var(--muted); }
.stats b { display: block; font-size: 21px; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.sec-tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-variant-numeric: tabular-nums; }
.sec-tbl th, .sec-tbl td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--line); font-size: 14px; }
.sec-tbl th:first-child, .sec-tbl td:first-child { text-align: left; }
.sec-tbl th { background: #f6f7fb; font-weight: 600; color: var(--muted); }
.sec-tbl tr:last-child td { border-bottom: 0; font-weight: 600; }
.rfilt { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0 12px; }
.rfilt button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; cursor: pointer; font-size: 13.5px; }
.rfilt button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.rq { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin-bottom: 12px; }
.rq .rqh { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.rq .rqh b { font-size: 15px; }
.chip { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.chip.correct { background: #e1f4e9; color: #16733e; } .chip.wrong { background: #fbe4e4; color: #a32b2b; }
.chip.partial { background: #fdf0d9; color: #8a5300; } .chip.blank, .chip.not_counted, .chip.ungraded { background: #eceef4; color: var(--muted); }
.yours { font-size: 14px; margin-top: 10px; color: var(--muted); }
.yours b { color: var(--ink); }
.rq .qbody { font-size: 16.5px; }

/* dialogs reuse the app's modal; give them the interface font */
body.st .modal { font-family: var(--ui); }

@media (max-width: 860px) {
  .tx { grid-template-columns: 1fr; }
  .tx-scroll { padding: 14px 16px 20px; }
  .secs, .actions { padding-left: 16px; padding-right: 16px; }
  .pal { position: fixed; inset: 58px 0 0 auto; width: min(340px, 88vw); z-index: 30; box-shadow: -8px 0 24px rgba(20,33,74,.18); transform: translateX(105%); transition: transform .2s; }
  .pal.open { transform: none; }
  .pal-close { display: block; margin-left: auto; }
  .pal-open { display: inline-flex; }
  .res-head { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .live { grid-template-columns: 1fr; }
  .st-top .who { display: none; }
  .actions .b { padding: 9px 12px; font-size: 14px; }
  .saved { display: none; }
}
@media (prefers-reduced-motion: reduce) { .timebar, .pal, .choice { transition: none; } }

.st-top .logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px; }

/* ---------------- dark theme: follows the phone / computer setting, or the student's own choice ----------------
   Light text on deep blue-grey; the institute's colour stays on the top bar and buttons; NTA answer colours unchanged.
   Formula and structure pictures (black lines) are turned light; figures keep a white card so labels stay readable. */
html[data-theme=dark] {
  color-scheme: dark;
  --ink: #e7ebf4; --ink-2: #c9d1e4; --paper: #0e131d; --card: #161d2b; --line: #2a3345; --muted: #9aa5bd;
  --s-nv: #2a3345; --saffron-soft: #3a2c14;
}
html[data-theme=dark] body.st { background: var(--paper); color: var(--ink); }
html[data-theme=dark] .b, html[data-theme=dark] .live, html[data-theme=dark] .trow, html[data-theme=dark] .empty,
html[data-theme=dark] .tx-q, html[data-theme=dark] .choice, html[data-theme=dark] .numin, html[data-theme=dark] .pal-foot,
html[data-theme=dark] .res-head, html[data-theme=dark] .ring > div, html[data-theme=dark] .sec-tbl, html[data-theme=dark] .rfilt button,
html[data-theme=dark] .rq, html[data-theme=dark] .modal { background: var(--card); color: var(--ink); }
html[data-theme=dark] .b:hover, html[data-theme=dark] .choice:hover { border-color: #46516a; }
html[data-theme=dark] .b.primary, html[data-theme=dark] .rfilt button.on { background: var(--brand); color: #fff; border-color: #4a5878; }
html[data-theme=dark] .b.go { background: var(--s-ans); color: #fff; border-color: var(--s-ans); }
html[data-theme=dark] .b.review { background: #2a2140; border-color: #4b3a72; color: #c9b4f2; }
html[data-theme=dark] .secs, html[data-theme=dark] .actions, html[data-theme=dark] .mx th, html[data-theme=dark] .sec-tbl th { background: #121926; }
html[data-theme=dark] .choice .key { border-color: #4a5570; color: var(--ink-2); }
html[data-theme=dark] .choice.sel { background: #1c2742; border-color: #7f93c9; }
html[data-theme=dark] .choice.sel .key { background: #7f93c9; border-color: #7f93c9; color: #0e131d; }
html[data-theme=dark] .numin:focus { border-color: #7f93c9; box-shadow: 0 0 0 3px #26324d; }
html[data-theme=dark] .pgrid button { border-color: #3a4560; }
html[data-theme=dark] .pgrid button.rva::after { border-color: var(--card); }
html[data-theme=dark] .counts b.c-nv { color: var(--ink) !important; }
html[data-theme=dark] .dot { box-shadow: 0 0 0 4px #16392a; }
html[data-theme=dark] .score-chip { color: #f3c77b; }
html[data-theme=dark] .live .facts span { color: #56617a; }
html[data-theme=dark] .empty { border-color: #3a4560; }
html[data-theme=dark] .chip.correct { background: #173a29; color: #7fe0a8; }
html[data-theme=dark] .chip.wrong { background: #46201f; color: #ff9d97; }
html[data-theme=dark] .chip.partial { background: #3e2f12; color: #f3c77b; }
html[data-theme=dark] .chip.blank, html[data-theme=dark] .chip.not_counted, html[data-theme=dark] .chip.ungraded { background: #232b3b; color: var(--muted); }
html[data-theme=dark] .modal header, html[data-theme=dark] .modal footer { border-color: var(--line); }
html[data-theme=dark] .modal .x { color: var(--ink); }
html[data-theme=dark] .qbody .sol { background: #121926; color: var(--ink); }
html[data-theme=dark] .qbody .ans, html[data-theme=dark] .qbody .opts .correct { color: #7fe0a8; }
html[data-theme=dark] .qbody table.match td, html[data-theme=dark] .qbody table.match th { border-color: #3a4560; }
html[data-theme=dark] .qbody table.match.wide th { background: #121926; }
html[data-theme=dark] .qbody img.struct, html[data-theme=dark] .qbody img.mimg, html[data-theme=dark] .qbody img.graph {
  filter: invert(.9) hue-rotate(180deg); }
html[data-theme=dark] .qbody img.fig { background: #fff; border-radius: 6px; padding: 4px; }
html[data-theme=dark] .qbody .psg-box { background: #121926 !important; }
html[data-theme=dark] .tbl td, html[data-theme=dark] .tbl th { border-color: var(--line); }
.theme-btn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; width: 36px; height: 32px; cursor: pointer; font-size: 16px; line-height: 1; }
.theme-btn:hover { background: rgba(255,255,255,.1); }
@media (max-width: 520px) {
  .st-top { gap: 8px; padding: 0 12px; }
  .st-top .brand { font-size: 16px; max-width: 52vw; }
  .st-top .ghost { padding: 6px 9px; white-space: nowrap; font-size: 13px; }
  .clock { font-size: 19px; }
  body.st:has(#st-clock:not([hidden])) .st-top .brand { max-width: 64px; }   /* during a test: logo only, room for the timer */
}

/* fit to every screen: wide monitors keep the test at a readable width; tablets get a narrower panel;
   small phones get one compact row of actions */
.tx { max-width: 1480px; margin: 0 auto; width: 100%; }
@media (min-width: 1500px) { .tx { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
@media (max-width: 1180px) and (min-width: 861px) { .tx { grid-template-columns: minmax(0, 1fr) 250px; } .actions .lg { display: none; } .saved { display: none; } }
@media (max-width: 860px) { .actions { gap: 6px; } }
@media (max-width: 480px) {
  .actions .lg { display: none; }
  .actions { padding: 10px 12px; gap: 6px; flex-wrap: nowrap; }
  .actions .b { padding: 10px 11px; }
  .actions .grow { display: none; }
  .actions #b-next { margin-left: auto; }
  .tx .qbody { font-size: 17px; }
  .wrap { padding: 20px 14px 50px; }
  .hello { font-size: 22px; }
}
@media (max-height: 480px) and (orientation: landscape) {        /* phone held sideways */
  .st-top { height: 46px; } .clock { font-size: 18px; } .clock small { display: none; }
  .pal { inset: 46px 0 0 auto; }
  .tx-scroll { padding-top: 10px; }
}
.xs { display: none; }
@media (max-width: 480px) { .xs { display: inline; } .nxs { display: none; } .actions .b { white-space: nowrap; } }
/* the test screen fills the screen exactly: question scrolls, action bar always visible */
body.st main.st-main { padding: 0; }
.tx { grid-template-rows: minmax(0, 1fr); }
.tx-q { min-height: 0; }

/* ---------------- phones (iPhone Safari / Chrome, Android) ----------------
   the page itself never moves: only the inside scrolls, nothing wider than the screen, no zoom when typing */
html, body.st { overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.st main.st-main { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@supports not (height: 100dvh) { body.st { height: -webkit-fill-available; } html { height: -webkit-fill-available; } }
.actions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.st-top { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
body.st input, body.st select, body.st textarea { font-size: max(16px, 1em); }
.qbody { overflow-wrap: break-word; }
.qbody table.match td:first-child, .qbody table.match td:nth-child(3) { white-space: nowrap; }
.qbody img { max-width: 100%; height: auto; }
.qbody img.fig { max-width: min(340px, 100%); }
.qbody .katex-display, .qbody table.match { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.qbody table.match { display: block; }
.qbody .opts.one { grid-template-columns: 1fr; }
.sec-wrap { overflow-x: auto; border-radius: 12px; margin-bottom: 4px; }
@media (max-width: 600px) {
  .qbody .opts, .qbody .sol, .choice .qbody { text-align: left; }
  .rq { padding: 14px 14px; }
  .sec-tbl th, .sec-tbl td { padding: 9px 8px; font-size: 13.5px; }
  .qbody table.match td, .qbody table.match th { padding: 3px 5px; }
  .qbody table.match th { white-space: normal; }
}
@media (max-width: 480px) { .st-top { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); } }

.pyq-cta { display: flex; flex-direction: column; gap: 4px; margin: 22px 0 6px; padding: 16px 18px; border-radius: 14px; text-decoration: none;
  background: var(--saffron-soft); color: var(--ink); border: 1px solid #f1d9ad; }
.pyq-cta span { color: var(--muted); font-size: 14px; }
html[data-theme=dark] .pyq-cta { background: #3a2d12; border-color: #5c4720; }

/* "Powered by Atomos": the platform, small, under a teacher's own name and logo */
.st-powered { text-align: center; font-size: 12px; color: var(--muted); padding: 10px 16px 22px; }

/* a little air between statements A. B. C. / Statement-I, II / Assertion, Reason (teacher, Oct 2026) */
.q-st { margin-top: .4em; }
.q-st + .q-closing, .q-st + .opts { margin-top: .5em; }
.sol { line-height: 1.7; }
