:root {
  --navy-950: #0d2135;
  --navy-900: #16324f;
  --navy-800: #21486b;
  --teal-700: #187963;
  --teal-600: #1f8a70;
  --teal-100: #dff3ed;
  --amber-600: #dd8b21;
  --amber-100: #fff0d6;
  --coral-600: #d75b48;
  --coral-100: #fde5e1;
  --blue-100: #e4eef9;
  --ink-900: #172536;
  --ink-700: #42566e;
  --ink-500: #75869a;
  --line: #d8e1eb;
  --panel: #ffffff;
  --page: #eef3f8;
  --wood: #d8b786;
  --wood-dark: #b99058;
  --shadow-sm: 0 4px 14px rgba(13, 33, 53, 0.08);
  --shadow-md: 0 16px 42px rgba(13, 33, 53, 0.18);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink-900);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(31, 138, 112, 0.32);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.hidden {
  display: none !important;
}

.app-shell {
  height: 100dvh;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 12% 5%, rgba(31, 138, 112, 0.07), transparent 24%),
    radial-gradient(circle at 87% 4%, rgba(221, 139, 33, 0.06), transparent 24%),
    var(--page);
}

.topbar {
  min-height: 66px;
  padding: calc(9px + var(--safe-top)) 18px 9px;
  display: grid;
  grid-template-columns: minmax(225px, 1fr) minmax(225px, 0.8fr) minmax(330px, 1fr);
  align-items: center;
  gap: 16px;
  color: #fff;
  background: linear-gradient(118deg, var(--navy-950), var(--navy-900) 58%, #1f4e67);
  box-shadow: 0 6px 20px rgba(13, 33, 53, 0.16);
  z-index: 10;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 34px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.brand-mark span {
  display: block;
  border-radius: 3px;
  background: #86d2bd;
}

.brand-mark span:nth-child(7) {
  grid-column: 1;
}

.brand-mark span:nth-child(8) {
  grid-column: 3;
}

.brand-title {
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.66);
  white-space: nowrap;
}

.class-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.class-switcher select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 38px 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 650;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.86) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.86) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 17px,
    calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.class-switcher select option {
  color: var(--ink-900);
}

.icon-button,
.close-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 19px;
}

.icon-button:active,
.top-action:active {
  transform: translateY(1px);
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-action {
  min-height: 42px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.top-action.primary {
  border-color: #86d2bd;
  color: var(--navy-950);
  background: #86d2bd;
}

.top-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.session-strip {
  min-height: 62px;
  padding: 8px 18px;
  display: grid;
  grid-template-columns: minmax(160px, 0.85fr) minmax(440px, 1.65fr) auto;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-title-button {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-900);
  font-weight: 760;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.session-title-button::after {
  content: " ✎";
  color: var(--ink-500);
  font-size: 12px;
}

.session-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  gap: 8px;
}

.metric-card {
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafc;
}

.metric-label {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-500);
  font-size: 9px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-right: 5px;
  display: inline-block;
  border-radius: 50%;
  background: var(--teal-600);
  box-shadow: 0 0 0 3px rgba(31, 138, 112, 0.1);
}

.display-controls {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf2f7;
}

.segmented {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  color: var(--ink-700);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.segmented.active {
  color: var(--navy-900);
  background: #fff;
  box-shadow: 0 2px 8px rgba(13, 33, 53, 0.08);
}

.workspace {
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.classroom-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.classroom-canvas {
  min-width: 980px;
  min-height: 100%;
  padding: 9px 18px 14px;
}

.front-zone {
  display: flex;
  justify-content: center;
  margin-bottom: 9px;
}

.blackboard {
  width: min(680px, 72%);
  height: 42px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  color: #eefbf6;
  border: 4px solid #8c6845;
  border-radius: 7px;
  background:
    linear-gradient(100deg, rgba(255,255,255,0.03), transparent 24%, rgba(255,255,255,0.025) 68%, transparent),
    #245b4d;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.18), 0 3px 8px rgba(13, 33, 53, 0.12);
}

.blackboard-label,
#blackboardHint {
  color: rgba(238, 251, 246, 0.72);
  font-size: 10px;
  white-space: nowrap;
}

.blackboard strong {
  text-align: center;
  font-size: 14px;
}

.desk-rows {
  display: grid;
  grid-template-rows: repeat(3, minmax(140px, 1fr));
  gap: 9px;
  min-height: calc(100% - 51px);
}

.desk-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.desk-row.two-desks {
  width: calc((100% - 24px) * 0.666666 + 12px);
  justify-self: center;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.desk-card {
  min-width: 0;
  min-height: 128px;
  padding: 6px 8px 7px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  border: 1px solid #d3dee9;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.desk-card:hover {
  border-color: #b9c9d9;
}

.desk-card[data-task="等待检查"] {
  border-color: #e6a443;
  box-shadow: 0 4px 16px rgba(221, 139, 33, 0.15);
}

.desk-card[data-task="已完成"] {
  border-color: #8bc5b5;
}

.desk-header {
  min-height: 23px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.desk-number {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 8px;
  color: #fff;
  background: var(--navy-900);
  font-size: 11px;
  font-weight: 750;
}

.desk-score-button,
.desk-status-button,
.desk-tool-button {
  min-height: 23px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: #eef3f8;
  color: var(--ink-700);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.desk-score-button {
  color: var(--teal-700);
  background: var(--teal-100);
}

.desk-status-button {
  min-width: 58px;
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desk-tool-button {
  margin-left: auto;
}

.desk-layout {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(41px, 1fr) 21px minmax(41px, 1fr);
  gap: 2px;
}

.seat-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.desk-surface {
  min-width: 0;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--wood-dark);
  border-radius: 6px;
  color: #5f4223;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 18px, rgba(117,80,38,0.04) 18px 19px),
    linear-gradient(#e2c596, var(--wood));
  box-shadow: inset 0 1px rgba(255,255,255,0.36);
  font-size: 8px;
  font-weight: 750;
}

.surface-role-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.76;
}

.student-card {
  min-width: 0;
  min-height: 41px;
  padding: 3px;
  position: relative;
  display: grid;
  grid-template-columns: 33px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  border: 1px solid #d8e2ec;
  border-radius: 9px;
  color: var(--ink-900);
  background: #f9fbfd;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition: transform 100ms ease, border-color 100ms ease, background 100ms ease;
}

.student-card:active {
  transform: scale(0.985);
}

.student-card:hover {
  border-color: #aac0d4;
}

.student-card.selected-swap {
  border-color: var(--amber-600);
  background: var(--amber-100);
  box-shadow: 0 0 0 2px rgba(221, 139, 33, 0.18);
}

.student-card.random-highlight {
  animation: pulse-card 900ms ease 2;
}

@keyframes pulse-card {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px rgba(31, 138, 112, 0.24); }
}

.student-card[data-attendance="absent"],
.student-card[data-attendance="leave"] {
  opacity: 0.52;
  filter: grayscale(0.42);
}

.student-card[data-attendance="late"] {
  border-color: #e3a54b;
  background: #fffaf0;
}

.student-card[data-attendance="early"] {
  border-color: #c398e8;
  background: #faf4ff;
}

.student-photo-wrap {
  width: 31px;
  height: 37px;
  position: relative;
  overflow: hidden;
  border-radius: 7px;
  background: var(--blue-100);
}

.student-photo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.student-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy-800);
  background:
    radial-gradient(circle at 50% 34%, #fff 0 17%, transparent 18%),
    radial-gradient(ellipse at 50% 110%, #fff 0 44%, transparent 45%),
    linear-gradient(145deg, #d9e9f8, #c9ddef);
  font-size: 0;
}

.student-text {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 2px;
}

.student-name-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.student-name {
  min-width: 0;
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-badge {
  flex: 0 0 auto;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 999px;
  color: var(--teal-700);
  background: var(--teal-100);
  font-size: 8px;
  font-weight: 800;
  text-align: center;
}

.score-badge.negative {
  color: var(--coral-600);
  background: var(--coral-100);
}

.student-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--ink-500);
  font-size: 8px;
  white-space: nowrap;
  overflow: hidden;
}

.student-role {
  overflow: hidden;
  text-overflow: ellipsis;
}

.attendance-chip {
  flex: 0 0 auto;
  padding: 1px 3px;
  border-radius: 4px;
  color: #8a5c14;
  background: var(--amber-100);
  font-size: 7px;
  font-weight: 800;
}

.empty-seat {
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  border-style: dashed;
  color: #8a99a9;
  background: rgba(248,250,252,0.7);
  text-align: center;
  font-size: 8px;
}

.empty-plus {
  font-size: 14px;
  line-height: 1;
}

.classroom-canvas.photo-only .student-card {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 2px;
}

.classroom-canvas.photo-only .student-photo-wrap {
  width: 38px;
  height: 44px;
}

.classroom-canvas.photo-only .student-text {
  display: none;
}

.classroom-canvas.compact .student-card {
  grid-template-columns: 28px minmax(0, 1fr);
  min-height: 42px;
}

.classroom-canvas.compact .student-photo-wrap {
  width: 28px;
  height: 35px;
}

.classroom-canvas.compact .student-meta {
  display: none;
}

.classroom-canvas.recognition-mode .student-name,
.classroom-canvas.recognition-mode .score-badge,
.classroom-canvas.recognition-mode .student-meta {
  visibility: hidden;
}

.classroom-canvas.recognition-mode .student-card.revealed .student-name,
.classroom-canvas.recognition-mode .student-card.revealed .score-badge,
.classroom-canvas.recognition-mode .student-card.revealed .student-meta {
  visibility: visible;
}

.mode-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  padding: 9px 15px;
  border: 1px solid rgba(13, 33, 53, 0.12);
  border-radius: 999px;
  color: #fff;
  background: rgba(13, 33, 53, 0.92);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
}

.bottom-toolbar {
  min-height: 70px;
  padding: 7px 14px calc(7px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(9, minmax(58px, 1fr));
  gap: 7px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 22px rgba(13, 33, 53, 0.08);
  z-index: 15;
}

.tool-button {
  min-width: 0;
  min-height: 54px;
  padding: 5px 4px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--ink-700);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
}

.tool-button:hover {
  background: #f1f5f9;
}

.tool-button.active {
  border-color: #9bcdbc;
  color: var(--teal-700);
  background: var(--teal-100);
}

.tool-icon {
  width: 27px;
  height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--navy-900);
  background: #e6edf5;
  font-size: 15px;
  font-weight: 800;
}

.tool-button.active .tool-icon {
  color: #fff;
  background: var(--teal-600);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 22, 36, 0.42);
  backdrop-filter: blur(2px);
}

.side-sheet {
  position: fixed;
  z-index: 100;
  top: 0;
  right: 0;
  width: min(440px, 92vw);
  height: 100dvh;
  padding-top: var(--safe-top);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
  box-shadow: -18px 0 45px rgba(13, 33, 53, 0.24);
  transform: translateX(104%);
  transition: transform 190ms ease;
}

.side-sheet.open {
  transform: translateX(0);
}

.sheet-header,
.dialog-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-header h2,
.dialog-header h2 {
  margin: 0;
  font-size: 21px;
}

.close-button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--ink-700);
  background: #edf2f7;
  font-size: 24px;
  line-height: 1;
}

