:root {
  --ink: #17223b;
  --ink-soft: #46536b;
  --muted: #7f8ba2;
  --muted-light: #a8b1c2;
  --line: #e5e9f1;
  --line-strong: #d8deea;
  --bg: #f5f7fb;
  --card: #ffffff;
  --primary: #3157d5;
  --primary-dark: #2546b5;
  --primary-soft: #edf2ff;
  --navy: #162d63;
  --green: #31ad7d;
  --green-soft: #eaf8f2;
  --orange: #ea8b52;
  --orange-soft: #fff3eb;
  --purple: #8365d7;
  --purple-soft: #f3efff;
  --danger: #d96565;
  --danger-soft: #fff1f0;
  --shadow-sm: 0 5px 16px rgba(25, 42, 78, .06);
  --shadow: 0 14px 36px rgba(25, 42, 78, .09);
  --shadow-lg: 0 28px 80px rgba(19, 32, 63, .2);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-width: 232px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

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

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: .58;
  transform: none !important;
}

input,
select,
textarea {
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: #aab3c3;
}

:focus-visible {
  outline: 3px solid rgba(49, 87, 213, .22);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow,
.step-kicker {
  margin: 0 0 5px;
  color: #8e9ab0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.primary,
.secondary,
.primary-lite,
.text-btn,
.row-action,
.master-button,
.paper-preview-link {
  min-height: 40px;
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 700;
  line-height: 1.2;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.primary {
  background: linear-gradient(135deg, #3157d5, #506ee0);
  box-shadow: 0 8px 18px rgba(49, 87, 213, .22);
  color: #fff;
}

.primary:hover {
  box-shadow: 0 11px 22px rgba(49, 87, 213, .28);
  transform: translateY(-1px);
}

.secondary {
  border: 1px solid #dce3f2;
  background: #f5f7fc;
  color: #3e5278;
}

.secondary:hover {
  border-color: #c8d3e9;
  background: #edf2fa;
}

.primary-lite {
  border: 1px solid #d3dcfb;
  background: var(--primary-soft);
  color: var(--primary);
}

.primary-lite:hover {
  border-color: #bfcdf7;
  background: #e2eaff;
}

.text-btn,
.paper-preview-link {
  min-height: auto;
  padding: 5px 7px;
  background: transparent;
  color: var(--primary);
}

.wide {
  width: 100%;
}

/* 登录 */
.login-screen {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background: linear-gradient(145deg, #eef3ff 0%, #f8f5ff 50%, #fff7f0 100%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(438px, 100%);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 28px;
  padding: 42px 42px 36px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 28px 76px rgba(44, 62, 113, .16);
  backdrop-filter: blur(22px);
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(140deg, #3157d5, #8468db);
  box-shadow: 0 12px 25px rgba(49, 87, 213, .27);
  color: #fff;
  font-size: 25px;
  font-weight: 900;
}

.brand-mark.small {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin: 0;
  border-radius: 13px;
  font-size: 18px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -.04em;
}

.login-subtitle {
  margin: 0 0 28px;
  color: var(--muted);
}

.login-card label,
.modal-card label {
  display: block;
  color: #596780;
  font-size: 12px;
  font-weight: 700;
}

.login-card label {
  margin-top: 15px;
}

.login-card input,
.modal-card input,
.modal-card select,
.modal-card textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fbfcfe;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.login-card input,
.modal-card input,
.modal-card select {
  min-height: 42px;
  padding: 9px 11px;
}

.modal-card textarea {
  min-height: 108px;
  padding: 11px 12px;
  resize: vertical;
}

.login-card input:focus,
.modal-card input:focus,
.modal-card select:focus,
.modal-card textarea:focus {
  border-color: #7891e5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 87, 213, .1);
}

.login-card .primary {
  margin-top: 22px;
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(5px);
}

.orb-a {
  top: -170px;
  right: -80px;
  width: 520px;
  height: 520px;
  background: rgba(157, 175, 255, .48);
}

.orb-b {
  bottom: -160px;
  left: -100px;
  width: 430px;
  height: 430px;
  background: rgba(255, 204, 171, .4);
}

/* 应用框架 */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 22px 14px 16px;
  background: rgba(255, 255, 255, .96);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 9px 22px;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: #98a3b7;
  font-size: 10px;
}

.workspace-pill {
  display: grid;
  grid-template-columns: 8px 1fr;
  align-items: center;
  column-gap: 8px;
  margin: 0 3px 22px;
  border: 1px solid #ebedf4;
  border-radius: 12px;
  padding: 10px 11px;
  background: #f7f8fc;
}

.workspace-pill i {
  grid-row: 1 / 3;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3bb78e;
  box-shadow: 0 0 0 4px rgba(59, 183, 142, .12);
}

.workspace-pill span {
  font-size: 12px;
  font-weight: 750;
}

.workspace-pill small {
  color: #9aa5b8;
  font-size: 10px;
}

#mainNav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 45px;
  align-items: center;
  gap: 10px;
  border-radius: 11px;
  padding: 10px 12px;
  background: transparent;
  color: #7d899f;
  font-weight: 700;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 8px;
  color: #97a2b6;
  font-size: 17px;
}

.nav-item:hover {
  background: #f3f6fc;
  color: var(--primary);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item.active span {
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
}

.help-card {
  display: flex;
  gap: 8px;
  margin: 12px 3px;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(145deg, #f6f2ff, #f1f5ff);
}

.help-card > span {
  color: var(--purple);
  font-size: 18px;
}

.help-card b,
.help-card small {
  display: block;
}

.help-card b {
  font-size: 11px;
}

.help-card small {
  margin-top: 3px;
  color: #979fb1;
  font-size: 9px;
}

.logout {
  width: 100%;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: #8f99aa;
  text-align: left;
}

.logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.main {
  width: calc(100% - var(--sidebar-width));
  max-width: 1700px;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 0 clamp(22px, 3vw, 44px) 54px;
}

.topbar {
  display: flex;
  height: 88px;
  align-items: center;
  justify-content: space-between;
}

.topbar-title h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -.04em;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: #71809a;
  font-size: 17px;
}

.avatar {
  background: linear-gradient(140deg, #3157d5, #8066d8);
  box-shadow: 0 8px 18px rgba(49, 87, 213, .22);
  color: #fff;
  font-weight: 850;
}

.mobile-menu {
  display: none;
}

.page {
  display: none;
  animation: page-in .25s ease both;
}

.page.active {
  display: block;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* 工作台 */
.hero {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  border: 1px solid #dfe6fa;
  border-radius: 22px;
  padding: 28px 31px;
  background: linear-gradient(115deg, #edf3ff 0%, #f8f7ff 54%, #fff7ef 100%);
}

.hero::after {
  position: absolute;
  top: -108px;
  right: 9%;
  width: 230px;
  height: 230px;
  border: 36px solid rgba(80, 110, 224, .07);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.hero h3 {
  margin: 0 0 7px;
  font-size: clamp(22px, 2.3vw, 27px);
  letter-spacing: -.045em;
}

.hero p:not(.eyebrow) {
  margin: 0;
  color: #75829a;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 0 0 auto;
  gap: 9px;
}

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

.stat-card {
  display: flex;
  min-height: 118px;
  align-items: flex-start;
  gap: 13px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 17px;
  padding: 18px;
}

.stat-card.blue { background: #edf2ff; }
.stat-card.mint { background: #eaf8f3; }
.stat-card.peach { background: #fff2e9; }
.stat-card.purple { background: #f3efff; }

.stat-icon {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
  font-size: 17px;
}

.mint .stat-icon { color: var(--green); }
.peach .stat-icon { color: var(--orange); }
.purple .stat-icon { color: var(--purple); }

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

.stat-card small {
  color: #7f8ba0;
  font-size: 11px;
}

.stat-card strong {
  margin: 4px 0 1px;
  font-size: 26px;
  line-height: 1.2;
}

.stat-card em {
  color: #9aa4b5;
  font-size: 10px;
  font-style: normal;
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, .75fr);
  gap: 18px;
}

.panel,
.table-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head h3,
.panel h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.panel-head p,
.page-toolbar p {
  margin: 0;
  color: #929db0;
  font-size: 12px;
}

.panel-head.stacked {
  align-items: center;
}

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

.mini-item {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 51px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 11px;
  background: #fafbfe;
  color: var(--ink);
  text-align: left;
}

.mini-item:hover {
  border-color: #dce4f7;
  background: #f4f7ff;
}

.mini-item > div {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.mini-item > div b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-item b,
.mini-item small {
  display: block;
}

.mini-item small {
  overflow: hidden;
  margin-top: 2px;
  color: #929db0;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-item .tag {
  max-width: 86px;
  flex: 0 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-panel {
  min-height: 260px;
}

.spark {
  color: var(--green);
  font-size: 19px;
}

.progress-ring {
  position: relative;
  display: grid;
  width: 142px;
  height: 142px;
  margin: 7px auto 14px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--rate, 0%), #edf0f6 0);
}

.progress-ring::after {
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.progress-ring > div {
  position: relative;
  z-index: 1;
  text-align: center;
}

.progress-ring strong,
.progress-ring small {
  display: block;
}

.progress-ring strong {
  font-size: 24px;
}

.progress-ring small {
  color: #8e99ad;
  font-size: 10px;
}

.progress-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  color: #7f8ba0;
  font-size: 11px;
}

.progress-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.progress-legend b {
  color: var(--ink);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.blue-dot { background: var(--primary); }
.green-dot { background: var(--green); }

/* 页面标题、常用操作和筛选 */
.page-description {
  margin: 5px 0 16px;
  color: #929db0;
  font-size: 12px;
  line-height: 1.4;
}

.page-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 5px 0 16px;
}

.page-toolbar h3 {
  margin: 0 0 3px;
  font-size: 22px;
  letter-spacing: -.04em;
}

.operation-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.operation-bar.compact {
  justify-content: flex-start;
}

.operation-bar .action-main {
  flex: 0 0 auto;
}

.operation-hint {
  margin: 0;
  color: #8793a7;
  font-size: 12px;
}

.filter-bar {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 8px;
}

.filter-bar select {
  width: auto;
  min-width: 118px;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 31px 8px 11px;
  background: #fff;
  color: #526078;
  outline: none;
}

.filter-bar select:focus {
  border-color: #7891e5;
  box-shadow: 0 0 0 3px rgba(49, 87, 213, .09);
}

.search-box {
  display: flex !important;
  min-width: 190px;
  min-height: 42px;
  flex: 1;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 11px;
  background: #fff;
  color: #98a3b5;
  font-size: 16px !important;
}

.search-box:focus-within {
  border-color: #7891e5;
  box-shadow: 0 0 0 3px rgba(49, 87, 213, .09);
}

.search-box input,
.modal-card .search-box input {
  min-width: 0;
  min-height: 40px;
  margin: 0;
  border: 0;
  padding: 8px 5px;
  background: transparent;
  box-shadow: none;
  outline: 0;
  font-size: 13px;
}

.search-box input:focus,
.modal-card .search-box input:focus {
  border: 0;
  box-shadow: none;
}

/* 题库列表 */
.table-panel {
  overflow: hidden;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: minmax(260px, 2.1fr) minmax(175px, 1fr) minmax(100px, .65fr) minmax(100px, .65fr) 126px;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
}

.table-head {
  background: #f8f9fc;
  color: #939eb2;
  font-size: 11px;
  font-weight: 700;
}

.table-row {
  min-height: 90px;
  border-top: 1px solid #edf0f5;
  transition: background .18s ease;
}

.table-row:hover {
  background: #fbfcff;
}

.question-name {
  min-width: 0;
}

.question-number-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.question-number-line b {
  color: #293853;
  font-size: 12px;
}

.question-name strong,
.question-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-name strong {
  color: #26334b;
  font-size: 13px;
}

.question-name small {
  margin-top: 3px;
  color: #98a3b6;
  font-size: 11px;
}

.tag,
.display-chip,
.source-chip,
.paper-kind,
.role-pill,
.question-no {
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.tag {
  padding: 5px 8px;
  background: #f2efff;
  color: #785fca;
}

.cell-meta span,
.cell-meta small {
  display: block;
}

.cell-meta span {
  color: #46546d;
  font-size: 12px;
  font-weight: 700;
}

.cell-meta small {
  margin-top: 2px;
  color: #98a3b5;
  font-size: 10px;
}

.display-chip {
  padding: 6px 8px;
  background: #f2f5fa;
  color: #64728b;
}

.display-chip.mode-text {
  background: #edf3ff;
  color: #4667c9;
}

.display-chip.mode-image {
  background: #fff2e8;
  color: #c6713f;
}

.display-chip.mode-mixed {
  background: #eaf8f2;
  color: #268b68;
}

.date-cell {
  color: #8793a7;
  font-size: 11px;
}

.row-action {
  min-height: 34px;
  border: 1px solid #dce3f2;
  padding: 7px 10px;
  background: #fff;
  color: var(--primary);
  font-size: 11px;
}

.row-action:hover {
  border-color: #c5d1ed;
  background: var(--primary-soft);
}

.row-actions,
.paper-top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.danger-action,
.card-delete {
  border: 1px solid #f0d5d7;
  background: #fff8f8;
  color: var(--danger);
}

.danger-action:hover,
.card-delete:hover {
  border-color: #e8bfc3;
  background: #fff0f1;
}

.empty {
  display: grid;
  min-height: 210px;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 34px;
  color: #9ba6b9;
  text-align: center;
}

.empty > span {
  display: grid;
  width: 43px;
  height: 43px;
  margin-bottom: 4px;
  place-items: center;
  border-radius: 14px;
  background: #f1f4fa;
  color: #8090ac;
  font-size: 21px;
}

.empty b {
  color: #637087;
  font-size: 13px;
}

.empty small {
  font-size: 11px;
}

.empty.compact-empty {
  min-height: 120px;
}

/* 学生卡片与错题入口 */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.student-grid > .empty,
.paper-list > .empty {
  grid-column: 1 / -1;
}

.student-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 17px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.student-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #3157d5, #7769dc, #31ad7d);
  content: "";
  opacity: .8;
}

.student-card:hover {
  border-color: #d5dff2;
  box-shadow: 0 16px 34px rgba(31, 48, 85, .11);
  transform: translateY(-2px);
}

.student-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #e8efff, #f1eeff);
  color: var(--primary);
  font-size: 18px;
  font-weight: 850;
}

.student-head > div {
  min-width: 0;
}

.student-head b,
.student-head small {
  display: block;
}

.student-head b {
  font-size: 14px;
}

.student-head small {
  margin-top: 2px;
  color: #9ba5b6;
  font-size: 10px;
}

.student-open {
  margin-left: auto;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.student-head .card-delete {
  min-height: 30px;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 9px;
}

.student-class {
  margin: 12px 0;
  border-radius: 8px;
  padding: 7px 9px;
  background: #f7f8fb;
  color: #6f7c92;
  font-size: 10px;
}

.student-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  text-align: center;
}

.student-stat-row span {
  border-right: 1px solid #edf0f5;
}

.student-stat-row span:last-child {
  border-right: 0;
}

.student-stat-row small,
.student-stat-row b {
  display: block;
}

.student-stat-row small {
  color: #959fb1;
  font-size: 9px;
}

.student-stat-row b {
  margin-top: 2px;
  font-size: 18px;
}

.student-stat-row b.warn { color: var(--orange); }
.student-stat-row b.good { color: var(--green); }

.student-progress {
  height: 5px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0f5;
}

.student-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #32ad7d, #65c7a2);
}

/* 试卷列表 */
.paper-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.paper-card {
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.paper-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.paper-card-top > div:first-child {
  min-width: 0;
  flex: 1 1 0;
}

.paper-kind {
  padding: 5px 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.paper-card h4 {
  margin: 9px 0 5px;
  color: #26344d;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.paper-card p {
  margin: 0;
  color: #929caf;
  font-size: 10px;
}

.paper-card p b {
  color: #526078;
}

.paper-preview-link {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid #d3dcfb;
  border-radius: 10px;
  padding: 7px 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.paper-preview-link:hover {
  border-color: #bfcdf7;
  background: #e2eaff;
}

.paper-top-actions .card-delete {
  min-height: 34px;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 10px;
}

.paper-top-actions {
  min-width: max-content;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.paper-top-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
  word-break: keep-all;
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #edf0f5;
}

.paper-actions button {
  min-height: 36px;
  flex: 1 1 auto;
  padding: 7px 10px;
  font-size: 10px;
}

/* 设置 */
.user-row {
  display: flex;
  min-height: 57px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #edf0f5;
  padding: 11px 0;
}

.user-row:first-child {
  border-top: 0;
}

.user-info b,
.user-info small {
  display: block;
}

.user-info small {
  margin-top: 2px;
  color: #96a0b2;
  font-size: 10px;
}

.role-pill {
  padding: 6px 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.tips {
  background: linear-gradient(145deg, #faf8ff, #f1f5ff);
}

.tip-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 13px;
  place-items: center;
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: var(--purple);
  font-size: 20px;
}

.tips h3 {
  font-size: 16px;
}

.tips p {
  color: #77859d;
  font-size: 12px;
  line-height: 1.8;
}

.tip-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 9px 0;
  color: #6f7d96;
  font-size: 11px;
}

.tip-line i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
}

/* 弹层与通用表单 */
.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 28, 53, .54);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 22px;
  padding: 27px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px) scale(.99);
  transition: opacity .2s ease, transform .2s ease;
  overscroll-behavior: contain;
}

.modal-card.entered {
  opacity: 1;
  transform: none;
}

.modal-close {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 14px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: rgba(244, 246, 250, .94);
  color: #8894a7;
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  background: #eef1f6;
  color: #46536a;
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -.03em;
}

.modal-card .sub {
  margin: 0 0 19px;
  color: #909bad;
  font-size: 12px;
}

.simple-form-modal {
  padding-top: 2px;
}

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

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

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-actions.sticky-actions {
  position: sticky;
  z-index: 6;
  bottom: -27px;
  margin: 20px -27px -27px;
  border-top: 1px solid var(--line);
  padding: 12px 27px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 -10px 22px rgba(28, 42, 74, .05);
  backdrop-filter: blur(12px);
}

.back-link {
  margin: -2px 0 14px;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.modal-loading {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #728099;
  font-size: 12px;
}

.modal-loading i {
  width: 28px;
  height: 28px;
  border: 3px solid #e0e6f2;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.button-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 5px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin .75s linear infinite;
}

.is-exporting {
  cursor: wait !important;
}

.download-frame {
  position: fixed;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.toast {
  position: fixed;
  z-index: 200;
  top: 20px;
  right: 24px;
  max-width: min(390px, calc(100vw - 32px));
  border-radius: 11px;
  padding: 11px 15px;
  background: #182640;
  box-shadow: 0 13px 32px rgba(19, 31, 57, .24);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-16px);
  transition: opacity .22s ease, transform .22s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error,
.toast.bad {
  background: #b94c53;
}

/* 题目录入与编辑：基础信息保持紧凑，编辑和预览并排 */
.modal-card.question-modal {
  width: min(1180px, 100%);
  padding: 24px 26px 26px;
}

.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-right: 34px;
}

.modal-title-row .sub {
  margin-bottom: 16px;
}

.save-hint {
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f3f5f9;
  color: #8c97a9;
  font-size: 10px;
}

.question-editor form {
  display: grid;
  gap: 13px;
}

.editor-section {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px;
  background: #fff;
}

.metadata-section {
  background: #fbfcfe;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
}

.section-heading > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
}

.section-heading b,
.section-heading small {
  display: block;
}

.section-heading b {
  color: #34415a;
  font-size: 13px;
}

.section-heading small {
  margin-top: 1px;
  color: #9ba5b6;
  font-size: 9px;
  font-weight: 500;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(105px, 1fr));
  gap: 10px;
}

.metadata-grid label {
  min-width: 0;
  font-size: 10px;
}

.field-required,
.field-optional {
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  border-radius: 999px;
  padding: 1px 5px;
  font-size: 8px;
  font-weight: 750;
  line-height: 1.5;
  vertical-align: 1px;
}

.field-required {
  background: var(--danger-soft);
  color: #c65057;
}

.field-optional {
  background: #eef1f6;
  color: #8994a7;
}

.field-help {
  display: block;
  margin-top: 4px;
  color: #98a3b6;
  font-size: 8px;
  font-weight: 500;
  line-height: 1.45;
}

.metadata-grid input,
.metadata-grid select {
  min-height: 38px;
  margin-top: 4px;
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: 12px;
}

.metadata-grid .question-no-field {
  grid-column: span 2;
}

.metadata-grid .title-field {
  grid-column: span 3;
}

.metadata-grid .paper-set-field {
  grid-column: span 2;
}

.title-field > small {
  margin-left: 4px;
  color: #9aa4b5;
  font-size: 9px;
  font-weight: 500;
}

.input-with-action {
  display: flex;
  align-items: stretch;
  margin-top: 4px;
}

.input-with-action input {
  min-width: 0;
  margin: 0;
  border-radius: 9px 0 0 9px;
}

.input-with-action button {
  flex: 0 0 auto;
  border: 1px solid #d4dceb;
  border-left: 0;
  border-radius: 0 9px 9px 0;
  padding: 0 10px;
  background: #eef2f9;
  color: #58709b;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.content-section {
  padding: 16px;
}

.input-method-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 550px;
  margin-bottom: 12px;
}

.input-method-switch button {
  display: flex;
  min-height: 55px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 11px;
  background: #f8f9fc;
  color: #66738a;
  text-align: left;
}

.input-method-switch button > i {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: #fff;
  color: #6d7b94;
  font-size: 16px;
  font-style: normal;
}

.input-method-switch button b,
.input-method-switch button small {
  display: block;
}

.input-method-switch button b {
  font-size: 11px;
}

.input-method-switch button small {
  margin-top: 1px;
  color: #98a2b4;
  font-size: 9px;
}

.input-method-switch button.active {
  border-color: #aebfec;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(49, 87, 213, .05);
  color: var(--primary);
}

.input-method-switch button.active > i {
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.image-source-panel {
  display: none;
  grid-template-columns: minmax(190px, .72fr) minmax(240px, 1.1fr);
  gap: 10px;
  margin-bottom: 12px;
  border: 1px solid #dce4f4;
  border-radius: 12px;
  padding: 11px;
  background: #f7f9fd;
}

.image-source-panel.visible {
  display: grid;
}

.upload-dropzone {
  display: flex !important;
  min-height: 92px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  border: 1px dashed #aab9db;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  color: #566984 !important;
  cursor: pointer;
  text-align: center;
  transition: border-color .18s ease, background .18s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragging,
.upload-dropzone:focus-within {
  border-color: var(--primary);
  background: #f1f5ff;
  box-shadow: 0 0 0 3px rgba(49, 87, 213, .1);
}

.upload-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.upload-dropzone .upload-icon {
  display: grid;
  width: 29px;
  height: 29px;
  margin-bottom: 2px;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
}

.upload-dropzone b {
  font-size: 10px;
}

.upload-dropzone small {
  color: #98a4b7;
  font-size: 8px;
  font-weight: 500;
}

.asset-panel {
  display: none;
  min-width: 0;
  min-height: 92px;
  align-items: center;
  gap: 10px;
  border: 1px solid #e0e6f0;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.asset-panel.has-asset {
  display: flex;
}

.asset-panel img {
  width: 84px;
  height: 70px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #f2f4f8;
  object-fit: contain;
}

.asset-panel > div {
  min-width: 0;
}

.asset-panel b,
.asset-panel small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-panel b {
  color: #45536c;
  font-size: 10px;
}

.asset-panel small {
  margin-top: 3px;
  color: #9aa4b5;
  font-size: 8px;
}

.remove-asset {
  min-height: 32px;
  margin-left: auto;
  border-radius: 8px;
  padding: 6px 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
}

.ocr-console {
  grid-column: 1 / -1;
  display: flex;
  min-height: 43px;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #e1e6f0;
  padding-top: 9px;
}

.ocr-status {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 7px;
  color: #718098;
  font-size: 10px;
}

.ocr-status i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a2acbb;
}

.ocr-status.status-ready i,
.ocr-status.status-completed i {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(49, 173, 125, .1);
}

.ocr-status.status-uploading i,
.ocr-status.status-processing i {
  border: 2px solid #c8d4f2;
  border-top-color: var(--primary);
  background: transparent;
  animation: spin .7s linear infinite;
}

.ocr-status.status-warning i {
  background: var(--orange);
}

.ocr-status.status-failed i {
  background: var(--danger);
}

.ocr-status.status-completed {
  color: #338866;
}

.ocr-status.status-failed {
  color: #ba5459;
}

.image-number-option {
  display: flex !important;
  max-width: 360px;
  min-width: 230px;
  flex: 0 1 auto;
  align-items: flex-start;
  gap: 7px;
  border-left: 1px solid #e0e5ef;
  padding-left: 10px;
  color: #56657d !important;
  cursor: pointer;
}

.image-number-option input {
  width: 16px !important;
  height: 16px;
  min-height: 0 !important;
  flex: 0 0 auto;
  margin: 1px 0 0 !important;
  padding: 0 !important;
  accent-color: var(--primary);
}

.image-number-option b,
.image-number-option small {
  display: block;
}

.image-number-option b {
  color: #4d5d76;
  font-size: 9px;
}

.image-number-option small {
  margin-top: 1px;
  color: #929dae;
  font-size: 8px;
  font-weight: 500;
  line-height: 1.35;
}

.ocr-button {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 7px 11px;
  font-size: 10px;
}

.editor-preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.manual-editor,
.live-preview-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px;
  background: #fbfcfe;
}

.pane-heading {
  display: flex;
  min-height: 32px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pane-heading b,
.pane-heading small {
  display: block;
}

.pane-heading b {
  color: #3a4860;
  font-size: 11px;
}

.pane-heading small {
  margin-top: 1px;
  color: #99a3b4;
  font-size: 8px;
}

.pane-heading > span {
  border-radius: 6px;
  padding: 4px 6px;
  background: #f0edff;
  color: #755fc3;
  font-size: 8px;
  white-space: nowrap;
}

.formula-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 7px;
}

.formula-toolbar button {
  min-height: 28px;
  border: 1px solid #dfe4ee;
  border-radius: 7px;
  padding: 5px 7px;
  background: #fff;
  color: #64718a;
  font-size: 9px;
}

.formula-toolbar button:hover {
  border-color: #bac9ed;
  background: var(--primary-soft);
  color: var(--primary);
}

.manual-editor textarea {
  min-height: 246px;
  margin: 0;
  border-radius: 9px;
  background: #fff;
  font: 13px/1.72 "Times New Roman", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.editor-tip {
  display: block;
  margin-top: 6px;
  color: #9ca6b7;
  font-size: 8px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.mode-switch button {
  min-height: 30px;
  border-radius: 7px;
  padding: 5px 7px;
  background: #eef1f6;
  color: #708098;
  font-size: 9px;
}

.mode-switch button.active {
  background: var(--primary);
  box-shadow: 0 5px 12px rgba(49, 87, 213, .2);
  color: #fff;
  font-weight: 700;
}

.preview-box {
  min-height: 291px;
  overflow: auto;
  border: 1px solid #dfe3eb;
  border-radius: 9px;
  padding: 14px;
  background: #fff;
}

.paper-question-preview {
  color: #111;
  font: 14px/1.72 "Times New Roman", "Noto Serif CJK SC", "SimSun", "宋体", serif;
}

.preview-question-line,
.paper-question-line {
  display: flex;
  align-items: flex-start;
}

.preview-question-line > b,
.paper-question-line > b {
  flex: 0 0 auto;
  font-weight: 400;
}

.preview-question-line > div,
.paper-question-line > div {
  min-width: 0;
  flex: 1;
}

.preview-box img,
.wrong-question-content > img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 7px auto;
  object-fit: contain;
}

.preview-placeholder {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 18px;
  color: #9da6b6;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  text-align: center;
}

.preview-placeholder.warning {
  color: #b57855;
}

.rich-question-text,
.paper-rich-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

math {
  font-family: "Cambria Math", "STIX Two Math", serif;
}

.math-inline {
  display: inline-block;
  margin: 0 .12em;
  vertical-align: -.12em;
}

.math-block {
  display: block;
  margin: .45em auto;
  text-align: center;
}

.answer-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfe;
}

.answer-editor summary {
  display: flex;
  min-height: 51px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}

.answer-editor summary::-webkit-details-marker {
  display: none;
}

.answer-editor summary b,
.answer-editor summary small {
  display: block;
}

.answer-editor summary b {
  color: #415069;
  font-size: 11px;
}

.answer-editor summary small {
  margin-top: 1px;
  color: #9ca5b6;
  font-size: 8px;
}

.answer-editor summary i {
  color: #7f8ca1;
  font-style: normal;
  transition: transform .18s ease;
}

.answer-editor[open] summary i {
  transform: rotate(180deg);
}

.answer-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, .7fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 11px 14px 14px;
}

.answer-editor-grid textarea {
  min-height: 90px;
}

.answer-upload {
  display: flex !important;
  min-height: 90px;
  align-items: center;
  justify-content: center;
  border: 1px dashed #bdc7d9;
  border-radius: 9px;
  padding: 10px;
  background: #fff;
  color: #77849a !important;
  cursor: pointer;
  text-align: center;
}

.answer-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.answer-upload span {
  font-size: 9px;
  font-weight: 600;
}

.answer-image-control {
  display: grid;
  gap: 6px;
}

.remove-answer {
  min-height: 32px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
}

.question-modal .modal-actions.sticky-actions {
  bottom: -26px;
  margin: 0 -26px -26px;
  padding-right: 26px;
  padding-left: 26px;
}

/* 学生错题本 */
.modal-card.wrongbook-modal {
  width: min(1120px, 100%);
  padding: 0;
  background: #f5f7fb;
}

.wrongbook-shell {
  min-height: 560px;
}

.wrongbook-profile {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  gap: 16px;
  overflow: hidden;
  padding: 28px 72px 28px 30px;
  background: linear-gradient(120deg, #17346e 0%, #3157c6 52%, #6871dc 100%);
  color: #fff;
}

.wrongbook-profile::after {
  position: absolute;
  top: -90px;
  right: 8%;
  width: 230px;
  height: 230px;
  border: 34px solid rgba(255, 255, 255, .06);
  border-radius: 50%;
  content: "";
}

.wrongbook-modal .modal-close {
  color: rgba(255, 255, 255, .78);
  background: rgba(255, 255, 255, .12);
}

.wrongbook-modal .modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, .2);
}

.wrongbook-avatar {
  position: relative;
  z-index: 1;
  display: grid;
  width: 67px;
  height: 67px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .36);
  border-radius: 22px;
  background: rgba(255, 255, 255, .15);
  box-shadow: 0 12px 30px rgba(10, 29, 72, .2);
  font-size: 27px;
  font-weight: 850;
  backdrop-filter: blur(10px);
}

.wrongbook-identity {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1;
}

.wrongbook-identity > span {
  color: rgba(255, 255, 255, .64);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
}

.wrongbook-identity h3 {
  margin: 4px 0 5px;
  color: #fff;
  font-size: 22px;
}

.wrongbook-identity p {
  margin: 0;
  color: rgba(255, 255, 255, .72);
  font-size: 11px;
}

.wrongbook-profile-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.wrongbook-profile-actions .secondary {
  border-color: rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .13);
  color: #fff;
}

.wrongbook-profile-actions .primary {
  background: #fff;
  box-shadow: 0 9px 20px rgba(7, 24, 65, .18);
  color: #274fb7;
}

.wrongbook-subject-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 23px;
  padding: 12px 0 2px;
  color: #7c889d;
  font-size: 11px;
}

.wrongbook-subject-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #59677f;
  font-weight: 700;
}

.wrongbook-subject-bar select {
  min-width: 130px;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 6px 28px 6px 9px;
  background: #fff;
  color: #526078;
  outline: none;
}

.wrongbook-subject-bar select:focus {
  border-color: #7891e5;
  box-shadow: 0 0 0 3px rgba(49, 87, 213, .09);
}

.wrong-actions .danger-text {
  margin-left: auto;
}

.wrongbook-summary {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, .65fr)) minmax(220px, 1.25fr);
  gap: 10px;
  /* The subject selector sits immediately above the statistics cards.  Keep
     the cards below it instead of pulling them upward over the selector. */
  margin: 10px 23px 0;
}

