/* =========================================================================
   chieh_class_v2 — design system
   ----------------------------------------------------------------------------
   Editorial / scholarly aesthetic. Warm paper background, deep ink type,
   vermillion margin-pen accent, hairline borders. Subtle dot grid recalls
   graph paper. Numbers/scores in monospace like an exam sheet.
   ========================================================================= */


/* -----------------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------------- */

:root {
  /* paper */
  --paper:           #FAF7EE;
  --paper-2:         #F4EFE0;
  --paper-tint:      #F1ECDB;

  /* ink */
  --ink:             #161513;
  --ink-2:           #3A3733;
  --ink-3:           #6B655B;
  --ink-4:           #9A9285;

  /* hairline */
  --rule:            #E2D9C2;
  --rule-2:          #CFC4A6;

  /* signature */
  --vermillion:      #C2410C;
  --vermillion-2:    #A6360A;
  --vermillion-tint: rgba(194, 65, 12, .08);

  /* secondary */
  --teal:            #0E5F6B;
  --teal-tint:       rgba(14, 95, 107, .08);

  /* status */
  --ok:              #2F7A4D;
  --ok-tint:         rgba(47, 122, 77, .10);
  --warn:            #B47A00;
  --warn-tint:       rgba(180, 122, 0, .12);
  --bad:             #B23A3A;
  --bad-tint:        rgba(178, 58, 58, .10);

  /* type */
  --font-display:    "Fraunces", "Times New Roman", serif;
  --font-body:       "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:       "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* shape */
  --radius-1:        4px;
  --radius-2:        10px;
  --radius-3:        16px;

  /* shadow (paper-soft) */
  --shadow-1:        0 1px 0 rgba(22, 21, 19, .03), 0 2px 4px rgba(22, 21, 19, .04);
  --shadow-2:        0 1px 0 rgba(22, 21, 19, .04), 0 4px 14px -2px rgba(22, 21, 19, .08);
  --shadow-lift:     0 1px 0 rgba(22, 21, 19, .05), 0 12px 28px -8px rgba(22, 21, 19, .14);

  /* layout */
  --reading:         min(74ch, 100%);
  --frame:           min(1180px, 100% - 2.5rem);

  /* motion */
  --ease:            cubic-bezier(.2, .7, .2, 1);
}

/* -----------------------------------------------------------------------------
   2. Base
   --------------------------------------------------------------------------- */

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 80% -10%, var(--paper-tint), transparent 65%),
    radial-gradient(900px 600px at -10% 110%, var(--paper-2), transparent 60%),
    var(--paper);
  background-attachment: fixed;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* faint graph-paper dot grid behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(22, 21, 19, .055) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 0 0;
  pointer-events: none;
  z-index: 0;
  mask-image: linear-gradient(to bottom, transparent, black 8rem, black calc(100% - 8rem), transparent);
}

main { position: relative; z-index: 1; }

/* -----------------------------------------------------------------------------
   3. Typography
   --------------------------------------------------------------------------- */

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 .6em;
  font-variation-settings: "opsz" 36, "SOFT" 30;
  line-height: 1.15;
}

h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); font-variation-settings: "opsz" 144, "SOFT" 50; letter-spacing: -.02em; }
h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); }
h3 { font-size: 1.25rem; font-weight: 600; font-variation-settings: "opsz" 36, "SOFT" 20; }
h4 { font-size: 1.02rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
     font-family: var(--font-body); color: var(--ink-3); margin-top: 2rem; }

p { margin: 0 0 1em; max-width: 68ch; }

a {
  color: var(--vermillion);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--vermillion) 28%, transparent);
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
a:hover { color: var(--vermillion-2); border-bottom-color: var(--vermillion); }

code, pre, .mono {
  font-family: var(--font-mono);
  font-feature-settings: "ss01";
  font-size: .92em;
}

code {
  background: var(--paper-2);
  padding: .12em .35em;
  border-radius: 3px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
}

em { font-family: var(--font-display); font-style: italic; font-weight: 400; }

/* -----------------------------------------------------------------------------
   4. Layout
   --------------------------------------------------------------------------- */

main {
  width: var(--frame);
  margin: 0 auto;
  padding: 2rem 0 6rem;
  animation: page-rise .6s var(--ease) both;
}

@keyframes page-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