.sheet-body,
.dialog-body {
  min-height: 0;
  padding: 17px 20px 24px;
  overflow: auto;
  overscroll-behavior: contain;
}

.sheet-footer,
.dialog-footer {
  padding: 12px 20px calc(12px + var(--safe-bottom));
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.dialog {
  position: fixed;
  z-index: 110;
  top: 50%;
  left: 50%;
  width: min(620px, calc(100vw - 30px));
  max-height: min(84dvh, 760px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow-md);
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.section-card {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfcfe;
}

.section-card:last-child {
  margin-bottom: 0;
}

.section-heading {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 780;
}

.section-description,
.help-text {
  color: var(--ink-500);
  font-size: 11px;
  line-height: 1.55;
}

.help-text {
  margin: 7px 0 0;
}

.student-profile {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.profile-photo {
  width: 84px;
  height: 112px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--blue-100);
  box-shadow: inset 0 0 0 1px rgba(13, 33, 53, 0.08);
}

.profile-photo img,
.profile-photo .student-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  margin: 0 0 5px;
  font-size: 24px;
}

.profile-meta {
  margin: 0 0 9px;
  color: var(--ink-500);
  font-size: 12px;
}

.profile-score-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.large-score {
  padding: 7px 9px;
  border-radius: 10px;
  color: var(--teal-700);
  background: var(--teal-100);
  font-size: 12px;
  font-weight: 800;
}

.large-score.total {
  color: var(--navy-800);
  background: var(--blue-100);
}

.reason-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.reason-button {
  min-height: 48px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.reason-button:hover {
  border-color: #aec3d6;
}

.reason-delta {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--teal-700);
  background: var(--teal-100);
  font-weight: 850;
}

.reason-button.negative .reason-delta {
  color: var(--coral-600);
  background: var(--coral-100);
}

.reason-label {
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
}

.primary-button {
  border: 1px solid var(--teal-700);
  color: #fff;
  background: var(--teal-600);
}

.secondary-button {
  border: 1px solid #bdcbd8;
  color: var(--navy-900);
  background: #edf3f8;
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink-700);
  background: #fff;
}

.danger-button {
  border: 1px solid #e2a69c;
  color: #a73d2d;
  background: var(--coral-100);
}

.wide-button {
  width: 100%;
}

