/* gradebook.css — Gradebook page styles */

/* Force page-main to constrain children so the grid fills remaining viewport.
   overflow-y:hidden prevents page-main from becoming a scroll container,
   forcing flex children to fit within the available space instead.
   Scoped by .page-gradebook (page-gradebook.js adds it to #main) so it only applies when the gradebook is active (not conflicting with reports.css). */
.page-main.page-gradebook {
  overflow-y: hidden !important;
  min-height: 0 !important;
}

/* Sidebar toggle hidden via JS in page-gradebook.js init() */

/* ══════════════════════════════════════════════════════════════
   TOOLBAR — Search, Show, New (gradebook-toolbar.js)
   The same "Three Things" bar as the Assignments page: the parts they
   share (Search with its Filter button, Show's badges, the chips, ⋯) are in
   styles.css. The filter panel floats over the grid, under Search.
   ══════════════════════════════════════════════════════════════ */
.gb-toolbar {
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  gap: 8px;
  /* Search is 260 wide when there is room, and gives way to 160 first. */
  --atb-search-min: 160px;
  --atb-search-max: 260px;
}
/* + New Assessment is the size it is on the Assignments bar. */
.gb-toolbar .tb-action-btn {
  flex-shrink: 0;
  padding: 0 12px;
  font-size: var(--text-sm);
}
/* Scores | Competencies keep their widths whichever is chosen: each button
   reserves its label's bold width, so nothing after them moves. */
.gb-toolbar .gb-seg-btn {
  display: inline-grid;
}
.gb-toolbar .gb-seg-btn::after {
  content: attr(data-label);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 600;
}
.gb-toolbar .atb-end .assess-menu {
  min-width: 180px;
}
/* × inside the field, just left of Filter, while the box holds a search;
   Escape does the same. */
.gb-search-clear {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-right: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-base);
  line-height: 1;
  cursor: pointer;
}
.gb-search-clear:hover {
  background: var(--overlay-hover);
}

/* The filter panel: up to three columns (Category, Competencies, Modules),
   each drawn only when the class has that thing. It is as wide as its
   columns need, and each column scrolls on its own past about eleven rows. */
.gbf-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: max-content;
  max-width: calc(100vw - 16px);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.16),
    0 0 0 0.5px var(--divider-medium);
}
.gbf-cols {
  display: flex;
  align-items: stretch;
}
.gbf-col {
  flex: 0 0 auto;
  min-width: 220px;
  max-width: 360px;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gbf-col + .gbf-col {
  border-left: 1px solid var(--divider-medium);
}
.gbf-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: var(--gbf-list-h, 374px);
  overflow-y: auto;
}
.gbf-panel .assess-filter-item {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3);
  white-space: nowrap;
}
.gbf-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gbf-folder {
  display: flex;
  align-items: center;
  gap: 2px;
}
.gbf-kid {
  padding-left: 36px !important;
}
.gbf-chev {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.gbf-chev:hover {
  background: var(--overlay-hover);
  color: var(--text);
}
.gbf-chev:focus-visible {
  outline: 2px solid var(--active);
  outline-offset: -2px;
}
.gbf-chev svg {
  transition: transform 0.15s;
}
.gbf-chev[aria-expanded='true'] svg {
  transform: rotate(90deg);
}
/* A folder with only some of its competencies ticked: a dash in its box. */
.assess-filter-item.is-some .assess-filter-box {
  border-color: var(--active);
  background: var(--active)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    center / 14px no-repeat;
}
.gbf-foot {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-2);
  border-top: 1px solid var(--divider-medium);
}
.gbf-panel .gbf-clear {
  flex: 0 0 auto;
  width: auto;
  height: 30px;
  padding: 0 12px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--link);
}

/* Point to preview (Scores view): while the pointer or the keyboard rests on
   an unpressed To Grade, To Return or Questions, the cells it would not keep
   dim, and the names of the students with none. The delay keeps the grid
   still as the pointer crosses the bar. */
.page-layout:has(.atb-show [data-show='tograde']:is(:hover, :focus-visible):not([aria-pressed='true']))
  :is(
    #gb-data .gb-scores-cell:not(:has(.gb-to-grade)),
    #gb-rowheads .gb-grid-rowhead:not(.gb-grid-rowhead-stats, [data-has~='tograde'])
  ),
.page-layout:has(.atb-show [data-show='toreturn']:is(:hover, :focus-visible):not([aria-pressed='true']))
  :is(
    #gb-data .gb-scores-cell:not(.gb-draft),
    #gb-rowheads .gb-grid-rowhead:not(.gb-grid-rowhead-stats, [data-has~='toreturn'])
  ),
.page-layout:has(.atb-show [data-show='questions']:is(:hover, :focus-visible):not([aria-pressed='true']))
  :is(
    #gb-data .gb-scores-cell:not(:has(.gb-question)),
    #gb-rowheads .gb-grid-rowhead:not(.gb-grid-rowhead-stats, [data-has~='questions'])
  ) {
  opacity: 0.3;
}
@media (prefers-reduced-motion: no-preference) {
  #gb-data .gb-scores-cell,
  #gb-rowheads .gb-grid-rowhead {
    transition: opacity 150ms ease;
  }
  .page-layout:has(.atb-show [data-show='tograde']:is(:hover, :focus-visible):not([aria-pressed='true']))
    :is(
      #gb-data .gb-scores-cell:not(:has(.gb-to-grade)),
      #gb-rowheads .gb-grid-rowhead:not(.gb-grid-rowhead-stats, [data-has~='tograde'])
    ),
  .page-layout:has(.atb-show [data-show='toreturn']:is(:hover, :focus-visible):not([aria-pressed='true']))
    :is(
      #gb-data .gb-scores-cell:not(.gb-draft),
      #gb-rowheads .gb-grid-rowhead:not(.gb-grid-rowhead-stats, [data-has~='toreturn'])
    ),
  .page-layout:has(.atb-show [data-show='questions']:is(:hover, :focus-visible):not([aria-pressed='true']))
    :is(
      #gb-data .gb-scores-cell:not(:has(.gb-question)),
      #gb-rowheads .gb-grid-rowhead:not(.gb-grid-rowhead-stats, [data-has~='questions'])
    ) {
    transition: opacity 150ms ease 120ms;
  }
}

