/* exam.4ab.in — the bank browser + paper builder.
   Loads after tokens.css. Every colour comes from a token so light and dark
   are both correct without a second palette here. */

body { background: var(--bg); }

/* ---------- shell ---------- */
.top {
  position: sticky; top: 0; z-index: 40;
  background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.top__in {
  max-width: var(--wrap); margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: var(--on-navy); font: 700 15px/1 var(--serif);
  display: flex; align-items: center; justify-content: center;
}
.brand__txt { font: 700 16px/1.1 var(--serif); color: var(--ink); }
.brand__sub { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; margin-left: 6px; }
.tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid transparent;
  background: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tab:hover { background: var(--chip-bg); color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--navy); border-color: var(--navy); color: var(--on-navy);
}
.top__spacer { flex: 1 1 auto; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.iconbtn:hover { background: var(--card-2); }

/* ---------- layout ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 18px; }
.split { display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }

.side { position: sticky; top: 74px; max-height: calc(100vh - 92px); overflow: auto; }
@media (max-width: 1000px) { .side { position: static; max-height: none; } }
.side .card { padding: 14px; }

.fgroup { margin-bottom: 14px; }
.fgroup > label,
.fgroup > .flabel {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.inp, select.inp, textarea.inp {
  width: 100%; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
  font-size: 14px;
}
.inp:focus { border-color: var(--focus); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }

.checks { display: flex; flex-direction: column; gap: 5px; max-height: 210px; overflow: auto; padding-right: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--navy-2); flex: none; }
.check span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check b { font-weight: 600; color: var(--muted); font-size: 12px; flex: none; }

/* ---------- results ---------- */
.bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 14px;
}
.bar__count { font: 700 15px/1 var(--serif); color: var(--ink); }

.q {
  padding: 14px 16px 16px; margin-bottom: 14px;
}
.q__head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.q__no {
  font: 700 13px/1 var(--mono); color: var(--on-navy); background: var(--navy);
  padding: 5px 9px; border-radius: 7px; flex: none;
}
/* 2026-09-04: the question ID (qid) sits top-right of the card head, opposite
   the running #N at the left — .q__no stays flex:none/first-child, this is
   pushed to the far right with margin-left:auto so chips fill the space
   between them and wrap normally on narrow screens. */
.q__qid {
  font: 600 11px/1 var(--mono); color: var(--muted); background: var(--crop-bg);
  border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 8px;
  flex: none; margin-left: auto; letter-spacing: .02em;
}
.q__edit {
  flex: none; font-size: 11.5px; padding: 4px 8px;
}
.q__crop {
  background: var(--crop-bg); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px; overflow-x: auto;
}
/* A crop is a 150-DPI image of a printed page. Upscaling it past its natural
   width just makes it blurry, so it is allowed to be smaller but never bigger. */
.q__crop img { display: block; height: auto; max-width: 100%; }
.q__foot {
  margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.q__foot code { font-family: var(--mono); font-size: 11.5px; }

/* De-dup (2026-09-04): the other compilations this same question was printed in,
   and the staff-only note for a cluster whose copies print different answers. */
.q__also {
  margin-top: 6px; font-size: 11.5px; line-height: 1.5;
}
.q__conflict {
  margin-top: 8px; padding: 8px 10px; border-radius: var(--r-md);
  background: rgba(138, 109, 31, .10); border: 1px solid rgba(138, 109, 31, .32);
  font-size: 12px; line-height: 1.5; color: var(--body);
}

.ans { margin-top: 11px; padding: 11px 13px; border-radius: var(--r-md);
  background: var(--card-2); border: 1px solid var(--line-2); }
.ans__k { font: 700 13px/1 var(--sans); color: var(--green); margin-bottom: 7px; }
.ans__e { font-size: 13.5px; color: var(--body); white-space: pre-wrap; }
.ans__warn { color: var(--amber); font-weight: 600; font-size: 13px; }

/* The stem/option text is mangled by the PDF text layer, so it is shown only as
   what it is -- the string the search matched -- never as the question itself. */
.srctext {
  margin-top: 10px; padding: 9px 11px; border-radius: 9px;
  background: var(--chip-bg); border: 1px dashed var(--chip-line);
  font: 11.5px/1.5 var(--mono); color: var(--muted); white-space: pre-wrap;
  word-break: break-word;
}
.srctext b { display: block; font: 700 10px/1 var(--sans); letter-spacing: .07em;
  text-transform: uppercase; margin-bottom: 5px; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-wrap: wrap; padding: 6px 0 22px; }
.pager__n { font-size: 13px; color: var(--muted); }

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

/* ---------- paper builder ---------- */
.grid2 { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.pool {
  display: flex; align-items: baseline; gap: 8px; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--chip-bg); border: 1px solid var(--chip-line);
  margin-bottom: 14px;
}
.pool b { font: 700 22px/1 var(--serif); color: var(--navy); }
.pool span { font-size: 13px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 12px 14px; border-radius: var(--r-md); background: var(--card-2); border: 1px solid var(--line-2); }
.stat b { display: block; font: 700 21px/1.1 var(--serif); color: var(--ink); }
.stat span { font-size: 11.5px; color: var(--muted); letter-spacing: .03em; }

.sec { margin-bottom: 16px; }
.sec h3 { font-size: 16px; margin-bottom: 4px; }
.sec__i { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.plist { display: flex; flex-direction: column; gap: 8px; }
.pitem {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px;
  border-radius: 9px; background: var(--card-2); border: 1px solid var(--line-2);
  font-size: 13px;
}
.pitem__n { font: 700 12px/1 var(--mono); color: var(--navy); flex: none; width: 34px; }
.pitem__t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--body); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.note {
  padding: 10px 13px; border-radius: var(--r-md); font-size: 13px;
  background: rgba(217, 119, 6, .1); border: 1px solid rgba(217, 119, 6, .28);
  color: var(--amber); margin-bottom: 14px;
}
.note--info {
  background: var(--chip-bg); border-color: var(--chip-line); color: var(--body);
}

.busy { opacity: .55; pointer-events: none; }

/* ---------- boot / error ---------- */
#boot { padding: 60px 20px; text-align: center; color: var(--muted); }
#boot .bar2 { width: 220px; height: 4px; border-radius: 3px; background: var(--line);
  margin: 14px auto 0; overflow: hidden; }
