/* 手写评分台：墨、纸、栏线。控件收在顶栏，画面留给字图。 */

:root {
  --ink: #1c1917;
  --muted: #6b645c;
  --rule: #d4cdc3;
  --paper: #fffcf7;
  --desk: #e4dfd6;
  --accent: #3d4f63;
  --warn-bg: #f7f0d8;
  --warn-ink: #6a5410;
  --err: #8b2e2e;
  --cell-mine: #b4d8a8;
  --cell-other: #b3c8ee;
  --cell-agree: #b4d8a8;
  --cell-conflict: #e8b4b4;
  --cell-partial: #b3c8ee;
  --cell-approved: #8cbf7a;
  --cell-rerate: #ecc4b0;
  --rerate-ink: #8a4530;
  --cell-rerate-back: #e08a6a;
  --rerate-back-ink: #7a3218;
  --doubt-fill: #f7e7b0;
  --doubt-ink: #c9a227;
  --sticky-top: 3.6rem;
  --z-sticky: 40;
  --z-modal: 1000;
  --shadow-pop: 0 10px 22px -12px rgba(28, 25, 23, 0.28), 0 1px 4px -1px rgba(28, 25, 23, 0.08);
  --list-floor: 11.5rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

html {
  scrollbar-gutter: stable;
  overflow-x: hidden;
  overflow-y: scroll;
}

body {
  min-height: 100vh;
}

input,
select,
button,
textarea {
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
}

.wrap {
  width: 100%;
  max-width: 1280px;
  min-width: 0;
  margin: 0 auto;
  padding: 0.65rem 0.9rem 1.2rem;
}

.chrome,
.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
}

.gate {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

html.need-login #gate:not([hidden]) {
  display: flex !important;
}

html.restoring #gate { display: none !important; }

.boot {
  display: none;
}

html.restoring #boot {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: var(--desk);
  color: var(--muted);
  font-size: 0.95rem;
}

html.restoring #wrap {
  display: none !important;
}

.wrap.is-busy {
  cursor: wait;
}

.wrap.is-busy #deskMain,
.wrap.is-busy #roster,
.wrap.is-busy #board,
.wrap.is-busy #admin,
.wrap.is-busy .chrome button:not(#btnWho),
.wrap.is-busy .chrome label {
  pointer-events: none;
}

.wrap.is-busy #codePanel,
.wrap.is-busy #reviewPanel,
.wrap.is-busy #comparePanel,
.wrap.is-busy #refPanel,
.wrap.is-busy #stage,
.wrap.is-busy #stageTools,
.wrap.is-busy #board,
.wrap.is-busy #roster,
.wrap.is-busy #desks,
.wrap.is-busy #reviewTasks,
.wrap.is-busy #admin,
.wrap.is-busy #adminTabs,
.wrap.is-busy #modes,
.wrap.is-busy #reviewView,
.wrap.is-busy #btnSubject,
.wrap.is-busy #btnBoard {
  opacity: 0.42;
}

.gate[hidden] { display: none !important; }

.gate-card {
  width: min(28rem, 100%);
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 1.4rem 1.35rem 1.2rem;
  box-shadow: var(--shadow-pop);
}

.gate-card h1 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 650;
}

.rater-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.rater-list button {
  justify-content: flex-start;
  width: 100%;
  background: #f3f0ea;
  border-color: var(--ink);
}

.new-rater label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.new-rater-row {
  display: flex;
  gap: 0.4rem;
}

.new-rater-row input { flex: 1; }

.wrap[hidden] { display: none; }

.chrome {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  margin-bottom: 0.5rem;
  background: var(--paper);
  box-shadow: 0 1px 0 var(--rule), 0 8px 16px -10px rgba(28, 25, 23, 0.28);
}

.work-row {
  --work-sep: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--work-sep);
  row-gap: 0.4rem;
  padding: 0.45rem 0.25rem;
  margin: 0 0.5rem;
  overflow: hidden;
}

.work-cluster {
  display: inline-flex;
  align-items: center;
  position: relative;
  gap: 0.4rem;
  min-width: 0;
}

.work-cluster:not(:has(> :not([hidden]))) {
  display: none;
}

.work-cluster[data-level="nav"] {
  gap: 0.35rem;
}

.work-cluster:has(> :not([hidden])) ~ .work-cluster:has(> :not([hidden]))::before {
  content: "";
  position: absolute;
  left: calc(var(--work-sep) / -2);
  top: 50%;
  width: 1px;
  height: 14px;
  margin: 0;
  transform: translateY(-50%);
  background: var(--rule);
  opacity: 0.7;
  pointer-events: none;
}

.work-cluster[data-level="desk"]:has(> :not([hidden])) ~ .work-cluster[data-level="desk"]:has(> :not([hidden]))::before {
  height: 12px;
  opacity: 0.55;
}

.work-cluster[data-level="filter"] {
  gap: 0.55rem;
}

.gate-card form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 0.55rem;
}

.gate-card form label span,
.field > span {
  font-size: 13px;
  color: var(--muted);
}

.gate-card form button {
  width: 100%;
  justify-content: center;
  margin-top: 0.2rem;
}

.stats {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--rule);
  padding: 0.18rem 0.45rem;
  font-variant-numeric: tabular-nums;
}

