:root {
  --ink: #1b2430;
  --muted: #5c6570;
  --paper: #f3efe6;
  --card: #fffdf8;
  --navy: #1e3a5f;
  --navy-2: #16314f;
  --amber: #c2410c;
  --line: #e4d8c4;
  --ok: #0f766e;
  --bad: #b91c1c;
  --shadow: 0 10px 30px rgba(30, 58, 95, 0.08);
  --radius: 16px;
  --shell: min(960px, calc(100% - 48px));
  --top-shell: min(1200px, calc(100% - 32px));
}

* { box-sizing: border-box; }
html {
  margin: 0;
  scrollbar-gutter: stable;
  overflow-y: scroll;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 50% -10%, #e8dcc8 0%, transparent 46%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.45;
}
.role-student {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.role-student input,
.role-student textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
a { color: var(--navy); }
code { font-size: 0.95em; background: #efe6d6; padding: 0.05em 0.35em; border-radius: 6px; }

.shell,
.wrap {
  width: var(--shell);
  margin-left: auto;
  margin-right: auto;
}
.wrap { padding: 28px 0 40px; }
.role-student .wrap { padding-bottom: 88px; }

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; letter-spacing: -0.02em; margin: 0 0 8px; }
h1 { font-size: clamp(1.55rem, 2.6vw, 2.05rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--amber);
  margin: 0 0 6px;
  font-weight: 700;
}

.top {
  background: var(--navy);
  color: #f6f0e6;
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-inner {
  width: var(--top-shell);
  margin: 0 auto;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  display: block;
  background: #16314f;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  font-family: Georgia, "Times New Roman", serif;
}
.brand-text b { font-size: 0.92rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-text span {
  margin-top: 2px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d9e4f2;
}
.top-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}
.top-nav a, .top-user a { color: #d9e4f2; text-decoration: none; font-size: 0.86rem; white-space: nowrap; }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.9rem; white-space: nowrap; }
.top-user .who-login { margin-left: 4px; opacity: 0.72; font-size: 0.82em; font-weight: 600; }
.top-user form, .row-actions form { display: inline; }
.top-user button, .row-actions button, .danger {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.bottom-nav { display: none; }

.flash {
  position: fixed;
  top: 12px;
  right: 16px;
  left: auto;
  z-index: 50;
  width: min(360px, calc(100% - 32px));
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.flash.is-gone {
  opacity: 0;
}
.login-body .flash { top: 16px; }
.flash.ok { background: #d9f0ec; color: #115e59; }
.flash.bad { background: #fde8e8; color: #9f1239; }
p.bad, span.bad { color: #9f1239; }

.panel, .card, .stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 22px; margin: 0 0 16px; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }

.attach-pick { display: grid; gap: 8px; }
.attach-pick-list {
  position: relative;
  height: 240px;
  overflow: auto;
  border: 1px solid #d7ccb8;
  border-radius: 10px;
  background: #fff;
  scrollbar-gutter: stable;
}
.attach-pick-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.attach-pick-item[hidden],
.attach-pick-item.off,
.attach-pick-empty[hidden] { display: none !important; }
.attach-pick-item:last-child { border-bottom: 0; }
.attach-pick-item:hover:not(.on) { background: #f6f1e7; }
.attach-pick-item.on { background: var(--amber); color: #fff; }
.attach-pick-empty {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  text-align: center;
  pointer-events: none;
}
.grid-form {
  display: grid;
  gap: 12px 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}
.wide { grid-column: 1 / -1; }

.stack {
  display: grid;
  gap: 14px;
}
.stack > label,
.grid-form > label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--muted);
  min-width: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input:not([type]),
select,
textarea {
  width: 100%;
  border: 1px solid #d7ccb8;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
input[type="file"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: 8px 0;
}
.file-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.file-pick.can-paste { align-items: flex-start; }
.file-pick-btn-wrap {
  position: relative;
  display: inline-flex;
}
.file-pick-btn-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 0;
}
.file-pick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.file-pick-paste {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.file-pick-name {
  color: var(--muted);
  font-size: 0.92rem;
}
.file-pick-hint {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 0.85rem;
}
.file-pick-preview {
  flex: 1 1 100%;
  display: none;
  max-width: min(100%, 420px);
  max-height: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 2px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.file-pick-preview.is-on { display: block; }
input[type="radio"],
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 18px;
  accent-color: var(--navy);
  vertical-align: middle;
}

.choices { display: grid; gap: 6px; margin-top: 10px; }
.choice {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
.choice span { line-height: 1.3; }
.q-figure {
  margin: 12px 0 16px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.q-figure img {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 480px);
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 8px;
  background: #fff;
}
.q-figure.is-thumb {
  margin: 8px 0 10px;
  padding: 8px;
  justify-content: flex-start;
}
.q-figure.is-thumb img { max-height: 120px; }
.q-file { margin: 8px 0 14px; }
.check-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-weight: 500;
}
.choice:has(input:checked) {
  border-color: var(--navy);
  background: #eef3f8;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  width: auto;
  justify-self: start;
}
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
.danger { color: var(--bad); }

.course-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.course-head h2 { margin: 0; }
.panel > .muted { margin-top: 6px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}
.storage-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: 16px; text-align: center; }
.stat b { display: block; font-size: 1.8rem; }
.stat span { color: var(--muted); }

.split,
.home-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  margin: 0 0 16px;
}
.home-grid { gap: 16px; }
.home-grid .panel,
.split .panel {
  margin: 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.home-grid .plain,
.split .plain {
  flex: 1;
  min-height: 6.5rem;
}
.home-grid .panel > a:last-child,
.split .panel > a:last-child {
  margin-top: auto;
  padding-top: 14px;
}
.home-grid .panel-wide { grid-column: 1 / -1; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.card .btn { margin-top: auto; align-self: start; }
.order-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.order-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: start;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.order-n {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}
.order-body { min-width: 0; }
.order-body strong {
  display: block;
  line-height: 1.35;
  overflow-wrap: break-word;
}
.order-body p { margin: 4px 0 0; }
.order-body .row-actions { margin-top: 8px; }
.order-move { display: flex; flex-direction: column; gap: 4px; align-self: center; padding-top: 0; }
.order-move button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 36px;
  height: 28px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  text-decoration: none;
}
.order-move button:disabled { opacity: 0.35; cursor: default; }
.role-student .order-item { grid-template-columns: 40px minmax(0, 1fr) auto; }
.order-item.is-locked { opacity: 0.72; }
.order-item.is-locked .order-n { background: #8a93a0; }
.locked-label { pointer-events: none; opacity: 0.7; }
.check-list { display: grid; gap: 8px; margin: 10px 0 0; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.plain.compact li { font-size: 0.92rem; }
.pill { background: #fde68a; color: #7c2d12; border-radius: 999px; padding: 1px 8px; font-style: normal; font-size: 0.75rem; }
.pill.auto { background: #e8eef5; color: var(--navy); }
.table-wrap { overflow-x: auto; }
.list-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 0.92rem;
}
.list-pager a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
  color: var(--navy);
}
.list-pager .is-off { color: var(--muted); }
.list-pager-n { color: var(--muted); }
.split .panel .list-pager,
.home-grid .panel .list-pager {
  margin-top: auto;
  padding-top: 14px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap select { width: auto; min-width: 148px; padding: 6px 8px; }
.dim { opacity: 0.55; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.task-list { padding-left: 18px; margin: 0; }
.task-list li { margin: 0 0 12px; }
.task-order { list-style: none; padding-left: 0; }
.task-order > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.task-order > li:last-child { border-bottom: 0; }
.task-order .task-body p { overflow-wrap: break-word; }
.q.ok,
.q.bad,
.q.wait {
  border-width: 1px;
}
.q.ok {
  border-color: #99d6cf;
  background: #f4fbf9;
  box-shadow: var(--shadow), inset 4px 0 0 var(--ok);
}
.q.bad {
  border-color: #f0b4b4;
  background: #fdf6f6;
  box-shadow: var(--shadow), inset 4px 0 0 var(--bad);
}
.q.wait {
  border-color: #e0b35c;
  background: #fffbeb;
  box-shadow: var(--shadow), inset 4px 0 0 #d97706;
}
.q-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-height: 28px;
  margin: 0 0 8px;
}
.q-head.eyebrow { margin-bottom: 8px; }
.q-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 6.4em;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  flex: 0 0 auto;
}
.q.ok .q-status { background: #d9f0ec; color: #115e59; }
.q.bad .q-status { background: #fde8e8; color: #9f1239; }
.q.wait .q-status { background: #fef3c7; color: #92400e; }
.q-key {
  min-height: 1.5em;
  margin: 0;
}
.q-key.is-placeholder {
  visibility: hidden;
}
.exam-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.timer {
  font-variant-numeric: tabular-nums;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1.2rem;
  min-width: 92px;
  text-align: center;
}
.bytes { font-variant-numeric: tabular-nums; white-space: nowrap; }
.storage-thumb {
  display: block;
  max-width: 120px;
  max-height: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.storage-group {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.storage-group:first-of-type { padding-top: 8px; }
.storage-group:last-child { border-bottom: 0; padding-bottom: 0; }
.storage-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.storage-head .row-actions { flex: 0 0 auto; }

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-body .wrap { width: auto; padding: 0; }
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  padding: 32px 28px 28px;
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin: 0 auto;
}
.login-brand { text-align: center; margin: 0 0 22px; }
.login-mark {
  width: 72px;
  height: 72px;
  display: block;
  margin: 0 auto 12px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-brand h1 { margin-bottom: 0; }
.login-card .stack { gap: 16px; }
.login-card .btn {
  width: 100%;
  justify-self: stretch;
  margin-top: 6px;
  padding: 12px 18px;
}

.viewer-body { overflow: hidden; }
html:has(.viewer-body) {
  overflow: hidden;
  scrollbar-gutter: auto;
}
.viewer-body .top,
.viewer-body .bottom-nav,
.kege-body .top,
.kege-body .bottom-nav { display: none; }
.viewer-main, .kege-main { width: 100%; margin: 0; max-width: none; padding: 0; }
.viewer {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
}
.viewer-bar, .draw-tools, .kege-top {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--navy);
  color: #fff;
}
.viewer-bar {
  justify-content: space-between;
  flex-wrap: nowrap;
}
.viewer-bar a, .draw-tools button, .pager button { color: #fff; }
.viewer-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.viewer-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}
.pager button, .draw-tools button {
  background: transparent;
  color: #e8eef6;
  border: 1px solid #3d5574;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.pager #prev,
.pager #next { min-width: 6.4rem; }
.pager #page-label {
  min-width: 5.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pager .zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}
.pager #zoom-out,
.pager #zoom-in {
  min-width: 2.2rem;
  padding-left: 0;
  padding-right: 0;
}
.pager #zoom-fit {
  min-width: 4.4rem;
  font-variant-numeric: tabular-nums;
}
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager #save-state,
.pager #watch-state {
  min-width: 12.5rem;
  white-space: nowrap;
}
.draw-tools { background: var(--navy-2); }
.draw-tools button.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.swatch { width: 22px; height: 22px; padding: 0 !important; border-radius: 50% !important; }
.pdf-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  background: #2a313c;
  display: flex;
  justify-content: safe center;
  align-items: safe center;
}
.pdf-sheet { position: relative; display: inline-block; margin: 16px; }
.pdf-missing {
  margin: auto;
  max-width: 28rem;
  padding: 24px;
  color: #e8eef6;
  text-align: center;
  line-height: 1.45;
}
#pdf-canvas, #draw-canvas, #guide-canvas, #notes-canvas { display: block; }
#guide-canvas, #draw-canvas, #notes-canvas { position: absolute; left: 0; top: 0; }
#guide-canvas { pointer-events: none; opacity: 0.4; }
#notes-canvas { pointer-events: none; }
.viewer.watch #guide-canvas { opacity: 1; }
#draw-canvas { touch-action: none; }
.can-draw #draw-canvas { cursor: crosshair; }
.practice-roster {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  background: #24364f;
}
.practice-roster button {
  flex: 0 0 auto;
  border: 1px solid #3d5574;
  background: transparent;
  color: #e8eef6;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.practice-roster button.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.practice-roster button.is-live { box-shadow: 0 0 0 2px #34d399; }
.practice-roster .muted { color: #c5d0de; }
.answers-upload {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  color: #e8eef6;
  font-size: 0.85rem;
}
.answers-upload input { max-width: 160px; color: #fff; }
.answers-upload button {
  border: 1px solid #3d5574;
  background: transparent;
  color: #e8eef6;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.viewer.has-answers .pdf-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 12px;
  padding: 8px;
}
.answers-sheet {
  background: #1c2430;
  padding: 10px;
  border-radius: 12px;
  text-align: center;
}
.answers-label {
  margin: 0 0 8px;
  color: #fbbf24;
  font-size: 0.82rem;
}
#answers-canvas { display: inline-block; max-width: 100%; height: auto; }

.kege { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.kege-top { justify-content: space-between; }
.kege-top .btn { background: #fff; color: var(--navy); }
.kege-layout { display: grid; grid-template-columns: 88px minmax(0, 720px); justify-content: center; gap: 0 24px; min-height: calc(100vh - 70px); }
.kege-nums {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 0;
  overflow: auto;
}
.kege-nums button {
  border: 1px solid #d3c6ae;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  font: inherit;
}
.kege-nums button.current { background: var(--navy); color: #fff; }
.kege-nums button.filled { box-shadow: inset 0 0 0 2px var(--ok); }
.kege-nums button.file-task { border-color: #d97706; }
.kege-task { padding: 24px 0; }
.task-attach { margin: 16px 0 20px; }
.task-upload { margin: 16px 0 20px; }
.check-file { padding: 12px 0 16px; border-bottom: 1px solid var(--line); }
.check-file:last-child { border-bottom: 0; }
.mark-board { margin: 12px 0 8px; }
.mark-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--navy-2);
  color: #fff;
  border-radius: 12px 12px 0 0;
}
.mark-tools button {
  background: transparent;
  color: #e8eef6;
  border: 1px solid #3d5574;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.mark-tools button.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.mark-save {
  min-width: 10rem;
  color: #d9e4f2;
  white-space: nowrap;
}
.mark-pager {
  justify-content: center;
  background: var(--navy);
  color: #fff;
  padding: 8px 12px;
  margin: 0;
}
.mark-pager button { color: #e8eef6; }
.mark-stage {
  overflow: auto;
  scrollbar-gutter: stable;
  background: #2a313c;
  min-height: 200px;
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: 0 0 12px 12px;
}
.mark-board .pdf-sheet { margin: 0 auto; }
.can-draw .mark-draw { cursor: crosshair; touch-action: none; }
.mark-draw { position: absolute; left: 0; top: 0; }
.mark-bg { display: block; }
.attach-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.attach-label { margin: 0 0 10px; font-weight: 600; }
.task-attach img,
.attach-card img {
  display: block;
  max-width: min(100%, 720px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
}
.task-attach .btn,
.attach-card .btn { margin-top: 10px; }
.task-attach figure { margin: 0; }
.csv-preview { margin: 0 0 8px; }
.csv-wrap { overflow: auto; max-height: 360px; border: 1px solid var(--line); border-radius: 10px; }
.csv-wrap table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: #fff; }
.csv-wrap th, .csv-wrap td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; white-space: nowrap; }
.csv-wrap th { background: #f3efe6; position: sticky; top: 0; }
.kege-task label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.note { white-space: pre-wrap; margin: 0; }
.task-text,
.statement {
  white-space: pre-wrap;
  margin: 0 0 14px;
}
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}
.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.credit-table th, .credit-table td { vertical-align: top; }
.credit-table th { min-width: 120px; }
.credit-form { margin-top: 8px; }
.credit-form button { font-size: 0.85rem; }

@media (max-width: 800px) {
  :root { --shell: min(960px, calc(100% - 28px)); --top-shell: min(960px, calc(100% - 20px)); }
  .role-student .top-nav { display: none; }
  .top-inner { flex-wrap: wrap; padding: 8px 0; }
  .role-teacher .top-nav { flex-wrap: wrap; justify-content: flex-start; gap: 10px 14px; }
  .split, .stats-grid, .home-grid, .grid-form, .kege-layout, .storage-stats { grid-template-columns: 1fr; }
  .home-grid .panel-wide { grid-column: auto; }
  .order-item { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .role-student .bottom-nav {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { text-align: center; font-size: 0.68rem; text-decoration: none; color: var(--navy); }
  .kege-nums { flex-direction: row; overflow-x: auto; padding: 12px; }
  .kege-nums button { min-width: 44px; }
  .kege-task { padding: 16px; }
  .storage-head { flex-wrap: wrap; }
}

.board-body { overflow: hidden; background: #1a2b42; }
html:has(.board-body) {
  overflow: hidden;
  scrollbar-gutter: auto;
}
.board-body .top,
.board-body .bottom-nav { display: none; }
.board-main { width: 100%; margin: 0; max-width: none; padding: 0; }
.board {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  background: #cfc6b6;
}
.board-dock {
  flex: 0 0 auto;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 8px 24px rgba(12, 24, 40, 0.28);
  z-index: 2;
}
.board-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}
.board-bar a { color: #fff; text-decoration: none; }
.board-bar .muted, .board-dock .muted { color: #b7c5d6; }
.board-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 0;
  padding: 0 12px 12px;
}
.board-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}
.board-group + .board-group {
  margin-left: 10px;
  padding-left: 14px;
  border-left: 1px solid #3d5574;
}
.board-tools button,
.board-upload {
  background: transparent;
  color: #e8eef6;
  border: 1px solid #3d5574;
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.2;
}
.board-tools button:hover,
.board-upload:hover {
  border-color: #8aa0b8;
  background: rgba(255, 255, 255, 0.08);
}
.board-tools button.on,
.board-upload.on {
  background: var(--amber);
  border-color: var(--amber);
  color: #fff;
}
.board-tools button.on:hover,
.board-upload.on:hover {
  background: #d34a12;
  border-color: #d34a12;
}
.board-tools .swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  min-width: 22px;
}
.board-tools .swatch.on {
  box-shadow: 0 0 0 2px #fff;
  border-color: #fff;
}
.board-tools .swatch.on:hover {
  background: inherit;
  border-color: #fff;
}
.board-bg-label {
  color: #b7c5d6;
  font-size: 0.8rem;
  margin-right: 4px;
}
.board-upload {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.board-upload input { display: none; }
.board-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(900px 280px at 50% 0%, rgba(255, 255, 255, 0.18), transparent 55%),
    #cfc6b6;
}
.board-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.board-drop {
  position: absolute;
  inset: 16px;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  border: 2px dashed #1e3a5f;
  border-radius: 18px;
  background: rgba(247, 241, 228, 0.88);
  color: var(--navy);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.board-drop[hidden] { display: none; }
#draw-canvas { cursor: crosshair; }
.board.can-draw #draw-canvas { touch-action: none; }
@media (max-width: 800px) {
  .board-group + .board-group {
    margin-left: 0;
    padding-left: 4px;
    border-left: 0;
  }
}