/* ── Table ─────────────────────────────────────────────────── */
.gb-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
  position: relative;
  padding: 0 20px;
}

/* Scroll shadow hints — fade in/out via JS classes */
.gb-scroll-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.gb-scroll-wrap::before,
.gb-scroll-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.gb-scroll-wrap::before {
  left: 0;
  background: linear-gradient(to right, var(--divider-subtle), transparent);
}
.gb-scroll-wrap::after {
  right: 0;
  background: linear-gradient(to left, var(--divider-subtle), transparent);
}
.gb-scroll-wrap.shadow-left::before {
  opacity: 1;
}
.gb-scroll-wrap.shadow-right::after {
  opacity: 1;
}

.gb-assess-title {
  font-family: var(--font-base);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  text-decoration: none;
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gb-assess-title:hover {
  color: var(--active);
}
.gb-assess-meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-content: center;
}
.gb-assess-date {
  font-family: var(--font-base);
  font-size: var(--text-2xs);
  color: var(--text-3);
  white-space: nowrap;
}
.gb-assess-type-pill {
  font-family: var(--font-base);
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 1px var(--space-2);
  border-radius: var(--radius);
  line-height: 1.4;
}
/* .sum / .form are kept for legacy hooks but the actual color is now driven
   by an inline style derived from CATEGORY_PALETTE (see shared/constants.js
   categoryTintByIndex). The fallbacks below only show up if inline style is
   missing for some reason. */
.gb-assess-type-pill.sum {
  background: var(--surface-2);
  color: var(--text-2);
}
.gb-assess-type-pill.form {
  background: var(--surface-2);
  color: var(--text-2);
}
.gb-assess-badge {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 1px var(--space-1);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--active);
  letter-spacing: var(--tracking-wide);
}

/* Section color stripe under assessment header */
.gb-assess-stripe {
  height: 3px;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Score cell */
.gb-score {
  text-align: center;
  padding: 4px 2px;
  border-bottom: 0.5px solid var(--divider-medium);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  min-width: 54px;
  background: var(--surface);
}
.gb-score:hover {
  background: rgba(0, 122, 255, 0.06);
}
.gb-score-val {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  color: #fff;
}
.gb-score-val.s0 {
  background: transparent;
  color: var(--text-3);
}
.gb-score-val.s1 {
  background: var(--score-1);
}
.gb-score-val.s2 {
  background: var(--score-2);
}
.gb-score-val.s3 {
  background: var(--score-3);
}
.gb-score-val.s4 {
  background: var(--score-4);
}
/* Dark mode's level colours are light, so their numbers are dark (white on
   them was about 2.7:1). */
@media (prefers-color-scheme: dark) {
  .gb-score-val:not(.s0) {
    color: #1d1d1f;
  }
}
/* A rubric competency whose criteria disagree: the lowest is shown, with a
   striped fill. */
.gb-score-val.gb-mixed {
  /* The rubric grid's mixed fill (assignments.css .rsg-level.active.mixed). */
  background-image: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.32) 3px,
    rgba(255, 255, 255, 0.32) 6px
  );
}
.gb-score.gb-focus,
#gb-data .gb-scores-cell.gb-focus {
  outline: 2px solid var(--active);
  outline-offset: -1px;
  z-index: 1;
  position: relative;
}
/* The selected cell draws its own ring; a focused cell without the
   selection (just after Escape) draws none. */
.gb-score:focus:not(.gb-focus),
.gb-scores-cell:focus:not(.gb-focus) {
  outline: none;
}
.gb-unscored {
  color: var(--text-3) !important;
  font-size: var(--text-xs);
  opacity: 0.5;
}

/* ── Assessment group discrimination ── */
.gb-group-start {
  border-left: 3px solid var(--border-2);
  padding-left: var(--space-2);
}
.gb-group-alt {
  background-color: rgba(0, 0, 0, 0.025);
}
th.gb-group-alt {
  background-color: rgba(0, 0, 0, 0.03);
}
.gb-stats-row td.gb-group-alt {
  background: var(--bg) !important;
}

/* Name column — z-index: body=5, header=10 (above all scrolling content) */
.gb-name {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--bg);
  padding: 8px 12px 8px 16px;
  font-size: var(--text-md);
  font-weight: 500;
  border-bottom: 0.5px solid var(--divider-medium);
  white-space: nowrap;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}
.gb-name a {
  color: var(--text);
  text-decoration: none;
}
.gb-name a:hover {
  color: var(--link);
}
.gb-corner {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg);
  padding: 8px 12px 8px 16px;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}

/* Overall column — always visible, paired with name */
.gb-overall-col {
  position: sticky;
  left: 160px;
  z-index: 5;
  background: var(--bg);
  text-align: center;
  padding: 8px 8px;
  border-bottom: 0.5px solid var(--divider-medium);
  border-right: 1px solid var(--divider-strong);
  width: 90px;
  min-width: 90px;
  max-width: 90px;
}
.gb-overall-col-header {
  position: sticky;
  left: 160px;
  z-index: 10;
  background: var(--bg);
  text-align: center;
  padding: 8px 8px;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-2);
  border-bottom: none;
  border-right: 1px solid var(--divider-strong);
  width: 90px;
  min-width: 90px;
  max-width: 90px;
}
.gb-overall-num {
  font-family: var(--font-base);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1;
}
.gb-overall-label {
  font-family: var(--font-base);
  font-size: var(--text-2xs);
  font-weight: 600;
  margin-top: 1px;
  line-height: 1;
}
.gb-stats-row .gb-overall-col {
  font-weight: 700;
  background: var(--bg) !important;
}

/* Sortable */
.gb-sortable {
  cursor: pointer;
  user-select: none;
}
.gb-sortable:hover {
  background: rgba(0, 122, 255, 0.06) !important;
}
.gb-sort-arrow {
  font-size: var(--text-2xs);
  margin-left: 2px;
  color: var(--active);
}

/* Average cell */
.gb-avg-cell {
  text-align: center;
  padding: var(--space-2) var(--space-1);
  border-bottom: 0.5px solid var(--divider-medium);
  background: var(--surface);
}
.gb-avg-val {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  line-height: 1;
}