#boot .bar2 i { display: block; height: 100%; width: 40%; background: var(--navy-2);
  animation: sl 1.1s ease-in-out infinite; }
@keyframes sl { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }
@media (prefers-reduced-motion: reduce) { #boot .bar2 i { animation: none; width: 100%; } }

/* ---------------------------------------------------------------- text-view (OCR) ----
   Replaces .q__crop's content for a question the server has typeset (see textview.js /
   exam-textview-build.php): real LaTeX via KaTeX, options each on their own line, every
   drawn structure its own small pixel-cropped image. .q__crop keeps its own padding/
   border from app.css above; this only styles what goes inside it. */
.q__crop--tv { padding: 14px 16px; }
.tv-wrap { font: 15px/1.55 var(--serif); color: var(--ink); }
.tv-stem { margin-bottom: 10px; }
.tv-stem__t, .tv-opt__t { white-space: pre-wrap; }
.tv-opts { display: flex; flex-direction: column; gap: 8px; }
.tv-opt { display: flex; align-items: flex-start; gap: 8px; }
.tv-opt__k { flex: none; font: 700 14px/1.55 var(--mono); color: var(--navy); }
.tv-opt__body { flex: 1 1 auto; }
/* Structures: small, separate, never merged into one picture — about 0.5-1.5in at the
   crops' own 150dpi, capped so a wide diagram never overwhelms a line of text.
   2026-09-04 [Sonnet·textview-organic]: inline-block, not block. A reaction scheme
   (reactant structure / arrow+conditions TEXT / product structure) is three separate
   parts in reading order — img, span, img — and `display:block` forced each onto its
   own line, stacking a left-to-right scheme vertically instead (the owner's brief:
   "keep them in reading order on one line"). inline-block lets consecutive img/text
   parts flow together like any other inline content, wrapping only when the container
   is too narrow — proven against a real match-the-column question (q i=793,
   "...column A... (P) [structure] (X) name (Q) [structure]...") whose 3 structures
   previously broke the list into 6 stacked blocks. A single stand-alone structure
   (still the common case for inorganic/physical) renders identically either way, since
   nothing else shares its line. */
.tv-stem__img, .tv-opt__img {
  display: inline-block; vertical-align: middle; max-width: 220px; height: auto; margin: 6px 8px 6px 0;
  border: 1px solid var(--line-2); border-radius: 6px; background: #fff;
}
.tv-opt .tv-opt__img { margin: 4px 8px 4px 0; }
/* KaTeX inherits the surrounding text colour/size rather than its own defaults, so it
   reads as part of the question instead of a visually distinct plugin. */
.tv-wrap .katex { font-size: 1.02em; color: inherit; }

/* 2026-09-04 [Sonnet·textview-quality] — display blocks, tables, the "being typed"
   placeholder. A reaction scheme (Mathpix `math` line) renders as its OWN block, on its
   own line, directly under the sentence it follows — the owner's report was that this
   used to render centred/right-floated with the sentence hanging alone on the left.
   KaTeX's OWN default for `\[...\]`/`$$...$$` (.katex-display) is centred; both the
   wrapper AND the KaTeX-generated element itself are overridden here so nothing inside
   a .tv-block can still end up centred by KaTeX's own CSS. */
.tv-block { display: block; text-align: left; margin: 8px 0; overflow-x: auto; }
.tv-block .katex-display,
.tv-wrap .katex-display { text-align: left; margin: 0.4em 0; }
/* KaTeX centres the equation on the INNER element (`.katex-display > .katex`), not on
   .katex-display — so overriding only the wrapper above left a reaction scheme sitting in
   the middle of the card (measured 2026-09-05: content offset 277px inside an 856px block).
   This is the selector that actually moves it. */
.tv-block .katex-display > .katex,
.tv-wrap .katex-display > .katex { text-align: left; }

/* Match-the-following / any Mathpix table region — a real <table>, never merged into
   surrounding prose or into an option's own text (see exam-textview-build.php V2). */
.tv-tablewrap { overflow-x: auto; margin: 8px 0; }
.tv-table { border-collapse: collapse; font-size: 0.95em; }
.tv-table th, .tv-table td {
  border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; vertical-align: top;
}
.tv-table th { background: var(--card-2); font-weight: 700; }

/* A question the OCR pass could not usefully type — never falls back to the crop
   either (owner's rule: the reader must never see the original photo). */
.tv-pending { padding: 4px 0; }
.tv-pending__t { color: var(--muted); font-style: italic; margin: 0; }