.attendance-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.attendance-button {
  min-height: 42px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.attendance-button.current {
  border-color: #87c3b2;
  color: var(--teal-700);
  background: var(--teal-100);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-field {
  display: grid;
  gap: 5px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  color: var(--ink-700);
  font-size: 11px;
  font-weight: 700;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #cbd7e3;
  border-radius: 10px;
  color: var(--ink-900);
  background: #fff;
}

.form-field textarea {
  min-height: 86px;
  resize: vertical;
}

.toggle-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toggle-copy strong {
  display: block;
  font-size: 12px;
}

.toggle-copy span {
  display: block;
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 10px;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5df;
  transition: background 140ms ease;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(13, 33, 53, 0.2);
  transition: transform 140ms ease;
}

.switch input:checked + span {
  background: var(--teal-600);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.table-selector {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.table-select-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
  font-weight: 750;
}

.table-select-button.selected {
  border-color: var(--teal-600);
  color: var(--teal-700);
  background: var(--teal-100);
}

.table-status-list {
  display: grid;
  gap: 9px;
}

.table-status-row {
  padding: 10px;
  display: grid;
  grid-template-columns: 54px repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.table-status-row strong {
  font-size: 12px;
}

.table-status-row select {
  min-width: 0;
  height: 38px;
  padding: 0 25px 0 8px;
  border: 1px solid #cad6e2;
  border-radius: 9px;
  background: #fff;
  font-size: 10px;
}

.class-list {
  display: grid;
  gap: 8px;
}

.class-list-item {
  padding: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.class-list-item.current {
  border-color: #95c9ba;
  background: #f2fbf8;
}

.class-list-copy {
  min-width: 0;
}

.class-list-copy strong,
.class-list-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.class-list-copy strong {
  font-size: 13px;
}

.class-list-copy span {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 10px;
}

.file-drop-card {
  min-height: 96px;
  padding: 14px;
  display: grid;
  place-items: center;
  border: 2px dashed #b8c8d7;
  border-radius: 14px;
  color: var(--ink-700);
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
}

.file-drop-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.file-drop-card span {
  display: block;
  color: var(--ink-500);
  font-size: 10px;
}

.import-report {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  color: var(--ink-700);
  background: #eef3f8;
  font-size: 11px;
  line-height: 1.55;
}

.random-card {
  padding: 10px 0 2px;
  display: grid;
  justify-items: center;
  text-align: center;
}

.random-photo {
  width: 150px;
  height: 200px;
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--blue-100);
  box-shadow: 0 12px 28px rgba(13, 33, 53, 0.18);
}

.random-photo img,
.random-photo .student-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.random-card h3 {
  margin: 0 0 4px;
  font-size: 28px;
}

.random-card p {
  margin: 0;
  color: var(--ink-500);
  font-size: 12px;
}

.ledger-list {
  display: grid;
  gap: 7px;
}

.ledger-item {
  padding: 9px 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.ledger-delta {
  min-width: 34px;
  padding: 5px 7px;
  border-radius: 8px;
  color: var(--teal-700);
  background: var(--teal-100);
  font-weight: 800;
  text-align: center;
}

.ledger-delta.negative {
  color: var(--coral-600);
  background: var(--coral-100);
}

.ledger-copy {
  min-width: 0;
}

.ledger-copy strong,
.ledger-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-copy strong {
  font-size: 11px;
}

.ledger-copy span,
.ledger-time {
  color: var(--ink-500);
  font-size: 9px;
}

.empty-state {
  padding: 28px 10px;
  color: var(--ink-500);
  text-align: center;
  font-size: 12px;
}

.toast-region {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  width: min(420px, calc(100vw - 28px));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border-radius: 12px;
  color: #fff;
  background: rgba(13, 33, 53, 0.94);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  animation: toast-in 160ms ease both;
}

.toast.success {
  background: rgba(24, 121, 99, 0.96);
}

.toast.warning {
  background: rgba(176, 103, 18, 0.96);
}

.toast.error {
  background: rgba(167, 61, 45, 0.96);
}

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

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(210px, 0.9fr) minmax(190px, 0.75fr) auto;
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .top-action {
    padding: 0 9px;
  }

  .session-strip {
    grid-template-columns: minmax(150px, 0.7fr) minmax(420px, 1.5fr) auto;
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .save-card {
    display: none;
  }

  .session-metrics {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
  }

  .segmented {
    padding: 0 7px;
    font-size: 10px;
  }
}

@media (max-width: 900px) {
  .topbar {
    min-width: 760px;
  }

  .session-strip {
    min-width: 760px;
  }

  .bottom-toolbar {
    min-width: 760px;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .brand-subtitle,
  .top-action span:last-child,
  .save-card,
  .display-controls {
    display: none;
  }

  .topbar {
    min-width: 0;
    grid-template-columns: auto minmax(170px, 1fr) auto;
  }

  .top-action {
    width: 42px;
    padding: 0;
  }

  .session-strip {
    min-width: 0;
    grid-template-columns: minmax(140px, 0.8fr) minmax(330px, 1.5fr);
  }

  .classroom-canvas {
    min-width: 980px;
  }

  .bottom-toolbar {
    min-width: 0;
    overflow-x: auto;
    grid-template-columns: repeat(9, 76px);
    justify-content: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ===== Version 2: teacher perspective, semesters, side seats and attendance popover ===== */
.topbar {
  grid-template-columns: minmax(190px, 0.72fr) minmax(390px, 1.25fr) auto;
  gap: 12px;
}

.context-switcher {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(145px, 0.85fr) minmax(145px, 1fr) 42px 42px;
  gap: 7px;
}

.context-select {
  min-width: 0;
  height: 46px;
  padding: 4px 7px 3px;
  display: grid;
  grid-template-rows: 11px 1fr;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
}

.context-select > span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.class-switcher .context-select select {
  height: 28px;
  padding: 0 25px 0 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: calc(100% - 9px) 11px, calc(100% - 4px) 11px;
  font-size: 11px;
}

.session-strip {
  grid-template-columns: minmax(150px, 0.72fr) minmax(520px, 1.95fr) auto;
}

.session-metrics {
  grid-template-columns: repeat(5, minmax(78px, 1fr));
}

.classroom-canvas {
  min-width: 1010px;
  display: flex;
  flex-direction: column;
}

.teacher-zone {
  flex: 0 0 auto;
  margin: 9px 0 0;
}

.desk-rows {
  flex: 1 1 auto;
  min-height: calc(100% - 51px);
}

.desk-card {
  min-height: 142px;
}

.desk-layout.with-side-seats {
  min-height: 0;
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) 43px;
  grid-template-rows: minmax(0, 1fr);
  gap: 4px;
}

.desk-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(42px, 1fr) 21px minmax(42px, 1fr);
  gap: 2px;
}

.side-seat-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.side-seat-card {
  width: 100%;
  min-height: 92px;
  padding: 3px 2px;
  grid-template-columns: 1fr;
  grid-template-rows: 38px auto;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 3px;
}

.side-seat-card .student-photo-wrap {
  width: 31px;
  height: 38px;
}

.side-seat-card .student-text {
  width: 100%;
  justify-items: center;
  gap: 1px;
}

.side-seat-card .student-name-line {
  max-width: 100%;
  justify-content: center;
}

.side-seat-card .student-name {
  max-width: 39px;
  font-size: 9px;
  text-align: center;
}

.side-seat-card .student-meta {
  max-width: 39px;
  justify-content: center;
  font-size: 7px;
}

.side-seat-card.empty-seat {
  grid-template-rows: auto auto;
  font-size: 7px;
}

.classroom-canvas.photo-only .side-seat-card {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.classroom-canvas.photo-only .side-seat-card .student-photo-wrap {
  width: 36px;
  height: 46px;
}

.classroom-canvas.compact .side-seat-card {
  grid-template-columns: 1fr;
  grid-template-rows: 35px auto;
}

.attendance-popover {
  position: fixed;
  z-index: 120;
  width: 252px;
  max-height: min(430px, calc(100dvh - 20px));
  padding: 11px;
  overflow: auto;
  border: 1px solid #cbd8e4;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 18px 46px rgba(13, 33, 53, 0.28);
}

.attendance-popover-header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 28px;
  gap: 9px;
  align-items: center;
}

.attendance-popover-photo {
  width: 42px;
  height: 54px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--blue-100);
}

.attendance-popover-photo img,
.attendance-popover-photo .student-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attendance-popover-name {
  min-width: 0;
}

.attendance-popover-name strong,
.attendance-popover-name span {
  display: block;
}

.attendance-popover-name strong {
  font-size: 14px;
}

.attendance-popover-name span {
  margin-top: 3px;
  color: var(--ink-500);
  font-size: 9px;
  line-height: 1.35;
}

.popover-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  color: var(--ink-500);
  background: #edf2f7;
  cursor: pointer;
}

.attendance-popover .attendance-actions {
  margin-top: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.attendance-popover .attendance-button:first-child {
  grid-column: 1 / -1;
}

.popover-semester-summary {
  margin-top: 9px;
  padding: 8px 9px;
  border-radius: 10px;
  color: var(--ink-700);
  background: #f2f6fa;
  font-size: 9px;
  line-height: 1.55;
}

.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.stat-card {
  min-width: 0;
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
}

.stat-card strong,
.stat-card span {
  display: block;
}

.stat-card strong {
  font-size: 16px;
}

.stat-card span {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 8px;
}

.attendance-history-list,
.student-manage-list,
.semester-list {
  display: grid;
  gap: 7px;
}

.attendance-history-item {
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 10px;
}

.attendance-history-item time {
  color: var(--ink-500);
}

.attendance-history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attendance-stat-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 10px;
}

.attendance-stat-table th {
  padding: 0 6px 3px;
  color: var(--ink-500);
  font-size: 8px;
  text-align: center;
}

.attendance-stat-table th:first-child {
  text-align: left;
}

.attendance-stat-table td {
  padding: 8px 6px;
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.attendance-stat-table td:first-child {
  border-left: 1px solid var(--line);
  border-radius: 10px 0 0 10px;
  text-align: left;
}

.attendance-stat-table td:last-child {
  border-right: 1px solid var(--line);
  border-radius: 0 10px 10px 0;
}

.student-link-button {
  padding: 0;
  border: 0;
  color: var(--navy-900);
  background: transparent;
  cursor: pointer;
  font-weight: 760;
}

.batch-status-group {
  margin-top: 10px;
}

.batch-status-group:first-child {
  margin-top: 0;
}

.batch-status-title {
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.batch-status-title strong {
  font-size: 11px;
}

.batch-status-title span {
  color: var(--ink-500);
  font-size: 8px;
}

.batch-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.batch-chip {
  min-height: 34px;
  padding: 5px 6px;
  border: 1px solid #cbd7e2;
  border-radius: 9px;
  color: var(--ink-700);
  background: #fff;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.quick-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.student-manage-list {
  max-height: 330px;
  overflow: auto;
  padding-right: 2px;
}

.student-manage-row {
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.student-manage-avatar {
  width: 34px;
  height: 43px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--blue-100);
}

.student-manage-avatar img,
.student-manage-avatar .student-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.student-manage-copy {
  min-width: 0;
}

.student-manage-copy strong,
.student-manage-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-manage-copy strong {
  font-size: 11px;
}

.student-manage-copy span {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.form-grid .field.full {
  grid-column: 1 / -1;
}

.dialog .field label,
.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-700);
  font-size: 10px;
  font-weight: 720;
}

.dialog .field input,
.dialog .field select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid #cbd7e2;
  border-radius: 10px;
  background: #fff;
}

.context-summary {
  padding: 10px 11px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(118deg, var(--navy-950), var(--navy-800));
}

.context-summary div {
  min-width: 0;
}

.context-summary span,
.context-summary strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-summary span {
  color: rgba(255,255,255,.62);
  font-size: 8px;
}

.context-summary strong {
  margin-top: 3px;
  font-size: 11px;
}

.side-seat-note {
  margin-top: 7px;
  padding: 7px 9px;
  border-radius: 9px;
  color: #7b561c;
  background: var(--amber-100);
  font-size: 9px;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(178px, .62fr) minmax(350px, 1.15fr) auto;
    gap: 8px;
  }

  .context-switcher {
    grid-template-columns: minmax(128px, .85fr) minmax(128px, 1fr) 38px 38px;
    gap: 5px;
  }

  .icon-button {
    width: 38px;
    height: 42px;
    flex-basis: 38px;
  }

  .session-strip {
    grid-template-columns: minmax(140px, .62fr) minmax(430px, 1.8fr) auto;
  }

  .session-metrics {
    grid-template-columns: repeat(4, minmax(75px, 1fr));
  }

  .save-card {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .context-switcher {
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) 38px;
  }

  #newClassBtn {
    display: none;
  }

  .semester-count-card {
    display: none;
  }

  .session-metrics {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
  }
}

/* =========================================================
   V3：前六桌竖向、奖惩分栏与留堂卫生提醒
   ========================================================= */

.desk-rows {
  grid-template-rows: minmax(132px, .9fr) repeat(2, minmax(146px, 1fr));
  gap: 8px;
}

.back-horizontal-row {
  align-items: stretch;
}

.vertical-desk-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.vertical-desk {
  min-height: 144px;
  padding-inline: 6px;
}

.horizontal-desk {
  min-height: 128px;
}

.vertical-desk-layout {
  min-height: 0;
  display: grid;
  grid-template-rows: 20px minmax(0, 1fr) 20px;
  gap: 2px;
}

.vertical-desk-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 47px minmax(0, 1fr);
  gap: 4px;
}

.seat-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
}