.wrongbook-summary > div {
  display: flex;
  min-height: 91px;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 11px 26px rgba(22, 41, 80, .09);
}

.summary-icon {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 800;
}

.summary-icon.total {
  background: var(--primary-soft);
  color: var(--primary);
}

.summary-icon.remain {
  background: var(--orange-soft);
  color: var(--orange);
}

.summary-icon.mastered {
  background: var(--green-soft);
  color: var(--green);
}

.wrongbook-summary p {
  margin: 0;
}

.wrongbook-summary p small,
.wrongbook-summary p b {
  display: block;
}

.wrongbook-summary p small,
.mastery-summary > small {
  color: #8f9aab;
  font-size: 9px;
}

.wrongbook-summary p b {
  margin-top: 1px;
  color: #26344e;
  font-size: 23px;
  line-height: 1.2;
}

.wrongbook-summary .mastery-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: center;
  gap: 3px 9px;
}

.mastery-summary b {
  color: var(--green);
  font-size: 20px;
}

.mastery-summary > span {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecf0f4;
}

.mastery-summary > span i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2faa7b, #61c6a0);
}

.wrongbook-list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 15px;
  margin: 25px 24px 12px;
}

.wrongbook-list-head h4 {
  margin: 0 0 2px;
  font-size: 15px;
}

