:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --pass: #3fb950;
  --fail: #f85149;
  --pending: #d29922;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  line-height: 1.45;
  min-height: 100vh;
  padding: 32px 20px 60px;
}
.sheet {
  max-width: 720px;
  margin: 0 auto;
}
header {
  border-bottom: 1px solid var(--line);
  padding: 0 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.title-block h1 {
  font-size: 24px;
  margin: 0 0 4px;
  font-weight: 600;
}
.title-block .sub {
  font-size: 12px;
  color: var(--muted);
}
.points-of { text-align: right; }
.points-of .big { font-size: 34px; font-weight: 700; line-height: 1; }
.points-of .lbl { font-size: 11px; color: var(--muted); }

.body { padding: 24px 0 0; }

.drop {
  display: block;
  border: 1px dashed var(--line);
  padding: 24px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
  cursor: pointer;
  border-radius: 6px;
}
.drop.drag { border-color: var(--text); background: rgba(255,255,255,0.03); }
.drop strong { display: block; font-size: 15px; margin-bottom: 4px; font-weight: 600; }
.drop span { font-size: 12px; color: var(--muted); }
.filename { margin-top: 12px; font-size: 13px; color: var(--muted); }
input[type=file] { display: none; }

.actions { display: flex; gap: 12px; margin: 18px 0 4px; align-items: center; }
button {
  font-family: inherit;
  font-size: 13px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
}
button:disabled { opacity: .35; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.status { font-size: 12px; color: var(--muted); }

.rubric { margin-top: 24px; }
.rubric-row {
  border-top: 1px solid var(--line);
  padding: 14px 0;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 14px;
  align-items: start;
}
.rubric-row:last-child { border-bottom: 1px solid var(--line); }
.mark { font-size: 16px; text-align: center; line-height: 1.3; }
.mark.pass { color: var(--pass); }
.mark.fail { color: var(--fail); }
.mark.pending { color: var(--pending); }
.r-name { font-weight: 600; font-size: 14px; }
.r-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.r-detail { font-size: 12px; margin-top: 8px; white-space: pre-wrap; }
.r-detail .good { color: var(--pass); }
.r-detail .bad { color: var(--fail); }
.r-score { font-size: 14px; white-space: nowrap; text-align: right; color: var(--muted); }
.word { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }

details.diff { margin-top: 8px; }
details.diff summary { cursor: pointer; font-size: 12px; color: var(--muted); }
pre.io {
  background: #010409;
  color: var(--text);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.5;
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
}
pre.io .miss { background: rgba(248,81,73,0.2); }

.summarybox {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
}
.summarybox-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.copy-wrap { display: flex; align-items: center; gap: 10px; }
.copy-wrap button { padding: 6px 12px; font-size: 12px; }
.summarybox-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.zero-banner {
  margin-top: 16px;
  background: rgba(248,81,73,0.12);
  color: var(--fail);
  border: 1px solid var(--fail);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 12px;
  text-align: center;
}

footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 26px;
}

/* Index pages: bullet list of links to the assignment pages. */
.links { margin: 24px 0 0; padding-left: 20px; font-size: 14px; }
.links li { margin: 6px 0; }
.links a { color: var(--text); }
.links a:hover { color: var(--pass); }

/* Two columns: the handout on the left, the grader on the right. An assignment
   page opts in by wrapping both sections in .split; a page with no handout
   leaves it out and keeps the single centred sheet. */
.split {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}
.split .sheet { max-width: none; margin: 0; }
/* Nothing sits above the handout in its column, so it starts at the top. */
.split .prose { padding-top: 0; }
@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}

/* Handout prose, rendered from an assignment's markdown by src/markdown.js.
   Every rule here is shared, so an assignment page carries only its layout. */
.prose { font-size: 13px; padding-top: 24px; }
.prose p { margin: 0 0 10px; }
.prose ol, .prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin: 5px 0; }
/* A nested list sits under its entry rather than floating a line away, and an
   entry that grew a paragraph keeps the spacing of one that did not. */