main > * { animation: stagger .55s var(--ease) both; }
main > *:nth-child(1) { animation-delay: .04s; }
main > *:nth-child(2) { animation-delay: .10s; }
main > *:nth-child(3) { animation-delay: .16s; }
main > *:nth-child(4) { animation-delay: .22s; }
main > *:nth-child(5) { animation-delay: .28s; }
main > *:nth-child(6) { animation-delay: .34s; }
main > *:nth-child(7) { animation-delay: .40s; }
main > *:nth-child(8) { animation-delay: .46s; }

@keyframes stagger {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------------------------------------------------
   5. Header / brand
   --------------------------------------------------------------------------- */

header.site-header {
  width: var(--frame);
  margin: 0 auto;
  padding: 1.6rem 0 1.2rem;
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 2;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.015em;
  text-decoration: none;
  border-bottom: none;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  display: inline-flex;
  align-items: baseline;
  gap: .55rem;
}

.brand .brand-mark {
  display: inline-block;
  width: 14px;
  height: 14px;
  background: var(--vermillion);
  transform: rotate(45deg);
  transform-origin: center;
  position: relative;
  top: -.05em;
  border-radius: 1px;
}

.brand:hover { color: var(--ink); }

.brand-sub {
  font-family: var(--font-mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .22em;
  color: var(--ink-4);
  margin-left: .8rem;
  border-left: 1px solid var(--rule);
  padding-left: .9rem;
}

.user-strip {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: .92rem;
  color: var(--ink-3);
}

.user-strip .user-name {
  font-weight: 600;
  color: var(--ink);
}

.user-strip form { margin: 0; }

/* role chip on user strip */
.role-chip {
  font-family: var(--font-mono);
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  padding: .18rem .5rem;
  border: 1px solid var(--rule-2);
  border-radius: 3px;
  background: var(--paper-2);
  color: var(--ink-3);
}
.role-chip.is-root  { background: var(--vermillion-tint); border-color: color-mix(in srgb, var(--vermillion) 35%, transparent); color: var(--vermillion-2); }
.role-chip.is-teach { background: var(--teal-tint);       border-color: color-mix(in srgb, var(--teal) 30%, transparent);       color: var(--teal); }

/* -----------------------------------------------------------------------------
   6. Page header (inside main)
   --------------------------------------------------------------------------- */

.page-header {
  margin: 1rem 0 2.4rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .22em;
  color: var(--vermillion);
  margin: 0 0 .8rem;
  display: inline-flex;
  align-items: center;
  gap: .65rem;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 1.2rem;
  height: 1px;
  background: currentColor;
}

.page-title { margin: 0 0 .3rem; }

.page-lede {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.18rem;
  font-weight: 400;
  color: var(--ink-2);
  font-variation-settings: "opsz" 144, "SOFT" 100;
  max-width: 56ch;
  margin: 0;
}

.page-meta {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--ink-3);
}
.page-meta .label { color: var(--ink-4); margin-right: .35rem; }

.crumbs {
  font-family: var(--font-mono);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--ink-3);
  margin: 0 0 1.2rem;
  /* Always render on a single line, no scrollbar. If the trail is
     longer than the container width it visually overflows; we tighten
     the letter-spacing/separators to keep typical names fitting. */
  white-space: nowrap;
  overflow: visible;
}
.crumbs .sep { margin: 0 .35rem; }
.crumbs a {
  color: inherit;
  border-bottom: 1px solid color-mix(in srgb, var(--vermillion) 30%, transparent);
}
.crumbs a:hover { color: var(--vermillion); border-bottom-color: var(--vermillion); }
.crumbs .sep { margin: 0 .5rem; color: var(--ink-4); }

/* -----------------------------------------------------------------------------
   7. Cards / panels
   --------------------------------------------------------------------------- */

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  padding: 1.6rem 1.8rem;
  box-shadow: var(--shadow-1);
  position: relative;
}

.panel-stack > * + * { margin-top: 1.4rem; }

.panel-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-3);
  margin: 0 0 1rem;
  display: flex;
  align-items: baseline;
  gap: .6rem;
}
.panel-title .count {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--ink-4);
  letter-spacing: .04em;
  text-transform: none;
  font-weight: 400;
}