.vertical-surface {
  min-height: 0;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  gap: 0;
  text-align: center;
  font-size: 7px;
}

.vertical-surface strong {
  font-size: 8px;
}

.vertical-surface small {
  max-width: 42px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 6px;
  opacity: .72;
}

.vertical-end-seat {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vertical-end-seat .student-card {
  width: 64%;
  min-height: 20px;
  height: 20px;
  grid-template-columns: 18px minmax(0, 1fr);
  padding: 1px 4px;
  border-radius: 7px;
}

.vertical-end-seat .student-photo-wrap {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.vertical-end-seat .student-name {
  font-size: 8px;
}

.vertical-end-seat .student-meta {
  display: none;
}

.vertical-end-seat .empty-seat {
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 4px;
  color: #8999aa;
}

.vertical-end-seat .empty-seat .empty-plus {
  font-size: 11px;
}

.vertical-desk .student-card:not(.side-seat-card) {
  min-height: 0;
  height: 100%;
  grid-template-columns: 25px minmax(0, 1fr);
  padding: 2px;
}

.vertical-desk .student-card:not(.side-seat-card) .student-photo-wrap {
  width: 25px;
  height: 29px;
}

.vertical-desk .student-card:not(.side-seat-card) .student-name {
  font-size: 9px;
}

.vertical-desk .student-card:not(.side-seat-card) .student-meta {
  font-size: 7px;
}

.horizontal-desk-layout {
  height: 100%;
}

.cleaning-badge {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 1px 4px;
  border-radius: 999px;
  color: #8a4f12;
  background: #ffdf9d;
  box-shadow: inset 0 0 0 1px rgba(138,79,18,.12);
  font-size: 7px;
  font-weight: 850;
  text-align: center;
}

.classroom-canvas.recognition-mode .cleaning-badge {
  visibility: hidden;
}

.classroom-canvas.recognition-mode .student-card.revealed .cleaning-badge {
  visibility: visible;
}

.score-section {
  position: relative;
  overflow: hidden;
}

.score-section::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
}

.reward-section {
  background: linear-gradient(135deg, #f5fcf9, #ffffff 58%);
}

.reward-section::before {
  background: var(--teal-600);
}

.deduction-section {
  background: linear-gradient(135deg, #fff8f6, #ffffff 58%);
}

.deduction-section::before {
  background: var(--coral-600);
}

.reason-button.reward .reason-delta {
  color: var(--teal-700);
  background: var(--teal-100);
}

.reason-button.deduction {
  border-color: #f1d1ca;
  background: #fffafa;
}

.reason-button.deduction:hover {
  border-color: #df8b7a;
  background: #fff4f1;
}

.danger-outline-button,
.warning-button {
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}

.danger-outline-button {
  border: 1px solid #e1a093;
  color: #a43f2c;
  background: #fff;
}

.danger-outline-button:hover {
  background: #fff4f1;
}

.warning-button {
  border: 1px solid #e4a13e;
  color: #71440d;
  background: #fff1cf;
}

.warning-button:hover {
  background: #ffe8b2;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-heading-row .section-heading {
  margin: 0;
}

.cleaning-duty-card {
  border-color: #dce5ed;
}

.cleaning-duty-card.has-pending {
  border-color: #e7ad55;
  background: linear-gradient(135deg, #fff8e8, #fff);
  box-shadow: 0 5px 18px rgba(221,139,33,.10);
}

.cleaning-alert-pill,
.cleaning-ok-pill {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 800;
}

.cleaning-alert-pill {
  color: #77470c;
  background: #ffe2a5;
}

.cleaning-ok-pill {
  color: var(--teal-700);
  background: var(--teal-100);
}

.cleaning-stat-grid {
  margin: 10px 0 7px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.cleaning-stat-grid > div {
  min-width: 0;
  padding: 8px;
  border: 1px solid #e2e9ef;
  border-radius: 10px;
  background: rgba(255,255,255,.82);
  text-align: center;
}

.cleaning-stat-grid span,
.cleaning-stat-grid strong {
  display: block;
}

.cleaning-stat-grid span {
  color: var(--ink-500);
  font-size: 8px;
}

.cleaning-stat-grid strong {
  margin-top: 3px;
  color: var(--navy-900);
  font-size: 13px;
}

.cleaning-reminder-list {
  margin-top: 9px;
  display: grid;
  gap: 7px;
}

.cleaning-reminder-row {
  padding: 8px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #ebd3a8;
  border-radius: 11px;
  background: #fffdf8;
}

.cleaning-reminder-row > div {
  min-width: 0;
}

.cleaning-reminder-row strong,
.cleaning-reminder-row span {
  display: block;
}

.cleaning-reminder-row strong {
  font-size: 10px;
}

.cleaning-reminder-row > div > span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink-500);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cleaning-reminder-row .cleaning-alert-pill {
  display: inline-block;
}

.cleaning-reminder-row .warning-button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 8px;
}

.cleaning-reminder-row.compact-row {
  padding: 7px 8px;
}

.cleaning-settings-card {
  background: linear-gradient(135deg, #fff9ed, #fff);
}

.threshold-setting-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--ink-700);
  font-size: 9px;
}

.threshold-setting-row input {
  width: 72px;
  height: 38px;
  padding: 0 8px;
  border: 1px solid #d7be8e;
  border-radius: 9px;
  background: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.fixed-seat-display {
  min-height: 42px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  border: 1px solid #cbd7e2;
  border-radius: 10px;
  color: var(--ink-700);
  background: #f5f8fb;
  font-size: 10px;
}

.placeholder-label {
  padding: 1px 4px;
  border-radius: 5px;
  color: #6b5a31;
  background: #f7e7bd;
  font-size: 7px;
}

@media (max-width: 1120px) {
  .classroom-canvas {
    min-width: 980px;
    padding-inline: 18px;
  }

  .vertical-desk-main {
    grid-template-columns: minmax(0, 1fr) 45px minmax(0, 1fr);
    gap: 3px;
  }

  .vertical-desk .desk-header {
    gap: 4px;
  }

  .vertical-desk .desk-number {
    padding-inline: 7px;
  }

  .vertical-desk .desk-status-button {
    min-width: 50px;
  }
}

@media (max-height: 720px) and (orientation: landscape) {
  .desk-rows {
    grid-template-rows: 126px 137px 137px;
  }

  .vertical-desk {
    min-height: 134px;
  }

  .vertical-desk-layout {
    grid-template-rows: 18px minmax(0, 1fr) 18px;
  }

  .vertical-end-seat .student-card {
    height: 18px;
    min-height: 18px;
  }
}

/* ===== Version 4: grades, per-session work scores and Excel export ===== */
.side-sheet.wide-sheet { width: min(860px, 96vw); }

.grade-tool-button .tool-icon {
  color: #7b5318;
  background: var(--amber-100);
}

.grade-tabs {
  margin-bottom: 14px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  border-radius: 13px;
  background: #e9eff5;
}
.grade-tab {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  color: var(--ink-700);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.grade-tab.active {
  color: #fff;
  background: var(--navy-900);
  box-shadow: var(--shadow-sm);
}
.grade-filter-card { padding: 10px 12px; }
.grade-filter-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px;
  gap: 10px;
}
.grade-search-box, .grade-sort-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 700;
}
.grade-search-box input, .grade-sort-box select, .work-score-editor input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-900);
  background: #fff;
}
.grade-context-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.student-grade-profile {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.student-grade-profile > div {
  padding: 9px 10px;
  border-radius: 10px;
  background: #f1f5f9;
}
.student-grade-profile span, .student-grade-profile strong { display: block; }
.student-grade-profile span { color: var(--ink-500); font-size: 9px; }
.student-grade-profile strong { margin-top: 3px; font-size: 12px; }
.grade-table-card { padding: 13px; }
.grade-table-scroll {
  width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 12px;
}
.grade-table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  font-size: 10px;
}
.semester-grade-table { min-width: 790px; }
.grade-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 7px;
  color: #fff;
  background: var(--navy-900);
  text-align: center;
  white-space: nowrap;
}
.grade-table th:first-child { border-radius: 10px 0 0 0; }
.grade-table th:last-child { border-radius: 0 10px 0 0; }
.grade-table td {
  padding: 8px 7px;
  border-right: 1px solid #e6ecf2;
  border-bottom: 1px solid #e6ecf2;
  text-align: center;
  vertical-align: middle;
}
.grade-table td:first-child { border-left: 1px solid #e6ecf2; }
.grade-table td:nth-child(2) { text-align: left; }
.grade-table small { color: var(--ink-500); font-size: 8px; }
.student-number-cell {
  color: var(--ink-700);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.positive-number { color: var(--teal-700) !important; font-weight: 780; }
.negative-number { color: var(--coral-600) !important; font-weight: 780; }
.net-number { font-weight: 800; }
.work-score-pill, .cleaning-ok-pill {
  display: inline-flex;
  min-height: 24px;
  padding: 4px 8px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--teal-700);
  background: var(--teal-100);
  font-size: 9px;
  font-weight: 800;
}
.work-score-pill.unscored { color: var(--ink-500); background: #e8eef4; }
.work-score-editor { display: flex; align-items: center; gap: 7px; }
.student-work-score-editor { margin-top: 10px; }
.student-work-score-editor input { max-width: 110px; }
.compact-work-score-editor {
  min-width: 128px;
  justify-content: center;
}
.compact-work-score-editor input {
  width: 64px;
  height: 32px;
  padding: 0 6px;
  text-align: center;
}
.mini-save-button, .mini-clear-button, .mini-detail-button, .grade-back-button {
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 9px;
  font-weight: 750;
}
.mini-save-button, .mini-detail-button {
  color: #fff;
  background: var(--teal-600);
}
.mini-clear-button, .grade-back-button {
  color: var(--ink-700);
  background: #e8eef4;
}
.grade-back-button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 10px;
}
.grade-no-results {
  padding: 25px 10px 10px;
  color: var(--ink-500);
  text-align: center;
  font-size: 11px;
}
.grade-session-list { display: grid; gap: 12px; }
.grade-session-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfcfe;
}
.grade-session-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.grade-session-card > header span, .grade-session-card > header strong { display: block; }
.grade-session-card > header span { color: var(--ink-500); font-size: 9px; }
.grade-session-card > header strong { margin-top: 3px; font-size: 14px; }
.grade-session-metrics {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.grade-session-metrics > div {
  padding: 8px;
  border-radius: 10px;
  background: #eef3f8;
  text-align: center;
}
.grade-session-metrics span, .grade-session-metrics strong { display: block; }
.grade-session-metrics span { color: var(--ink-500); font-size: 8px; }
.grade-session-metrics strong { margin-top: 3px; font-size: 12px; }
.detail-work-score-editor {
  margin-top: 10px;
  padding: 9px;
  border-radius: 10px;
  background: #fff7e8;
}
.detail-work-score-editor label {
  color: #7b5318;
  font-size: 9px;
  font-weight: 750;
}
.detail-work-score-editor input {
  width: 80px;
  height: 32px;
  text-align: center;
}
.grade-event-list { margin-top: 10px; display: grid; gap: 6px; }
.grade-event {
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 40px minmax(100px, 0.6fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid #cfe5dc;
  border-radius: 9px;
  background: #f4fbf8;
}
.grade-event.deduction {
  border-color: #f0c8c1;
  background: #fff6f4;
}
.grade-event > span {
  color: var(--teal-700);
  font-weight: 850;
  text-align: center;
}
.grade-event.deduction > span { color: var(--coral-600); }
.grade-event > strong { font-size: 10px; }
.grade-event > small, .empty-grade-events { color: var(--ink-500); font-size: 9px; }
.empty-grade-events {
  padding: 8px;
  border-radius: 9px;
  background: #eef3f8;
  text-align: center;
}
.ledger-delta.work-score-ledger {
  color: #7b5318;
  background: var(--amber-100);
}
@media (max-width: 760px) {
  .grade-filter-row, .grade-context-summary, .student-grade-profile, .grade-session-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .detail-work-score-editor { flex-wrap: wrap; }
}

/* =========================================================
   V5：桌面放大、学生卡片收紧、照片优先、顶部控制区压缩
   ========================================================= */

/* 顶部学期、班级与课堂控制区更紧凑，为教室座位图释放高度。 */
.topbar {
  min-height: 52px;
  padding: calc(5px + var(--safe-top)) 12px 5px;
  grid-template-columns: minmax(160px, .52fr) minmax(330px, 1fr) auto;
  gap: 8px;
}

.brand-block { gap: 8px; }

.brand-mark {
  width: 34px;
  height: 28px;
  padding: 4px;
  gap: 2px;
  border-radius: 9px;
}

.brand-title { font-size: 15px; }
.brand-subtitle { margin-top: 1px; font-size: 9px; }

.context-switcher {
  grid-template-columns: minmax(118px, .88fr) minmax(130px, 1fr) 34px 34px;
  gap: 5px;
}

.context-select {
  height: 36px;
  padding: 3px 6px 2px;
  grid-template-rows: 9px 1fr;
  border-radius: 10px;
}

.context-select > span {
  font-size: 7px;
  letter-spacing: .06em;
}

.class-switcher .context-select select {
  height: 22px;
  padding-right: 20px;
  background-position: calc(100% - 8px) 8px, calc(100% - 4px) 8px;
  background-size: 4px 4px, 4px 4px;
  font-size: 10px;
}

.icon-button {
  flex-basis: 34px;
  width: 34px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
}

.top-actions { gap: 5px; }

.top-action {
  min-height: 36px;
  padding: 0 9px;
  gap: 4px;
  border-radius: 10px;
  font-size: 11px;
}

.session-strip {
  min-height: 49px;
  padding: 5px 12px;
  grid-template-columns: minmax(145px, .58fr) minmax(450px, 1.85fr) auto;
  gap: 8px;
}

.eyebrow {
  margin-bottom: 1px;
  font-size: 8px;
  letter-spacing: .1em;
}

.session-title-button { font-size: 14px; }
.session-title-button::after { font-size: 10px; }

.session-metrics { gap: 5px; }

.metric-card {
  padding: 4px 7px;
  border-radius: 9px;
}

.metric-label {
  margin-bottom: 1px;
  font-size: 7px;
}

.metric-card strong { font-size: 11px; }

.status-dot {
  width: 6px;
  height: 6px;
  margin-right: 4px;
  box-shadow: 0 0 0 2px rgba(31, 138, 112, .1);
}

.display-controls {
  padding: 2px;
  border-radius: 10px;
}

.segmented {
  min-height: 27px;
  padding: 0 7px;
  border-radius: 8px;
  font-size: 9px;
}

/* 整体桌区略加宽，桌卡之间留出更清晰的通道。 */
.classroom-canvas {
  min-width: 1010px;
  padding: 8px 16px 12px;
}

.desk-rows {
  grid-template-rows: minmax(154px, .82fr) repeat(2, minmax(188px, 1fr));
  gap: 10px;
}

.vertical-desk-row { gap: 13px; }

.desk-card {
  padding: 6px 7px 8px;
  gap: 5px;
  border-radius: 18px;
}

.desk-header {
  min-height: 22px;
  gap: 4px;
}

.desk-number {
  padding: 3px 7px;
  border-radius: 7px;
  font-size: 10px;
}

.desk-score-button,
.desk-status-button,
.desk-tool-button {
  min-height: 21px;
  padding: 2px 6px;
  border-radius: 7px;
  font-size: 8px;
}

/* 后方横桌：增高桌面，学生卡片更短更窄，照片占比更高。 */
.horizontal-desk { min-height: 154px; }

.desk-layout.with-side-seats.horizontal-desk-layout {
  grid-template-columns: 49px minmax(0, 1fr) 49px;
  gap: 6px;
}

.horizontal-desk .desk-main {
  grid-template-rows: minmax(40px, 1fr) 32px minmax(40px, 1fr);
  gap: 4px;
}

.horizontal-desk .seat-row { gap: 5px; }

.horizontal-desk .student-card:not(.side-seat-card) {
  min-height: 40px;
  padding: 2px 3px;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 3px;
  border-radius: 8px;
}

.horizontal-desk .student-card:not(.side-seat-card) .student-photo-wrap {
  width: 34px;
  height: 40px;
  border-radius: 7px;
}

.horizontal-desk .student-card:not(.side-seat-card) .student-name { font-size: 9px; }
.horizontal-desk .student-card:not(.side-seat-card) .student-meta { font-size: 6.5px; }

.horizontal-desk .desk-surface {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 8px;
  box-shadow:
    inset 0 1px rgba(255,255,255,.55),
    inset 0 -8px 18px rgba(112,72,28,.08),
    0 2px 5px rgba(73,50,24,.09);
}

.side-seat-card {
  min-height: 86px;
  padding: 3px 2px;
  grid-template-rows: 43px auto;
  border-radius: 8px;
}

.side-seat-card .student-photo-wrap {
  width: 35px;
  height: 43px;
}

.side-seat-card .student-name { max-width: 43px; font-size: 8px; }
.side-seat-card .student-meta { max-width: 43px; font-size: 6px; }

/* 前六张竖桌：显著放宽木质桌面，学生卡片向桌边收紧。 */
.vertical-desk {
  min-height: 188px;
  padding-inline: 7px;
}

.vertical-desk-layout {
  grid-template-rows: 22px minmax(0, 1fr) 22px;
  gap: 4px;
}

.vertical-desk-main {
  grid-template-columns: minmax(0, 1fr) 82px minmax(0, 1fr);
  gap: 5px;
}

.seat-column { gap: 4px; }

.left-seats .student-card { justify-self: end; }
.right-seats .student-card { justify-self: start; }

.vertical-desk .student-card:not(.side-seat-card) {
  width: 86%;
  min-height: 31px;
  height: 100%;
  padding: 2px 3px;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 3px;
  border-radius: 8px;
}

.vertical-desk .student-card:not(.side-seat-card) .student-photo-wrap {
  width: 31px;
  height: 37px;
  border-radius: 7px;
}

.vertical-desk .student-card:not(.side-seat-card) .student-name { font-size: 8.5px; }
.vertical-desk .student-card:not(.side-seat-card) .student-meta { font-size: 6.5px; gap: 2px; }
.vertical-desk .student-card:not(.side-seat-card) .score-badge,
.vertical-desk .student-card:not(.side-seat-card) .cleaning-badge {
  min-width: 16px;
  padding-inline: 3px;
  font-size: 6.5px;
}

.vertical-surface {
  padding: 7px 5px;
  border-radius: 10px;
  font-size: 8px;
  box-shadow:
    inset 0 1px rgba(255,255,255,.55),
    inset -8px 0 18px rgba(112,72,28,.08),
    0 2px 5px rgba(73,50,24,.09);
}

.vertical-surface strong { font-size: 10px; }
.vertical-surface small { max-width: 58px; font-size: 6px; }

.vertical-end-seat .student-card {
  width: 54%;
  min-height: 22px;
  height: 22px;
  grid-template-columns: 22px minmax(0, 1fr);
  padding: 1px 4px;
}

.vertical-end-seat .student-photo-wrap {
  width: 22px;
  height: 22px;
}

.vertical-end-seat .student-name { font-size: 7.5px; }

/* 照片模式继续强调人像，同时保持卡片边界简洁。 */
.classroom-canvas.photo-only .horizontal-desk .student-photo-wrap {
  width: 38px;
  height: 45px;
}

.classroom-canvas.photo-only .vertical-desk .student-card:not(.side-seat-card) {
  width: 68%;
}

.classroom-canvas.photo-only .vertical-desk .student-photo-wrap {
  width: 35px;
  height: 42px;
}

/* 1024px iPad 横屏的专门收紧，避免顶部横向拥挤。 */
@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(150px, .5fr) minmax(315px, 1fr) auto;
    gap: 6px;
    padding-inline: 9px;
  }

  .context-switcher {
    grid-template-columns: minmax(108px, .85fr) minmax(116px, 1fr) 32px 32px;
    gap: 4px;
  }

  .icon-button {
    width: 32px;
    height: 34px;
    flex-basis: 32px;
  }

  .top-action {
    min-height: 34px;
    padding-inline: 7px;
    font-size: 10px;
  }

  .session-strip {
    grid-template-columns: minmax(135px, .55fr) minmax(435px, 1.9fr) auto;
    padding-inline: 9px;
    gap: 6px;
  }

  .classroom-canvas {
    min-width: 980px;
    padding-inline: 16px;
  }

  .vertical-desk-main {
    grid-template-columns: minmax(0, 1fr) 78px minmax(0, 1fr);
    gap: 4px;
  }

  .vertical-desk .student-card:not(.side-seat-card) { width: 84%; }
}