/* Student popover — fixed-position tooltip appended to body */
#gb-tooltip {
  display: none;
  position: fixed;
  z-index: var(--z-popover);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  padding: var(--space-3);
  white-space: nowrap;
  min-width: 200px;
  pointer-events: none;
}
#gb-tooltip.dark {
  background: var(--text);
  color: var(--surface);
  border: none;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  white-space: normal;
  max-width: 260px;
  line-height: 1.4;
  min-width: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.gb-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  font-size: var(--text-base);
}
.gb-tip-label {
  color: var(--text-3);
}
.gb-tip-val {
  font-weight: 600;
}
.gb-tip-head {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-2);
}
.gb-tip-head:first-child {
  margin-top: 0;
}
.gb-tip-name {
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
}
.gb-tip-name + .gb-tip-head {
  margin-top: 0;
}
/* The card on a student's name (teacher/student-outlook.js): the grade with
   how it has moved and a line of it over the year, a bar a category as wide
   as its share of the grade, then the missing work and what handing each
   piece in adds. One width, so a long title is cut, never the card wider. */
#gb-tooltip.gb-tip-student {
  width: 296px;
  box-sizing: border-box;
  padding: var(--space-3);
  white-space: normal;
  font-size: var(--text-base);
}
.gb-tip-student .gb-tip-name {
  margin-bottom: 4px;
}
.gb-card-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.gb-tip-student .gb-tip-grade {
  font-size: 22px;
  line-height: 1.2;
}
.gb-card-move {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: var(--text-sm);
  font-weight: 600;
}
.gb-card-move.is-up {
  color: var(--score-3-dark);
}
.gb-card-move.is-down {
  color: var(--score-1-dark);
}
.gb-card-line {
  flex: none;
}
.gb-card-cats {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-2);
}
.gb-card-seg {
  min-width: 0;
  height: 10px;
  border-radius: 4px;
  background: var(--seg-track, var(--border));
  overflow: hidden;
}
.gb-card-seg > div {
  height: 100%;
}
.gb-card-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 1px 0;
}
.gb-card-what {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gb-card-row small {
  font-size: var(--text-xs);
  color: var(--text-2);
  white-space: nowrap;
}
.gb-card-row b {
  white-space: nowrap;
}
/* A category's line: its share follows its name, and a long name is cut, not the share. */
.gb-card-cat .gb-card-what {
  flex: 0 1 auto;
}
.gb-card-cat b {
  margin-left: auto;
}
.gb-card-row .gb-card-gain {
  width: 38px;
  text-align: right;
  font-size: var(--text-sm);
  color: var(--score-3-dark);
}
.gb-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-2);
}
.gb-card-more {
  padding: 1px 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
}
.gb-card-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  padding-top: var(--space-2);
  border-top: 1px solid var(--divider-medium);
  font-weight: 600;
}
.gb-tip-grade {
  font-size: var(--text-lg);
  font-weight: 700;
}
.gb-tip-note {
  font-size: var(--text-sm);
  color: var(--text-2);
}
.gb-tip-foot {
  margin-top: 8px;
}

/* The Class Average card (Class Results, docs/plans/class-results-plan.md). */
#gb-tooltip.gb-tip-avg {
  width: 300px;
  box-sizing: border-box;
  padding: var(--space-4);
  white-space: normal;
  border-radius: var(--radius);
}
.gb-tip-avg-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.gb-tip-avg .gb-tip-grade {
  font-size: 24px;
  line-height: 1.15;
  white-space: nowrap;
}
.gb-tip-avg .gb-tip-grade small {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
}
.gb-tip-avg .gb-tip-head {
  margin-top: 12px;
  margin-bottom: var(--space-2);
}
.gb-tip-bar {
  display: flex;
  gap: 2px;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
}
.gb-tip-levels {
  display: flex;
  gap: 8px;
  margin-top: var(--space-2);
}
.gb-tip-levels > div {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.gb-tip-levels b {
  font-size: var(--text-md);
}
.gb-tip-levels span {
  font-size: var(--text-xs);
  color: var(--text-2);
  white-space: nowrap;
}
.gb-tip-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.gb-tip-stats-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.gb-tip-stats > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.gb-tip-stats span {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-2);
}
.gb-tip-stats b {
  font-size: var(--text-md);
  white-space: nowrap;
}
.gb-tip-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}
.gb-tip-chips .cr-chip,
.cr-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}
.cr-chip .gb-late {
  margin-left: 0;
  vertical-align: 0;
}
.gb-tip-open {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: var(--space-3);
  border-top: 1px solid var(--divider-subtle);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--score-4-text);
}

/* Class stats row */
.gb-stats-row td {
  background: var(--bg) !important;
  border-top: 1px solid var(--divider-strong);
}
/* The Scores view's Class Average row: its rows' 40px height. */
.gb-scores-stats td.gb-scores-avg {
  height: 40px;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 700;
}
/* A Class Average cell opens Class Results. */
.gb-stats-row td[data-action='classResults'] {
  cursor: pointer;
}
.gb-stats-row td[data-action='classResults']:hover,
.gb-stats-row td.gb-col-hover[data-action='classResults'] {
  background: var(--active-light) !important;
}
.gb-stats-row td[data-action='classResults']:focus-visible {
  outline: 2px solid var(--active);
  outline-offset: -2px;
}
.gb-stats-row td.cr-is-open {
  background: var(--active-light) !important;
  box-shadow: inset 0 0 0 2px var(--active);
}
.gb-scores-avg .gb-avg-val {
  font-family: var(--font-base);
}
.gb-grid-rowheads .gb-scores-stats-head {
  height: 40px;
  box-sizing: border-box;
}
.gb-stats-row .gb-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-2);
}