/* Two-column grid for split admin views */
.grid-two {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: 1fr;
}
@media (min-width: 940px) {
  .grid-two { grid-template-columns: 1fr 1fr; }
}

.grid-asym {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 980px) {
  .grid-asym { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
}

/* Course-card grid (student & teacher home) */
.course-grid {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-bottom: 2rem;
}

.course-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-1);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  position: relative;
  overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
  min-height: 175px;
}
.course-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--vermillion) 0%, var(--vermillion) 30%, transparent 30%);
  transition: background .25s var(--ease);
}
.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--rule-2);
  color: var(--ink);
}
.course-card:hover::before {
  background: linear-gradient(90deg, var(--vermillion) 0%, var(--vermillion) 100%);
}
.course-card .num {
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .14em;
  color: var(--ink-4);
  text-transform: uppercase;
  margin-bottom: .9rem;
}
.course-card .title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  letter-spacing: -.015em;
  margin: 0 0 .5rem;
  line-height: 1.1;
}
.course-card .meta {
  font-size: .82rem;
  color: var(--ink-3);
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px dashed var(--rule);
  display: flex;
  gap: .8rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.course-card .meta .sec {
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .04em;
}
.course-card .arrow {
  position: absolute;
  bottom: 1.4rem;
  right: 1.5rem;
  color: var(--vermillion);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.course-card:hover .arrow { opacity: 1; transform: translateX(0); }

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--rule-2);
  border-radius: var(--radius-2);
  color: var(--ink-3);
  font-style: italic;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

/* -----------------------------------------------------------------------------
   8. Tables
   --------------------------------------------------------------------------- */

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .94rem;
  margin: .25rem 0 1.4rem;
}

table.data th {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--rule-2);
  background: transparent;
}

table.data td {
  padding: .8rem .9rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  color: var(--ink-2);
}

table.data tbody tr:hover td { background: var(--paper-2); }

table.data td.num,
table.data th.num { font-family: var(--font-mono); font-size: .9em; }

table.data td.id {
  font-family: var(--font-mono);
  font-size: .82em;
  color: var(--ink-4);
  width: 4ch;
}

table.data td.actions {
  text-align: right;
  white-space: nowrap;
}

table.data td.actions form { display: inline; }
table.data td.actions form + form,
table.data td.actions form + a,
table.data td.actions a + form { margin-left: .4rem; }

/* -----------------------------------------------------------------------------
   9. Buttons
   --------------------------------------------------------------------------- */

button, .btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: .92rem;
  line-height: 1.2;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-1);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: transform .12s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}
button:hover, .btn:hover { background: var(--ink-2); border-color: var(--ink-2); color: var(--paper); }
button:active, .btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--vermillion);
  border-color: var(--vermillion);
  color: var(--paper);
  border-bottom-color: var(--vermillion);
}
.btn-primary:hover { background: var(--vermillion-2); border-color: var(--vermillion-2); color: var(--paper); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-2);
  border-bottom-color: var(--rule-2);
}
.btn-ghost:hover { background: var(--paper-2); border-color: var(--ink-3); color: var(--ink); }

.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
  border-bottom-color: color-mix(in srgb, var(--bad) 30%, transparent);
  font-size: .82rem;
  padding: .4rem .8rem;
}
.btn-danger:hover { background: var(--bad-tint); border-color: var(--bad); color: var(--bad); }

.btn-sm  { font-size: .82rem; padding: .35rem .8rem; }
.btn-xs  { font-size: .74rem; padding: .25rem .55rem; letter-spacing: .02em; }

.btn-link {
  background: transparent;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--vermillion) 28%, transparent);
  color: var(--vermillion);
  padding: 0;
  border-radius: 0;
  font-weight: 500;
}
.btn-link:hover { background: transparent; color: var(--vermillion-2); border-bottom-color: var(--vermillion); }

/* -----------------------------------------------------------------------------
   10. Forms
   --------------------------------------------------------------------------- */

input[type="text"], input[type="email"], input[type="number"],
input[type="datetime-local"], input[type="password"],
input:not([type]), textarea, select {
  font-family: var(--font-body);
  font-size: .95rem;
  padding: .58rem .8rem;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-1);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--vermillion);
  box-shadow: 0 0 0 3px var(--vermillion-tint);
  background: var(--paper);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236B655B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.2rem;
}

label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: .35rem;
}