.chip-doubt { color: #6a5410; border-color: #e2d39a; }

.modes,
.desks,
.review-tasks,
.admin-tabs {
  display: inline-flex;
  border: 1px solid var(--rule);
  background: #fff;
}

.modes[hidden],
.desks[hidden],
.review-tasks[hidden],
.admin-tabs[hidden],
.review-view[hidden],
.legend[hidden],
#rvRaters[hidden],
#admin[hidden],
#deskMain[hidden],
#btnSubject[hidden],
#btnBoard[hidden],
#adminUsersPanel[hidden],
#adminDataPanel[hidden],
#adminSubjectsBlock[hidden],
#adminCatalogBlock[hidden],
#uncertainNoteWrap[hidden],
.modes label[hidden],
.desks label[hidden],
.review-tasks label[hidden],
.admin-tabs label[hidden],
.legend-other[hidden],
.legend-coop[hidden],
#aiBlock[hidden],
#aiWait[hidden] {
  display: none;
}

.modes label,
.desks label,
.review-tasks label,
.admin-tabs label {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0.7rem;
  min-height: 34px;
  border-right: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  color: var(--ink);
}

.modes label:last-child,
.desks label:last-child,
.review-tasks label:last-child,
.admin-tabs label:last-child { border-right: 0; }

.modes input,
.desks input,
.review-tasks input,
.admin-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.modes label:has(input:checked),
.desks label:has(input:checked),
.review-tasks label:has(input:checked),
.admin-tabs label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.modes label:focus-within,
.desks label:focus-within,
.review-tasks label:focus-within,
.admin-tabs label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.review-view {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
}

.review-view label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.review-view select {
  min-width: 6.2rem;
}

#rvRaters {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
}

.now {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  min-width: 4.5rem;
}

#btnBoard {
  font-variant-numeric: tabular-nums;
}

#btnSubject.is-open,
#btnBoard.is-open {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.banner {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border-top: 1px solid #e2d39a;
}

.board {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 0;
  padding: 0.55rem 0.75rem 0.75rem;
  margin-bottom: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
}

.legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
  margin-left: auto;
  justify-content: flex-end;
}

.board-find {
  display: flex;
  align-items: center;
  margin: 0;
}

.board-find input {
  width: 9.5rem;
}