.wrongbook-list-head p {
  margin: 0;
  color: #929cae;
  font-size: 10px;
}

.wrongbook-list-head > span {
  border-radius: 999px;
  padding: 5px 9px;
  background: #e9edf5;
  color: #6f7c91;
  font-size: 10px;
  font-weight: 700;
}

.wrongbook-list {
  display: grid;
  gap: 10px;
  padding: 0 24px 26px;
}

.wrong-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

/* Mastered rows stay visible as an audit trail.  Keep them readable but make
   their completed state unmistakable at a glance. */
.wrong-card.mastered-card {
  border-color: #dfe4ea;
  background: #f7f8fa;
  opacity: .72;
  filter: saturate(.55);
}

.wrong-card.mastered-card:hover,
.wrong-card.mastered-card:focus-within {
  opacity: .96;
  filter: none;
}

.mastered-card .wrong-card-index {
  background: linear-gradient(180deg, #eef0f3, #f7f8fa);
  color: #8993a2;
}

.mastered-card .question-no {
  background: #eceff2;
  color: #687484;
}

.error-state {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfe5d7;
  border-radius: 999px;
  padding: 3px 7px;
  background: #eaf8f2;
  color: #268965;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.mastered-card .error-state {
  border-color: #d2d8e0;
  background: #e9edf1;
  color: #687484;
}

.restore-button {
  border-color: #b9c8f3;
  background: #eef2ff;
  color: #4866bc;
}

.restore-button:hover {
  border-color: #9eafe8;
  background: #e2e9ff;
}

.wrong-card-index {
  display: grid;
  min-height: 155px;
  align-content: start;
  justify-content: center;
  padding-top: 17px;
  background: linear-gradient(180deg, #edf2ff, #f7f9fd);
  color: #4866bc;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
}

.wrong-card-main {
  min-width: 0;
  padding: 15px 16px 13px;
}

.wrong-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wrong-card-head > div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.question-no {
  padding: 5px 7px;
  background: #edf2ff;
  color: var(--primary);
  font-weight: 750;
}

.wrong-date {
  color: #9aa4b5;
  font-size: 9px;
  white-space: nowrap;
}

.wrong-card h4 {
  margin: 9px 0 3px;
  color: #2d3a52;
  font-size: 13px;
  line-height: 1.5;
}

.wrong-summary {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #7b879b;
  font-size: 11px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.wrong-detail {
  margin: 11px 0 4px;
  border: 1px solid #e0e5ee;
  border-radius: 10px;
  padding: 13px;
  background: #fbfcfe;
  color: #111;
  font: 13px/1.75 "Times New Roman", "Noto Serif CJK SC", "SimSun", "宋体", serif;
}

.wrong-question-content img,
.wrong-detail > img,
.wrong-answer img {
  display: block;
  max-width: 100%;
  max-height: 390px;
  margin: 8px auto;
  object-fit: contain;
}

.wrong-answer {
  margin-top: 12px;
  border-top: 1px dashed #d9dfe9;
  padding-top: 10px;
  color: #af4e51;
}

.wrong-answer > b {
  display: block;
  margin-bottom: 4px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 10px;
}

.wrong-meta {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.wrong-meta span {
  border-radius: 6px;
  padding: 4px 6px;
  background: #f4f6f9;
  color: #8190a6;
  font-size: 8px;
}

.wrong-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 11px;
  border-top: 1px solid #eef0f4;
  padding-top: 11px;
}

.wrong-actions button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 9px;
}

.master-button {
  border: 1px solid #bfe5d7;
  background: var(--green-soft);
  color: #268965;
}

.master-button:hover {
  border-color: #9dd7c2;
  background: #ddf4eb;
}

/* Keep the recovery action visually distinct from the green "mastered"
   action, even though both buttons share the master-button base class. */
.master-button.restore-button {
  border-color: #b9c8f3;
  background: #eef2ff;
  color: #4866bc;
}

.master-button.restore-button:hover {
  border-color: #9eafe8;
  background: #e2e9ff;
}

.success-empty > span {
  background: var(--green-soft);
  color: var(--green);
}

/* 从题库选择错题 */
.modal-search {
  margin: 12px 0;
}

.error-question-filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(110px, 1fr));
  gap: 7px;
  margin: 12px 0;
}