.form-stack > * + * { margin-top: 1rem; }

.form-row {
  display: grid;
  gap: .9rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .form-row.two   { grid-template-columns: 1fr 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr 1fr; }
  .form-row.four  { grid-template-columns: repeat(4, 1fr); }
}

.form-inline {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-inline > * { flex: 1 1 12rem; }
.form-inline button { flex: 0 0 auto; }

.field-hint {
  display: block;
  margin-top: .4rem;
  font-size: .82rem;
  color: var(--ink-3);
  font-style: italic;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

/* compact inline action form (table cell) */
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.inline-form select {
  width: auto;
  padding: .3rem 1.6rem .3rem .55rem;
  font-size: .82rem;
}

/* -----------------------------------------------------------------------------
   11. Status badges + chips
   --------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .22rem .55rem;
  border-radius: 3px;
  border: 1px solid var(--rule-2);
  background: var(--paper-2);
  color: var(--ink-3);
  white-space: nowrap;
}
.chip.is-ok    { background: var(--ok-tint);   border-color: color-mix(in srgb, var(--ok) 30%, transparent);   color: var(--ok); }
.chip.is-warn  { background: var(--warn-tint); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.chip.is-bad   { background: var(--bad-tint);  border-color: color-mix(in srgb, var(--bad) 30%, transparent);  color: var(--bad); }
.chip.is-mark  { background: var(--vermillion-tint); border-color: color-mix(in srgb, var(--vermillion) 30%, transparent); color: var(--vermillion-2); }
.chip.is-teal  { background: var(--teal-tint); border-color: color-mix(in srgb, var(--teal) 30%, transparent); color: var(--teal); }

/* topic key (kbd-like) */
kbd, .topic-key {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .8em;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: .1em .45em;
  border-radius: 3px;
  color: var(--ink-2);
}

/* score number — exam-paper style */
.score {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.3rem;
  letter-spacing: -.02em;
  font-variation-settings: "opsz" 144;
  color: var(--ink);
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
}
.score .of {
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 400;
  color: var(--ink-4);
  letter-spacing: .05em;
}
.score.is-mark { color: var(--vermillion); }

/* -----------------------------------------------------------------------------
   12. Action bar — for course-detail/exam-config page heads
   --------------------------------------------------------------------------- */

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin: -.4rem 0 1.2rem;
  padding: .6rem 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
  font-family: var(--font-mono);
  font-size: .8rem;
  letter-spacing: .04em;
}
.actions-row .sep { color: var(--ink-4); margin: 0 .25rem; }
.actions-row a {
  border: none;
  color: var(--ink-2);
}
.actions-row a:hover { color: var(--vermillion); }

/* -----------------------------------------------------------------------------
   13. Question / problem page
   --------------------------------------------------------------------------- */

.question-frame {
  --gutter: clamp(1.2rem, 2vw, 2rem);
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
}

.question-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-3);
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.question-rail .qix { color: var(--ink); font-weight: 600; }
.question-rail .qof { color: var(--ink-4); }
.question-rail .exit {
  border: none;
  font-size: .76rem;
  color: var(--ink-3);
}
.question-rail .exit:hover { color: var(--vermillion); }

.q-progress-icons {
  display: flex;
  gap: 4px;
  margin: 1rem 0 .35rem;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1;
}
.q-progress-icons .q-icon {
  flex: 1;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0;
}
.q-progress-icons .q-icon.is-correct { color: var(--ok); }
.q-progress-icons .q-icon.is-wrong   { color: var(--bad); }
.q-progress-icons .q-icon.is-pending { color: var(--ink-4); font-weight: 500; }

.q-progress {
  display: flex;
  gap: 4px;
  margin: 0 0 0;
  padding-bottom: .8rem;
}
.q-progress-dot {
  flex: 1;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  transition: background .2s var(--ease), height .15s var(--ease);
  display: block;
  cursor: pointer;
  text-decoration: none;
}
.q-progress-dot.is-current { background: var(--vermillion); }
.q-progress-dot.is-done    { background: var(--ink-2); }
.q-progress-dot:hover {
  background: var(--vermillion);
  height: 7px;
}
.q-progress-dot:focus-visible {
  outline: 2px solid var(--vermillion);
  outline-offset: 2px;
}