/* Row banding — border-separate required for sticky z-index to work in Chrome */
.gb-table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
}
.gb-table th,
.gb-table td {
  padding: 0;
}
.gb-table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--bg);
}
.gb-table thead th.gb-corner {
  z-index: 12;
}
.gb-table thead th.gb-overall-col-header {
  z-index: 12;
}
.gb-table tbody tr {
  height: 48px;
}
.gb-table tbody tr:nth-child(even) td {
  background-color: rgba(0, 0, 0, 0.015);
}
.gb-table tbody tr:nth-child(even) td.gb-group-alt {
  background-color: var(--overlay-hover);
}
.gb-table tbody tr:nth-child(even) td.gb-name,
.gb-table tbody tr:nth-child(even) th.gb-name {
  background-color: var(--bg);
}
.gb-table tbody tr:nth-child(even) td.gb-overall-col {
  background-color: var(--bg);
}
.gb-table tbody tr:hover td {
  background-color: var(--active-light) !important;
}
.gb-table tbody tr:hover td.gb-group-alt {
  background-color: var(--active-light) !important;
}
.gb-table tbody tr:hover td.gb-name,
.gb-table tbody tr:hover th.gb-name {
  background-color: var(--active-light) !important;
}
.gb-table tbody tr:hover td.gb-overall-col {
  background-color: var(--active-light) !important;
}
/* ══════════════════════════════════════════════════════════
   SCORES VIEW — Apple Numbers-inspired spreadsheet
   ══════════════════════════════════════════════════════════ */

/* ── 4-quadrant grid layout (like a spreadsheet app) ────── */
/* Inner radius for quadrant corners: 1px inset from the grid border */
/* Earthy palette scoped to the grid and its key. Emerging keeps the app's
   red (styles.css), so it reads the same on every page (Colin, 2026-11-01). */
.gb-grid,
.gb-key,
#gb-tooltip.gb-tip-avg,
.cr-panel {
  --score-2: #b8893a;
  --score-3: #548c5a;
  --score-4: #3e7d91;
  --score-2-bg: #f3ecda;
  --score-2-text: #7a5a1e;
  --score-3-bg: #dde9de;
  --score-3-text: #365c3a;
  --score-4-bg: #daeaee;
  --score-4-text: #2a5868;
  --score-2-dark: #9e7530;
  --score-3-dark: #467a4c;
  --score-4-dark: #306d80;
}
@media (prefers-color-scheme: dark) {
  .gb-grid,
  .gb-key,
  #gb-tooltip.gb-tip-avg,
  .cr-panel {
    --score-2: #dda854;
    --score-3: #6bae70;
    --score-4: #5aa0ae;
    --score-2-bg: rgba(221, 168, 84, 0.2);
    --score-2-text: #e5bc72;
    --score-3-bg: rgba(107, 174, 112, 0.2);
    --score-3-text: #82c487;
    --score-4-bg: rgba(90, 160, 174, 0.2);
    --score-4-text: #78b8c6;
    --score-2-dark: #dda854;
    --score-3-dark: #6bae70;
    --score-4-dark: #5aa0ae;
  }
}
.gb-grid {
  --qr: calc(var(--radius) - 1px);
}
.gb-grid {
  display: grid;
  /* minmax(0, …): the score area is as wide as the box and scrolls inside
     it, instead of growing to fit every column and pushing the page sideways. */
  /* The names column fits its longest name, or the width the teacher
     dragged it to (gradebook-name-width.js). */
  grid-template-columns: var(--gb-name-w, 200px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  flex: 1;
  min-height: 0;
}
/* Q1: Corner — fixed top-left */
.gb-grid-corner {
  grid-row: 1;
  grid-column: 1;
  background: var(--bg);
  border-right: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  position: relative;
  z-index: 2;
  overflow: hidden;
  border-top-left-radius: var(--qr);
}
/* Q2: Column headers — scrolls horizontally via JS transform on inner div.
   Clipped to the box; the Scores data area keeps room at its right end for
   the last tilted titles (below). scrollLeft is not used here. */
.gb-grid-colheads {
  grid-row: 1;
  grid-column: 2;
  overflow: hidden;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  position: relative;
  border-top-right-radius: var(--qr);
}
.gb-grid-colheads-inner {
  display: flex;
  position: relative;
  width: max-content;
}
.gb-grid-colhead {
  flex: 0 0 48px;
  width: 48px;
  height: 200px;
  position: relative;
  display: flex;
  flex-direction: column;
  border-right: none;
}
/* 45-degree divider line between columns */
.gb-grid-colhead::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
  border-right: 1px solid var(--divider-subtle);
  transform-origin: bottom right;
  transform: skewX(-45deg);
  pointer-events: none;
}
.gb-grid-colhead-text {
  flex: 1;
  position: relative;
  overflow: visible;
}
/* Tilted label: one block per column, rotated 45° about its bottom-left
   corner, with the title and the date stacked inside it so both read along
   the same slant from the same origin. The block is centred across the
   slanted band (band is 48px wide at the base; the two lines are ~37px
   measured the same way), and its length is the header's diagonal so a long
   title ends in an ellipsis before it reaches the top edge. */
.gb-grid-colhead-label {
  position: absolute;
  bottom: 0;
  left: 43px;
  width: calc(var(--gb-head-h, 200px) * 1.414 - 40px);
  transform-origin: bottom left;
  transform: rotate(-45deg);
  display: flex;
  flex-direction: column;
  text-align: left;
  /* A click on a title opens its column menu. */
  cursor: pointer;
}
.gb-grid-colhead .gb-scores-assess-name,
.gb-grid-colhead .gb-scores-assess-meta {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}
.gb-grid-colhead .gb-scores-assess-meta {
  font-size: var(--text-xs);
}
/* The title and a ⋯ that shows the title opens the column's menu. */
.gb-colhead-name-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}
.gb-colhead-name-row .gb-scores-assess-name {
  flex: 0 1 auto;
  min-width: 0;
}
.gb-colhead-menu-mark {
  flex: none;
  display: inline-block;
  color: var(--text-3);
  line-height: 1;
  /* Turned back upright against the title's slant, so it points down like
     any menu's arrow and doesn't read as a cut-off title's "…". */
  transform: rotate(45deg);
}
.gb-grid-colhead-label:hover .gb-colhead-menu-mark,
.gb-grid-colhead.gb-col-menu .gb-colhead-menu-mark {
  color: var(--active);
}
.gb-grid-colhead-label:focus {
  outline: none;
}
.gb-grid-colhead-label:focus-visible {
  outline: 2px solid var(--active);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Subtle color fill behind angled header — inherits section color via inline style */
.gb-grid-colhead-stripe {
  height: 4px;
  flex-shrink: 0;
}
.gb-grid-colhead-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.07;
  pointer-events: none;
  transform-origin: bottom right;
  transform: skewX(-45deg);
}
/* Header row resize handle (bottom edge of colheads, inside its clip) */
.gb-header-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: row-resize;
  z-index: 10;
}
.gb-header-resize-handle:hover,
.gb-header-resize-handle:active {
  background: rgba(0, 122, 255, 0.3);
}
/* A grab bar shows the header's edge can be dragged, while the pointer is
   over the header. */