.legend-other,
.legend-coop {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.lg {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--rule);
  vertical-align: middle;
}
.lg-empty { background: #fff; }
.lg-mine { background: var(--cell-mine); border-color: #5f8c57; }
.lg-part {
  background: linear-gradient(135deg, var(--cell-mine) 50%, #fff 50%);
  border-color: #5f8c57;
}
.lg-other { background: var(--cell-other); border-color: #5a78b4; }
.lg-agree { background: var(--cell-agree); border-color: #5f8c57; }
.lg-partial { background: var(--cell-partial); border-color: #5a78b4; }
.lg-progress {
  background: linear-gradient(135deg, var(--cell-partial) 50%, #fff 50%);
  border-color: #5a78b4;
}
.lg-conflict { background: var(--cell-conflict); border-color: #b4554a; }
.lg-approved { background: var(--cell-approved); border-color: #4f7d42; }
.lg-rerate { background: var(--cell-rerate); border-color: var(--rerate-ink); }
.lg-rerate-back { background: var(--cell-rerate-back); border-color: var(--rerate-back-ink); }
.lg-doubt { background: var(--doubt-fill); border-color: var(--doubt-ink); }
.lg-live {
  border-style: dashed;
  border-color: #b4554a;
  background: #fff;
}
.lg-here { border-color: var(--ink); background: #fff; }

.board-scroller {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.board.is-wait {
  cursor: wait;
}

.board.is-wait .board-head,
.board.is-wait .board-scroller {
  pointer-events: none;
}

.board.is-wait .board-scroller {
  min-height: 8.5rem;
}

.board-wait {
  display: none;
}

.board.is-wait .board-wait {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  min-height: 8.5rem;
  background: var(--paper);
}

.board.is-wait .board-wait-text,
.admin-panel.is-wait .board-wait-text {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 8.5rem;
  max-height: 100vh;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.18em;
  animation: stage-wait-pulse 1.15s ease-in-out infinite;
}

.board-wait[hidden] {
  display: none !important;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 34px);
  gap: 4px;
}

button.cell {
  position: relative;
  box-sizing: border-box;
  width: 34px;
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  aspect-ratio: 1 / 1;
  margin: 0;
  padding: 0;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-shadow: none;
  background: #fff;
  font-size: 15px;
  font-weight: 650;
  line-height: 1;
}

.cell.mine { background: var(--cell-mine); }
.cell.other { background: var(--cell-other); }
.cell.mine.other { background: linear-gradient(135deg, var(--cell-mine) 50%, var(--cell-other) 50%); }
.cell.part { background: linear-gradient(135deg, var(--cell-mine) 50%, #fff 50%); }
.cell.part.other { background: linear-gradient(135deg, var(--cell-mine) 50%, var(--cell-other) 50%); }
.cell.agree { background: var(--cell-agree); }
.cell.conflict { background: var(--cell-conflict); }
.cell.partial { background: var(--cell-partial); }
.roster-cell.partial { background: linear-gradient(135deg, var(--cell-partial) 50%, #fff 50%); }
.cell.approved { background: var(--cell-approved); }
.cell.rerate {
  background:
    linear-gradient(var(--rerate-ink), var(--rerate-ink)) top / 100% 3px no-repeat,
    var(--cell-rerate);
}
.cell.rerate-back {
  background:
    linear-gradient(var(--rerate-back-ink), var(--rerate-back-ink)) top / 100% 3px no-repeat,
    var(--cell-rerate-back);
}
.cell.doubt::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 7px;
  height: 3px;
  transform: translateX(-50%);
  background: var(--doubt-ink);
  pointer-events: none;
}
.cell.live { z-index: 1; }
.cell.live::before {
  content: "";
  position: absolute;
  inset: 1px;
  border: 2px dashed #b4554a;
  pointer-events: none;
  z-index: 2;
}
.cell.here {
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
  z-index: 1;
}
.cell.away { opacity: 0.4; }

.board.is-vacant {
  padding: 0.9rem 0.9rem 1rem;
}

.board.is-vacant .board-head {
  display: none;
}

.board-grid.is-vacant {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2rem;
  padding: 0.15rem 0;
}

.vacant {
  margin: 0;
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.board-grid.is-find .cell.nomatch { opacity: 0.18; }
.board-grid.is-find .cell.find {
  opacity: 1;
  font-weight: 700;
}

.guide,
.guide-title,
.guide-lead,
.guide-cards,
.gcard,
.gn { display: none; }

.flags {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.65rem;
  margin-bottom: 0.55rem;
}

.flag-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 28px;
}

.flag-row.rad {
  grid-column: 1 / -1;
}

.flag-row label {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  cursor: pointer;
  flex: 0 1 auto;
  font-size: 15px;
  white-space: nowrap;
}

.flag-rad {
  color: var(--muted);
  font-weight: 500;
}

.flag-help {
  flex: 0 0 auto;
  width: 22px;
  min-height: 22px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  color: var(--accent);
  line-height: 1;
}

.help-pop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.35);
  display: flex;
  align-items: safe center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 1rem;
  overflow: auto;
}

.help-pop[hidden] { display: none; }

.help-card {
  width: min(36rem, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 0.9rem 1rem 1.05rem;
  box-shadow: var(--shadow-pop);
}

.help-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}

.help-top h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.switch-card {
  width: min(22rem, 100%);
  max-height: none;
}

.switch-card h2 {
  margin: 0 0 0.45rem;
  font-size: 15px;
  font-weight: 650;
}

.switch-copy {
  margin: 0 0 0.9rem;
  font-size: 15px;
  color: var(--ink);
}

#doubtWho {
  margin-bottom: 0.35rem;
  font-size: 13px;
  color: var(--muted);
}

#doubtWho .doubt-who-name {
  font-weight: 650;
}

.doubt-note {
  margin: 0 0 0.85rem;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.doubt-note.is-empty {
  color: var(--muted);
}

#doubtPop .switch-actions {
  grid-template-columns: 1fr;
}

.switch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.switch-actions .primary {
  justify-content: center;
}

.switch-actions button {
  width: 100%;
  justify-content: center;
}

.help-body p { margin: 0 0 0.55rem; font-size: 15px; }

.help-pts {
  margin: 0 0 0.55rem;
  padding-left: 1.15em;
  font-size: 15px;
}

.help-pts li { margin: 0.18rem 0; }

.viz {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin: 0.7rem 0 0.85rem;
  padding: 0.7rem 0.5rem;
  background: #fff;
  border: 1px solid var(--rule);
}

.viz-hand {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.75rem 1.15rem;
}

.viz-case {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  min-width: 0;
}

.viz-many {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
}

.viz-many .viz-case {
  min-width: 0;
}

.viz-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  flex: none;
}

.viz-arrow {
  flex: none;
  line-height: 1;
}

.viz-cap {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.glyph {
  font-family: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC", serif;
  font-size: 2.4rem;
  line-height: 1;
  font-weight: 600;
}

.help-shots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.help-shot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem 0.25rem 0.15rem;
  background: var(--paper);
  border: 1px solid var(--rule);
}

.help-shot img {
  display: block;
  height: 68px;
  width: auto;
  max-width: 92px;
  object-fit: contain;
  background: #fff;
}

.help-shot figcaption {
  margin: 0.18rem 0 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
  max-width: 6.4rem;
}

@media (max-width: 28rem) {
  .viz-case {
    flex: 1 1 100%;
  }
  .viz-many {
    grid-template-columns: 1fr;
  }
}

button.help-jump {
  display: inline;
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.viz-not {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: -0.35rem 0 0.65rem;
}
.viz-arrow { color: var(--muted); font-size: 1.2rem; }

.help-note {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.who {
  margin-left: auto;
}

.board-summary {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  font-size: 15px;
  color: var(--ink);
}

.field input,
.field select {
  min-width: 6.5rem;
}

.toggles {
  display: flex;
  gap: 0.75rem;
  font-size: 15px;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.nav {
  display: flex;
  gap: 0.35rem;
}

.nav select {
  min-width: 7.5rem;
}

.statusline {
  margin: 0;
  padding: 0 0.75rem 0.45rem;
  font-size: 0.78rem;
  color: var(--ink);
}

#gateError { color: var(--err); }

input[type="text"],
input[type="password"],
input[type="search"],
select {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  padding: 0.28rem 0.45rem;
  min-height: 34px;
  border-radius: 0;
  box-shadow: none;
}

input[type="search"] {
  appearance: none;
  -webkit-appearance: none;
}

input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

button {
  font: inherit;
  font-weight: 400;
  min-height: 34px;
  padding: 0 0.75rem;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
}

button[hidden] {
  display: none;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.danger {
  color: var(--err);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 22rem);
  gap: 0.5rem;
  align-items: start;
}

.col-image {
  position: sticky;
  top: var(--sticky-top);
  z-index: 21;
  align-self: start;
  background: var(--desk);
  padding-top: 0;
  padding-bottom: 0.35rem;
  min-width: 0;
}

.col-code {
  position: sticky;
  top: var(--sticky-top);
  z-index: 20;
  align-self: start;
}

.stage {
  display: grid;
  place-items: center;
  padding: 0.5rem;
  min-height: 280px;
}

.stage-wrap {
  position: relative;
  min-width: 0;
}

.stage-tools {
  display: none !important;
}

.stage-tools[hidden] {
  display: none;
}

.stage-tools button {
  min-height: 28px;
  padding: 0 0.55rem;
  font-size: 13px;
  background: var(--paper);
}

.stage-tools button.is-on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.stage.is-invert img {
  filter: invert(1);
}

.stage.is-blink img {
  animation: stage-blink 0.8s step-end infinite;
}

.stage.is-invert.is-blink img {
  animation: stage-blink-inv 0.8s step-end infinite;
}

@keyframes stage-blink {
  50% { filter: invert(1); }
}

@keyframes stage-blink-inv {
  50% { filter: none; }
}

.stage-wait {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 280px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.18em;
  animation: stage-wait-pulse 1.15s ease-in-out infinite;
}

.stage-wait[hidden],
#stageMiss[hidden],
#stageImg[hidden],
#stageShot[hidden],
#editBoxLayer[hidden],
#editBoxHint[hidden] {
  display: none !important;
}

.stage-shot {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
  overflow: visible;
}

.edit-box-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.stage-shot.is-draw {
  touch-action: none;
}

.stage-shot.is-draw img {
  -webkit-user-drag: none;
  user-select: none;
}

.stage-shot.is-draw[data-cursor="draw"],
.stage-shot.is-draw[data-cursor="draw"] img {
  cursor: crosshair;
}

.stage-shot.is-draw[data-cursor="move"],
.stage-shot.is-draw[data-cursor="move"] img {
  cursor: grab;
}

.stage-shot.is-draw[data-cursor="grabbing"],
.stage-shot.is-draw[data-cursor="grabbing"] img {
  cursor: grabbing;
}

.stage-shot.is-draw[data-cursor="nwse"],
.stage-shot.is-draw[data-cursor="nwse"] img {
  cursor: nwse-resize;
}

.stage-shot.is-draw[data-cursor="nesw"],
.stage-shot.is-draw[data-cursor="nesw"] img {
  cursor: nesw-resize;
}

.stage-shot.is-draw[data-cursor="ns"],
.stage-shot.is-draw[data-cursor="ns"] img {
  cursor: ns-resize;
}

.stage-shot.is-draw[data-cursor="ew"],
.stage-shot.is-draw[data-cursor="ew"] img {
  cursor: ew-resize;
}

.edit-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #8a6a12;
  background: rgba(201, 162, 39, 0.22);
}

.edit-box.is-draw {
  background: rgba(201, 162, 39, 0.12);
  border-style: dashed;
}

.edit-box.is-sel {
  border-color: var(--ink);
  background: rgba(201, 162, 39, 0.28);
}

.edit-box.is-peer {
  border-style: dashed;
}

.edit-box-name {
  position: absolute;
  left: -2px;
  bottom: 100%;
  margin: 0 0 2px;
  padding: 0 0.32rem;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--ink);
  background: rgba(255, 252, 247, 0.94);
  border: 1px solid var(--rule);
  pointer-events: none;
  white-space: nowrap;
}

.edit-box-name.is-below {
  top: 100%;
  bottom: auto;
  margin: 2px 0 0;
}

.edit-box-name.is-end {
  left: auto;
  right: -2px;
}

.edit-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-sizing: border-box;
}

.edit-handle[data-handle="nw"] { left: 0; top: 0; }
.edit-handle[data-handle="n"] { left: 50%; top: 0; }
.edit-handle[data-handle="ne"] { left: 100%; top: 0; }
.edit-handle[data-handle="e"] { left: 100%; top: 50%; }
.edit-handle[data-handle="se"] { left: 100%; top: 100%; }
.edit-handle[data-handle="s"] { left: 50%; top: 100%; }
.edit-handle[data-handle="sw"] { left: 0; top: 100%; }
.edit-handle[data-handle="w"] { left: 0; top: 50%; }

.edit-box-hint {
  position: absolute;
  left: 50%;
  bottom: 0.45rem;
  transform: translateX(-50%);
  margin: 0;
  padding: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: none;
  border: 0;
  pointer-events: none;
  white-space: nowrap;
  text-shadow:
    0 0 3px var(--paper),
    0 0 6px var(--paper),
    0 1px 0 var(--paper);
}

@keyframes stage-wait-pulse {
  50% { opacity: 0.4; }
}

.stage > * {
  grid-area: 1 / 1;
}

.stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 9.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
}

.stage-in {
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 1;
}

.stage-in.is-shown:not(.stage-out),
.miss.is-shown {
  opacity: 1;
}

.stage-out {
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 0;
}

.tick {
  animation: tick 160ms ease;
}

@keyframes tick {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

@keyframes edgeIn {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-in,
  .stage-out { transition: none; opacity: 1; }
  .tick { animation: none; }
  .stage.is-blink img,
  .stage.is-invert.is-blink img { animation: none; }
  .stage-wait,
  .board-wait-text { animation: none; }
}

.idle .stage,
.stage.is-empty,
.stage.is-wait,
.stage:has(.miss),
.stage:has(.stage-wait) {
  min-height: 280px;
}

.idle .miss {
  font-size: 1.02rem;
  color: var(--ink);
  max-width: 28rem;
}

.miss {
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid #e2d39a;
  text-align: center;
  line-height: 1.65;
  max-width: 22rem;
  padding: 0.85rem 1rem;
}

.keys {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.idle .keys,
.idle .col-code,
.wrap.is-parked .col-code {
  opacity: 0.45;
  pointer-events: none;
}

#codePanel.is-aes > .code-title,
#codePanel.is-aes #ratingFormBits,
#codePanel.is-aes .doubt,
#codePanel.is-aes #btnSave,
#codePanel.is-aes #btnClear {
  display: none;
}

#codePanel.is-approved .flags,
#codePanel.is-approved .fields,
#codePanel.is-approved .doubt,
#codePanel.is-approved #btnSuggest,
#codePanel.is-approved .ai-actions,
#codePanel.is-approved .ai-panel,
#codePanel.is-approved .ai-wait,
#codePanel.is-approved #btnSave,
#codePanel.is-approved #btnClear {
  opacity: 0.45;
  pointer-events: none;
}

.ref {
  padding: 0.7rem 0.85rem 0.8rem;
}

.ref-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
}

.ref-char {
  font-family: inherit;
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1;
  min-height: 2.2rem;
}

.ref-scratch-glyph {
  font-family: inherit;
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1;
  min-height: 2.2rem;
  letter-spacing: 0.08em;
  padding-left: 0.55rem;
  margin-left: 0.05rem;
  border-left: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.ref-scratch-glyph[hidden] {
  display: none;
}

.ref-scratch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--rule);
}

.ref-scratch-kicker {
  flex: none;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.ref-scratch input {
  flex: 1;
  min-width: 0;
}

.rows {
  display: grid;
  grid-template-columns: 5.2em 1fr;
  gap: 0.22rem 0.55rem;
  font-size: 0.9rem;
}

.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 500; }
.rows dd.na {
  color: var(--muted);
  font-weight: 400;
}

.rules {
  margin: 0.4rem 0;
  padding: 0.2rem 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.rules p { margin: 0.4rem 0 0; }

.code {
  padding: 0.7rem 0.85rem 0.9rem;
}

.code-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

#codePanel[hidden],
#reviewPanel[hidden],
#comparePanel[hidden],
#reviewGlyphBlock[hidden],
#aestheticPanel[hidden] {
  display: none;
}

.compare-panel {
  margin-top: 0.35rem;
  padding: 0.85rem 0.9rem 0.8rem;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.compare-panel:has(#reviewCompare:empty) {
  display: none;
}

.col-image:has(#comparePanel:not([hidden])) {
  max-height: calc(100vh - var(--sticky-top));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.col-image:has(#comparePanel:not([hidden])) .stage-wrap {
  flex: 0 1 auto;
  min-height: 0;
}

.col-image:has(#comparePanel:not([hidden])) .stage {
  min-height: 0;
}

.col-image:has(#comparePanel:not([hidden])) .stage img {
  max-height: min(48vh, calc(100vh - 20rem));
}

.col-image:has(#comparePanel:not([hidden])) .compare-panel {
  flex: 1 1 auto;
  min-height: min(var(--list-floor), max-content);
}

.col-image:has(#comparePanel:not([hidden])) .keys {
  flex-shrink: 0;
}

.aes-sliders {
  display: grid;
  gap: 1rem;
  margin: 0.15rem 0 0.55rem;
}

.aes-row {
  min-width: 0;
}

.aes-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
}

.aes-head label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.aes-now {
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ink);
  min-width: 1.2em;
  text-align: right;
}

.aes-row:has(.aes-slider.is-empty) .aes-now {
  color: var(--muted);
  font-weight: 500;
}

.aes-slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.aes-slider:focus {
  outline: none;
}

.aes-slider:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.aes-slider::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 1px;
  background: linear-gradient(var(--ink), var(--ink)) 0 / var(--aes-pct, 0%) 100% no-repeat,
    var(--rule);
}

.aes-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  cursor: pointer;
}

.aes-slider.is-empty::-webkit-slider-thumb {
  background: var(--paper);
}

.aes-slider::-moz-range-track {
  height: 3px;
  border: 0;
  border-radius: 1px;
  background: var(--rule);
}

.aes-slider::-moz-range-progress {
  height: 3px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
}

.aes-slider.is-empty::-moz-range-progress {
  background: transparent;
}

.aes-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  cursor: pointer;
}

.aes-slider.is-empty::-moz-range-thumb {
  background: var(--paper);
}

.aes-slider:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.aes-ends {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.28rem 0 0.12rem;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
}

.aes-ends b {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.aes-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.1rem;
}

.aes-ticks button {
  appearance: none;
  min-height: 0;
  width: 1.4em;
  height: 24px;
  padding: 0;
  justify-content: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.aes-ticks button:hover:not(:disabled) {
  color: var(--ink);
}

.aes-ticks button.is-on {
  color: var(--ink);
}

#admin {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: start;
}

#adminDataPanel {
  grid-column: 1 / -1;
}