#problem-area {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: 2.2rem clamp(1.5rem, 3vw, 2.5rem);
  box-shadow: var(--shadow-2);
  position: relative;
  animation: fade-up .35s var(--ease) both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

#problem-area::before {
  content: "Q";
  position: absolute;
  top: 1.2rem;
  left: -2.4rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--vermillion);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.prompt {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-size: 1.18rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background: transparent;
  padding: 0;
  border-radius: 0;
  margin-bottom: 1.6rem;
}
.prompt mjx-container[jax="SVG"][display="true"] { margin: 1rem 0; }

#problem-area img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.4rem auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper);
  padding: .5rem;
}

.answer-form {
  border-top: 1px dashed var(--rule);
  padding-top: 1.6rem;
  margin-top: 1.6rem;
}

.answer-form label.choice {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .85rem 1rem;
  margin-bottom: .55rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
  font-weight: 400;
  color: var(--ink);
  font-size: .98rem;
  font-family: var(--font-body);
}
.answer-form label.choice:hover { border-color: var(--ink-3); background: var(--paper-2); }
.answer-form label.choice input[type="radio"] {
  appearance: none;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid var(--rule-2);
  border-radius: 50%;
  margin: 0;
  position: relative;
  flex: 0 0 1.1rem;
  cursor: pointer;
  background: var(--paper);
  transition: border-color .12s var(--ease);
}
.answer-form label.choice input[type="radio"]:checked {
  border-color: var(--vermillion);
}
.answer-form label.choice input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--vermillion);
  border-radius: 50%;
}
.answer-form label.choice:has(input:checked) {
  border-color: var(--vermillion);
  background: var(--vermillion-tint);
}
.answer-form label.choice .label-letter {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .82rem;
  color: var(--vermillion);
  flex: 0 0 auto;
}

.answer-form .answer-text {
  display: block;
}
.answer-form .answer-text label {
  font-family: var(--font-mono);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-3);
}
.answer-form .answer-text input {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  padding: .85rem 1rem;
}

.answer-form .submit-row {
  margin-top: 1.4rem;
  display: flex;
  justify-content: flex-end;
}

/* result feedback */
.feedback {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1rem 1.2rem;
  margin: 0 0 1.4rem;
  border-radius: var(--radius-1);
  border-left: 4px solid;
}
.feedback.ok      { color: var(--ok);  background: var(--ok-tint);   border-color: var(--ok); }
.feedback.bad     { color: var(--bad); background: var(--bad-tint);  border-color: var(--bad); }
.feedback.warn    { color: var(--warn); background: var(--warn-tint); border-color: var(--warn); }
.feedback .glyph {
  font-family: var(--font-display);
  font-size: 1.8rem;
  line-height: 1;
}
.feedback .body { font-size: 1rem; color: var(--ink-2); font-family: var(--font-body); font-style: normal; font-weight: 400; }
.feedback .body code { font-size: .92em; }

.q-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.6rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.q-nav a {
  border: none;
  color: var(--ink-2);
  font-weight: 600;
}
.q-nav a:hover { color: var(--vermillion); }
.q-nav .spacer { flex: 1; }

/* "Finished & Grade" button on the last question — styled to match the
   adjacent Skip link rather than the heavier btn-primary surface. */
.q-nav button.finish-and-grade {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--ink-2);
  font-weight: 600;
  text-transform: inherit;
  letter-spacing: inherit;
}
.q-nav button.finish-and-grade:hover { color: var(--vermillion); }

/* -----------------------------------------------------------------------------
   14. Exam timer — sticky at top
   --------------------------------------------------------------------------- */

.timer {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ink);
  color: var(--paper);
  padding: .7rem 1.1rem;
  border-radius: var(--radius-1);
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  font-family: var(--font-mono);
  font-size: .92rem;
  letter-spacing: .04em;
  box-shadow: var(--shadow-2);
}
.timer::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermillion);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}
.timer .label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: rgba(250, 247, 238, .65);
}
.timer .value { font-weight: 600; font-size: 1.05rem; }

/* -----------------------------------------------------------------------------
   15. Exam overview / review
   --------------------------------------------------------------------------- */

.exam-overview {
  display: grid;
  gap: 1.4rem;
}

.exam-status-table .status-cell {
  text-align: center;
  width: 5rem;
}