.error-question-filters .modal-search {
  min-width: 0;
  margin: 0;
}

.error-question-filters select {
  min-width: 0;
}

.question-pick-list {
  max-height: min(480px, 55dvh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 5px;
}

.question-pick-item {
  display: grid !important;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  min-height: 55px;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 8px 9px;
  cursor: pointer;
}

.question-pick-item:hover {
  background: #f6f8fc;
}

.question-pick-item input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

.question-pick-item span {
  min-width: 0;
}

.question-pick-item b,
.question-pick-item small {
  display: block;
}

.question-pick-item b {
  color: #46536b;
  font-size: 11px;
}

.question-pick-item small {
  overflow: hidden;
  color: #909bad;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-pick-item em {
  border-radius: 6px;
  padding: 4px 6px;
  background: #f1effc;
  color: #7560be;
  font-size: 8px;
  font-style: normal;
}

.question-pick-item.disabled {
  opacity: .52;
  cursor: default;
}

.filtered-out {
  display: none !important;
}

/* 个性化组卷 */
.modal-card.paper-builder-modal {
  width: min(900px, 100%);
}

.paper-title-field {
  margin-bottom: 15px;
}

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

.paper-pick {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px;
  background: #fafbfe;
}

.paper-pick-title {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.paper-pick-title > div {
  flex: 0 0 auto;
}

.paper-pick-title b,
.paper-pick-title small {
  display: block;
}

.paper-pick-title b {
  color: #47556d;
  font-size: 11px;
}

.paper-pick-title small {
  color: #9ba4b5;
  font-size: 8px;
}

.modal-card .pick-search {
  width: min(155px, 50%);
  min-height: 34px;
  margin: 0;
  padding: 6px 9px;
  font-size: 10px;
}

.check-list {
  height: 250px;
  overflow: auto;
  border: 1px solid #e0e4ec;
  border-radius: 9px;
  padding: 4px;
  background: #fff;
}

.check-item {
  display: grid !important;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  min-height: 51px;
  align-items: center;
  gap: 7px;
  border-radius: 7px;
  padding: 7px 8px;
  cursor: pointer;
}

.check-item:hover {
  background: #f5f7fb;
}

.check-item input {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

.check-item > span {
  min-width: 0;
}

.check-item b,
.check-item small {
  display: block;
}

.check-item b {
  color: #45536b;
  font-size: 10px;
}

.check-item small {
  overflow: hidden;
  color: #96a0b2;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-item em {
  color: #836bc8;
  font-size: 8px;
  font-style: normal;
}

.check-item.picked {
  background: #f1f5ff;
}

.check-item.picked em {
  background: #e6edff;
  color: var(--primary);
  font-weight: 750;
}

/* A4 试卷预览 */
.modal-card.paper-preview-modal {
  width: min(1180px, 100%);
  padding: 0;
  background: #e9edf4;
}

.paper-preview-toolbar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid #dfe4ed;
  padding: 13px 63px 13px 20px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
}

.paper-preview-toolbar h3 {
  font-size: 17px;
}

.paper-preview-toolbar small {
  color: #909bad;
  font-size: 9px;
}

.paper-preview-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.paper-preview-variants {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: #eef1f7;
}

.paper-preview-variant {
  min-height: 32px;
  border-radius: 8px;
  padding: 6px 10px;
  background: transparent;
  color: #71809a;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.paper-preview-variant.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.paper-preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.paper-preview-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 9px;
}

#paperPreviewBody {
  overflow: auto;
  padding: 22px;
}

.paper-document {
  width: min(210mm, 100%);
  min-height: 297mm;
  margin: 0 auto;
  padding: 15mm 20mm 14mm;
  background: #fff;
  box-shadow: 0 12px 36px rgba(25, 38, 69, .15);
  color: #000;
  font: 10.5pt/18pt "Times New Roman", "Noto Serif CJK SC", "SimSun", "宋体", serif;
}

.paper-template-header {
  display: flex;
  height: 8mm;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: .75pt solid #999;
  font-size: 9pt;
  line-height: 12pt;
}

.paper-document-head {
  margin: 0 0 4mm;
  padding-top: 2mm;
  text-align: center;
}

.paper-document-head h1 {
  margin: 0;
  font-size: 15pt;
  font-weight: 700;
  line-height: 18pt;
}

.paper-meta {
  min-height: 18pt;
  font-size: 10.5pt;
  line-height: 18pt;
  text-align: center;
}

.paper-type-group h2 {
  margin: 0;
  font-size: 10.5pt;
  font-weight: 700;
  line-height: 18pt;
}

.paper-question {
  position: relative;
  margin: 0;
  break-inside: auto;
}

.paper-question-line {
  line-height: 18pt;
}

.paper-question-image {
  display: block;
  max-width: 100%;
  max-height: 108mm;
  margin: 0 auto;
  object-fit: contain;
}

.paper-answer {
  color: #c00000;
  line-height: 18pt;
}

.paper-template-footer {
  margin-top: 8mm;
  color: #777;
  font-size: 9pt;
  text-align: center;
}

.paper-question-tools {
  position: absolute;
  top: 2px;
  right: -17mm;
}

.paper-question-tools button {
  border: 1px solid #d6def2;
  border-radius: 6px;
  padding: 4px 6px;
  background: #f2f5ff;
  color: #526dc4;
  font: 8px/1.2 "PingFang SC", "Microsoft YaHei", sans-serif;
  white-space: nowrap;
}

.paper-question-tools button.done {
  border-color: #bfe3d6;
  background: #e8f7f1;
  color: #2c8d6a;
}

@media print {
  body {
    background: #fff;
  }

  .paper-document {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .paper-question-tools,
  .paper-template-footer {
    display: none;
  }
}

/* 中等屏幕 */
@media (max-width: 1180px) {
  :root {
    --sidebar-width: 210px;
  }

  .main {
    padding-right: 22px;
    padding-left: 22px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metadata-grid {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
  }

  .metadata-grid .question-no-field,
  .metadata-grid .title-field {
    grid-column: span 2;
  }

  .wrongbook-summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .wrongbook-summary .mastery-summary {
    grid-column: 1 / -1;
    min-height: 72px;
  }
}

@media (max-width: 930px) {
  :root {
    --sidebar-width: 190px;
  }

  .sidebar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .operation-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .operation-bar .action-main {
    align-self: flex-start;
  }

  .filter-bar {
    width: 100%;
    flex-wrap: wrap;
  }

  .filter-bar .search-box {
    flex-basis: 230px;
  }

  .table-head,
  .table-row {
    grid-template-columns: minmax(220px, 1.7fr) minmax(130px, .85fr) minmax(92px, .6fr) 58px;
  }

  .table-head span:nth-child(4),
  .date-cell {
    display: none;
  }

  .metadata-grid {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }

  .metadata-grid .question-no-field {
    grid-column: span 1;
  }

  .metadata-grid .title-field {
    grid-column: span 2;
  }

  .editor-preview-grid {
    grid-template-columns: 1fr;
  }

  .manual-editor textarea {
    min-height: 210px;
  }

  .preview-box {
    min-height: 235px;
  }

  .wrongbook-profile {
    flex-wrap: wrap;
  }

  .wrongbook-profile-actions {
    width: 100%;
    padding-left: 83px;
  }
}

/* 手机端：固定底部导航，弹层使用全屏工作流 */
@media (max-width: 720px) {
  body {
    font-size: 13px;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .sidebar.open {
    position: fixed;
    z-index: 50;
    inset: auto 0 0;
    display: block;
    width: 100%;
    height: calc(70px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid #e1e5ed;
    padding: 5px 7px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -8px 28px rgba(22, 37, 70, .09);
    backdrop-filter: blur(16px);
    transform: none;
  }

  .sidebar .brand,
  .sidebar .workspace-pill,
  .sidebar .sidebar-footer {
    display: none;
  }

  #mainNav {
    display: grid;
    height: 64px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
  }

  .nav-item {
    display: flex;
    min-width: 0;
    min-height: 61px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    border-radius: 9px;
    padding: 3px 1px;
    font-size: 10px;
    text-align: center;
  }

  .nav-item span {
    width: 30px;
    height: 30px;
    font-size: 19px;
  }

  .nav-item:hover {
    transform: none;
  }

  .nav-item.active {
    background: transparent;
    color: var(--primary);
  }

  .nav-item.active span {
    background: var(--primary-soft);
    box-shadow: none;
  }

  .main {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
    padding: 0 13px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    height: calc(70px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  .topbar-title .eyebrow {
    margin-bottom: 3px;
    font-size: 8px;
  }

  .topbar-title h2 {
    font-size: 19px;
  }

  .top-actions {
    gap: 7px;
  }

  .icon-btn,
  .avatar {
    width: 37px;
    height: 37px;
    border-radius: 11px;
  }

  .mobile-menu {
    display: none;
  }

  .hero {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    border-radius: 18px;
    padding: 22px 19px;
  }

  .hero::after {
    right: -80px;
  }

  .hero h3 {
    font-size: 21px;
  }

  .hero p:not(.eyebrow) {
    max-width: 260px;
    font-size: 11px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-actions button {
    min-height: 43px;
    padding: 8px 10px;
    font-size: 11px;
  }

  .stat-grid {
    gap: 9px;
    margin: 12px 0;
  }

  .stat-card {
    min-height: 98px;
    gap: 8px;
    border-radius: 14px;
    padding: 13px 11px;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 14px;
  }

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

  .stat-card em {
    display: none;
  }

  .dashboard-grid,
  .settings-grid {
    gap: 10px;
  }

  .panel {
    border-radius: 14px;
    padding: 15px;
  }

  .progress-panel {
    min-height: 240px;
  }

  .page-toolbar {
    margin: 3px 0 12px;
  }

  .page-toolbar h3 {
    font-size: 19px;
  }

  .page-toolbar p {
    font-size: 10px;
  }

  .operation-bar {
    gap: 9px;
    margin-bottom: 11px;
  }

  .operation-bar .action-main {
    width: 100%;
    min-height: 44px;
    align-self: stretch;
  }

  .operation-bar.compact {
    align-items: stretch;
  }

  .operation-hint {
    padding: 0 2px;
    font-size: 9px;
  }

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

  .filter-bar select {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding-left: 9px;
    font-size: 11px;
  }

  .filter-bar .search-box {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .table-panel {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .table-head {
    display: none;
  }

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

  .table-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 0;
    gap: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 13px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .table-row .question-name {
    grid-column: 1 / -1;
  }

  .table-row .cell-meta {
    grid-column: 1;
  }

  .table-row > div:nth-child(3) {
    grid-column: 1;
  }

  .table-row .row-actions {
    grid-column: 2;
    grid-row: 2 / 4;
    align-self: end;
    flex-direction: column;
  }

  .table-row .row-action {
    min-width: 57px;
    width: 100%;
  }

  .question-name small {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .empty {
    min-height: 180px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
  }

  .student-grid,
  .paper-list {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .student-card {
    border-radius: 14px;
    padding: 15px;
  }

  .student-open {
    font-size: 9px;
  }

  .student-head {
    flex-wrap: wrap;
  }

  .student-head .card-delete {
    margin-left: auto;
  }

  .paper-card {
    border-radius: 14px;
    padding: 15px;
  }

  .paper-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .paper-actions button:first-child {
    grid-column: auto;
  }

  .paper-top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head.stacked {
    align-items: flex-start;
    flex-direction: column;
  }

  /* 全屏弹层 */
  .modal {
    display: block;
    padding: 0;
  }

  .modal-card,
  .modal-card.question-modal,
  .modal-card.wrongbook-modal,
  .modal-card.paper-builder-modal,
  .modal-card.paper-preview-modal {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    padding: calc(18px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
    box-shadow: none;
  }

  .modal-card.wrongbook-modal,
  .modal-card.paper-preview-modal {
    padding: 0;
  }

  .modal-close {
    position: fixed;
    z-index: 110;
    top: calc(9px + env(safe-area-inset-top));
    right: 10px;
    width: 38px;
    height: 38px;
  }

  .modal-card:not(.wrongbook-modal):not(.paper-preview-modal) #modalContent {
    padding-top: 8px;
  }

  .modal-card h3 {
    font-size: 19px;
  }

  .modal-title-row {
    display: block;
    padding-right: 38px;
  }

  .save-hint {
    display: inline-flex;
    margin: -8px 0 11px;
  }

  .form-grid,
  .student-form-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .form-grid .full {
    grid-column: auto;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: minmax(90px, .7fr) minmax(130px, 1.3fr);
  }

  .modal-actions button {
    min-height: 44px;
  }

  .modal-actions.sticky-actions,
  .question-modal .modal-actions.sticky-actions {
    bottom: calc(-16px - env(safe-area-inset-bottom));
    margin: 16px -14px calc(-16px - env(safe-area-inset-bottom));
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }

  .toast {
    top: calc(11px + env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    max-width: none;
    text-align: center;
  }

  /* 手机题目录入 */
  .question-editor form {
    gap: 10px;
  }

  .editor-section {
    border-radius: 13px;
    padding: 12px;
  }

  .section-heading {
    margin-bottom: 10px;
  }

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

  .metadata-grid .question-no-field,
  .metadata-grid .title-field {
    grid-column: 1 / -1;
  }

  .metadata-grid input,
  .metadata-grid select {
    min-height: 42px;
  }

  .input-method-switch {
    max-width: none;
  }

  .input-method-switch button {
    min-height: 60px;
    padding: 8px;
  }

  .input-method-switch button > i {
    display: none;
  }

  .image-source-panel.visible {
    grid-template-columns: 1fr;
  }

  .upload-dropzone {
    min-height: 112px;
  }

  .ocr-console {
    grid-column: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .image-number-option {
    width: 100%;
    max-width: none;
    min-width: 0;
    border: 1px solid #e0e6f0;
    border-radius: 9px;
    padding: 9px;
    background: #fff;
  }

  .ocr-button {
    min-height: 42px;
  }

  .editor-preview-grid {
    gap: 9px;
  }

  .manual-editor,
  .live-preview-pane {
    padding: 10px;
  }

  .manual-editor textarea {
    min-height: 220px;
    font-size: 16px;
  }

  .formula-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .formula-toolbar::-webkit-scrollbar {
    display: none;
  }

  .formula-toolbar button {
    min-height: 44px;
    flex: 0 0 auto;
  }

  .mode-switch button {
    min-height: 44px;
    padding: 5px 3px;
  }

  .preview-box {
    min-height: 220px;
    padding: 12px;
  }

  .answer-editor-grid {
    grid-template-columns: 1fr;
  }

  /* 手机错题本 */
  .wrongbook-profile {
    min-height: 190px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 11px;
    padding: calc(23px + env(safe-area-inset-top)) 52px 26px 18px;
  }

  .wrongbook-avatar {
    width: 55px;
    height: 55px;
    border-radius: 17px;
    font-size: 22px;
  }

  .wrongbook-identity h3 {
    font-size: 19px;
  }

  .wrongbook-identity p {
    font-size: 9px;
  }

  .wrongbook-profile-actions {
    width: 100%;
    padding-left: 0;
  }

  .wrongbook-profile-actions button {
    min-height: 40px;
    flex: 1;
    padding: 7px 9px;
    font-size: 10px;
  }

  .error-question-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .error-question-filters .modal-search {
    grid-column: 1 / -1;
  }

  .wrongbook-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin: 8px 12px 0;
  }

  .wrongbook-subject-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin: 0 13px;
    padding-top: 10px;
    font-size: 9px;
  }

  .wrongbook-subject-bar select {
    min-height: 38px;
  }

  .wrongbook-summary > div {
    min-width: 0;
    min-height: 81px;
    justify-content: center;
    gap: 5px;
    border-radius: 12px;
    padding: 10px 5px;
  }

  .summary-icon {
    width: 29px;
    height: 29px;
    border-radius: 9px;
    font-size: 12px;
  }

  .wrongbook-summary p small {
    font-size: 8px;
  }

  .wrongbook-summary p b {
    font-size: 19px;
  }

  .wrongbook-summary .mastery-summary {
    grid-column: 1 / -1;
    min-height: 64px;
    justify-content: stretch;
    padding: 11px 13px;
  }

.wrongbook-list-head {
    margin: 20px 13px 9px;
  }

  .wrongbook-list-head p {
    max-width: 260px;
    font-size: 9px;
  }

  .wrongbook-list {
    gap: 9px;
    padding: 0 12px calc(20px + env(safe-area-inset-bottom));
  }

  .wrong-card {
    grid-template-columns: 36px minmax(0, 1fr);
    border-radius: 12px;
  }

  .wrong-card-index {
    min-height: 165px;
    padding-top: 15px;
    font-size: 10px;
  }

  .wrong-card-main {
    padding: 12px 11px 11px;
  }

  .wrong-card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .wrong-date {
    order: 2;
  }

  .wrong-card h4 {
    margin-top: 7px;
  }

  .wrong-actions {
    display: grid;
    grid-template-columns: .75fr 1.25fr;
  }

  .wrong-actions button {
    min-height: 44px;
    padding: 7px 5px;
  }

  .question-pick-list {
    max-height: calc(100dvh - 245px);
  }

  /* 手机组卷和试卷预览 */
  .paper-pick-grid {
    grid-template-columns: 1fr;
  }

  .check-list {
    height: min(220px, 27dvh);
  }

  .paper-preview-toolbar {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    padding: calc(13px + env(safe-area-inset-top)) 50px 10px 12px;
  }

  .paper-preview-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .paper-preview-variants,
  .paper-preview-actions {
    width: 100%;
  }

  .paper-preview-variant,
  .paper-preview-actions button {
    flex: 1;
  }

  .paper-preview-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .paper-preview-actions button {
    min-height: 44px;
    padding: 5px 3px;
    font-size: 8px;
  }

  #paperPreviewBody {
    padding: 10px 6px calc(18px + env(safe-area-inset-bottom));
  }

  .paper-document {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 15mm 20mm 14mm;
    transform-origin: top left;
  }

  .paper-preview-shell {
    overflow: hidden;
  }

  .paper-question-tools {
    right: -18mm;
  }
}

.mastered-list-head {
  margin-top: 14px;
  border-top: 1px dashed #dfe4ec;
  padding-top: 17px;
}

.mastered-list .empty {
  border-color: #e5e8ed;
  background: #fafbfc;
}

@media (max-width: 430px) {
  .main {
    padding-right: 10px;
    padding-left: 10px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 12px 9px;
  }

  .stat-card small {
    font-size: 9px;
  }

  .student-open {
    max-width: 64px;
    white-space: normal;
    text-align: right;
  }

  .input-method-switch button small {
    display: none;
  }

  .wrongbook-summary > div {
    flex-direction: column;
    text-align: center;
  }

  .wrong-card h4 {
    font-size: 12px;
  }

  .paper-pick-title {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-card .pick-search {
    width: 100%;
  }
}

/* 录入新题弹窗：提升辅助说明、状态提示和快捷控件的可读性 */
.question-modal .step-kicker {
  color: #65728a;
  font-size: 11px;
}

.question-modal .modal-title-row .sub {
  color: #687791;
  font-size: 13px;
}

.question-modal .save-hint {
  color: #65728a;
  font-size: 11px;
}

.question-modal .section-heading small {
  color: #71809a;
  font-size: 10px;
  line-height: 1.45;
}

.question-modal .metadata-grid label {
  color: #4f5f78;
  font-size: 11px;
}

.question-modal .field-required,
.question-modal .field-optional {
  padding: 2px 6px;
  font-size: 9px;
}

.question-modal .field-help,
.question-modal .title-field > small {
  color: #71809a;
  font-size: 10px;
  line-height: 1.45;
}

.question-modal .input-with-action button,
.question-modal .ocr-button,
.question-modal .remove-asset,
.question-modal .remove-answer {
  font-size: 11px;
}

.question-modal .input-method-switch button b {
  font-size: 12px;
}

.question-modal .input-method-switch button small,
.question-modal .upload-dropzone small,
.question-modal .asset-panel small,
.question-modal .image-number-option small,
.question-modal .pane-heading small,
.question-modal .answer-editor summary small {
  color: #71809a;
  font-size: 10px;
  line-height: 1.4;
}

.question-modal .upload-dropzone b,
.question-modal .asset-panel b,
.question-modal .image-number-option b {
  font-size: 11px;
}

.question-modal .ocr-status {
  color: #5f6f88;
  font-size: 11px;
  line-height: 1.4;
}

.question-modal .pane-heading b,
.question-modal .answer-editor summary b {
  font-size: 12px;
}

.question-modal .pane-heading > span {
  font-size: 10px;
}

.question-modal .formula-toolbar button,
.question-modal .mode-switch button,
.question-modal .answer-upload span {
  font-size: 10px;
  line-height: 1.35;
}

.question-modal .editor-tip {
  color: #71809a;
  font-size: 10px;
  line-height: 1.45;
}

@media (max-width: 430px) {
  .question-modal .input-method-switch button {
    min-height: 68px;
  }

  .question-modal .input-method-switch button small {
    display: block;
  }
}

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

/* 批量录入、班级管理与班级错题登记 */
.action-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.danger-text {
  color: var(--danger) !important;
}

.batch-import-modal {
  width: min(1040px, 100%);
}

.batch-import-shell {
  padding-top: 2px;
}

.batch-import-step {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  background: #fbfcff;
}

.batch-import-step .section-heading {
  margin-bottom: 12px;
}

.batch-upload-box {
  display: flex;
  min-height: 108px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border: 1px dashed #b8c6e8;
  border-radius: 12px;
  background: #f4f7ff;
  color: var(--primary);
  text-align: center;
  cursor: pointer;
}

.batch-upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.batch-upload-box b {
  font-size: 12px;
}

.batch-upload-box small {
  color: #8997b2;
  font-size: 9px;
}

.batch-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 27px;
  margin-top: 9px;
}

.batch-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #dce4f6;
  border-radius: 7px;
  padding: 5px 7px;
  background: #fff;
  color: #52617b;
  font-size: 9px;
}

.batch-file-chip b {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 8px;
}

.batch-file-chip small {
  color: #9aa6ba;
}

.batch-ocr-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 11px;
}

.batch-status {
  color: #7d8ba3;
  font-size: 10px;
}

.batch-meta-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.batch-meta-grid label {
  min-width: 0;
}

.batch-raw-text,
.roster-text {
  display: block;
  width: 100%;
  min-height: 130px;
  margin-bottom: 9px;
  resize: vertical;
  font: 12px/1.7 "SFMono-Regular", Consolas, monospace;
}

.batch-candidate-list {
  display: grid;
  max-height: 470px;
  overflow: auto;
  gap: 9px;
  margin-top: 12px;
  padding-right: 2px;
}

.batch-candidate {
  border: 1px solid #dfe5f0;
  border-radius: 12px;
  padding: 11px;
  background: #fff;
}

.batch-candidate-head,
.class-manager-row,
.batch-error-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.batch-candidate-head > div:nth-child(2),
.batch-error-question-head > div:first-child {
  min-width: 0;
  flex: 1;
}

.batch-candidate-head b,
.batch-candidate-head small,
.batch-error-question-head b,
.batch-error-question-head small {
  display: block;
}

.batch-candidate-head b,
.batch-error-question-head b {
  color: #40506b;
  font-size: 11px;
}

.batch-candidate-head small,
.batch-error-question-head small {
  overflow: hidden;
  color: #9aa5b8;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-order {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.batch-candidate-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.batch-candidate-tools .text-btn,
.batch-error-question-head .text-btn {
  min-height: 28px;
  padding: 4px 6px;
  font-size: 9px;
}

.batch-warning {
  margin: 8px 0;
  border-radius: 7px;
  padding: 6px 8px;
  background: var(--orange-soft);
  color: #b36a3f;
  font-size: 9px;
  line-height: 1.5;
}

.batch-candidate-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(130px, .6fr);
  gap: 8px;
  margin-top: 9px;
}

.batch-candidate-fields .full {
  grid-column: 1 / -1;
}

.batch-candidate-fields textarea {
  min-height: 90px;
  resize: vertical;
  font-size: 11px;
  line-height: 1.65;
}

.class-manager-modal {
  padding-top: 2px;
}

.class-manager-list {
  display: grid;
  gap: 7px;
  max-height: 340px;
  overflow: auto;
  margin-top: 17px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.class-manager-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fbfcfe;
}

.class-manager-row > div:first-child {
  min-width: 0;
}

.class-manager-row b,
.class-manager-row small {
  display: block;
}

.class-manager-row b {
  color: #40506b;
  font-size: 11px;
}

.class-manager-row small {
  color: #929eb2;
  font-size: 9px;
}

.class-manager-row > div:last-child {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.class-manager-row button {
  min-height: 29px;
  padding: 5px 7px;
  font-size: 9px;
}

.batch-result {
  display: flex;
  gap: 9px;
  margin-top: 10px;
  color: #75849c;
  font-size: 10px;
}

.batch-result b {
  color: var(--green);
}

.batch-error-modal {
  width: min(1080px, 100%);
}

.batch-error-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 13px 0 8px;
}

.batch-error-toolbar label:first-child {
  width: min(260px, 100%);
}

.batch-error-toolbar .search-box {
  width: min(240px, 100%);
  margin: 0;
}

.batch-error-question-list {
  display: grid;
  max-height: min(530px, 58dvh);
  overflow: auto;
  gap: 9px;
  margin-top: 11px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.batch-error-question {
  border: 1px solid #dfe5f0;
  border-radius: 11px;
  padding: 10px;
  background: #fff;
}

.batch-error-student-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.batch-error-student-list label {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  border-radius: 7px;
  padding: 6px 7px;
  background: #f7f9fc;
  cursor: pointer;
}

.batch-error-student-list label:hover {
  background: var(--primary-soft);
}

.batch-error-student-list input {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

.batch-error-student-list span,
.batch-error-student-list small {
  display: block;
  min-width: 0;
}

.batch-error-student-list span {
  overflow: hidden;
  color: #53627b;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-error-student-list small {
  color: #9ca7b9;
  font-size: 8px;
}

@media (max-width: 720px) {
  .action-cluster {
    width: 100%;
  }

  .action-cluster .action-main {
    flex: 1;
  }

  .batch-meta-grid,
  .batch-candidate-fields {
    grid-template-columns: 1fr 1fr;
  }

  .batch-candidate-fields .full {
    grid-column: 1 / -1;
  }

  .class-manager-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .class-manager-row > div:last-child {
    width: 100%;
  }

  .class-manager-row button {
    flex: 1;
  }
}

@media (max-width: 430px) {
  .batch-meta-grid,
  .batch-candidate-fields {
    grid-template-columns: 1fr;
  }

  .batch-candidate-fields .full {
    grid-column: auto;
  }

  .batch-candidate-head {
    align-items: flex-start;
  }

  .batch-candidate-tools {
    flex-direction: column;
  }
}