#adminDataPanel .admin-head {
  flex-wrap: wrap;
}

.admin-col {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.admin-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-height: max(
    calc(var(--list-floor) + 9rem),
    calc(100vh - var(--sticky-top) - 1.8rem)
  );
  overflow: hidden;
  padding: 0.7rem 0.85rem 0.9rem;
}

.admin-panel.is-wait {
  cursor: wait;
}

.admin-wait {
  display: none;
}

.admin-panel.is-wait .admin-wait {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--paper);
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.7rem;
  margin-bottom: 0.45rem;
}

.admin-head .code-title { margin: 0; }

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

#admin .hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

#admin .hint.err {
  margin: 0;
  color: var(--err);
}

#admin .board-scroller {
  flex: 1 1 auto;
  min-height: min(var(--list-floor), max-content);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--paper);
  border-bottom: 2px solid var(--rule);
}

#admin .board-scroller thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  border-bottom: 0;
  box-shadow: 0 2px 0 var(--rule);
}

#admin .board-scroller thead th.admin-cell-edit {
  z-index: 4;
  box-shadow: -8px 0 8px -8px rgba(28, 25, 23, 0.18), 0 2px 0 var(--rule);
}

#admin .board-scroller .admin-table td {
  background: var(--paper);
}

#adminSubjectsBlock,
#adminCatalogBlock {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.admin-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  font-size: 15px;
}