.prose li > ul, .prose li > ol { margin: 5px 0 0; }
.prose li > p { margin: 0 0 6px; }
.prose li > p:last-child { margin-bottom: 0; }
.prose h1 { font-size: 24px; margin: 26px 0 10px; font-weight: 600; }
.prose h1:first-child {
  margin: 0 0 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 26px 0 10px;
}
.prose h2:first-child { margin-top: 0; }
.prose code {
  background: #010409;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
.prose pre.io { margin: 8px 0 10px; }
.prose pre.io code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose a { color: var(--pass); }
.prose img { max-width: 100%; border-radius: 6px; margin: 8px 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.prose blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 10px;
  font-size: 12px;
}
.prose th, .prose td {
  border-bottom: 1px solid var(--line);
  padding: 7px 10px 7px 0;
  text-align: left;
  vertical-align: top;
}
.prose th { color: var(--muted); font-weight: 600; }
.prose .align-left { text-align: left; }
.prose .align-center { text-align: center; }
.prose .align-right { text-align: right; }

/* A handout that failed to load says so where the prose would have been. */
.handout-error { color: var(--fail); }

/* The optional editor pane, rendered by page.js when an assignment asks for
   one. It sits at the top of the grader column, above the drop zone. */
.editor-pane { margin-bottom: 22px; }

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 12px;
}
.editor-actions { display: flex; gap: 8px; }
.editor-actions button { padding: 5px 11px; font-size: 11.5px; }

/* The gutter is a sibling rather than a background, so it has to match the
   textarea's metrics exactly: same font, same size, same line-height, same
   vertical padding. A pixel of drift here and line 40 points at line 39. */
.editor {
  display: flex;
  background: #010409;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  height: 46vh;
  min-height: 260px;
  resize: vertical;
}
.editor .gutter,
.editor .highlight,
.editor textarea {
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 0;
  margin: 0;
  border: 0;
  background: none;
}
/* Each layer is a window that clips and a block inside it that moves. The
   window never scrolls; editor.js translates the block. */
.editor .gutter code,
.editor .highlight code {
  display: block;
  font: inherit;
  background: none;
  padding: 0;
  border: 0;
}
.editor .gutter {
  color: var(--muted);
  text-align: right;
  padding-right: 10px;
  padding-left: 12px;
  min-width: 44px;
  overflow: hidden;
  user-select: none;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

/* The textarea and the coloured copy behind it are stacked, so they need a
   positioned box of their own rather than a slot in the editor's flex row. */
.editor .code-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.editor .highlight,
.editor textarea {
  position: absolute;
  inset: 0;
  padding-left: 12px;
  padding-right: 12px;
  white-space: pre;
  tab-size: 4;
  overflow-wrap: normal;
  word-break: normal;
}
/* Behind the textarea, and scrolled by it rather than by the wheel: a scroll
   of its own would slide the colour off the text. */
.editor .highlight {
  color: var(--text);
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.editor textarea {
  /* The text itself is drawn by the layer below; the textarea keeps the
     caret, the selection, and every behaviour a real textarea has. */
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  resize: none;
  outline: none;
  overflow: auto;
}
/* Opaque, this would paint over the colours instead of marking them. */
.editor textarea::selection { background: rgba(88,166,255,0.32); }

/* One colour per token kind from highlight.js. Chosen against #010409 and
   kept close to the palette the rest of the sheet already uses. */
.editor .highlight .tok-comment { color: #8b949e; font-style: italic; }
.editor .highlight .tok-string { color: #a5d6ff; }
.editor .highlight .tok-number { color: #f0883e; }
.editor .highlight .tok-keyword { color: #ff7b72; }
.editor .highlight .tok-builtin { color: #79c0ff; }
.editor .highlight .tok-def { color: #d2a8ff; }
.editor .highlight .tok-decorator { color: #d2a8ff; }
.editor .highlight .tok-op { color: #ff7b72; }

.run-bar { display: flex; gap: 10px; align-items: center; margin: 12px 0 0; }
.run-bar button { padding: 8px 16px; }
.run-bar select {
  font-family: inherit;
  font-size: 12px;
  background: #010409;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  max-width: 260px;
}

.stdin-label {
  display: block;
  margin: 14px 0 5px;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
textarea.stdin {
  width: 100%;
  background: #010409;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 11px;
  resize: vertical;
}

.console { margin-top: 14px; }
.console pre.io { margin: 0 0 8px; }
.console pre.io.bad { border-color: var(--fail); }
.console .jump { padding: 5px 11px; font-size: 11.5px; }
.console-note { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.console-note.good { color: var(--pass); }
.console-note.bad { color: var(--fail); }

/* Stacked in one column there is no second column to borrow height from, so
   the editor takes a fixed slice of the viewport instead of half of it. */
@media (max-width: 900px) {
  .editor { height: 340px; }
}