@media (max-height: 720px) and (orientation: landscape) {
  .topbar { min-height: 48px; }
  .session-strip { min-height: 45px; }

  .desk-rows {
    grid-template-rows: 148px 178px 178px;
  }

  .vertical-desk { min-height: 176px; }
  .vertical-desk-layout { grid-template-rows: 20px minmax(0, 1fr) 20px; }

  .vertical-desk .student-card:not(.side-seat-card) .student-photo-wrap {
    width: 29px;
    height: 34px;
  }
}


/* V5 细节：空座位仍使用居中单列，不受照片卡片网格影响。 */
.horizontal-desk .student-card.empty-seat:not(.side-seat-card),
.vertical-desk .student-card.empty-seat:not(.side-seat-card) {
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  white-space: nowrap;
}
.horizontal-desk .student-card.empty-seat:not(.side-seat-card) span:last-child,
.vertical-desk .student-card.empty-seat:not(.side-seat-card) span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   V6：主教室单屏显示、端部加座按需显隐
   ========================================================= */

/* 主座位页固定在当前视口内：不再使用教室区域滚动。 */
.classroom-scroll {
  overflow: hidden;
  overscroll-behavior: none;
  scrollbar-gutter: auto;
}

.classroom-canvas {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 5px 12px 6px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 38px;
  gap: 4px;
  overflow: hidden;
}