.admin-table th {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.15rem 0.4rem 0.4rem;
  white-space: nowrap;
}

.admin-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.admin-table th[data-sort]:hover,
.admin-table th[aria-sort] {
  color: var(--ink);
}

.admin-table th[data-sort]::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0.28em;
  vertical-align: 0.18em;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 5px solid var(--rule);
}

.admin-table th[aria-sort="ascending"]::after {
  border-bottom-color: var(--ink);
}

.admin-table th[aria-sort="descending"]::after {
  border-bottom: 0;
  border-top: 5px solid var(--ink);
}

.admin-table td {
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.55rem 0.4rem;
  text-align: left;
  vertical-align: middle;
}

.admin-table tbody tr:first-child td {
  padding-top: 0.85rem;
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
  padding-bottom: 0.85rem;
}

.admin-person {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 7.5rem;
  height: 2.15rem;
}

.admin-code-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 2.15rem;
  height: 2.15rem;
  flex: none;
  background: #fff;
  border: 1px solid var(--rule);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.admin-code-cell.is-on {
  border-color: #2f7a3e;
  background: #e7f2e9;
  color: #1f4d28;
}

.admin-who {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.08rem;
  min-width: 0;
  height: 2.15rem;
  line-height: 1.1;
}

.admin-who b {
  font-weight: 650;
  font-size: 15px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-sub {
  font-size: 11px;
  line-height: 1.1;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-roles {
  display: inline-flex;
  position: relative;
  border: 1px solid var(--rule);
  background: #fff;
}

.admin-roles label {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0.65rem;
  min-height: 34px;
  border-right: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}

.admin-roles label:last-child { border-right: 0; }

.admin-roles input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.admin-roles label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.admin-roles label:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.admin-roles.is-read {
  pointer-events: none;
}

.admin-roles.is-read span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.65rem;
  min-height: 34px;
  border-right: 1px solid var(--rule);
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}

.admin-roles.is-read span:last-child { border-right: 0; }

.admin-roles.is-read span.is-on {
  background: var(--accent);
  color: #fff;
}

.admin-state {
  white-space: nowrap;
  color: var(--ink);
}

.admin-state.is-off { color: var(--err); }

.admin-cell-stat {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}

.admin-cell-stat.is-empty {
  color: var(--muted);
}

.admin-cell-assign {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-cell-coop-read {
  white-space: nowrap;
}

.admin-cell-edit {
  width: 1%;
  white-space: nowrap;
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--paper);
  box-shadow: -8px 0 8px -8px rgba(28, 25, 23, 0.18);
}

.admin-table thead th.admin-cell-edit {
  z-index: 3;
}

.admin-row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.admin-row-actions button {
  flex: none;
}

#adminUsers tbody tr.is-off .admin-who {
  color: var(--muted);
}