.gb-header-resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--text-3);
  opacity: 0;
  transition: opacity 0.15s;
}
#gb-colheads:hover .gb-header-resize-handle::after {
  opacity: 1;
}

/* Score-only columns: white fill to match data cell background below */
.gb-colhead-score-only .gb-grid-colhead-fill {
  opacity: 0.85;
}

/* Designation tags inline with student name */
.gb-des-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 4px;
  margin-left: var(--space-1);
  border-radius: 3px;
  background: var(--overlay-hover);
  color: var(--text-3);
  vertical-align: middle;
  cursor: default;
}

/* Q3: Row headers — scrolls vertically (driven by data) */
.gb-grid-rowheads {
  grid-row: 2;
  grid-column: 1;
  overflow: hidden;
  border-right: 2px solid var(--border);
  background: var(--bg);
  border-bottom-left-radius: var(--qr);
}
/* Room for the data area's horizontal scrollbar, so both scroll the same
   distance (set in initGridScrollSync). A block, not padding: Safari leaves end padding out
   of the scroll height. */
.gb-grid-rowheads::after {
  content: '';
  display: block;
  height: var(--gb-hscroll, 0px);
}
.gb-grid-rowhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 0.5px solid var(--divider-subtle);
  box-sizing: border-box;
  height: 40px;
}
.gb-grid-rowhead.gb-scores-alt {
  background: rgba(0, 0, 0, 0.015);
}
.gb-grid-rowhead-name {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  text-decoration: none;
}
.gb-grid-rowhead-name:hover {
  color: var(--link);
}
.gb-grid-rowhead-grade {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  flex-shrink: 0;
  margin-left: 8px;
}
/* "Proficient" under a Proficiency class's overall, as in Competencies. */
.gb-grid-rowhead-grade .gb-grade-word {
  font-size: 12px;
  font-weight: 600;
}
/* ── Competencies grid variant ─────────────────────────────── */
.gb-grid-corner-comp {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
/* The Competencies view's names share their column with "3.3 Proficient",
   so on a wide screen the column takes 240px: 15-letter names and the
   Rubrics by Competency picker fit whole. */
@media (min-width: 1200px) {
  .gb-grid.gb-grid-comp {
    grid-template-columns: var(--gb-name-w, 240px) minmax(0, 1fr);
  }
}
/* Sort toggle sits in the empty top of the corner, above Student / Overall. */
/* View options sit in the empty top of the corner, above Student / Overall. */
.gb-corner-tools {
  align-self: flex-start;
  margin-bottom: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}
.gb-corner-tools .gb-rubric-cols-select {
  max-width: 100%;
  font-size: var(--text-sm);
}
.gb-grid-corner-row1 {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}
.gb-grid-corner-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
/* "Student" in the grid corner is a plain-text button that cycles the name sort. */
.gb-name-sort {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
}
.gb-name-sort:hover {
  color: var(--active);
}
/* The name order on, on its own line under Student: "Last Name A–Z". */
.gb-name-sort {
  text-align: left;
}
.gb-sort-order {
  display: block;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
}
.gb-grid-colheads-comp {
  flex-direction: column;
}
.gb-grid-colheads-row1 {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.gb-grid-assess-group {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-2) var(--space-1);
  text-align: center;
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
/* Title clamps to two lines; hover or focus shows the whole title
   (_showAssessTitleTip in page-gradebook.js). */
.gb-grid-assess-group .gb-assess-title {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  text-decoration: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.gb-grid-assess-group .gb-assess-title:hover {
  color: var(--active);
}
.gb-grid-assess-group .gb-assess-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  justify-content: center;
  margin-top: 2px;
}
/* In a narrow column the pill, date and badges wrap as whole pieces. */
.gb-grid-assess-group .gb-assess-type-pill {
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gb-grid-assess-group .gb-assess-stripe {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.gb-grid-colheads-row2 {
  display: flex;
}
.gb-grid-tag-header {
  flex: 0 0 54px;
  width: 54px;
  text-align: center;
  padding: 4px 2px;
  font-family: var(--font-base);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  border-right: 0.5px solid var(--divider-subtle);
  border-bottom: 2px solid; /* color set inline */
  background: var(--surface);
  box-sizing: border-box;
  /* A code never spills into the next column; the full name is on hover. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gb-grid-tag-header.gb-code-long {
  letter-spacing: 0;
}
/* A criterion column's header is its name, not a competency code */
.gb-grid-tag-header-crit {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gb-grid-rowhead-comp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 48px;
  box-sizing: border-box;
  border-bottom: 0.5px solid var(--divider-subtle);
}
.gb-grid-rowhead-overall {
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  margin-left: 8px;
  text-align: right;
}
.gb-grid-rowhead-overall small {
  display: block;
  font-size: 12px;
  font-weight: 600;
}
/* Row hover sync — applied by JS across Q3 and Q4 */
.gb-grid-rowhead.gb-row-hover,
.gb-grid-rowhead.gb-col-menu {
  background: var(--active-light) !important;
}
.gb-table tbody tr.gb-row-hover td,
.gb-table tbody tr.gb-col-menu td {
  background: var(--active-light) !important;
}
.gb-scores-table tbody tr.gb-row-hover td,
.gb-scores-table tbody tr.gb-col-menu td {
  background: var(--active-light) !important;
}
.gb-grid-rowhead-stats {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-2);
  height: 48px;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
}
/* The class's overall, at the foot of the Overall column. */
.gb-grid-rowhead-stats .gb-class-overall {
  margin-left: auto;
}
/* Competencies data table — rows must match Q3 height exactly */
.gb-grid-comp .gb-table {
  border-collapse: collapse;
}
.gb-grid-comp .gb-table tbody tr {
  height: 48px;
}
.gb-grid-comp .gb-table td {
  box-sizing: border-box;
}
.gb-grid-comp .gb-score {
  min-width: 54px;
  width: 54px;
  background: var(--surface);
  box-sizing: border-box;
}
.gb-grid-comp .gb-stats-row td {
  border-top: 1px solid var(--border);
  box-sizing: border-box;
}

/* Q4: Data area — scrolls both ways, drives Q2 and Q3 */
.gb-grid-data {
  grid-row: 2;
  grid-column: 2;
  overflow: auto;
  border-bottom-right-radius: var(--qr);
}
/* Each Scores title slants right by the header's height, so the data area
   scrolls that much further for the last titles to show in full. An empty
   column, not padding: Safari leaves end padding out of the scroll width. */
.gb-grid:not(.gb-grid-comp) > .gb-grid-data {
  display: grid;
  grid-template-columns: max-content var(--gb-head-h, 200px);
  align-content: start;
}
.gb-grid:not(.gb-grid-comp) > .gb-grid-data::after {
  content: '';
}

.gb-scores-table {
  border-collapse: collapse;
  width: max-content;
  font-family: var(--font-base);
  font-size: var(--text-sm);
}
.gb-scores-table th,
.gb-scores-table td {
  border: 1px solid var(--divider-subtle);
  padding: 0;
  text-align: center;
  white-space: nowrap;
}
/* Remove top border on first data row so lines don't bleed into header */
.gb-scores-table tbody tr:first-child td {
  border-top: none;
}

/* Header — z-index hierarchy: cells(1) < frozen-body(5) < header(8) < corner(12) */
.gb-scores-table thead th {
  background: var(--bg);
  font-weight: 600;
  font-size: var(--text-xs);
  position: sticky;
  top: 0;
  z-index: 8;
}
/* Scores table lives inside Q4 data area — no sticky, no frozen */

/* Column header text styles (shared between old table and new grid) */
.gb-scores-assess-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.gb-scores-assess-meta {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 400;
}

/* Data rows */
.gb-scores-row td {
  padding: 0;
}
.gb-scores-alt td {
  background: rgba(0, 0, 0, 0.015);
}
.gb-scores-row:hover td {
  background: var(--active-light) !important;
}

/* Row height matches Q3 row headers */
.gb-scores-row {
  height: 40px;
}

/* Score cells */
.gb-scores-cell {
  padding: 8px 4px;
  cursor: pointer;
  transition: background 0.1s;
  width: 48px;
  min-width: 48px;
  position: relative;
  text-align: center;
  background: var(--surface);
}
.gb-scores-cell:hover {
  outline: 2px solid var(--active);
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}
.gb-scores-val {
  font-weight: 600;
  font-size: var(--text-sm);
}
/* A Both class's level: the proficiency over its percent, one column wide. */
.gb-cell-both {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.gb-cell-both small {
  font-size: var(--text-xs);
  font-weight: 600;
}
/* The cell being edited (click, Tab, Enter or score mode): the app's active
   tint on the cell, and the theme's focus ring on the editor itself. The
   hover rectangle stays off while the editor is open so the ring is the
   only outline. The out-of-range warning outline still wins (!important). */
.gb-scores-focus,
.gb-scores-cell:focus-within {
  outline: none;
  background: var(--active-light) !important;
  position: relative;
  z-index: 1;
}

/* Inline input — a small rounded field on the tinted cell */
.gb-scores-input {
  display: block;
  width: 100%;
  height: 24px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--surface);
  text-align: center;
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  outline: none;
  padding: 0;
  -moz-appearance: textfield;
}
.gb-scores-input:focus {
  box-shadow:
    0 0 0 2px var(--active),
    0 0 0 5px var(--active-light) !important;
}
.gb-scores-input::-webkit-inner-spin-button,
.gb-scores-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

/* The key under the grid: what the colours and marks mean. */
.gb-key {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3) 0;
  font-family: var(--font-base);
  font-size: 12px;
  color: var(--text);
}
.gb-key-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
/* Graded Separately: Late's small letter, in dark grey. */
.gb-late.gb-separate {
  background: #545458;
}
.gb-key-item .gb-late {
  margin-left: 0;
  vertical-align: 0;
}
.gb-key-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.gb-key-gap {
  width: 6px;
}
.gb-key-dash {
  color: var(--text-3);
  font-weight: 700;
}
.gb-code-tip {
  max-width: 340px;
  line-height: 1.35;
}
.gb-code-tip-sub {
  margin-top: var(--space-2);
  font-weight: 600;
}
.gb-code-tip-icans {
  margin: var(--space-2) 0 0;
  padding-left: 16px;
}
.gb-code-tip-icans li {
  margin: 2px 0;
}
.gb-grid-tag-header:focus-visible {
  outline: 2px solid var(--active);
  outline-offset: -2px;
}
.gb-code-tip-group {
  margin-top: 2px;
  opacity: 0.75;
}

/* Nothing to show: one white card, a plain sentence and the one step
   that changes it. */
.gb-empty {
  max-width: 440px;
  margin: 12px auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.06);
  text-align: center;
}
.gb-empty-text {
  margin: 0;
  font-family: var(--font-base);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* Context menus */
.gb-ctx-menu {
  position: fixed;
  z-index: var(--z-top);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  font-family: var(--font-base);
  font-size: var(--text-sm);
}
/* Each item: its line icon, then its label, as on the Assignments menus. */
.gb-ctx-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.08s;
}
.gb-ctx-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.gb-ctx-menu:focus {
  outline: none;
}
.gb-ctx-item:hover,
.gb-ctx-item:focus {
  outline: none;
  background: var(--active-fill);
  color: #fff;
}
.gb-ctx-item.is-disabled,
.gb-ctx-item.is-disabled:hover {
  background: none;
  color: var(--text-3);
  cursor: default;
}
.gb-ctx-danger {
  color: var(--priority);
}
.gb-ctx-danger:hover,
.gb-ctx-danger:focus {
  background: var(--priority);
  color: #fff;
}
.gb-ctx-hint {
  margin-left: auto;
  padding-left: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
}
.gb-ctx-item:hover .gb-ctx-hint,
.gb-ctx-item:focus .gb-ctx-hint {
  color: #fff;
  opacity: 0.9;
}
.gb-ctx-divider {
  height: 1px;
  background: var(--divider-subtle);
  margin: 4px 0;
}
/* A line that opens a list (the menu on a student's name,
   teacher/gradebook-student-menu.js): a chevron at its right, lit while its
   list is open. The list is a panel of its own beside the line. */
.gb-ctx-chevron {
  margin-left: auto;
}
.gb-ctx-parent.is-open {
  background: var(--active-fill);
  color: #fff;
}
.gb-ctx-sub {
  position: fixed;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
}
.gb-ctx-sub[hidden] {
  display: none;
}
.gb-ctx-sub .gb-ctx-hint {
  padding-left: 20px;
}

/* New assignment popover */
.gb-add-popover {
  position: fixed;
  z-index: var(--z-top);
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 16px;
  font-family: var(--font-base);
}
.gb-add-popover-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.gb-add-field {
  margin-bottom: var(--space-3);
}
.gb-add-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}
.gb-add-field input,
.gb-add-field select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-base);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  box-sizing: border-box;
}
.gb-add-field input:focus,
.gb-add-field select:focus {
  outline: none;
  border-color: var(--active);
  box-shadow: 0 0 0 3px var(--active-light);
}
.gb-add-row {
  display: flex;
  gap: var(--space-3);
}
.gb-add-row .gb-add-field {
  flex: 1;
}
.gb-add-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--divider-subtle);
  border-radius: var(--radius-xs);
}
.gb-add-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  padding: 2px var(--space-2);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  background: var(--overlay-hover);
}
.gb-add-tag input {
  width: 14px;
  height: 14px;
  margin: 0;
}
.gb-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider-subtle);
}
.gb-add-cancel {
  font-family: var(--font-base);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.gb-add-confirm {
  font-family: var(--font-base);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-xs);
  background: var(--active-fill);
  color: #fff;
  cursor: pointer;
}
.gb-add-confirm:hover {
  opacity: 0.9;
}