.desk-rows {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, .85fr) repeat(2, minmax(0, 1fr));
  gap: 6px;
  overflow: hidden;
}

.desk-row,
.desk-row.two-desks {
  min-height: 0;
}

.teacher-zone,
.front-zone {
  min-height: 0;
  margin: 0;
}

.blackboard {
  width: min(670px, 72%);
  height: 38px;
  padding-inline: 15px;
  gap: 14px;
  border-width: 3px;
}

.blackboard-label,
#blackboardHint {
  font-size: 9px;
}

.blackboard strong {
  font-size: 13px;
}

/* 三排桌子必须在剩余高度中自动收缩，不再把画布撑出视口。 */
.desk-card,
.vertical-desk,
.horizontal-desk {
  height: 100%;
  min-height: 0;
  padding: 5px 6px 6px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 3px;
  border-radius: 14px;
  overflow: hidden;
}

.desk-header {
  min-height: 20px;
}

.desk-number {
  padding: 3px 6px;
  font-size: 9px;
}

.desk-score-button,
.desk-status-button,
.desk-tool-button {
  min-height: 20px;
  padding: 2px 5px;
  font-size: 7.5px;
}

/* 第7、8桌：空短边加座不占位；有人或调整座位时才恢复。 */
.horizontal-desk-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) 45px;
  grid-template-rows: minmax(0, 1fr);
  gap: 5px;
}