#adminUsers tbody tr.is-off .admin-row-actions,
#adminUsers tbody tr.is-off .admin-row-actions button {
  opacity: 1;
  pointer-events: auto;
}

.admin-off {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  color: var(--muted);
}

.admin-off:has(input:checked) { color: var(--err); }

.admin-off:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.admin-del-cell {
  white-space: nowrap;
  width: 1%;
}

.admin-del {
  color: var(--err);
}

.admin-del:disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: not-allowed;
}

.edit-card {
  width: min(24rem, 100%);
  max-height: min(88vh, 640px);
}

.edit-user-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.edit-user-form > label,
.edit-user-form > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

.edit-user-form > label > span,
.edit-user-label {
  font-size: 13px;
  color: var(--muted);
}

.edit-user-form input[type="text"],
.edit-user-form input[type="password"],
.edit-user-form select {
  width: 100%;
  min-height: 34px;
  font-size: 15px;
}

.edit-user-form .admin-off {
  flex-direction: row;
  align-items: center;
}

#assignForm .assign-opts {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.25rem;
}

#assignForm .assign-opts label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.edit-user-form > .switch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.15rem;
}

.edit-user-form > .edit-user-danger {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  margin-top: 0;
}

.edit-user-danger > button {
  width: 100%;
  justify-content: center;
}

.edit-user-del {
  width: 100%;
  justify-content: center;
}

.edit-card .hint {
  margin: 0 0 0.55rem;
  font-size: 13px;
  color: var(--ink);
}

.edit-card .hint.err { color: var(--err); }

.import-catalog-actions {
  margin: 0 0 0.75rem;
}