/* Not submitted / Excused in place of a score */
.gb-status {
  display: inline-block;
  padding: 1px var(--space-1);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}
.gb-status-ns {
  background: var(--score-1-dark);
}
.gb-status-exc {
  background: var(--accent-purple);
}

/* Late: the score stays and a small L follows it (the printed sheet's mark),
   in the Late colour the Assignments page uses. On a level tile it sits on
   the tile's corner so the tile keeps its size. */
.gb-late {
  display: inline-block;
  min-width: 16px;
  height: 16px;
  margin-left: 2px;
  padding: 0 var(--space-1);
  border-radius: 4px;
  background: var(--score-2-text);
  color: #fff;
  font-family: var(--font-base);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  vertical-align: 2px;
}
/* The deeper shades keep white text at 4.5:1 or more; dark mode's light
   shades take dark text instead. */
@media (prefers-color-scheme: dark) {
  .gb-status-ns,
  .gb-status-exc,
  .gb-late {
    color: #1d1d1f;
  }
}
.gb-score-val .gb-late {
  position: absolute;
  top: -5px;
  right: -6px;
  margin: 0;
  box-shadow: 0 0 0 1.5px var(--surface);
}
/* In a Scores cell Late (and Graded Separately's S) sits in the cell's
   bottom-right corner, so "100%" and its L still fit the 48px column. */