.horizontal-desk-layout.hide-first-end.hide-second-end {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.horizontal-desk-layout.hide-first-end.show-second-end {
  grid-template-columns: minmax(0, 1fr) 45px;
}

.horizontal-desk-layout.show-first-end.hide-second-end {
  grid-template-columns: 45px minmax(0, 1fr);
}

.horizontal-desk-layout.hide-first-end .left-side-seat,
.horizontal-desk-layout.hide-second-end .right-side-seat,
.hidden-end-seat {
  display: none !important;
}

.horizontal-desk .desk-main {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(35px, 1fr) 27px minmax(35px, 1fr);
  gap: 3px;
}

.horizontal-desk .seat-row {
  min-height: 0;
  gap: 4px;
}

.horizontal-desk .student-card:not(.side-seat-card) {
  height: 100%;
  min-height: 0;
  padding: 2px 3px;
  grid-template-columns: 32px minmax(0, 1fr);
}

.horizontal-desk .student-card:not(.side-seat-card) .student-photo-wrap {
  width: 32px;
  height: 38px;
  max-height: 100%;
}

.horizontal-desk .desk-surface {
  min-height: 27px;
  padding-inline: 10px;
}

.side-seat-wrap {
  min-height: 0;
}

.side-seat-card {
  width: 100%;
  height: min(82px, 100%);
  min-height: 0;
  grid-template-rows: minmax(36px, 1fr) auto;
}

.side-seat-card .student-photo-wrap {
  width: 32px;
  height: 40px;
  max-height: 100%;
}

/* 第1–6桌：端部加座覆盖在桌面两端，不再增加整排高度。 */
.vertical-desk-layout {
  height: 100%;
  min-height: 0;
  position: relative;
  display: block;
}

.vertical-desk-main {
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 80px minmax(0, 1fr);
  gap: 4px;
}

.seat-column {
  min-height: 0;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
}

.vertical-desk .student-card:not(.side-seat-card) {
  width: 84%;
  height: 100%;
  min-height: 0;
  padding: 2px 3px;
  grid-template-columns: 30px minmax(0, 1fr);
}

.vertical-desk .student-card:not(.side-seat-card) .student-photo-wrap {
  width: 30px;
  height: 36px;
  max-height: 100%;
}

.vertical-surface {
  height: 100%;
  min-height: 0;
  padding: 7px 5px;
}

.vertical-end-seat {
  width: min(92px, 32%);
  height: 22px;
  min-height: 0;
  position: absolute;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.vertical-end-seat.top-end-seat {
  top: 1px;
}

.vertical-end-seat.bottom-end-seat {
  bottom: 1px;
}

.vertical-end-seat .student-card {
  width: 100%;
  height: 22px;
  min-height: 22px;
  padding: 1px 4px;
  grid-template-columns: 21px minmax(0, 1fr);
  border-color: #c7d7e5;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 2px 6px rgba(13, 33, 53, .11);
}

.vertical-end-seat .student-photo-wrap {
  width: 21px;
  height: 21px;
}

.vertical-end-seat .student-name {
  font-size: 7.5px;
}

.vertical-desk-layout.show-first-end .vertical-surface {
  padding-top: 25px;
}

.vertical-desk-layout.show-second-end .vertical-surface {
  padding-bottom: 25px;
}

/* 调整座位模式中的空端位保持明显，但不会推动页面出现滚动。 */
.vertical-end-seat .empty-seat,
.side-seat-wrap .empty-seat {
  color: #718399;
  background: rgba(246, 249, 252, .96);
}

.vertical-end-seat .empty-seat {
  grid-template-columns: auto auto;
  gap: 4px;
}

.vertical-end-seat .empty-seat span:last-child {
  font-size: 7px;
}

/* 底部工具栏本身也禁止横向滚动。 */
.bottom-toolbar {
  overflow: hidden;
}

/* 1024×768 iPad 横屏及较矮横屏的进一步收紧。 */
@media (max-width: 1120px) {
  .classroom-canvas {
    min-width: 0;
    padding-inline: 10px;
  }

  .desk-row {
    gap: 9px;
  }

  .desk-row.two-desks {
    width: calc((100% - 18px) * .666666 + 9px);
  }

  .vertical-desk-main {
    grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr);
  }
}

@media (max-height: 760px) and (orientation: landscape) {
  .classroom-canvas {
    grid-template-rows: minmax(0, 1fr) 35px;
    padding-block: 4px 5px;
    gap: 3px;
  }

  .blackboard {
    height: 35px;
  }

  .desk-rows {
    gap: 5px;
  }

  .horizontal-desk .desk-main {
    grid-template-rows: minmax(33px, 1fr) 25px minmax(33px, 1fr);
  }

  .horizontal-desk .desk-surface {
    min-height: 25px;
  }

  .horizontal-desk .student-card:not(.side-seat-card) .student-photo-wrap {
    width: 30px;
    height: 35px;
  }

  .vertical-desk .student-card:not(.side-seat-card) .student-photo-wrap {
    width: 28px;
    height: 34px;
  }
}

/* =========================================================
   V7：作品分自动保存与劳动课堂宠物养成
   ========================================================= */

/* 座位卡片中的照片与宠物保持同一视觉组，不扩大卡片高度。 */
.student-avatar-cluster {
  width: 40px;
  height: 100%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
}

.student-avatar-cluster .student-photo-wrap {
  flex: 0 0 auto;
}

.student-card:not(.empty-seat) {
  grid-template-columns: 40px minmax(0, 1fr);
  overflow: visible;
}

.horizontal-desk .student-card:not(.side-seat-card):not(.empty-seat),
.vertical-desk .student-card:not(.side-seat-card):not(.empty-seat) {
  grid-template-columns: 40px minmax(0, 1fr);
}

.student-pet-mini {
  --pet-delay: 0s;
  width: 22px;
  height: 24px;
  position: absolute;
  right: -4px;
  bottom: -1px;
  z-index: 4;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(13, 33, 53, .2));
  transform-origin: 50% 90%;
  animation: pet-bob 2.5s ease-in-out var(--pet-delay) infinite;
}

.student-pet-mini.pet-mood-happy {
  animation-name: pet-happy-bob;
  animation-duration: 1.9s;
}

.student-pet-mini.pet-mood-concerned {
  animation-name: pet-concerned-bob;
  animation-duration: 2.8s;
}

.student-pet-mini.pet-mood-resting {
  opacity: .78;
  animation-duration: 3.4s;
}

.pet-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.pet-level-dot {
  width: 11px;
  height: 11px;
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 50%;
  color: #fff;
  background: var(--navy-900);
  box-shadow: 0 1px 3px rgba(13,33,53,.2);
  font-size: 6px;
  font-weight: 850;
  line-height: 1;
}

@keyframes pet-bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-3px) rotate(1deg); }
}

@keyframes pet-happy-bob {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-4px) scale(1.04); }
  62% { transform: translateY(-2px) rotate(3deg); }
}

@keyframes pet-concerned-bob {
  0%, 100% { transform: translateY(1px) rotate(-2deg); }
  50% { transform: translateY(-1px) rotate(2deg); }
}

.classroom-canvas.photo-only .student-avatar-cluster {
  width: 52px;
  justify-content: center;
}

.classroom-canvas.photo-only .student-pet-mini {
  width: 25px;
  height: 27px;
  right: -1px;
}

.side-seat-card .student-avatar-cluster,
.vertical-end-seat .student-avatar-cluster {
  width: 31px;
}

.side-seat-card .student-pet-mini,
.vertical-end-seat .student-pet-mini {
  width: 17px;
  height: 18px;
  right: -3px;
  bottom: -1px;
}

/* 学生详情中的宠物成长卡。 */
.student-pet-card {
  background:
    radial-gradient(circle at 8% 12%, rgba(76, 177, 136, .09), transparent 30%),
    radial-gradient(circle at 92% 86%, rgba(238, 181, 73, .12), transparent 34%),
    #fffdf8;
}

.student-pet-hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.student-pet-large {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border: 1px solid #dbe6ef;
  border-radius: 20px;
  background: linear-gradient(145deg, #f8fbfd, #edf4f8);
  box-shadow: 0 7px 18px rgba(13, 33, 53, .09);
  animation: pet-bob 3s ease-in-out infinite;
}

.student-pet-large .pet-svg {
  width: 79px;
  height: 79px;
}

.student-pet-large.pet-mood-happy { animation-name: pet-happy-bob; }
.student-pet-large.pet-mood-concerned { animation-name: pet-concerned-bob; }

.student-pet-copy { min-width: 0; }
.student-pet-copy .section-heading-row { margin-bottom: 4px; }
.student-pet-copy .section-heading { margin: 0; font-size: 17px; }
.student-pet-copy p { margin: 0 0 8px; color: var(--ink-500); font-size: 11px; line-height: 1.45; }
.student-pet-copy small { display: block; margin-top: 6px; color: var(--teal-700); font-size: 9px; font-weight: 750; }

.pet-stage-pill {
  padding: 5px 8px;
  border-radius: 999px;
  color: #76520f;
  background: #fff0bf;
  font-size: 8px;
  font-weight: 850;
  white-space: nowrap;
}

.pet-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4edf1;
}