.subject-card {
  width: min(46rem, 100%);
  max-height: max(
    calc(var(--list-floor) + 8rem),
    min(90vh, 780px)
  );
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.subject-card .help-top {
  flex: none;
}

.subject-card .admin-data-summary {
  margin: 0 0 0.45rem;
}

.subject-card .admin-data-actions {
  margin-bottom: 0.55rem;
}

.subject-file-scroller {
  min-height: min(var(--list-floor), max-content);
  flex: 1 1 auto;
  max-height: min(28rem, max(var(--list-floor), 52vh));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 2px solid var(--rule);
}

.subject-file-scroller .admin-table {
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.subject-file-scroller thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  border-bottom: 0;
  box-shadow: 0 2px 0 var(--rule);
}

.subject-file-scroller thead th.admin-cell-edit {
  z-index: 4;
  box-shadow: -8px 0 8px -8px rgba(28, 25, 23, 0.18), 0 2px 0 var(--rule);
}

.subject-file-scroller tbody tr:last-child td {
  padding-bottom: 0.7rem;
}

.subject-file-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.subject-file-actions .admin-file {
  min-height: 34px;
  padding: 0 0.55rem;
  font-size: 15px;
}

#adminSubjects .admin-cell-stat.is-miss,
#subjectFiles .admin-cell-stat.is-miss {
  color: var(--err);
}

#subjectFiles .admin-cell-stat.is-ok {
  color: var(--ink);
}

.admin-table input[data-ranges] {
  width: 100%;
  min-width: 7.5rem;
}

.admin-table input:disabled,
.admin-table select:disabled {
  opacity: 0.45;
  background: var(--desk);
  color: var(--muted);
}

.edit-user-form .admin-new-pair,
.admin-new-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  min-width: 0;
  width: 100%;
}

@media (min-width: 520px) {
  .edit-user-form .admin-new-pair,
  .admin-new-pair {
    grid-template-columns: 1fr 1fr;
  }
}

#adminNewUser .admin-new-pair label,
#adminNewUser .admin-new-roles,
#assignForm .admin-new-pair > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
  width: 100%;
}

#assignForm #assignRanges {
  margin-top: 0.15rem;
}

#adminNewUser .admin-new-pair label > span {
  font-size: 13px;
  color: var(--muted);
}

.admin-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem 0.8rem;
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--rule);
}

.admin-foot .primary { justify-content: center; }

.admin-cell-coop {
  width: 4.2rem;
  white-space: nowrap;
}

.admin-cell-coop label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
}

.admin-data-tabs {
  margin-left: auto;
}

.admin-data-summary {
  flex-shrink: 0;
  margin: 0 0 0.45rem;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.admin-data-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.admin-subjects-track {
  display: flex;
  margin-left: auto;
}

.admin-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  gap: 0.4rem 0.7rem;
  margin-top: 0.85rem;
  font-size: 15px;
}

.admin-pager label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-pager select,
.admin-pager input[type="number"] {
  min-height: 34px;
  font-size: 15px;
  color: var(--ink);
}

.admin-pager input[type="number"] {
  width: 3.4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.admin-pager-range {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.admin-file {
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 0.7rem;
  border: 1px solid var(--rule);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
}

.admin-file input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 0;
  cursor: pointer;
}

.admin-find,
#adminCatalogFind {
  min-width: 10rem;
  flex: 1 1 12rem;
  min-height: 34px;
}

#adminSubjects .admin-cell-stat.is-miss {
  color: var(--err);
}

.review-compare {
  overflow-x: auto;
  overflow-y: auto;
  margin: 0;
  min-width: 0;
  min-height: min(var(--list-floor), max-content);
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.review-compare > p {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.review-compare table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
}

.review-compare thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0.5rem 0.5rem;
  white-space: nowrap;
  background: var(--paper);
}

.review-compare thead th:first-child,
.review-compare .rater-id {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: var(--paper);
  box-shadow: 4px 0 8px -6px rgba(28, 25, 23, 0.22);
}

.review-compare thead th:first-child {
  z-index: 3;
  width: 1%;
}

.review-compare col.compare-who {
  width: 1%;
}

.review-compare .compare-rad {
  font-weight: 650;
  letter-spacing: 0;
}

.review-compare td {
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.22rem 0.45rem;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.2;
}

.review-compare tbody tr:first-child td {
  padding-top: 0.55rem;
}

.review-compare tbody tr:last-child td {
  border-bottom: 0;
}

.review-compare .rater-id {
  text-align: left;
  width: 1%;
  white-space: nowrap;
  font-weight: 650;
  line-height: 1.2;
}

.compare-rerate {
  display: inline;
  margin: 0 0 0 0.15rem;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--rerate-ink);
  vertical-align: baseline;
}

.compare-rerate.is-back {
  color: var(--rerate-back-ink);
}

button.compare-doubt {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0 0 0 0.15rem;
  padding: 0;
  vertical-align: baseline;
  border: 0;
  border-radius: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--doubt-ink);
  background: transparent;
}

.review-compare td.is-empty,
.review-compare td.is-miss {
  color: var(--muted);
  font-weight: 400;
}

.review-compare td.is-miss {
  text-align: center;
}

.review-compare table.compare-aes thead th:not(:first-child),
.review-compare table.compare-aes td:not(.rater-id) {
  text-align: center;
}

.review-compare table.compare-aes td.is-miss {
  text-align: center;
}

.review-compare td.is-on {
  font-weight: 650;
}

.review-compare td.is-aux {
  white-space: nowrap;
}

.review-compare th.clash,
.review-compare td.clash {
  background: var(--cell-conflict);
}

.review-hint {
  font-size: 13px;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid #e2d39a;
  padding: 0.35rem 0.55rem;
  margin: 0 0 0.45rem;
}

#reviewPanel .save-row > button {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  margin-top: 0.35rem;
}

#reviewPanel .save-row > .primary {
  margin-top: 0;
  min-height: 40px;
}

#reviewPanel .save-row > #btnApprove {
  margin-top: 0;
  min-height: 40px;
}

.rerate-list {
  margin: 0.5rem 0 0.7rem;
}

.rerate-list label {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0.35rem 0;
  font-size: 15px;
}