.exam-status-table .glyph {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: normal;
}
.exam-status-table .glyph.ok  { color: var(--ok); }
.exam-status-table .glyph.bad { color: var(--bad); }
.exam-status-table .glyph.q   { color: var(--ink-4); }

.review-item {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-2);
  padding: 0;
  margin-bottom: .9rem;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.review-item summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  font-family: var(--font-body);
  font-size: .98rem;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: background .15s var(--ease);
}
.review-item summary::-webkit-details-marker { display: none; }
.review-item summary:hover { background: var(--paper-2); }
.review-item[open] > summary { border-bottom-color: var(--rule); background: var(--paper-2); }
.review-item summary .qnum {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .14em;
}
.review-item summary .title { flex: 1; color: var(--ink); }
.review-item .body {
  padding: 1.2rem 1.4rem 1.6rem;
}

/* -----------------------------------------------------------------------------
   16. Confirm splash (exam start)
   --------------------------------------------------------------------------- */

.confirm-splash {
  max-width: 640px;
  margin: 2rem auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-3);
  padding: 2.4rem 2.4rem 2.2rem;
  box-shadow: var(--shadow-2);
}
.confirm-splash .warn-strap {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--vermillion);
  margin-bottom: 1rem;
}
.confirm-splash .warn-strap::before {
  content: "▲";
  font-size: .7rem;
}
.confirm-splash p { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink-2); }
.confirm-splash label.checkbox {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 1.2rem 0;
  font-family: var(--font-body);
  font-size: .94rem;
  color: var(--ink-2);
  cursor: pointer;
}
.confirm-splash .actions {
  display: flex;
  gap: .8rem;
  align-items: center;
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--rule);
}

/* -----------------------------------------------------------------------------
   17. Score history list (student/course)
   --------------------------------------------------------------------------- */

.score-table .topic { font-weight: 500; color: var(--ink); }
.score-table .topic .key { display: block; font-family: var(--font-mono); font-size: .76rem; color: var(--ink-4); margin-top: .2rem; }
.score-table .pct { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }
.score-table .pct.dim { color: var(--ink-4); font-weight: 400; }
.score-table .pct .small { font-size: .8em; color: var(--ink-4); margin-left: .35rem; }

/* Hint disclosure — used on the student question page, the admin
   View drawer, and the Edit drawer's preview pane. Renders an explicit
   ▶ / ▼ glyph so the affordance shows up consistently regardless of
   browser default marker behaviour. */
.hint-disclosure {
  margin-top: 1rem;
  padding: .5rem .8rem;
  background: var(--paper-2);
  border: 1px dashed var(--rule);
  border-radius: var(--radius-1);
}
.hint-disclosure > summary { list-style: none; }
.hint-disclosure > summary::-webkit-details-marker { display: none; }
.hint-disclosure > summary::marker { display: none; }
.hint-disclosure > summary {
  cursor: pointer;
  font-size: .88rem;
  color: var(--ink-3);
  user-select: none;
}
/* Glyph rendered as an actual unicode triangle so it's guaranteed
   visible — zero-sized CSS-border triangles silently disappear in
   some browsers when the parent uses inline-flex. */
.hint-disclosure > summary::before {
  content: "▶";
  display: inline-block;
  margin-right: .45rem;
  font-size: .7em;
  color: var(--ink-3);
  transition: transform .15s var(--ease, ease);
  transform-origin: 50% 50%;
}
.hint-disclosure[open] > summary::before {
  transform: rotate(90deg);
  color: var(--ink);
}
.hint-disclosure[open] > summary { color: var(--ink); margin-bottom: .35rem; }
.hint-body {
  font-size: .92rem;
  color: var(--ink-2);
  line-height: 1.5;
}

/* Compact circular close affordance for drawer/panel headers. */
.drawer-close {
  margin-left: auto;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease),
              border-color .15s var(--ease), transform .15s var(--ease);
}
.drawer-close:hover {
  color: var(--vermillion);
  background: var(--vermillion-tint);
  border-color: var(--vermillion);
}
.drawer-close:active { transform: scale(.92); }
.drawer-close:focus-visible {
  outline: 2px solid var(--vermillion);
  outline-offset: 2px;
}

/* The aggregator the professor designates as the "imported grade" gets
   highlighted in the assignments table. */