.pet-progress-track > span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #34a884, #74bd86);
  transition: width .25s ease;
}

.pet-choice-grid {
  margin-top: 13px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.pet-choice-button {
  min-width: 0;
  min-height: 70px;
  padding: 6px 4px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink-700);
  background: #fff;
  cursor: pointer;
  font-size: 8px;
  font-weight: 780;
}

.pet-choice-button:hover { border-color: #85b7aa; }
.pet-choice-button.active {
  border-color: var(--teal-600);
  background: #e7f7f2;
  box-shadow: 0 0 0 2px rgba(31, 138, 112, .12);
}
.pet-choice-art { width: 42px; height: 42px; }
.pet-choice-art .pet-svg { width: 100%; height: 100%; }

/* 作品分：无保存按钮，输入停顿、失焦或 Enter 时自动写入。 */
.autosave-work-score-editor {
  min-width: 0;
}

.work-autosave-status {
  flex: 0 0 auto;
  min-width: 42px;
  color: var(--ink-500);
  font-size: 8px;
  font-weight: 750;
  white-space: nowrap;
}

.work-autosave-status.saved { color: var(--teal-700); }
.work-autosave-status.pending,
.work-autosave-status.saving { color: #9a6915; }
.work-autosave-status.error { color: var(--coral-600); }
.work-autosave-status.idle { color: var(--teal-700); }

.work-score-editor input.invalid-score-input {
  border-color: var(--coral-600);
  background: #fff5f3;
  box-shadow: 0 0 0 2px rgba(214, 87, 67, .12);
}

.compact-work-score-editor {
  grid-template-columns: minmax(58px, 76px) auto;
}

.compact-work-score-editor input { width: 72px; }

.detail-work-score-editor {
  grid-template-columns: auto minmax(72px, 100px) auto;
}

/* 宠物设置页。 */
.pet-rules-card {
  background: linear-gradient(120deg, #f2faf6, #fffaf0);
}

.pet-rule-flow {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink-500);
  font-size: 9px;
}

.pet-rule-flow span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pet-rule-flow b { color: var(--teal-700); font-size: 8px; }
.pet-toggle-card { padding-block: 8px; }
.pet-toggle-card .toggle-row { padding: 10px 0; }
.pet-toggle-card .toggle-row + .toggle-row { border-top: 1px solid var(--line); }

.pet-library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pet-library-card {
  min-height: 88px;
  padding: 8px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbfd;
}

.pet-library-card > span { width: 55px; height: 55px; }
.pet-library-card strong { font-size: 9px; }

.pet-threshold-list {
  margin-bottom: 10px;
  display: grid;
  gap: 6px;
}

.pet-threshold-row {
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 28px minmax(120px, 1fr) minmax(90px, auto) 50px;
  align-items: center;
  gap: 9px;
  border: 1px solid #e0e8ef;
  border-radius: 11px;
  background: #fff;
}

.pet-threshold-level {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--navy-900);
  font-size: 9px;
  font-weight: 850;
}

.pet-threshold-copy strong,
.pet-threshold-copy small { display: block; }
.pet-threshold-copy strong { font-size: 10px; }
.pet-threshold-copy small { margin-top: 2px; color: var(--ink-500); font-size: 8px; }

.pet-threshold-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-500);
  font-size: 9px;
}

.pet-threshold-row input {
  width: 72px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  text-align: center;
}

.pet-threshold-fixed,
.pet-stage-count {
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--teal-700);
  background: var(--teal-100);
  font-size: 8px;
  font-weight: 780;
  text-align: center;
  white-space: nowrap;
}

.pet-stage-count {
  color: var(--ink-500);
  background: #eef3f7;
}

.pet-more-card { background: linear-gradient(120deg, #f6fbf8, #fffaf3); }

/* 随机点名也显示学生当前宠物。 */
.random-portrait-wrap {
  margin-bottom: 14px;
  position: relative;
}
.random-portrait-wrap .random-photo { margin-bottom: 0; }
.random-pet {
  width: 88px;
  height: 88px;
  position: absolute;
  right: -46px;
  bottom: -10px;
  padding: 5px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #f4f9fb;
  box-shadow: 0 8px 20px rgba(13,33,53,.17);
  animation: pet-bob 2.6s ease-in-out infinite;
}

@media (max-width: 1120px) {
  .student-avatar-cluster { width: 37px; }
  .student-card:not(.empty-seat),
  .horizontal-desk .student-card:not(.side-seat-card):not(.empty-seat),
  .vertical-desk .student-card:not(.side-seat-card):not(.empty-seat) {
    grid-template-columns: 37px minmax(0, 1fr);
  }
  .student-pet-mini { width: 20px; height: 22px; right: -4px; }
  .side-seat-card .student-pet-mini,
  .vertical-end-seat .student-pet-mini { width: 15px; height: 17px; }
}

@media (max-width: 700px) {
  .student-pet-hero { grid-template-columns: 78px minmax(0, 1fr); }
  .student-pet-large { width: 78px; height: 78px; }
  .student-pet-large .pet-svg { width: 66px; height: 66px; }
  .pet-threshold-row { grid-template-columns: 28px minmax(90px, 1fr) auto; }
  .pet-stage-count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .student-pet-mini,
  .student-pet-large,
  .random-pet { animation: none !important; }
}

/* V7 小屏侧栏：成长等级标签允许换行，避免右侧被裁切。 */
.student-pet-copy .section-heading-row {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 5px 8px;
}
.student-pet-copy .pet-stage-pill {
  padding: 4px 7px;
  font-size: 7.5px;
}


/* v8 reliability and scoring-dialog refinements */
.sheet-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-undo-button {
  min-height: 38px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #cbd7e3;
  border-radius: 11px;
  color: var(--navy-800);
  background: #fff;
  font-size: 10px;
  font-weight: 800;
}

.sheet-undo-button:not(:disabled):hover {
  border-color: #8ea9c0;
  background: #f4f8fb;
}

.sheet-undo-button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.overlay.dialog-visible {
  z-index: 105;
}

.reason-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.reason-note-badge {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 999px;
  color: #99402f;
  background: #ffe6df;
  font-size: 8px;
  font-weight: 850;
  white-space: nowrap;
}

.dialog .field textarea {
  width: 100%;
  min-height: 104px;
  padding: 10px 11px;
  border: 1px solid #cbd7e3;
  border-radius: 10px;
  color: var(--ink-900);
  background: #fff;
  resize: vertical;
  font: inherit;
}

.dialog .field textarea:focus,
.dialog .field input:focus {
  outline: 3px solid rgba(31, 138, 112, .14);
  border-color: #5ba992;
}

.required-mark {
  margin-left: 4px;
  color: var(--coral-600);
  font-size: 9px;
}

.field-optional {
  margin-left: 5px;
  color: var(--ink-500);
  font-size: 9px;
  font-weight: 600;
}

.score-confirm-summary {
  background: #fff8f6;
  border-color: #f0cfc7;
}

.score-confirm-line {
  margin-top: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 11px;
  color: #8d3828;
  background: #ffece7;
}

.score-confirm-line span {
  font-weight: 850;
}

.score-dialog-grid {
  align-items: start;
}

@media (max-width: 640px) {
  .sheet-undo-button span:last-child { display: none; }
  .reason-note-badge { font-size: 7px; padding-inline: 4px; }
}


/* v8.1: actual date and session-time history */
.session-history-list {
  display: grid;
  gap: 12px;
}

.session-history-card {
  margin: 0;
}

.session-history-card .section-heading-row {
  align-items: flex-start;
}

.session-sequence-label {
  display: block;
  margin-bottom: 3px;
  color: var(--teal-700);
  font-size: 12px;
  font-weight: 800;
}

.session-time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.session-time-grid > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafc;
}

.session-time-grid span {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-500);
  font-size: 11px;
}

.session-time-grid strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink-900);
  font-size: 13px;
  line-height: 1.35;
}

.session-history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.session-history-stats span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-100);
  color: var(--ink-700);
  font-size: 11px;
  font-weight: 700;
}

.session-time-detail {
  display: block;
  margin-top: 3px;
  color: var(--ink-500);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

@media (max-width: 760px) {
  .session-time-grid { grid-template-columns: 1fr; }
}