.rerate-list .rerate-who {
  font-weight: 650;
}

.fields label,
.doubt label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0.35rem 0 0.15rem;
}

.fields input,
.doubt input[type="text"] {
  width: 100%;
  font-size: 15px;
}

.fields input:disabled,
.doubt input:disabled {
  opacity: 0.5;
  background: #f3f0ea;
  cursor: not-allowed;
}

.doubt .inline:has(input:disabled) {
  cursor: not-allowed;
}

.field-hint {
  margin: 0.2rem 0 0;
  font-size: 13px;
  color: var(--err);
}

.flag-row:has(input:disabled) {
  opacity: 0.45;
}

.flag-row:has(input:disabled) label {
  cursor: not-allowed;
}

.flag-row input:disabled {
  cursor: not-allowed;
}

.doubt {
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--rule);
}

.doubt .inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

#uncertainNoteWrap {
  display: grid;
  gap: 0.28rem;
  margin-top: 0.45rem;
}

.save-row {
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--rule);
}

.legend-doubt[hidden] {
  display: none;
}

.ai-panel {
  margin-top: 0.45rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--rule);
  background: #fff;
}

.ai-error {
  margin: 0.45rem 0 0;
  max-height: 4.6rem;
  overflow: auto;
  word-break: break-word;
}

.ai-wait {
  margin-top: 0.45rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--rule);
  background: #fff;
}

.ai-wait-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.ai-wait-status {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}

.ai-wait-elapsed {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ai-wait-track {
  position: relative;
  height: 2px;
  margin-top: 0.5rem;
  background: var(--rule);
  overflow: hidden;
}

.ai-wait-gleam {
  position: absolute;
  top: 0;
  left: 0;
  width: 38%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: ai-wait-scan 1.4s ease-in-out infinite;
}

@keyframes ai-wait-scan {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-wait-gleam {
    animation: none;
    width: 100%;
    opacity: 0.35;
  }
}

.ai-source {
  margin: 0 0 0.35rem;
  font-size: 12px;
  color: var(--muted);
}

.ai-reason {
  margin: 0 0 0.35rem;
  font-size: 15px;
  color: var(--ink);
}

.ai-alike {
  margin: 0.15rem 0 0.4rem;
}

.ai-alike-label {
  margin: 0 0 0.28rem;
  font-size: 13px;
  color: var(--muted);
}

.ai-alike-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-alike-item {
  display: flex;
  flex-direction: column;
  min-width: 52px;
  border: 1px solid var(--rule);
  background: #fff;
}

.ai-alike-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  font-size: 17px;
  font-weight: 650;
  line-height: 1;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}

.ai-alike-acts {
  display: flex;
  flex-direction: column;
}

button.ai-alike-act {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 22px;
  height: auto;
  margin: 0;
  padding: 0.12rem 0.28rem;
  justify-content: center;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink);
  background: #fff;
}

button.ai-alike-act:first-child {
  border-top: 0;
}

button.ai-alike-act.is-on {
  background: var(--cell-mine);
}

button.ai-alike-act:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ai-code {
  margin: 0.15rem 0 0.45rem;
}

.ai-code-box {
  border: 1px solid var(--rule);
  background: #fff;
  padding: 0.45rem 0.5rem 0.5rem;
  display: grid;
  gap: 0.4rem;
}

.ai-code-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ai-code-flag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 0.45rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}

.ai-code-row {
  display: grid;
  grid-template-columns: minmax(5.2rem, auto) minmax(0, 1fr);
  gap: 0.45rem;
  align-items: start;
  padding-top: 0.38rem;
  border-top: 1px solid var(--rule);
}

.ai-code-k {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.ai-code-v {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
  text-align: right;
  justify-self: end;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.ai-code-v.is-empty {
  font-weight: 400;
  color: var(--muted);
}

.ai-code-v.is-glyph {
  font-size: 18px;
  line-height: 1.1;
}

.ai-code-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  font-weight: 650;
}

.ai-code-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.ai-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.ai-actions[hidden] {
  display: none;
}

.ai-actions button {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  min-height: 34px;
}

.save-row > .primary {
  width: 100%;
  min-height: 40px;
  justify-content: center;
}

.save-row > .ghost {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  margin-top: 0.35rem;
  color: var(--muted);
}

.save-row > .danger {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  margin-top: 0.35rem;
  color: var(--err);
}

.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.page-nav button {
  width: 100%;
  min-height: 36px;
  justify-content: center;
}

.warn {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid #e2d39a;
  padding: 0.35rem 0.55rem;
  white-space: pre-line;
}

.edge-hint {
  animation: edgeIn 160ms ease;
}

.err {
  color: var(--err);
  font-size: 0.86rem;
  margin: 0.35rem 0 0;
}

@media (max-width: 900px) {
  .main,
  #admin { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
  .col-code { position: static; }
  .nav { margin-left: 0; }
  .stage,
  .idle .stage,
  .stage.is-empty,
  .stage.is-wait,
  .stage:has(.miss),
  .stage:has(.stage-wait) { min-height: 220px; }
  .stage-wait { min-height: 220px; }
  .stage img { max-height: min(42vh, calc(100vh - 9.5rem)); }
  .col-image:has(#comparePanel:not([hidden])) .stage img {
    max-height: min(30vh, calc(100vh - 22rem));
  }
  .col-image:has(.warn:not([hidden])) {
    padding-top: 0.4rem;
  }
}

@media (max-width: 720px) {
  .board-grid { gap: 2px; }
  .admin-foot {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-foot .primary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