.pct.score-official,
.score-official {
  background: var(--vermillion-tint);
  color: var(--vermillion-2);
  padding: .12em .42em;
  border-radius: 4px;
}

/* Compact assignment-mode form: question count + score mode on a single
   row, narrower controls so both fit. */
.assn-mode-form {
  flex-wrap: nowrap;
  gap: .25rem;
  align-items: center;
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
}
/* Override .form-inline's `flex: 1 1 12rem` so children size to content
   instead of each claiming 12rem — otherwise Score Format and the
   "out of N pts" controls get pushed onto a second row. Higher
   specificity (form.assn-mode-form vs .form-inline) so we beat the
   inherited rule regardless of source-order. */
form.assn-mode-form > *,
.assn-mode-form > * { flex: 0 0 auto !important; min-width: 0; }

/* The two logical groups (question-count + score-format) each render as
   a single flex child of the form so their internals can't be split
   across rows by the outer wrap. */
.assn-mode-group {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.assn-mode-form .dim-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  margin: 0 .15rem 0 0;
}
.assn-mode-form .compact {
  font-size: .82rem;
  padding: .1rem .3rem;
  height: auto;
  max-width: 11rem;
  text-overflow: ellipsis;
}
.assn-mode-form .compact-num {
  width: 3rem;
  font-size: .82rem;
  padding: .1rem .25rem;
  height: auto;
}
.assn-mode-form .assn-mode-sep {
  color: var(--ink-4);
  margin: 0 .2rem;
}

/* Summary row at the bottom of each assignment table — averages of the
   per-assignment max/min/avg across all assignments of that kind. */
.score-table tfoot .summary-row td {
  border-top: 2px solid var(--rule);
  padding-top: .8rem;
  background: var(--paper-2);
}
.score-table tfoot .summary-row .summary-label {
  font-family: var(--font-mono);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
}

/* -----------------------------------------------------------------------------
   18. List items (homework etc.)
   --------------------------------------------------------------------------- */

.tile-list { list-style: none; padding: 0; margin: 0; }
.tile-list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  background: var(--paper);
  margin-bottom: .55rem;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.tile-list li:hover { border-color: var(--rule-2); background: var(--paper-2); }
.tile-list li strong { color: var(--ink); font-weight: 600; font-family: var(--font-body); }
.tile-list li .key {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--ink-3);
  margin-left: auto;
}
.tile-list li form { margin-left: .6rem; }

/* -----------------------------------------------------------------------------
   19. Section dividers (∫ ∑ etc.)
   --------------------------------------------------------------------------- */

.section-mark {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.6rem 0 1.4rem;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .2em;
}
.section-mark::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.section-mark .glyph {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--vermillion);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

/* -----------------------------------------------------------------------------
   20. Misc utilities
   --------------------------------------------------------------------------- */

.muted   { color: var(--ink-3); }
.dim     { color: var(--ink-4); }
.center  { text-align: center; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }

/* -----------------------------------------------------------------------------
   Tab bars (admin/teacher/TA/student all share this look)
   ---------------------------------------------------------------------------*/
.admin-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--rule);
  margin: 0 0 1.6rem;
  padding: 0;
}
.admin-tabs .tab {
  appearance: none; background: transparent; border: 0;
  padding: .8rem 1.1rem .9rem;
  font-family: var(--font-body);
  font-size: .92rem;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: .5rem;
  transition: color .12s var(--ease), border-color .12s var(--ease);
}
.admin-tabs .tab:hover { color: var(--ink); }
.admin-tabs .tab.is-active {
  color: var(--vermillion);
  border-bottom-color: var(--vermillion);
}
.admin-tabs .tab-glyph {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--vermillion);
  opacity: .85;
}
.admin-tabs .tab-count {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--ink-4);
  background: var(--paper-2);
  border-radius: 9px;
  padding: .08rem .5rem;
}
.admin-tabs .tab.is-active .tab-count {
  color: var(--vermillion);
  background: var(--vermillion-tint);
}
.tab-panel { display: none; animation: panelFade .18s var(--ease); }
.tab-panel.is-active { display: block; }
@keyframes panelFade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* selection */
::selection { background: var(--vermillion-tint); color: var(--ink); }

/* scrollbar (subtle) */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule-2);
  border-radius: 6px;
  border: 3px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