.gb-scores-val .gb-late {
  position: absolute;
  right: 1px;
  bottom: 1px;
  min-width: 14px;
  height: 14px;
  margin: 0;
  padding: 0 2px;
  border-radius: 4px;
  font-size: var(--text-xs);
  line-height: 14px;
}
.gb-scores-val .gb-late + .gb-late {
  right: 17px;
}

/* Warning indicator for out-of-range scores */
.gb-scores-cell.gb-scores-warning {
  outline: 2px solid var(--late) !important;
  outline-offset: -2px;
}
.gb-scores-cell.gb-scores-warning::after {
  content: '\26A0';
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 12px;
  color: var(--late);
}

/* Score mode: subtle column highlight */
.gb-scores-col-active {
  background: rgba(0, 122, 255, 0.03) !important;
}

/* Header hover, and a column whose menu is open: highlight entire column */
.gb-grid-colhead.gb-col-hover .gb-grid-colhead-fill,
.gb-grid-colhead.gb-col-menu .gb-grid-colhead-fill {
  opacity: 0.25;
}
.gb-grid-colhead.gb-col-hover::after,
.gb-grid-colhead.gb-col-menu::after {
  border-right-color: var(--active);
}
.gb-scores-cell.gb-col-hover,
.gb-scores-cell.gb-col-menu {
  background: var(--active-light) !important;
}
.gb-table tbody tr:not(.gb-stats-row) td.gb-score.gb-col-hover,
.gb-grid-tag-header.gb-col-hover {
  background-color: var(--active-light) !important;
}
/* The column lights at once: its cells' background fade is for a row's hover. */
.gb-scores-cell.gb-col-hover,
.gb-score.gb-col-hover {
  transition: none;
}

/* A row whose grade is IE or No Letter Grade (a reporting basis for the
   term in view): the name stays whole at every column width and the grade
   takes what is left, ending in an ellipsis; the full text is on hover. */
.gb-row-basis .gb-grid-rowhead-name {
  flex: 0 0 auto;
}
.gb-row-basis .gb-grid-rowhead-grade,
.gb-row-basis .gb-grid-rowhead-overall {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}
.gb-row-basis .gb-grid-rowhead-grade {
  align-items: stretch;
  text-align: right;
}
.gb-row-basis .gb-grade-text,
.gb-row-basis .gb-grid-rowhead-overall small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Draft and Returned (S1-F1) ──────────────────────────────
   A grade not yet returned is marked with a dashed outline, the grader
   dialog's Draft mark (assignments.css .grader-draft-mark), and loses its
   fill. Drawn only in a class that holds grades until they are returned. */
