:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --canvas: #eff3f8;
  --paper: #fff;
  --ink: #182a42;
  --muted: #53647b;
  --navy: #14253c;
  --line: #d7e0eb;
  --accent: #174ebd;
  --accent-hover: #103d99;
  --selected: #eaf1ff;
  --success: #145a45;
  --success-bg: #e8f5ee;
  --warn: #7c480d;
  --warn-bg: #faf0dc;
  --danger: #9e2e33;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; }
::selection { background: #dbe8ff; color: var(--ink); }
:focus-visible { outline: 3px solid #326bdd; outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: .18em; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 2rem; letter-spacing: -.035em; line-height: 1.15; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; line-height: 1.25; }
h3 { font-size: 1.0625rem; line-height: 1.3; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .64; }
input { width: 100%; min-width: 0; min-height: 46px; border: 1px solid #aabbd0; border-radius: 8px; padding: .55rem .7rem; background: var(--paper); color: var(--ink); caret-color: var(--accent); }
input::placeholder { color: #65768c; opacity: 1; }
input:focus { border-color: var(--accent); }

.visually-hidden, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 10; top: 8px; left: 10px; padding: 10px; background: var(--paper); }
.topbar { background: var(--navy); color: #fff; }
.topbar-inner { max-width: 72rem; margin: auto; display: flex; justify-content: space-between; align-items: center; min-height: 4rem; gap: .75rem; padding: .5rem 1.5rem; }
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1rem; font-weight: 700; letter-spacing: -.015em; }
.brand-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; background: #dce8ff; color: #183d86; border-radius: .65rem; font-size: .875rem; font-weight: 800; }
.button { min-height: 44px; border-radius: 8px; border: 1px solid transparent; padding: .55rem .9rem; font-size: .9375rem; font-weight: 650; }
.primary { color: #fff; background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { background: var(--paper); color: var(--ink); border-color: #aabbd0; }
.secondary:hover:not(:disabled) { background: var(--selected); }
.sign-out { color: #edf4ff; border-color: #5c6e87; background: transparent; }
.sign-out:hover { background: #233a57; }
.topbar :focus-visible { outline-color: #a9c7ff; }
.page { max-width: 72rem; margin: 0 auto; padding: 2.15rem 1.5rem 2.5rem; }
.muted { color: var(--muted); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.sign-in, #loading { max-width: 28rem; margin: 4.5vh auto 0; padding: 1.65rem; }
.sign-in p, #loading p { margin-top: .55rem; }
.sign-in form { margin-top: 1.35rem; }
.sign-in label { display: block; font-weight: 650; margin-bottom: .35rem; }
.sign-in .button { width: 100%; margin-top: .9rem; }
#retry { margin-top: .9rem; }

.overview { display: grid; grid-template-columns: 1fr minmax(15rem, 23rem); align-items: center; gap: 1rem; margin-bottom: 1.45rem; }
.overview .muted { margin-top: .3rem; font-size: .9375rem; }
.progress-panel { background: #e3ebf7; padding: .7rem .9rem; border-radius: 10px; }
.progress-title { display: flex; justify-content: space-between; gap: .5rem; align-items: center; font-size: .875rem; margin-bottom: .4rem; }
#progress-pending { color: var(--muted); }
progress { width: 100%; height: 7px; display: block; border: 0; border-radius: 8px; background: #cbd8ea; accent-color: var(--accent); overflow: hidden; }
progress::-webkit-progress-bar { background: #cbd8ea; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--accent); }

.workspace-grid { display: grid; align-items: start; grid-template-columns: minmax(17rem, .85fr) minmax(0, 1.55fr); gap: 1.3rem; }
.roster { min-width: 0; }
.roster-controls { display: grid; gap: .8rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.filter { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; border-radius: 9px; padding: .2rem; background: #eef2f7; }
.filter button { border: 1px solid transparent; border-radius: 7px; background: transparent; min-height: 42px; color: var(--muted); padding: .3rem; font-size: .875rem; font-weight: 650; }
.filter button:hover { color: var(--accent); }
.filter button[aria-pressed="true"] { background: var(--paper); border-color: #d2dfef; color: #1b458e; }
#student-list { margin: 0; padding: .25rem .5rem; list-style: none; max-height: min(65vh, 45rem); overflow: auto; scrollbar-color: #aabbd0 transparent; }
#student-list li + li { border-top: 1px solid #e5ebf2; }
.student { text-align: left; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .6rem; width: 100%; margin: .2rem 0; padding: .55rem .65rem; min-height: 58px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); }
.student:hover { background: #f2f6fc; }
.student[aria-current="true"] { background: var(--selected); border-color: #c5d6f7; }
.student .student-id { display: block; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; margin-top: .12rem; }
.student strong { display: block; font-size: .9375rem; line-height: 1.25; overflow-wrap: anywhere; }
.state { display: inline-block; white-space: nowrap; padding: .18rem .45rem; border-radius: 5px; font-weight: 650; font-size: .8125rem; background: #edf1f6; color: #465a71; }
.state[data-state="marked"] { background: var(--success-bg); color: var(--success); }
.state[data-state="partial"] { background: var(--warn-bg); color: var(--warn); }
.roster-message { padding: .9rem 1rem; }

.editor { min-width: 0; }
#editor-content, #editor-empty { padding: 1.2rem 1.35rem; }
.back { display: none; }
.student-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.student-heading h2 { font-size: 1.55rem; overflow-wrap: anywhere; }
.student-heading .muted { font-size: .875rem; margin-top: .25rem; font-variant-numeric: tabular-nums; }
#mark-fields { min-width: 0; border: 0; margin: 1rem 0 0; padding: 0; }
legend { padding: 0; margin-bottom: .35rem; font-weight: 750; font-size: 1.0625rem; }
.score-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; min-height: 56px; padding: .25rem 0; border-bottom: 1px solid #e5ebf2; }
.score-row label, .link-label label { font-weight: 600; font-size: .9375rem; }
.score-control { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.score-control input { width: 4rem; padding: .35rem .35rem; text-align: center; appearance: textfield; }
.score-control input::-webkit-inner-spin-button { appearance: none; }
.score-control span, .score-total span { color: var(--muted); font-size: .875rem; }
.score-total { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .65rem 0 0; padding: .5rem .75rem; background: #edf3ff; border-radius: 8px; }
.score-total p { display: flex; align-items: baseline; gap: .5rem; font-variant-numeric: tabular-nums; }
.score-total output { font-weight: 800; color: #194488; font-size: 1.35rem; }
.links { display: grid; gap: .65rem; margin-top: 1.2rem; }
.links h3 span { margin-left: .35rem; color: var(--muted); font-size: .8125rem; font-weight: 500; }
.link-label { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.link-label a { font-size: .8125rem; font-weight: 650; }
.form-footer { margin-top: .9rem; }
.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .55rem; }
.feedback:not(:empty) { margin-bottom: .55rem; color: var(--success); font-size: .875rem; }
.feedback[data-error="true"] { color: var(--danger); }
#reload-marks { margin-bottom: .65rem; }

@media (max-width: 47rem) {
  .topbar-inner { padding-inline: .85rem; min-height: 3.6rem; }
  .page { padding: 1.05rem .75rem 1.6rem; }
  h1 { font-size: 1.65rem; }
  .overview { grid-template-columns: 1fr; gap: .65rem; margin-bottom: .8rem; }
  .workspace-grid { display: block; }
  #student-list { max-height: none; overflow: visible; }
  #workspace:not(.student-open) #editor, .student-open #roster, .student-open .overview { display: none; }
  .back { display: inline-block; margin-bottom: .7rem; }
  #editor-content, #editor-empty { padding: .9rem; }
  .student-heading { padding-bottom: .75rem; }
  .student-heading h2 { font-size: 1.35rem; }
  #mark-fields { margin-top: .75rem; }
  .links { margin-top: .9rem; }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
