/* chem-hw.io: minimal, white, phone-first */
:root {
  color-scheme: only light;
  --ink: #15181c;
  --muted: #646b75;
  --faint: #9aa1aa;
  --line: #e3e6ea;
  --soft: #f5f6f8;
  --accent: #1f4fd1;
  --accent-soft: #eef2fd;
  --ok: #1a9a52;
  --ok-soft: #ebf8f0;
  --bad: #d23c3c;
  --bad-soft: #fdf0f0;
  --late: #b45309;
  --late-soft: #fff4e5;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { background: #fff; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: #fff; color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
p { margin: 0 0 12px; }
sub, sup { font-size: .72em; line-height: 0; }
.ce { white-space: nowrap; }
mjx-container { max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }
.muted { color: var(--muted); }
.ink { color: var(--ink); }
.small { font-size: .88rem; }
.wrap { max-width: 680px; margin: 0 auto; padding: 20px 16px 64px; }
.wrap.wide { max-width: 1000px; }

/* ---------- Buttons and forms ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  border: 1.5px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: 10px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
.btn.ghost, button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover, button.ghost:hover { border-color: var(--faint); }
button.danger, .btn.danger { background: #fff; color: var(--bad); border-color: #f1c4c4; }
button.linkish { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 500; font-size: .9rem; }
button.linkish:hover { color: var(--ink); }
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=datetime-local]:disabled { color: var(--faint); background: var(--soft); }  /* "No due date" checked */
textarea { min-height: 140px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 12px 0; }
.check input { margin-top: 5px; width: 18px; height: 18px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 200px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.error { color: var(--bad); font-weight: 500; margin: 10px 0; }
.flash {
  max-width: 680px; margin: 12px auto 0; padding: 10px 14px; border-radius: 10px;
  background: var(--accent-soft); color: #1b3a8f; font-size: .93rem;
}
.wrap.wide + .flash, body .flash { width: calc(100% - 32px); }

/* ---------- Sign in (teacher pages), and the public front page: student sign in at the top, then what chem-hw.io is ---------- */
.signin { position: relative; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.home .signin { min-height: 0; place-items: start center; padding: clamp(24px, 5vh, 56px) 16px 4px; }  /* teacher login sits just above the line */
.teacher-link { margin-top: 26px; font-size: 1.05rem; color: #b8bec6; text-decoration: none; letter-spacing: .02em; }
.teacher-link:hover { color: #8a8f98; }
.signin form { width: 100%; max-width: 320px; text-align: center; }
.prose { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.prose h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 10px; }
.prose h2 { font-size: 1.08rem; margin: 26px 0 6px; }
.prose p, .prose li { line-height: 1.6; color: #3a4048; }
.prose ul { margin: 6px 0; padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose .lede { font-size: 1.05rem; }
/* Below the sign-in box: there for anyone looking the site up, so kept small and grey */
.home-about { padding-top: 24px; padding-bottom: 4px; border-top: 1px solid var(--line); }
.home-about h1 { font-size: 1rem; color: #5b626c; margin-bottom: 4px; }
.home-about h2 { font-size: .9rem; color: #5b626c; margin: 16px 0 4px; }
.home-about p, .home-about .lede { font-size: .86rem; line-height: 1.55; color: var(--muted); }
.home-about a { color: var(--muted); text-decoration: underline; }
.legal { padding-top: 16px; padding-bottom: 8px; }
.home-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; max-width: 680px; margin: 28px auto 0;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.home-foot a { color: var(--muted); }
/* The Curie-ous Kitten (one of the pets) sits just above the footer's line at the left: a small playful touch */
.home-kitten { max-width: 680px; margin: 12px auto 0; padding: 0 16px; }
.home-kitten span { display: block; width: 32px; height: 32px; }
.home-kitten .pet-svg { transition: transform .2s ease; }
.home-kitten span:hover .pet-svg { transform: translateY(-3px); }
.home-kitten + .home-foot { margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .home-kitten .pet-svg { transition: none; } }
.wordmark {
  display: inline-block; /* so the gradient spans just the word */
  font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 28px;
  color: #c4314b; /* fallback if gradient text isn't supported */
  background: linear-gradient(90deg, #e63946 0%, #9b3fd0 50%, #2563eb 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.code-input {
  text-align: center; font-size: 1.6rem !important; letter-spacing: .12em; font-variant-numeric: tabular-nums;
  padding: 12px !important;
}
.signin button { width: 100%; margin-top: 14px; padding: 12px; font-size: 1rem; }

/* ---------- Student assignment list ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; max-width: 680px; margin: 0 auto; }
/* The top margin starts the list where the "All caught up" line starts; under that line it merges with the line's own gap. */
.alist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.alist a, .alist .closed {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink);
}
.alist a:hover { border-color: var(--faint); text-decoration: none; }
.alist .closed { color: var(--muted); }
.alist .t { font-weight: 600; }
.alist .m { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.alist .s { text-align: right; font-size: .88rem; color: var(--muted); white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.alist .s.done { color: var(--ok); font-weight: 600; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; }
.badge.late { background: var(--late-soft); color: var(--late); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.gray { background: var(--soft); color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 48px 0; }

/* Desktop: the student pages (assignment list and assignments, plus the teacher's
   full-page preview) a bit bigger, the same as browser zoom at 125%. Not the
   preview inside the question picker. */
@media (min-width: 900px) {
  body.student-page, body.player-page:not(.embed) { zoom: 1.25; }
}

/* ---------- Player ---------- */
.player-page { background: #fff; }
/* Student preview shown inside the question picker's viewer: just the question. */
.embed .pbar, .embed .banner.preview, .embed .next-row { display: none; }
.embed .qwrap { padding-top: 14px; padding-bottom: 28px; }
.pbar {
  position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.dot { flex: 0 0 auto; width: 24px; height: 24px; padding: 0; border: 0; background: none; display: grid; place-items: center; border-radius: 6px; }
.dot i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; transition: transform .15s; }
.dot.cur { background: var(--soft); }
.dot.cur i { transform: scale(1.35); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }
.dot.full i { background: var(--ok); }
.dot.half i { background: #8fd1a9; }
.dot.zero i { background: var(--bad); }
.dot.tried i { background: #f2b8b8; }
/* One slim row: the dots scroll underneath the back arrow and the score, which sit on top
   with a soft white fade. On wide screens the row stays in the same column as the question.
   The row and the arrow/score layer are both exactly 38px tall: iPhone Safari adds about
   8px of empty space under a sideways-scrolling row, which pushed the dots off-center. */
.pbar-in { position: absolute; top: 0; left: 0; right: 0; height: 38px; max-width: 680px; margin: 0 auto; z-index: 1;
  display: flex; justify-content: space-between; align-items: stretch; pointer-events: none; }
.pbar .back, .pbar .score { display: flex; align-items: center; pointer-events: auto; }
.pbar .back { color: var(--ink); padding: 0 22px 0 14px; background: linear-gradient(270deg, rgba(255,255,255,0), #fff 20px); }
.pbar .back:hover { text-decoration: none; }
.pbar .back svg { display: block; width: 12px; height: 20px; }
.pbar .score { font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
  padding: 0 14px 0 34px; background: linear-gradient(90deg, rgba(255,255,255,0), #fff 28px); }
/* Center the score by the height of its digits, not the font's line, so it lines up
   with the dots and the arrow the same way in every browser. */
.pbar .score-n { display: block; text-box: trim-both cap alphabetic; }
@supports not (text-box: trim-both cap alphabetic) { .pbar .score-n { position: relative; top: -1px; } }
.dots { position: relative; max-width: 680px; height: 38px; margin: 0 auto; display: flex; gap: 2px;
  overflow-x: auto; overflow-y: hidden; padding: 7px 100px 7px 50px; scrollbar-width: none; }
.dots::-webkit-scrollbar { display: none; }
.dots.few { padding-left: 100px; }  /* every dot fits: center them under the score and arrow */
.dot:first-child { margin-left: auto; }  /* a short assignment's dots sit in the middle */
.dot:last-child { margin-right: auto; }
.qwrap { max-width: 680px; margin: 0 auto; padding: 18px 16px 120px; }
.banner { font-size: .85rem; padding: 8px 12px; border-radius: 10px; margin-bottom: 14px; }
.banner.late { background: var(--late-soft); color: var(--late); }
.banner.preview { background: var(--accent-soft); color: #1b3a8f; }
.model { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.model-title { font-weight: 600; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.passage { font-size: .95rem; color: #2b3036; }
.passage p { margin: 0 0 8px; }
.fig { margin: 14px 0; text-align: center; }
.fig img { max-width: 100%; height: auto; cursor: zoom-in; }
.choice .fig img { cursor: inherit; }  /* a tap on a choice's picture picks the choice (no zoom) */
.qlabel { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stem { font-weight: 600; font-size: 1.05rem; margin-bottom: 14px; }
.choices { display: grid; gap: 10px; }
.choice {
  width: 100%; text-align: left; display: flex; gap: 12px; align-items: flex-start;
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  transition: border-color .15s, box-shadow .2s, background .2s;
}
.choice:hover:not(:disabled) { border-color: var(--faint); }
.choice:disabled { opacity: 1; cursor: default; }
.choice .l { font-weight: 700; color: var(--muted); min-width: 1.1em; }
.choice .c { flex: 1; min-width: 0; }
.choice .c .fig { text-align: left; margin: 6px 0 0; }
.choice .box { width: 20px; height: 20px; border: 1.5px solid var(--faint); border-radius: 5px; flex: 0 0 auto; margin-top: 2px; display: grid; place-items: center; }
.choice.sel { border-color: var(--ink); }
.choice.sel .box { background: var(--ink); border-color: var(--ink); }
.choice.sel .box::after { content: ""; width: 9px; height: 5px; border: solid #fff; border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px); }
.choice.picked { border-color: var(--ink); background: var(--soft); }  /* multiple choice, before Check */
.choice.picked .l { color: var(--ink); }
.choice.pending { border-color: var(--ink); background: var(--soft); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 0 0 4px rgba(26,154,82,.18); }
.choice.right .l { color: var(--ok); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 0 0 4px rgba(210,60,60,.14); }
.choice.wrong .l { color: var(--bad); }
.choice.right.sel .box { background: var(--ok); border-color: var(--ok); }
.choice.wrong.sel .box { background: var(--bad); border-color: var(--bad); }
.choice.reveal .box { border-color: var(--ok); }
.choice.reveal { border-color: var(--ok); border-style: dashed; }
.choice.reveal .l { color: var(--ok); }
.choice.faded { opacity: .55; }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(26,154,82,.45); } 100% { box-shadow: 0 0 0 4px rgba(26,154,82,.18); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.choice.right.anim { animation: glow .45s ease-out; }
.choice.wrong.anim { animation: shake .3s ease-in-out; }
.qtools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
/* numeric answers */
.numrow { display: flex; align-items: center; gap: 10px; }
.numin {
  font: inherit; font-size: 1.25rem; font-variant-numeric: tabular-nums; width: 100%; max-width: 240px;
  padding: 11px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .2s, background .2s;
}
.numin:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.numin.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 0 0 4px rgba(26,154,82,.18); color: var(--ink); }
.numin.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 0 0 4px rgba(210,60,60,.14); }
.numin.right.anim { animation: glow .45s ease-out; }
.numin.wrong.anim { animation: shake .3s ease-in-out; }
.numrow .unit { font-size: 1.05rem; color: var(--muted); }
.qwrap .tried { margin-top: 8px; }  /* the "You tried:" line; not the top-bar dot, which also has class "tried" */
/* written answers */
.wtext {
  font: inherit; width: 100%; min-height: 88px; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink); resize: vertical; line-height: 1.45;
}
.wtext:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wcount { margin-left: auto; font-variant-numeric: tabular-nums; }
.wtry { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.wtry-head { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; margin-bottom: 6px; }
.wtry-head .badge { font-size: .72rem; }
.wtry-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wtry-fb { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .95rem; }
.wtry button { margin-top: 10px; }
.wtry.v-full { border-color: var(--ok); background: var(--ok-soft); }
.wtry.v-full .badge { background: #fff; color: var(--ok); }
.wtry.v-partial { border-color: #e2b04a; background: #fffaf0; }
.wtry.v-partial .badge { background: #fff; color: var(--late); }
.wtry.v-none { border-color: #f1c4c4; background: var(--bad-soft); }
.wtry.v-none .badge { background: #fff; color: var(--bad); }
.wtry.v-pending { border-style: dashed; }
.wtry.v-pending .badge { background: var(--soft); color: var(--muted); }
.note.answer { background: var(--ok-soft); }

/* ---------- Written-answer feedback: a little sparkle, nothing loud ---------- */
.wtry-fb.glow {
  position: relative; overflow: hidden; margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(120deg, rgba(230,57,70,.55), rgba(155,63,208,.55), rgba(37,99,235,.55)) border-box;
}
.fb-label { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 4px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; }
.fb-label span {
  background: linear-gradient(90deg, #e63946, #9b3fd0 55%, #2563eb);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: #7b3fbf;
}
.fb-spark { width: 15px; height: 15px; flex: 0 0 auto; overflow: visible; }
.fb-spark path { fill: url(#fbg); transform-box: fill-box; transform-origin: center; }
.fb-text { font-size: .95rem; }

/* When feedback has just arrived: one soft glow, a light sweep, words fading in. */
.wtry-fb.glow.fresh { animation: fbGlow 1.9s ease-out 1; }
.wtry-fb.glow.fresh::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(155,63,208,.12) 50%, transparent 65%);
  transform: translateX(-100%); animation: fbSweep 1.3s ease-out .1s 1;
}
.wtry-fb.glow.fresh .fb-spark .s1 { animation: fbTwinkle 1.2s ease-in-out 2; }
.wtry-fb.glow.fresh .fb-spark .s2 { animation: fbTwinkle 1.2s ease-in-out .35s 2; }
.fb-text span { display: inline-block; animation: fbWord .45s ease-out both; }

/* While an answer is being checked */
.checking {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px dashed rgba(155,63,208,.45); background: #fcfaff; font-size: .93rem; font-weight: 600;
}
.checking .fb-spark { width: 18px; height: 18px; }
.checking .fb-spark .s1 { animation: fbTwinkle 1.6s ease-in-out infinite; }
.checking .fb-spark .s2 { animation: fbTwinkle 1.6s ease-in-out .5s infinite; }
.shimmer {
  background: linear-gradient(90deg, #8a8f98 0%, #8a8f98 35%, #9b3fd0 47%, #2563eb 53%, #8a8f98 65%, #8a8f98 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  color: #6b46c1; animation: fbShimmer 1.8s linear infinite;
}

@keyframes fbGlow {
  0% { box-shadow: 0 0 0 0 rgba(155,63,208,0); }
  30% { box-shadow: 0 0 16px 2px rgba(155,63,208,.22); }
  100% { box-shadow: 0 0 0 0 rgba(155,63,208,0); }
}
@keyframes fbSweep { to { transform: translateX(100%); } }
@keyframes fbTwinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(.55) rotate(25deg); opacity: .6; }
}
@keyframes fbWord { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes fbShimmer { from { background-position: 100% 0; } to { background-position: 0% 0; } }

@media (prefers-reduced-motion: reduce) {
  .wtry-fb.glow.fresh, .wtry-fb.glow.fresh::after, .fb-spark path, .fb-text span, .shimmer { animation: none !important; }
  .wtry-fb.glow.fresh::after { display: none; }
}
.feedback { font-weight: 600; font-size: .95rem; min-height: 1.5em; margin-top: 14px; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.note { border-radius: 10px; padding: 10px 14px; margin-top: 12px; font-size: .95rem; }
.note.hint { background: var(--accent-soft); }
.note.explain { background: var(--soft); }
.note b { font-weight: 700; }
.next-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 18px; }
.finish { text-align: center; padding: 48px 0; }
.finish .big { font-size: 3rem; font-weight: 700; letter-spacing: -0.02em; }
.zoom {
  position: fixed; inset: 0; z-index: 50; background: #fff; overflow: auto; -webkit-overflow-scrolling: touch;
  display: flex; align-items: flex-start; justify-content: flex-start; padding: 56px 12px 24px;
}
.zoom img { max-width: none; height: auto; flex: 0 0 auto; margin: 0 auto; }
.zoom .close {
  position: fixed; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--ink); color: #fff; border: 0; font-size: 1.4rem; line-height: 1; padding: 0;
}

/* ---------- Teacher ---------- */
.tnav { border-bottom: 1px solid var(--line); }
.tnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; max-width: 1000px; margin: 0 auto; flex-wrap: wrap; }
.tnav .brand, .topbar .brand { /* the logo, teacher and student pages */
  font-weight: 800; letter-spacing: -0.01em;
  color: #c4314b; /* fallback if gradient text isn't supported */
  background: linear-gradient(90deg, #e63946 0%, #9b3fd0 50%, #2563eb 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.tnav .brand:hover, .topbar .brand:hover { text-decoration: none; }
.tnav nav { display: flex; gap: 6px 18px; align-items: center; flex-wrap: wrap; }
.tnav nav a { color: var(--muted); font-weight: 500; font-size: .95rem; }
.tnav nav a.on { color: var(--ink); }
.tnav form { margin: 0; }
@media (max-width: 480px) {
  .tnav nav { gap: 6px 11px; }
  .tnav nav a, .tnav nav .linkish { font-size: .87rem; }
  .nav-long { display: none; }
}
.card { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
/* Assigned work: one row per assignment, one tile per class (finished count and a thin progress line) */
.aw-row { padding: 14px 2px; border-bottom: 1px solid var(--line); }
.aw-row:first-child { border-top: 1px solid var(--line); }
.aw-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.aw-name { font-weight: 600; }
.aw-due { font-size: .88rem; color: var(--muted); white-space: nowrap; }
.aw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.aw-chip { position: relative; display: flex; flex-direction: column; min-width: 104px; padding: 6px 12px 10px;
  border: 1.5px solid var(--line); border-radius: 10px; color: var(--ink); overflow: hidden; }
.aw-chip:hover { border-color: var(--faint); text-decoration: none; }
.aw-class { font-size: .74rem; font-weight: 700; color: var(--muted); }
.aw-count { font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.aw-count small { font-weight: 400; color: var(--muted); font-size: .8em; }
.aw-note { font-size: .72rem; font-weight: 600; color: #3f454d; line-height: 1.3; margin-top: 1px; }
.aw-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--soft); }
.aw-bar i { display: block; height: 100%; background: var(--ok); }
.aw-analysis { background: var(--soft); border-color: var(--soft); }  /* after an assignment's class tiles */
.aw-analysis:hover { border-color: var(--faint); }
@media (max-width: 520px) {
  .aw-head { flex-direction: column; align-items: flex-start; gap: 0; }
  .aw-chip { min-width: 0; flex: 0 0 calc((100% - 16px) / 3); }
}
/* Account page */
.stack-form { display: grid; gap: 8px; max-width: 340px; margin: 6px 0 0; }
.invite-box { border: 1.5px solid var(--accent); border-radius: 10px; padding: 12px; margin: 10px 0; background: #f7faff; }
/* Uploader name on shared library sets */
.chip { display: inline-block; font-size: .74rem; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px;
  background: var(--soft); color: var(--muted); vertical-align: 2px; margin-left: 6px; white-space: nowrap; }
/* Library tabs */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin: 18px 0 4px; }
.tabs a { padding: 8px 0; color: var(--muted); font-weight: 600; font-size: .95rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { font-weight: 500; color: var(--faint); margin-left: 4px; }
/* Slim one-row bar for "Add a question set" and "New assignment" */
.quickbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 6px; padding: 8px 8px 8px 14px;
  background: var(--soft); border-radius: 10px; }
.qb-label { font-size: .9rem; font-weight: 600; color: var(--ink); margin-right: auto; }
.qb-hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
.quickbar input[type=text] { flex: 1 1 220px; width: auto; padding: 7px 10px; font-size: .95rem; background: #fff; }
.btn-sm, button.btn-sm, .btn.btn-sm { padding: 7px 14px; font-size: .88rem; font-weight: 600; border-radius: 8px; }
.quick-file { position: relative; }
.quick-file input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.quick-file input[type=file]:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.quick-file label { margin: 0; cursor: pointer; }
.quick-file label.busy { color: var(--muted); pointer-events: none; }
/* Results page: Settings (folds open) and the extension bar, quiet like the bars above */
.qb-stack { display: grid; gap: 8px; margin: 16px 0 6px; }
.qb-stack .quickbar { margin: 0; }
.qb-fold { background: var(--soft); border-radius: 10px; }
.qb-fold > summary { list-style: none; border-radius: 10px; }
.qb-fold > summary::-webkit-details-marker { display: none; }
.qb-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qb-fold > summary:hover .btn { border-color: var(--faint); }
.qb-fold .quickbar { background: none; flex-wrap: nowrap; }
.qb-fold .btn { flex: 0 0 auto; }
.qb-fold .qb-close, .qb-fold[open] .qb-change, .qb-fold[open] .qb-hint { display: none; }
.qb-fold[open] .qb-close { display: inline; }
.qb-form { padding: 0 14px 14px; }
.qb-form .row { max-width: 640px; }
.qb-form label:not(.check) { margin-top: 4px; }
.qb-form .check { margin: 8px 0; }
.qb-form .actions { margin-top: 12px; }
.qb-save { margin-left: auto; }  /* Save on the right, like the action buttons on the bars; Unassign stays on the left */
.qb-ext select, .qb-ext input[type=datetime-local] { width: auto; padding: 7px 10px; font-size: .95rem; }
.qb-ext select { flex: 0 1 240px; }
@media (max-width: 520px) {
  .qb-ext select, .qb-ext input[type=datetime-local] { flex: 1 1 100%; }
  .qb-wide { display: none; }  /* phones: just "Unassign", so it fits beside Save settings */
}
/* Analysis page: one row per question */
.an-table td { vertical-align: middle; }
.an-table .an-n { width: 56px; }
.an-q { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 8px;
  border: 1.5px solid var(--line); border-radius: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.an-q:hover { border-color: var(--accent); text-decoration: none; }
.an-score { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-count { color: var(--muted); }
.an-wait { display: block; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.an-bar { width: 120px; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.an-bar i { display: block; height: 100%; background: var(--ok); }
.an-vstat { flex: 1; min-width: 0; text-align: center; font-size: .88rem; color: var(--muted); }
.wclass { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 0; }
.tabs .count.waiting { color: var(--late); }
.an-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin: 14px 0 4px; }
.an-tools[hidden] { display: none; }
.seg { display: inline-flex; gap: 2px; padding: 2px; margin-left: auto; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 12px; font-size: .85rem; font-weight: 600; border-radius: 7px; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--soft); color: var(--ink); }
/* A column for each class after the all-classes total */
.an-cls { white-space: nowrap; font-variant-numeric: tabular-nums; }
.an-cls b { display: block; font-size: .92rem; }
.an-cls small { color: var(--muted); font-size: .78rem; }
@media (max-width: 600px) { .an-vstat { font-size: .8rem; } }
@media (max-width: 520px) { .an-bar { width: 56px; } }
.ext-remove { display: inline; }
.ext-remove::before { content: "· "; font-size: .8rem; color: var(--muted); }
.ext-remove button.linkish { font-size: .8rem; color: var(--accent); }
.ext-remove button.linkish:hover { text-decoration: underline; }
/* Assignment page: Rename, the Assign form (draft panel and "Assign to more classes"), Questions heading */
.rename-form { display: none; }
.rename-form:target { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; }
.rename-form input { flex: 1 1 240px; width: auto; padding: 7px 10px; font-size: .95rem; }
.assign-panel { background: var(--soft); border-radius: 12px; padding: 14px 16px 16px; margin-top: 18px; }
.assign-panel h2 { margin: 0 0 10px; font-size: 1.05rem; }
.assign-fields .af-label, .assign-fields label.af-label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.assign-fields > .af-label:first-child { margin-top: 0; }
.picks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.assign-fields label.pick { position: relative; display: inline-flex; margin: 0; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.pick span { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; font-size: .9rem; font-weight: 600; color: var(--ink); }
.pick span::before { content: ""; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  box-sizing: border-box; border: 1.5px solid var(--faint); border-radius: 50%; font-size: .62rem; line-height: 1; color: #fff; }
.pick:hover span { border-color: var(--faint); }
.pick input:checked + span { border-color: var(--ink); }
.pick input:checked + span::before { content: "\2713"; background: var(--ink); border-color: var(--ink); }
.pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
button.pick-all { padding: 4px 6px; color: var(--accent); font-size: .88rem; font-weight: 600; }
.assign-fields .af-dates { max-width: 640px; }
.assign-fields .af-dates input { padding: 8px 11px; }
.af-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; margin-top: 12px; }
.assign-fields .af-opts .check { margin: 0; align-items: center; }
.assign-fields .af-opts .check input { margin-top: 0; }
.af-after { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-weight: 500; font-size: .9rem; }
.af-after[hidden] { display: none; }
.af-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 16px; }
.page-head { margin: 26px 0 10px; }
.page-head h2 { margin: 0; }
.more-classes { margin-top: 10px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 28px 0 10px; }
.sec-head h2 { margin: 0; }
.sec-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.lock-note { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin: -2px 0 10px; font-size: .88rem; color: var(--muted); }
.lock-note button.linkish { color: var(--accent); font-size: .88rem; font-weight: 600; }
@media (max-width: 520px) { .af-after { flex-direction: column; align-items: flex-start; gap: 6px; } }
.card h2 { margin-top: 0; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.code { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; letter-spacing: .03em; }
.name-missing { color: var(--faint); font-style: italic; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--ok); }
.hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }
/* List pages (Assignments, Classes, Library): two-line rows like Assigned work */
.lrows { margin-top: 18px; }
.lrow { padding: 12px 2px; border-bottom: 1px solid var(--line); }
.lrow:first-child { border-top: 1px solid var(--line); }
.tabs + .lrows { margin-top: 0; }
.tabs + .lrows .lrow:first-child { border-top: 0; }
.lrow-1 { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; }
.lrow-name { font-weight: 600; color: var(--ink); }
.lrow-name:hover { color: var(--accent); text-decoration: none; }
.lrow-side { font-size: .88rem; color: var(--muted); white-space: nowrap; }
.lrow-2 { margin-top: 2px; font-size: .88rem; color: var(--muted); }
.lrow-2 b { color: var(--ink); font-weight: 600; }
@media (max-width: 520px) { .lrow-1 { flex-direction: column; gap: 0; } }
/* Classes: archived ones folded away under "Show N archived classes" */
.arch-fold { margin-top: 16px; }
.arch-fold > summary { list-style: none; width: fit-content; padding: 4px 0; color: var(--accent); font-size: .9rem; }
.arch-fold > summary::-webkit-details-marker { display: none; }
.arch-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.arch-fold[open] > summary { color: var(--muted); }
.arch-hide, .arch-fold[open] .arch-show { display: none; }
.arch-fold[open] .arch-hide { display: inline; }
.arch-fold .lrows { margin-top: 8px; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.pill { font-size: .8rem; color: var(--muted); }
.warnbox { background: var(--late-soft); color: #7a3b06; border-radius: 10px; padding: 10px 14px; font-size: .9rem; margin: 12px 0; }
details summary { cursor: pointer; font-weight: 600; }

/* ---------- Question cards (set and assignment pages) ---------- */
.qcards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qcard { position: relative; display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; scroll-margin-top: 90px; }
.qcard-link { position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.qcard:has(.qcard-link) { transition: border-color .12s, background-color .12s; }
.qcard:has(.qcard-link:hover) { border-color: #c4cad3; background: #fafbfc; }
.qcard:target { border-color: var(--accent); }
.qcard .qn { font-weight: 700; color: var(--muted); min-width: 1.6em; font-variant-numeric: tabular-nums; }
.qbody { flex: 1; min-width: 0; }
.qmodel { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.qtext { font-size: .93rem; }
.qmeta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.qthumb { width: 72px; height: 54px; object-fit: contain; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.qremove { position: relative; z-index: 2; margin: 0; flex: 0 0 auto; align-self: center; }
.qremove button { font-size: .82rem; }
.qremove button:hover { color: var(--bad); }
.qnote { color: var(--accent); font-weight: 600; }
.qsrc { font-style: italic; }
/* Checking cards for the question bank tools: while the tools are open, clicking a card checks it. */
.qpick { display: none; }
.picking[open] ~ .qcards .qcard { padding-left: 44px; }
.picking[open] ~ .qcards .qpick { display: block; position: absolute; inset: 0; z-index: 3; margin: 0; border-radius: inherit; cursor: pointer; }
.picking[open] ~ .qcards .qpick input { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin: -9px 0 0; cursor: pointer; }
.picking[open] ~ .qcards .qcard:has(.qpick input:checked) { border-color: var(--ink); background: var(--soft); }
.picking[open] ~ .qcards .qremove { display: none; }
.pick-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pick-acts select { width: auto; flex: 0 1 320px; min-width: 0; padding: 7px 10px; font-size: .95rem; }
button.pick-toggle { color: var(--accent); font-size: .88rem; font-weight: 600; }

/* ---------- Question bank (library tab and category pages) ---------- */
.bank-note { margin: 14px 0 0; }
.bank { display: grid; gap: 12px; margin-top: 16px; }
.bcat { border: 1.5px solid var(--line); border-radius: 12px; }
.bcat-head { display: flex; align-items: center; gap: 4px 12px; padding: 12px 14px; }
.bcat-name { font-weight: 700; color: var(--ink); margin-right: auto; }
.bcat-mix { margin: -9px 14px 12px; font-size: .88rem; color: var(--muted); }
.bsubs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.bsub { display: flex; align-items: center; gap: 4px 12px; padding: 9px 14px 9px 30px; }
.bsub + .bsub { border-top: 1px solid var(--line); }
.bsub-name { color: var(--ink); font-weight: 500; margin-right: auto; }
.bsub-name.other { color: var(--muted); }
.bcat-name:hover, .bsub-name:hover { color: var(--accent); text-decoration: none; }
.bmove { display: inline-flex; gap: 2px; margin: 0 -4px 0 0; width: 50px; flex: 0 0 auto; justify-content: flex-end; }
.bmove button { padding: 2px 6px; font-size: 1rem; line-height: 1; }
.bmove button:disabled { visibility: hidden; }
.lrow-side .bmove { margin-left: 8px; vertical-align: middle; }
.bsub-add { border-top: 1px solid var(--line); padding: 8px 14px 8px 30px; }
.bsub-add > summary { list-style: none; cursor: pointer; color: var(--accent); font-size: .86rem; font-weight: 600; width: fit-content; }
.bsub-add > summary::-webkit-details-marker { display: none; }
.bsub-add > summary::before { content: "+ "; }
.bsub-add[open] > summary { color: var(--muted); }
.bsub-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 4px; }
.bsub-form input[type=text] { flex: 1 1 220px; width: auto; padding: 7px 10px; font-size: .95rem; }
.crumb-sep { color: var(--faint); margin: 0 2px; }
.bank-subrows { margin-top: 0; }
@media (max-width: 520px) { .bsub, .bsub-add { padding-left: 20px; } }

/* ---------- Assignment builder ---------- */
.bgrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; margin-top: 16px; }
#bfilter { margin-bottom: 12px; }
.btabs { display: flex; width: fit-content; margin: 0 0 10px; }
.bset { border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.bset-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--soft); transition: background-color .12s; }
.bset-head:hover { background: #eceef2; }
.bset-head input { width: 18px; height: 18px; flex: 0 0 auto; }
.bset-title { all: unset; cursor: pointer; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem; }
.bset-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.bset-title .pill { font-weight: 400; white-space: nowrap; }
.bset-chev { flex: 0 0 auto; color: var(--muted); transition: transform .15s ease; }
.bset.open .bset-chev { transform: rotate(90deg); }
.bset-act { margin-left: auto; padding-left: 8px; font-size: .82rem; font-weight: 500; color: var(--accent); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .bset-chev, .bset-head { transition: none; } }
.bq-list { list-style: none; margin: 0; padding: 0; }
.bq { border-top: 1px solid var(--line); display: flex; align-items: center; }
.bq label { flex: 1; min-width: 0; }
.bq-view { flex: 0 0 auto; margin-right: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px;
  font-size: .82rem; font-weight: 600; color: var(--accent); background: #fff; border: 1.5px solid var(--line); border-radius: 8px; }
.bq-view:hover { border-color: var(--accent); }
/* Question viewer (flip through questions as students see them) */
.qv { position: fixed; inset: 0; z-index: 50; background: rgba(17, 20, 24, .42); display: flex; align-items: center; justify-content: center; padding: 20px; }
.qv[hidden] { display: none; }
.qv-panel { background: #fff; width: min(720px, 100%); height: min(880px, 100%); border-radius: 14px; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); }
.qv-top { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.qv-title { flex: 1; min-width: 0; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qv-count { font-size: .85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.qv-x, button.qv-x { background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1; padding: 2px 6px; font-weight: 400; }
.qv-x:hover { color: var(--ink); }
.qv-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.qv-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fafbfc; }
.qv-add { min-width: 190px; }
.qv-add.on, button.qv-add.on { background: var(--ok-soft); color: var(--ok); border-color: #b9e3c6; }
.qv-add .lbl-rm { display: none; }
.qv-add.on:hover .lbl-on { display: none; }
.qv-add.on:hover .lbl-rm { display: inline; }
button.qv-add.danger:hover { border-color: var(--bad); }
/* After taking a chosen question out in the viewer: "Removed … Undo" */
.qv-note { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; border-top: 1px solid var(--line);
  background: var(--soft); font-size: .85rem; color: var(--muted); }
.qv-note[hidden] { display: none; }
.qv-note b { color: var(--ink); font-weight: 600; }
.qv-note button.linkish { color: var(--accent); font-size: .85rem; font-weight: 600; }
@media (max-width: 600px) {
  .qv { padding: 0; }
  .qv-panel { height: 100%; border-radius: 0; }
  .qv-bottom { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .qv-add { min-width: 0; flex: 1; }
  .qv-long { display: none; }
}
.bq.on { background: var(--ok-soft); }
.bq label { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; margin: 0; font-weight: 400; font-size: .92rem; cursor: pointer; }
.bq input { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; }
.bq-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.btray { position: sticky; top: 12px; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; max-height: calc(100vh - 24px); overflow: auto; background: #fff; }
.btray-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.btray-count { font-size: 1rem; }
.btray-acts { display: flex; align-items: center; gap: 8px; }
.bq-view.bt-preview { margin-right: 0; padding: 9px 11px; }
.btray-list { list-style: none; margin: 0; padding: 0; }
.btray-list li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--line); font-size: .85rem; }
.bt-num { font-weight: 700; color: var(--muted); min-width: 1.6em; font-variant-numeric: tabular-nums; }
.bt-text { flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.bt-tools { display: flex; gap: 6px; flex: 0 0 auto; }
.bt-tools button { font-size: 1rem; padding: 0 2px; }
.bt-tools button:disabled { opacity: .25; }
.bt-tools .bt-view { color: var(--accent); }
.bt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.bt-main .bt-text { flex: none; max-width: 100%; }
/* Questions you've already given this school year: a tag on each, a count per set, a strip in the preview */
.qused { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; padding: 1px 8px 1px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .76rem; font-weight: 600; }
.qused > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qused svg { width: 12px; height: 12px; flex: 0 0 auto; }
.qused.draft { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); padding-left: 8px; }
@media (max-width: 520px) {  /* phones: the whole tag on two lines rather than cut short */
  .qused { align-items: flex-start; border-radius: 8px; }
  .qused svg { margin-top: 2px; }
  .qused > span { white-space: normal; }
}
.used-n { color: var(--accent); }
.hide-used { margin: -2px 0 12px; font-size: .9rem; }
.hide-used[hidden] { display: none; }
.hide-used .pill { margin-left: 4px; }
.qv-used { padding: 9px 16px 10px; background: var(--accent-soft); border-bottom: 1px solid #dde4fa; font-size: .85rem; }
.qv-used.draft { background: var(--soft); border-bottom-color: var(--line); }
.qvu-head { display: flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; }
.qvu-head svg { width: 13px; height: 13px; flex: 0 0 auto; }
.qvu-list { list-style: none; margin: 3px 0 0; padding: 0 0 0 19px; color: var(--muted); }
.qv-used.draft .qvu-list { margin: 0; padding: 0; }
.qvu-list li { margin-top: 2px; }
.qvu-list b { color: var(--ink); font-weight: 600; }
@media (max-width: 800px) {
  .bgrid { grid-template-columns: minmax(0, 1fr); }  /* minmax: a long "Used in …" tag shortens instead of widening the page */
  .btray { position: sticky; bottom: 0; top: auto; max-height: 45vh; box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
}

/* ---------- Written answer review (teacher) ---------- */
.wreview { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.wreview summary { font-size: .95rem; }
.wrev { border-top: 1px solid var(--line); padding: 12px 0; }
.wrev-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; margin-bottom: 6px; }
.wrev-head .score { font-variant-numeric: tabular-nums; }
.wrev-try { margin: 8px 0; }
.wrev-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; margin-top: 4px; }
.wrev-fb { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.wrev-set { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.wrev-set button.ghost { padding: 4px 12px; font-size: .88rem; }

/* ---------- Code slips (print) ---------- */
.slips-page .noprint { max-width: 1000px; margin: 0 auto; padding: 16px; }
.slips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.slip { border: 1px dashed #b9bfc7; padding: 16px 14px; text-align: center; break-inside: avoid; }
.slip .site { font-weight: 700; font-size: .95rem; }
.slip .nm { margin: 8px 0 4px; font-size: 1rem; min-height: 1.5em; }
.slip .cd { font-size: 1.5rem; font-weight: 700; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.slip .how { font-size: .75rem; color: var(--muted); margin-top: 6px; }
.slip-pet { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; font-size: .72rem; color: var(--muted); }
.slip-art { width: 22px; height: 22px; flex: 0 0 auto; }
@media print {
  .noprint, .flash { display: none !important; }
  .slips { padding: 0; }
  body { font-size: 12pt; }
}
@media (max-width: 600px) {
  .slips { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Lab Pets (student pages) ---------- */
.snav { display: flex; align-items: center; gap: 16px; font-size: .9rem; }
.snav a { color: var(--muted); }
.snav a:hover { color: var(--ink); text-decoration: none; }
.snav a.on { color: var(--ink); font-weight: 600; }
.snav form { margin: 0; }

/* "A pet is waiting…" strip under a finished homework */
.alist .with-pet { border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.alist .with-pet > a:first-child, .alist .with-pet > .closed { border: 0; border-radius: 0; }
.alist .pet-strip { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0; border-top: 1.5px solid var(--line);
  border-radius: 0; background: var(--soft); padding: 9px 16px; font-size: .88rem; font-weight: 700; color: var(--ink); }
.alist .pet-strip:hover { background: #eceef1; }
.alist .pet-strip .go { color: var(--muted); font-weight: 600; }

/* Pixel pets */
.pet-svg { display: block; width: 100%; height: 100%; }

/* My pets */
.pet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 6px; }
.pet-head h1 { font-size: 1.5rem; margin: 0; }
.pet-count { color: var(--muted); font-size: .92rem; white-space: nowrap; }
.pet-grid { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .pet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 640px) { .pet-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.pet-slot { position: relative; border: 1.5px solid var(--line); border-radius: 14px; padding: 18px 4px 8px; text-align: center; background: #fff; }
.pet-no { position: absolute; top: 6px; left: 8px; font-size: .68rem; font-weight: 700; color: var(--faint); }
.pet-art { width: 64px; max-width: 80%; aspect-ratio: 1; margin: 0 auto; }
.pet-slot:not(.found) .pet-art { opacity: .9; }
.pet-name { font-size: .74rem; font-weight: 700; margin-top: 4px; line-height: 1.2; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.pet-slot:not(.found) .pet-name { color: var(--faint); letter-spacing: .1em; }
.pet-rar { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: .64rem; font-weight: 600; color: var(--faint); }
.pet-slot.found .pet-rar { color: var(--muted); }
.pet-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #8a94a3; }
.pet-dot.uncommon { background: #1a9a52; }
.pet-dot.rare { background: #2563eb; }
.pet-dot.legendary { background: #9b3fd0; }

/* My pets: how many of a pet (×4), and pets traded away entirely (faded, still discovered). */
.pet-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.pet-x { position: absolute; top: 5px; right: 6px; font-size: .66rem; font-weight: 800; line-height: 1.45; padding: 0 6px;
  border-radius: 999px; color: var(--accent); background: var(--accent-soft); }
.pet-slot.gone .pet-art { opacity: .28; }
.pet-slot.gone .pet-name { color: var(--faint); }
.trade-flash { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: #1b3a8f; font-size: .93rem; }
.trade-note { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 10px 14px; border-radius: 12px; background: var(--ok-soft); }
.trade-note-art { width: 40px; height: 40px; flex: 0 0 auto; }
.trade-note-title { display: block; font-size: .95rem; }
.trade-note-text { display: block; font-size: .85rem; color: var(--muted); }

/* Trades, under My pets. "You get" is what the other student gives. */
.trades .sec-head { margin-top: 26px; }
.trade-none { margin: 0; }
.offer { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 4px; align-items: center;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; }
.offer[hidden] { display: none; }
.offer-side { grid-column: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.offer-label { flex: 0 0 58px; font-size: .74rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.offer-pets { display: flex; flex-wrap: wrap; gap: 4px; }
.offer-btn { grid-column: 2; grid-row: 1 / span 2; }
.offer.off .offer-side { opacity: .45; }
.offer.mine { background: var(--soft); border-color: var(--soft); }
.offer.mine .tp-art { background: #fff; }
.mine-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.mine-head b { font-size: .95rem; }
.mine-head span { flex: 1; font-size: .8rem; color: var(--muted); }
.mine-head form { margin: 0; }
.mine-head .btn-sm { padding: 4px 10px; font-size: .8rem; }
.tp { display: flex; flex-direction: column; align-items: center; width: 58px; }
.tp-art { position: relative; width: 42px; height: 42px; padding: 5px; border-radius: 10px; background: var(--soft); }
.tp-art .pet-dot { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; }
.tp-name { font-size: .58rem; font-weight: 700; line-height: 1.15; text-align: center; margin-top: 2px; }
.tp.unk .tp-name { color: var(--faint); letter-spacing: .08em; }
.pager { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.pager[hidden] { display: none; }
button.pg { min-width: 38px; height: 38px; padding: 0 8px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff;
  color: var(--ink); font-size: .95rem; }
button.pg.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* "Make this trade?": a sheet from the bottom of the screen. */
dialog.sheet { position: fixed; inset: auto 0 0; width: 100%; max-width: 520px; max-height: 92vh; margin: 0 auto; overflow: auto;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom)); border: 0; border-radius: 22px 22px 0 0; background: #fff;
  color: var(--ink); box-shadow: 0 -10px 30px rgba(0,0,0,.18); }
dialog.sheet::backdrop { background: rgba(21,24,28,.45); }
.sheet form { margin: 0; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: #d9dce1; margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 2px; font-size: 1.2rem; }
.crow { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.crow-art { width: 48px; height: 48px; flex: 0 0 auto; padding: 6px; border-radius: 12px; background: var(--soft); }
.crow b { display: block; font-size: .95rem; }
.crow > div > span { display: block; font-size: .8rem; color: var(--muted); line-height: 1.35; }
.sheet-btns { display: grid; gap: 8px; margin-top: 14px; }
.sheet-btns button { width: 100%; padding: 12px; }

/* Make an offer: three slots a side, and a picker. */
.olabel { font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 14px 0 6px; }
.oslots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 420px; }
button.oslot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 104px; padding: 12px 4px 8px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
  font-size: inherit; font-weight: inherit; text-align: center; }
button.oslot .pet-art { width: 44px; display: block; }
.oslot-name { font-size: .72rem; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.oslot.unk .oslot-name { color: var(--faint); letter-spacing: .1em; }
button.oslot.empty { border-style: dashed; color: var(--faint); font-size: 1.7rem; font-weight: 300; }
button.oslot.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
button.oslot.active .oslot-name { color: var(--ink); }
.opick-head { font-size: .88rem; font-weight: 600; margin: 18px 0 8px; }
.opick { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; max-width: 520px; }
.opick button { position: relative; display: block; aspect-ratio: 1; width: 100%; padding: 4px; border: 0; border-radius: 8px; background: var(--soft); }
.opick button.gone svg { opacity: .28; }
.opick button.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.opick button:disabled { opacity: .3; cursor: default; }
.opick .pet-x { top: -3px; right: -3px; font-size: .56rem; padding: 0 4px; }
.opost { width: 100%; max-width: 420px; margin-top: 18px; padding: 12px; }
.ofoot { margin-top: 10px; max-width: 520px; }

/* Traded! (the spin page's look) */
.tr-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; }
.tr-title .kao { font-size: 1.1rem; font-weight: 400; color: var(--muted); }
.tr-pets { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 8px; }
.tr-got { width: 112px; }
.tr-pets.one .tr-got { width: auto; }
.tr-stage { display: grid; place-items: center; width: 112px; height: 112px; margin: 0 auto 4px; }
.tr-pets.one .tr-stage { width: 210px; height: 210px; }
.tr-stage > * { grid-area: 1 / 1; }
.tr-glow { width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(circle, var(--glow) 0%, var(--glow) 38%, rgba(255,255,255,0) 70%); }
.tr-pet { width: 72px; height: 72px; animation: spin-pop .5s cubic-bezier(.2,1.6,.4,1) both, spin-hop 1.6s ease-in-out .5s infinite; }
.tr-pets.one .tr-pet { width: 128px; height: 128px; }
.tr-name { margin: 6px 0 2px; font-size: 1rem; }
.tr-pets.one .tr-name { font-size: 1.15rem; }
.tr-gave { margin: 6px 0 18px; }
@media (prefers-reduced-motion: reduce) { .tr-pet { animation: none; } }

/* Spin page */
.spin-page { max-width: 480px; text-align: center; padding-bottom: 40px; }
.spin-finish { padding: 4px 0; }
.spin-finished { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.spin-score { font-size: 3rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.spin-earned { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 14px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; background: var(--soft); color: var(--muted); }
.spin-earned.gold { background: #fff6d6; color: #8a6400; }
.spin-coin { width: 18px; height: 18px; display: block; }
.spin-stage { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
/* The wheel: a thin ring of 20 slices in the rarity colors (drawn by spin.js) around a pixel "?" */
.spin-box { position: relative; width: 280px; height: 296px; transition: height .5s cubic-bezier(.4,0,.2,1); }
.spin-ringwrap { position: absolute; left: 0; top: 0; width: 280px; height: 296px; transform-origin: 140px 156px;
  transition: opacity .5s ease, transform .6s cubic-bezier(.2,.7,.3,1), visibility 0s linear .6s; }
.spin-pointer { position: absolute; left: 50%; top: 6px; width: 20px; height: 26px; margin-left: -10px; z-index: 2; }
.spin-pointer.tick { animation: spin-tick .45s ease-out; }
@keyframes spin-tick { 35% { transform: translateY(-6px); } }
.spin-ring { position: absolute; left: 0; top: 16px; width: 280px; height: 280px; transition: transform 4.2s cubic-bezier(.12,.7,.18,1); will-change: transform; }
.spin-seg { transition: stroke .5s; }
.spin-ring.landed .spin-seg:not(.win) { stroke: #eceef1; }
.spin-seg.win { animation: spin-blink .25s ease-in-out 4 alternate; }
@keyframes spin-blink { to { opacity: .35; } }
.spin-mid { position: absolute; left: 50%; top: 156px; width: 180px; height: 180px; margin: -90px 0 0 -90px; display: grid; place-items: center;
  transition: top .5s cubic-bezier(.4,0,.2,1); }
.spin-mid > * { grid-area: 1 / 1; }
.spin-q { width: 80px; height: 80px; color: #c9ced6; transition: transform .25s ease-in, opacity .25s; }
.spin-mid.open .spin-q { transform: scale(.4); opacity: 0; }
.spin-glow { width: 180px; height: 180px; border-radius: 50%; opacity: 0; transition: opacity .5s;
  background: radial-gradient(circle, var(--glow) 0%, var(--glow) 38%, rgba(255,255,255,0) 70%); }
.spin-mid.open .spin-glow { opacity: 1; }
.spin-pet { width: 112px; height: 112px; transition: width .5s cubic-bezier(.2,.7,.3,1), height .5s cubic-bezier(.2,.7,.3,1); }
.spin-pet:not(:empty) { animation: spin-pop .5s cubic-bezier(.2,1.6,.4,1) both, spin-hop 1.6s ease-in-out .5s infinite; }
@keyframes spin-pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes spin-hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
/* After the reveal: the ring fades away (growing a little), the pet grows to full size, then
   the space closes up and the name appears (.spin-in). "gone": there was no pet left to give. */
.spin-box.fade .spin-ringwrap { opacity: 0; transform: scale(1.1); visibility: hidden; }
.spin-box.fade .spin-pet { width: 128px; height: 128px; }
.spin-box.tight { height: 180px; }
.spin-box.tight .spin-mid { top: 90px; }
.spin-box.gone { height: 0; }
.spin-box.gone .spin-mid { display: none; }
.spin-btn { margin-top: 20px; min-width: 140px; padding: 10px 22px; gap: 8px; }
.spin-btn .spin-coin { width: 16px; height: 16px; }
.spin-btn.fading { opacity: 0; transition: opacity .3s; }
.spin-in { margin-top: 4px; animation: spin-rise .45s ease-out both; }
@keyframes spin-rise { from { opacity: 0; transform: translateY(8px); } }
.spin-tag { display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: #eef0f3; color: #4b5563; }
.spin-tag.uncommon { background: #e3f5ea; color: #13703b; }
.spin-tag.rare { background: #e4ecfd; color: #1c46b4; }
.spin-tag.legendary { background: #f3e6fb; color: #6a1f99; }
.spin-tag.new { background: var(--ink); color: #fff; }
.spin-result h2 { margin: 6px 0 2px; font-size: 1.15rem; }
.spin-joke { color: var(--muted); font-size: .9rem; margin: 2px 0 16px; }
.spin-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.spin-actions a { color: var(--muted); font-size: .9rem; }
.spin-actions a.spin-mypets { color: #fff; background: var(--ink); border-radius: 10px; padding: 10px 0; width: 180px; font-weight: 600; }
.spin-actions a:hover { text-decoration: none; }
@media (prefers-reduced-motion: reduce) {
  .spin-pointer.tick, .spin-seg.win, .spin-pet:not(:empty), .spin-in { animation: none; }
  .spin-ring, .spin-ringwrap, .spin-box, .spin-mid, .spin-q, .spin-glow, .spin-pet, .spin-seg, .spin-btn.fading { transition: none; }
}

/* Kaomoji (text faces) for happy moments and empty pages. */
.kao { white-space: nowrap; }
.kao-big { font-size: 2rem; color: var(--muted); margin: 0 0 6px; }
.caught-up { color: var(--muted); text-align: center; margin: 6px 0 14px; }

/* ---------- Lab Pets on the teacher side ---------- */
/* A homework's results: the pet each student won, and a line by the Students heading. */
.pet-cell { white-space: nowrap; }
.tpet { display: inline-flex; align-items: center; gap: 7px; font-size: .86rem; vertical-align: middle; }
.tpet-art { width: 24px; height: 24px; flex: 0 0 auto; padding: 2px; border-radius: 7px; background: var(--soft); }
.spin-wait { font-size: .8rem; color: var(--late); background: var(--late-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.psum { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.psum-art { width: 20px; height: 20px; flex: 0 0 auto; }
@media (max-width: 640px) { .tpet-name { display: none; } }
/* The end of a teacher's preview: try the spin. */
.tspin { max-width: 440px; margin: 22px auto 0; border: 1.5px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.tspin p { font-size: .92rem; color: var(--muted); margin: 10px 0 14px; }
.tspin p b { color: var(--ink); }
.tspin-pets { display: flex; justify-content: center; gap: 8px; }
.tspin-pet { width: 34px; height: 34px; }
.finish-back { margin: 22px 0 0; }
.spin-demo .banner.preview { margin-bottom: 8px; }