/* Scores view: the outline sits inside the cell, in the level's colour. */
.gb-scores-cell.gb-draft::before,
.gb-score-pts.gb-draft::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1.5px dashed currentColor;
  border-radius: 6px;
  pointer-events: none;
}
/* Competencies view: a level's tile is outlined in place of filled. */
.gb-score.gb-draft .gb-score-val {
  box-sizing: border-box;
  background: transparent;
  border: 1.5px dashed var(--text-3);
  color: var(--text-2);
}
.gb-score.gb-draft .gb-score-val.s1 {
  border-color: var(--score-1);
  color: var(--score-1-text);
}
.gb-score.gb-draft .gb-score-val.s2 {
  border-color: var(--score-2);
  color: var(--score-2-text);
}
.gb-score.gb-draft .gb-score-val.s3 {
  border-color: var(--score-3);
  color: var(--score-3-text);
}
.gb-score.gb-draft .gb-score-val.s4 {
  border-color: var(--score-4);
  color: var(--score-4-text);
}
/* Points and Complete/Incomplete cells there have no tile: the cell's own
   outline, in grey. */
.gb-score-pts.gb-draft {
  position: relative;
}
.gb-score-pts.gb-draft::before {
  inset: 3px 5px;
  border-color: var(--text-3);
}
/* The key's swatch. */
.gb-key-draft {
  box-sizing: border-box;
  width: 22px;
  height: 14px;
  border: 1.5px dashed var(--score-3);
  border-radius: 4px;
}
/* Return N Graded under a Competencies header. */
.gb-return-drafts {
  display: inline-block;
  /* The narrowest header is 120px. The button reaches 4px into the header's
     padding on each side, which fits "Return 3 Graded" on one line in the
     Mac's font. Where a font is wider (Linux, some Windows setups) the
     words wrap to a second line: the count is never cut off. */
  max-width: calc(100% + 8px);
  margin: 4px -4px 0;
  min-height: 22px;
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: 11px;
  background: var(--active-fill);
  color: #fff;
  font-family: var(--font-base);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}
.gb-return-drafts:hover {
  background: var(--btn-hover-blue);
}
/* And at the top of a Scores column's menu, under who is waiting. */
.gb-ctx-note {
  max-width: 240px;
  padding: 8px 16px 2px;
  font-size: var(--text-xs);
  line-height: 1.35;
  color: var(--text-2);
}
.gb-ctx-return {
  font-weight: 600;
  color: var(--link);
}
/* Questions From Students (S10-F4): the yellow dot on a cell whose student
   asked a question not answered yet, in the key and in "N questions". */
.gb-question {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-radius: 50%;
  background: #f5b800;
  box-shadow: 0 0 0 1.5px var(--surface);
  vertical-align: middle;
}
.gb-key-item .gb-question {
  margin: 0 var(--space-1) 0 0;
}
/* A cell's corner marks: the camera top right, the question dot top left,
   Revising bottom left, Late bottom right (above). Out of the cell's flow, so no mark makes a column
   wider than its tilted header. On a draft's dashed outline each sits on a
   patch of the cell's white; they step aside for the editor. */
.gb-scores-cell > .gb-work-camera,
.gb-scores-cell > .gb-question,
.gb-scores-cell > .gb-revising {
  position: absolute;
  margin: 0;
  line-height: 0;
  pointer-events: none;
}
.gb-scores-cell > .gb-work-camera {
  top: 3px;
  right: 3px;
}
.gb-scores-cell > .gb-work-camera svg {
  width: 10px;
  height: 10px;
}
.gb-scores-cell.gb-scores-warning > .gb-work-camera {
  right: 16px;
}
.gb-scores-cell > .gb-question {
  top: 4px;
  left: 4px;
}
.gb-scores-cell > .gb-revising {
  bottom: 3px;
  left: 3px;
}
.gb-scores-cell.gb-draft > .gb-work-camera,
.gb-scores-cell.gb-draft > .gb-revising {
  padding: 1px;
  border-radius: 3px;
  background: var(--surface);
}
.gb-scores-cell.gb-draft > .gb-work-camera {
  top: 2px;
  right: 2px;
}
.gb-scores-cell.gb-draft > .gb-revising {
  bottom: 2px;
  left: 2px;
}
.gb-scores-cell:has(.gb-scores-input) > .gb-work-camera,
.gb-scores-cell:has(.gb-scores-input) > .gb-question,
.gb-scores-cell:has(.gb-scores-input) > .gb-revising {
  display: none;
}

/* A short window (a 1366 × 768 laptop's browser is about 640 px tall; 125%
   display scaling leaves less): the rows, the key and the slanted header give
   back height so more students show. Rows stay in step: the names, the
   scores and the Class Average change together. The header's own cap is in
   gradebook-chrome.js (_headMax). */
@media (max-height: 700px) {
  .gb-grid-rowhead,
  .gb-grid-rowheads .gb-scores-stats-head,
  .gb-scores-stats td.gb-scores-avg,
  .gb-scores-row {
    height: 32px;
  }
  .gb-scores-cell {
    padding: var(--space-1);
  }
  /* Late's L sits in the cell's bottom-right corner; the score rides near
     the top so the two never touch. */
  .gb-scores-cell:has(.gb-late) {
    vertical-align: top;
    padding-top: 2px;
  }
  .gb-grid-rowhead-comp,
  .gb-grid-rowhead-stats,
  .gb-grid-comp .gb-table tbody tr {
    height: 40px;
  }
  .gb-key {
    gap: var(--space-1) var(--space-3);
    padding-top: var(--space-1);
  }
}

/* The names column's right edge: drag to widen, double-click to fit
   (gradebook-name-width.js). A strip over the column's border, the whole
   height of the grid, that shows the drag colour on hover or focus. */
.gb-name-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--gb-name-w, 200px) - 5px);
  width: 8px;
  cursor: col-resize;
  z-index: 3;
  touch-action: none;
}
.gb-name-resize-handle:hover,
.gb-name-resize-handle:active,
.gb-name-resize-handle:focus-visible {
  background: rgba(0, 122, 255, 0.3);
  outline: none;
}
