/* The signed-in application: top bar, tabs, the two-pane question paper / answer key screens. */

/* ---------- top bar ---------- */
/* "Skip to content" for keyboard users: out of sight until it has the focus. (Its own class name: a plain .skip once
   styled the "not asked" lines of Template Management's header step too, and pulled them out of their box.) */
.skiplink { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: var(--r-ctl); background: var(--blue); color: var(--blue-ink); font-weight: 600; text-decoration: none; }
.skiplink:focus { top: 10px; }
.appbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: stretch; gap: 8px; padding: 0 20px; min-height: 58px;
}
.appbar .brandmark { align-self: center; margin-right: 14px; font-size: calc(1.05 * var(--fz)); white-space: nowrap; flex: none; }
.appbar > nav { display: flex; min-width: 0; }
.tabs { display: flex; align-items: stretch; gap: 2px; margin: 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > li { display: flex; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--ink-2);
  font-weight: 600; font-size: calc(.9375 * var(--fz)); text-decoration: none; white-space: nowrap; border-radius: 0;
}
.tab:hover { color: var(--ink); background: var(--hover); }
.tab[aria-current='page'] { color: var(--ink); }
.tab[aria-current='page']::after { /* the red correction-pen line under the tab you are on */
  content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--tab-mark);
}
.tab:focus-visible { outline-offset: -3px; }
.appbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.schoolchip { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 4px 12px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: calc(.875 * var(--fz)); font-weight: 600; color: var(--ink-2); }
.schoolchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.usermenu { position: relative; }
.userbtn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 3px 12px 3px 4px; border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); background: var(--surface); cursor: pointer; font-weight: 600; font-size: calc(.9 * var(--fz)); color: var(--ink);
}
.userbtn:hover { background: var(--hover); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-text); font-weight: 700; font-size: calc(.85 * var(--fz)); letter-spacing: .02em; }
.userbtn .who { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* menus and pop-up panels are always solid (--surface-solid), even in a theme whose panels are glass */
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 300px; padding: 6px; border: 1px solid var(--line-strong);
  border-radius: 14px; background: var(--surface-solid, var(--surface)); box-shadow: var(--shadow-pop);
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-weight: 600; font-size: calc(.9375 * var(--fz)); text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.menu-item .icon { color: var(--ink-3); }
/* the user menu: a card with who you are, what you can do, and Sign out on its own */
.uc-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 14px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--brand-tile) 11%, var(--surface-solid, var(--surface)));
}
.avatar.lg { width: 46px; height: 46px; font-size: calc(1.05 * var(--fz)); background: var(--brand-tile); color: #fff; }
.uc-who { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 4px; min-width: 0; }
.uc-name { font-size: calc(1.02 * var(--fz)); line-height: 1.25; overflow-wrap: anywhere; }
.uc-role { padding: 1px 9px; border-radius: var(--r-pill); background: var(--surface-solid, var(--surface)); border: 1px solid var(--line-strong); color: var(--ink-2); font-size: calc(.78 * var(--fz)); font-weight: 700; }
/* a long school name wraps inside the card (it never runs off the page) */
.uc-school { display: flex; align-items: flex-start; gap: 6px; width: 100%; max-width: 100%; padding: 6px 8px; border-radius: 8px;
  background: var(--surface-solid, var(--surface)); color: var(--ink-2); font-size: calc(.85 * var(--fz)); line-height: 1.35; }
.uc-school span { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.uc-school .icon { flex: none; margin-top: 1px; color: var(--ink-3); }
.uc-id { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px 8px; color: var(--ink-3); font-size: calc(.85 * var(--fz)); }
.uc-id b { color: var(--ink); font-weight: 700; overflow-wrap: anywhere; text-align: right; }
.uc-items { display: grid; gap: 2px; padding: 4px 0; border-top: 1px solid var(--line); }
.uc-foot { padding-top: 4px; border-top: 1px solid var(--line); }
.menu-item.signout { color: var(--red); }
.menu-item.signout .icon { color: var(--red); }
.menu-item.signout:hover { background: var(--red-soft); }
/* the spell check switch */
.menu-item .sw { position: relative; flex: none; width: 34px; height: 20px; margin-left: auto; border-radius: 999px; background: var(--line-strong); transition: background-color .15s; }
.menu-item .sw i { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform .15s; }
.menu-item[aria-checked='true'] .sw { background: var(--blue); }
.menu-item[aria-checked='true'] .sw i { transform: translateX(14px); }

/* ---------- pages ---------- */
.page { width: min(100%, 1560px); margin: 0 auto; padding: 18px 24px 48px; }
.pagehead { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: 0 0 16px; }
.pagehead h1 { font-size: calc(1.45 * var(--fz)); }
.pagehead .sub { color: var(--ink-3); font-size: calc(.9375 * var(--fz)); }
.schoolpick { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.schoolpick .lbl { white-space: nowrap; }
.schoolpick select { width: auto; min-width: 220px; max-width: 320px; }
.emptystate { max-width: 560px; margin: 8vh auto; padding: 28px; text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-panel); }
.emptystate h2 { margin: 12px 0 8px; }
.emptystate p { color: var(--ink-2); margin-bottom: 16px; }
.emptystate .icon { margin: 0 auto; color: var(--ink-3); }

/* ---------- the two-pane tools ---------- */
.bench { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 18px; align-items: start; }
/* the question paper and answer key screens keep the sizes they were given in Version 5 (the rest of the site is a
   little smaller: --fz in base.css) */
.bench { --fz: 1rem; font-size: var(--fz); }
.wizard {
  position: sticky; top: 76px; display: flex; flex-direction: column; max-height: calc(100vh - 96px); padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: 0 1px 2px rgb(18 32 63 / 6%);
}
.wz-head { padding: 18px 20px 4px; }
.wz-head .chip { margin-bottom: 8px; }
.wz-head h2 { margin-bottom: 2px; overflow-wrap: anywhere; }
.wz-body { padding: 14px 20px 4px; overflow-y: auto; min-height: 90px; }
.wz-body .err { margin-bottom: 0; }
.wz-actions { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); margin-top: 8px; }
.wz-actions .btn.primary { min-width: 120px; }
.wz-note { margin: 0 0 14px; color: var(--ink-2); font-size: calc(.9375 * var(--fz)); }
.wz-stack { display: grid; gap: 10px; }
.wz-stack .btn { justify-content: flex-start; }

.paper-pane { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.pane-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.pane-bar .status { font-weight: 600; color: var(--ink-2); font-size: calc(.9375 * var(--fz)); }
.pane-bar .save { color: var(--ink-3); font-size: calc(.875 * var(--fz)); }
.paper-pane .desk { height: calc(100vh - 170px); min-height: 420px; }
.seg { display: none; }

.pick { display: grid; gap: 8px; margin-top: 6px; }
.pick.off { opacity: .5; pointer-events: none; }
.or { margin: 12px 0 8px; color: var(--ink-3); font-size: calc(.875 * var(--fz)); text-align: center; }
.drop {
  display: grid; gap: 4px; place-items: center; padding: 26px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); border-radius: var(--r-panel); background: var(--surface-2); color: var(--ink-2);
}
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop strong { color: var(--ink); font-size: calc(1.05 * var(--fz)); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.qbox { margin: 0 0 14px; padding: 12px 14px; background: var(--surface-2); border-left: 3px solid var(--pen-red); border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.qsec { margin-bottom: 4px; color: var(--ink-3); font-size: calc(.8125 * var(--fz)); font-weight: 600; }
.qtext { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-paper); font-size: calc(1.05 * var(--fz)); line-height: 1.4; }
.qtext + .qtext { margin-top: 6px; }

textarea.line { min-height: 42px; resize: none; overflow: hidden; }
textarea.line.tall { min-height: 68px; }

/* ---------- the two wizards are a size smaller than the rest of the site ----------
   The paper beside them is what matters, so the steps use smaller text, lower boxes and tighter spacing.
   (The paper pane itself is not changed.) */
.wizard { font-size: calc(.9375 * var(--fz)); }
.wizard .wz-head { padding: 13px 16px 2px; }
.wizard .wz-head .chip { margin-bottom: 5px; padding: 1px 9px; font-size: calc(.75 * var(--fz)); }
.wizard .wz-head h2 { font-size: calc(1.12 * var(--fz)); }
.wizard .wz-body { padding: 10px 16px 2px; }
.wizard .wz-actions { gap: 6px; padding: 9px 14px 11px; margin-top: 4px; }
.wizard .wz-actions .btn.primary { min-width: 100px; }
.wizard .wz-note { margin-bottom: 10px; font-size: calc(.84 * var(--fz)); }
.wizard .wz-stack { gap: 7px; }
.wizard .btn { min-height: 34px; padding: 0 12px; font-size: calc(.86 * var(--fz)); gap: 6px; }
.wizard .btn.sm { min-height: 28px; padding: 0 8px; font-size: calc(.8 * var(--fz)); }
.wizard .fld { gap: 3px; margin-bottom: 9px; }
.wizard .lbl { font-size: calc(.8 * var(--fz)); }
.wizard .hint { font-size: calc(.76 * var(--fz)); }
.wizard :is(input:where(:not([type='radio'], [type='checkbox'], [type='file'], [type='range'])), select, textarea) {
  min-height: 34px; padding: 5px 10px; font-size: calc(.9 * var(--fz));
}
.wizard select { padding-right: 32px; background-position: right 11px center; }
.wizard textarea { min-height: 64px; }
.wizard textarea.line { min-height: 34px; }
.wizard textarea.line.tall { min-height: 54px; }
.wizard .choices { gap: 6px; margin-bottom: 10px; }
.wizard .choice { gap: 8px; padding: 7px 10px; font-size: calc(.88 * var(--fz)); }
.wizard .checkline { gap: 8px; font-size: calc(.88 * var(--fz)); }
.wizard input[type='radio'], .wizard input[type='checkbox'] { width: 16px; height: 16px; }
.wizard .qbox { margin-bottom: 10px; padding: 8px 11px; }
.wizard .qtext { font-size: calc(.96 * var(--fz)); }
.wizard .drop { padding: 16px 12px; }
.wizard .drop strong { font-size: calc(.95 * var(--fz)); }
.wizard .or { margin: 8px 0 6px; }
.wizard .err { font-size: calc(.84 * var(--fz)); }

/* ---------- picture picker (Label the diagram) ---------- */
.pic-pick { display: grid; gap: 8px; margin: 0 0 12px; }
.pic-pick .drop { padding: 12px 10px; }
.pic-pick .drop .icon { width: 22px; height: 22px; }
.pic-stage { container-type: inline-size; width: 86%; margin: 0 auto; padding: 7px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface-2); }
.pic-stage .hint { font-size: calc(.72 * var(--fz)); }
.pic-page { position: relative; width: 100%; margin: 0 auto; background: #fff; border: 1px solid var(--line-strong); box-shadow: var(--shadow-sheet); overflow: hidden; }
.pic-page img { position: absolute; left: 50%; top: 0; transform: translateX(-50%); max-width: none; outline: 2px solid var(--blue); }
.pic-ctl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.pic-ctl .fld { margin: 0; }
.pic-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.pic-align { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.pic-align .lbl { margin: 0; }
.segbtns { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface-2); }
.segbtns .btn { border-color: transparent; background: transparent; box-shadow: none; }
.segbtns .btn[aria-pressed='true'] { background: var(--surface); border-color: var(--blue); color: var(--blue-text); }
.pic-range { width: 100%; accent-color: var(--blue); }

/* ---------- dialogs with forms ---------- */
dialog.modal form .fld:last-of-type { margin-bottom: 4px; }
dialog.modal .row.end { justify-content: flex-end; }
dialog.modal.scroll { padding: 0; max-height: calc(100vh - 32px); }
dialog.modal.scroll[open] { display: flex; flex-direction: column; }
dialog.modal.scroll > form, dialog.modal.scroll > div { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.modal-head { padding: 22px 24px 0; }
.modal-head h3 { margin-bottom: 8px; }
.modal-head .modal-text { margin-bottom: 14px; }
.modal-body { padding: 4px 24px 0; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal-foot { margin-top: 0 !important; padding: 12px 24px 18px; border-top: 1px solid var(--line); background: var(--surface-solid, var(--surface)); border-radius: 0 0 var(--r-panel) var(--r-panel); }

/* ---------- a top bar with more tabs than fit (app.js fitBar): first without icons, then the tabs on a row of their own ---------- */
.appbar.compact .tab .icon { display: none; }
.appbar.compact .tab { padding: 0 13px; }
.appbar.compact .userbtn .who { display: none; }
.appbar.tight .tab { padding: 0 9px; }
.appbar.tight .tabs { gap: 0; }
.appbar.stacked { flex-wrap: wrap; padding: 0 12px; row-gap: 0; }
.appbar.stacked .brandmark { margin-right: auto; padding: 8px 0; }
.appbar.stacked .appbar-end { margin-left: 0; padding: 8px 0; gap: 8px; }
.appbar.stacked > nav { order: 3; flex: 0 0 100%; margin: 0 -12px; padding: 0 8px; border-top: 1px solid var(--line); }
.appbar.stacked .tabs { width: 100%; }
.appbar.stacked .tab { min-height: 44px; }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .bench { grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); }
}
@media (max-width: 1500px) {
  .tab .icon { display: none; }
  .tab { padding: 0 13px; }
  .userbtn .who { display: none; }
  .userbtn { padding-right: 10px; }
}
@media (max-width: 1180px) {
  .appbar { flex-wrap: wrap; padding: 0 12px; row-gap: 0; }
  .appbar .brandmark { margin-right: auto; padding: 8px 0; }
  .appbar-end { margin-left: 0; padding: 8px 0; gap: 8px; }
  .appbar > nav { order: 3; flex: 0 0 100%; margin: 0 -12px; padding: 0 8px; border-top: 1px solid var(--line); }
  .tabs { width: 100%; }
  .tab { min-height: 44px; }
}
@media (max-width: 900px) {
  .appbar .brandmark span { display: none; }
  .schoolchip { display: none; }
  .userbtn { padding-right: 4px; }
  .page { padding: 14px 12px 40px; }
  .bench { grid-template-columns: minmax(0, 1fr); }
  .wizard { position: static; max-height: none; }
  .wz-actions { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-radius: 0 0 var(--r-panel) var(--r-panel); }
  .paper-pane .desk { height: 70vh; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); }
  .seg button { min-height: 38px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; }
  .seg button[aria-pressed='true'] { background: var(--blue); color: var(--blue-ink); }
  .bench[data-view='build'] .paper-pane, .bench[data-view='preview'] .wizard { display: none; }
  .schoolpick { margin-left: 0; width: 100%; }
  .schoolpick select { flex: 1; max-width: none; min-width: 0; }
  .pic-ctl { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .tab { padding: 0 12px; }
}

/* ---------- spell check: a see-through copy over the text box draws the red underlines ---------- */
.spell { position: relative; }
.sp-over { position: absolute; z-index: 1; margin: 0; overflow: hidden; pointer-events: none; color: transparent; background: transparent;
  border-style: solid; border-color: transparent; white-space: pre-wrap; overflow-wrap: break-word; }
.sp-bad { text-decoration: underline wavy #e5484d; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-skip-ink: none; }
.sp-note { display: inline-flex; align-items: center; gap: 6px; justify-self: start; width: fit-content; margin-top: 6px; padding: 3px 10px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); border-radius: var(--r-pill); background: var(--red-soft); color: var(--red); font-size: calc(.8125 * var(--fz)); font-weight: 600; }
.sp-note > * { pointer-events: none; }
.sp-note:hover { background: color-mix(in srgb, var(--red) 16%, var(--red-soft)); }
.sp-pop { position: fixed; z-index: 1000; display: grid; gap: 8px; width: min(320px, calc(100vw - 16px)); padding: 10px 12px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); box-shadow: 0 12px 32px rgb(0 0 0 / .18); }
.sp-head { display: flex; align-items: center; gap: 8px; font-size: calc(.9 * var(--fz)); }
.sp-head svg { flex: none; color: var(--red); }
.sp-sugs { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-sug { font-weight: 700; }
.sp-acts { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }

