/* ============================================
   组卷系统 - 组卷网风格样式表
   设计理念：白底卡片 + 蓝色主调 + 清晰层次
   ============================================ */

/* ---- 设计 token ---- */
:root {
  --color-primary: #2563eb;
  --color-primary-light: #3b82f6;
  --color-primary-dark: #1d4ed8;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;
  --color-text: #1e293b;
  --color-text-2: #475569;
  --color-muted: #64748b;
  --color-muted-light: #94a3b8;
  --color-tag-bg: #eff6ff;
  --color-tag-text: #1d4ed8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* ---- 移动端设计 token ---- */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  --touch-target: 44px;
  --topbar-h: 56px;
  --topbar-h-mobile: 52px;
}

*, *::before, *::after { box-sizing: border-box; }

input, select, textarea, button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--color-surface) inset !important;
  -webkit-text-fill-color: var(--color-text) !important;
  caret-color: var(--color-text);
}

html {
  font-size: clamp(13px, 0.4vw + 12.4px, 15.5px);
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  min-height: 100vh;
  min-height: 100dvh;
}

/* MathJax / 题目内表格 / 长公式 —— 移动端禁止撑爆父容器 */
.mjx-container, .q-body table, .q-body img,
.q-body svg, .q-body video, .q-body iframe {
  max-width: 100%;
}
.mjx-container { overflow-x: auto; overflow-y: hidden; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- 滚动条美化 ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- 顶部导航栏 ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.logout-btn:hover {
  background: var(--color-bg);
  border-color: var(--color-border-hover);
  color: var(--color-text);
}

.user-role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
  margin-right: 8px;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.3px;
}

.nav { display: flex; align-items: center; gap: 4px; }

.navlink {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.navlink:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.navlink.active {
  background: var(--color-tag-bg);
  color: var(--color-primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* ---- 主容器 ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* ---- 卡片面板 ---- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.panel:hover { box-shadow: var(--shadow-md); }

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.panel-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--color-primary);
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ---- 表单区域 ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.field { display: flex; flex-direction: column; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

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

.field input[readonly] {
  background: var(--color-bg);
  color: var(--color-muted);
}

/* ---- 按钮 ---- */
button, .btnlike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  user-select: none;
}

button:active, .btnlike:active { transform: translateY(1px); }

button:hover, .btnlike:hover {
  background: var(--color-bg);
  border-color: var(--color-border-hover);
}

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

button.primary:hover, .btnlike.primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

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

button.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

button.ghost {
  background: transparent;
  border-color: transparent;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

button.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ---- 行布局 ---- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- 小字提示 ---- */
.small, .hint {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.5;
}

.hint {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  margin: 8px 0;
}

/* ---- 标签选择（checkbox/radio） ---- */
label.chk-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

label.chk-label:hover { background: var(--color-bg); }

/* ---- 表格 ---- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover td { background: #f8fafc; }

.table input, .table select {
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--color-surface);
}

/* ---- 试题卡片 ---- */
.q-list { display: flex; flex-direction: column; gap: 10px; }

.q-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.q-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-hover);
}

.q-card.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.q-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

/* q-card-body: vertical stack inside the card, takes remaining width */
.q-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.q-no {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.q-card.selected .q-no {
  background: var(--color-primary-dark);
}

.q-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.q-meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
}

.q-meta-tag.danger { background: #fef2f2; color: #b91c1c; }
.q-meta-tag.warning { background: #fffbeb; color: #92400e; }
.q-meta-tag.success { background: #f0fdf4; color: #166534; }
.q-meta-tag.muted { background: var(--color-bg); color: var(--color-muted); }

.q-body {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-text);
}

/* 题目内容中嵌入的 HTML 表格（来自题库原始数据）：
   1. 保留 Word border="1" 的结构
   2. 用 CSS 重绘干净边框替代 inline 样式
   3. overflow-x:auto 防止宽表格撑爆容器
*/
.q-body table {
  border-collapse: collapse !important;
  border: 1px solid #cbd5e1 !important;
  table-layout: fixed;
  width: auto;
  max-width: 100%;
  overflow-x: auto;
  display: table;
}
.q-body td, .q-body th {
  border: 1px solid #cbd5e1 !important;
  padding: 4px 8px;
  min-width: 30px;
}
.q-body table img { max-width: 100%; height: auto; }

/* ================================================================
   通用的题目内容表格样式（innerHTML 直写的区域复用此 class）
   来源：Word 导出的题目答案/解析中的表格
================================ ================================= */
.table-default table {
  border-collapse: collapse !important;
  border: 1px solid #cbd5e1 !important;
  table-layout: fixed;
  width: auto;
  max-width: 100%;
  overflow-x: auto;
  display: table;
}
.table-default td, .table-default th {
  border: 1px solid #cbd5e1 !important;
  padding: 4px 8px;
  min-width: 30px;
  word-break: break-word;
}
.table-default table img { max-width: 100%; height: auto; }
.table-default table * { max-width: 100%; word-break: break-word; }

.q-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  opacity: 1;
}

.q-card:hover .q-actions { opacity: 1; }

.q-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 14px 10px;
  border-top: 1px solid var(--color-border);
  background: #fafbfc;
}
.q-card-foot button { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
.q-card-mv { display: none; }

@media (max-width: 1024px) {
  .q-card-foot { flex-wrap: wrap; }
  .q-card-mv {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 16px;
    cursor: pointer;
  }
  .q-card-mv:active { background: var(--color-primary); color: #fff; }
}

/* 折叠区域 */
.q-fold {
  display: none;
  padding: 0 14px 10px;
  border-top: 1px dashed var(--color-border);
}

.q-card.expanded .q-fold { display: block; }

.q-toggle {
  font-size: 11.5px;
  color: var(--color-primary);
  cursor: pointer;
  user-select: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.q-toggle:hover { background: var(--color-tag-bg); }

/* ---- 分割布局 ---- */
.split {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.split-main { flex: 1; min-width: 0; }

.split-side {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
}

.side-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.side-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- 题型分布列表 ---- */
.dist-list { display: flex; flex-direction: column; gap: 6px; }

.dist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: grab;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font-size: 13px;
  user-select: none;
}

.dist-item:hover {
  border-color: var(--color-primary-light);
  background: var(--color-tag-bg);
}

.dist-item:active { cursor: grabbing; }

.dist-name { font-weight: 500; color: var(--color-text); }

.dist-count {
  font-size: 12px;
  color: var(--color-muted);
  font-weight: 600;
  background: var(--color-bg);
  padding: 1px 7px;
  border-radius: 99px;
}

.dist-move {
  display: none;
  flex-direction: column;
  gap: 1px;
  margin-right: 4px;
  flex-shrink: 0;
}
.dist-mv-btn {
  width: 18px;
  height: 14px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dist-mv-btn:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.dist-mv-btn:disabled { opacity: 0.3; cursor: not-allowed; }

@media (max-width: 1024px) {
  /* 触屏：隐藏拖拽视觉提示，显示上下按钮 */
  .dist-item { cursor: default; padding: 8px 10px; }
  .dist-move { display: flex; }
}

/* ---- 试题调整区 ---- */
.q-adj-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.q-adj-type-group { margin-bottom: 6px; }

.q-adj-type-label {
  font-size: 11px;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  padding-left: 2px;
}

.q-adj-row { display: flex; flex-wrap: wrap; gap: 4px; }

.q-adj-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  cursor: grab;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  user-select: none;
  position: relative;
  gap: 2px;
}

.q-adj-item:hover {
  background: var(--color-tag-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.q-adj-item:active { cursor: grabbing; transform: scale(0.95); }

.q-adj-num { min-width: 16px; text-align: center; }

.q-adj-mv {
  display: none;
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-muted);
  font-size: 7px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
.q-adj-mv:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
}
.q-adj-mv:disabled { opacity: 0.25; cursor: not-allowed; }

@media (max-width: 1024px) {
  /* 触屏：显示上下移动按钮 + 加大触摸区 */
  .q-adj-item { padding: 0 4px; gap: 3px; min-width: 30px; height: 30px; }
  .q-adj-mv { display: inline-flex; width: 16px; height: 16px; font-size: 8px; }
  .q-adj-item { cursor: default; }
}

/* ---- 左侧分类树（学科网风格） ---- */
.page-layout { display: flex; gap: 20px; align-items: flex-start; }

.page-tree-panel {
  width: 290px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.tree-section { border-bottom: 1px solid var(--color-border); }
.tree-section:last-child { border-bottom: none; }

/* 树面板整体折叠触发器（移动端用） */
.tree-collapse-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-muted);
  background: var(--color-bg);
  border: none;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.tree-collapse-toggle .tct-chevron {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--color-muted-light);
}
.tree-collapse-toggle[aria-expanded="true"] .tct-chevron { transform: rotate(180deg); }
.tree-collapse-toggle:hover { background: #e2e8f0; }
.tree-collapse-body { display: block; }

@media (max-width: 1024px) {
  .tree-collapse-toggle { display: flex; }
  .page-tree-panel { padding: 0; }
  .tree-section-header:first-child { border-radius: 0; }
}

.tree-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-muted);
  background: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.tree-section-header:hover { background: #e2e8f0; }

.tree-section-header .chevron {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--color-muted-light);
}

.tree-section-header.open .chevron { transform: rotate(90deg); }

.tree-node { position: relative; }

.tree-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.tree-item:hover { background: var(--color-tag-bg); color: var(--color-primary); }

.tree-item.selected {
  background: var(--color-tag-bg);
  color: var(--color-primary);
  font-weight: 600;
  border-left-color: var(--color-primary);
}

.tree-toggle {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: var(--color-muted-light);
  transition: transform 0.2s, background 0.15s, color 0.15s;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.tree-toggle:hover { background: rgba(0,0,0,.06); color: var(--color-primary); }
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle-placeholder {
  cursor: default;
  background: transparent;
}
.tree-toggle-placeholder:hover { background: transparent; color: var(--color-muted-light); }

.tree-children {
  border-left: 1px dashed var(--color-border);
  margin-left: 22px;
}
.tree-children[hidden] { display: none !important; }
.tree-children.expanded { display: block; }

.tree-loading {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- 右侧内容 ---- */
.page-content { flex: 1; min-width: 0; }

/* ---- 分页 ---- */
.pager { display: flex; align-items: center; gap: 8px; }

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
}

.page-btn:hover { background: var(--color-bg); border-color: var(--color-border-hover); }
.page-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- 模态框 ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

/* 移动端：键盘弹起时 backdrop 改用 flex-start + overflow 滚动，让弹框贴顶部不被键盘遮住 */
@media (max-width: 768px) {
  .modal-backdrop.is-keyboard-open {
    align-items: flex-start;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .modal-backdrop.is-keyboard-open .modal {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.modal {
  width: min(960px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
}

.modal-title { font-size: 16px; font-weight: 700; margin: 0; }

/* ---- 颜色按钮（答案颜色选择器） ---- */
.color-btn-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.color-btn:hover {
  transform: scale(1.15);
  border-color: var(--color-border-hover);
}

.color-btn.selected {
  border-color: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-primary), 0 0 0 5px var(--color-surface);
}

.color-btn.default {
  background: #fff;
  border: 2px dashed #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #6b7280;
  font-weight: 700;
}

/* ---- 标签页 ---- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--color-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--color-text); }

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: var(--color-tag-bg);
}

/* ---- 空状态 ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--color-muted);
  text-align: center;
  gap: 10px;
}

.empty-state-icon { font-size: 40px; opacity: 0.4; }
.empty-state-text { font-size: 13.5px; }

/* ---- 工具栏 ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ---- 统计摘要 ---- */
.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  min-width: 80px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label { font-size: 11px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ============================================
   响应式 & 移动端
   ============================================ */

/* ---- hamburger 按钮（移动端显示） ---- */
.topbar-hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 36px;
  height: 36px;
  padding: 8px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.topbar-hamburger span {
  display: block;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.topbar-hamburger:hover { background: var(--color-bg); }

.user-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  flex-shrink: 0;
}
.user-icon-btn:hover { background: var(--color-bg); color: var(--color-text); }

/* ---- 移动端抽屉 ---- */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 299;
  animation: drawerFadeIn 0.2s ease;
}
.mobile-drawer-backdrop[hidden] { display: none; }

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(82vw, 320px);
  background: var(--color-surface);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, .12);
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
}
.mobile-drawer[aria-hidden="false"] { transform: translateX(0); }

.mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.mobile-drawer-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--color-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.mobile-drawer-close:hover { background: var(--color-bg); color: var(--color-text); }

.mobile-drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.m-navlink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-left: 3px solid transparent;
  min-height: var(--touch-target);
}
.m-navlink:hover { background: var(--color-bg); }
.m-navlink.active {
  background: var(--color-tag-bg);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: 600;
}
.m-nav-sep {
  display: block;
  height: 1px;
  background: var(--color-border);
  margin: 8px 18px;
}
.mobile-drawer-foot {
  border-top: 1px solid var(--color-border);
  padding: 8px 0;
  flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
}
.m-foot-link {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  min-height: var(--touch-target);
}
.m-foot-link:hover { background: var(--color-bg); }
.m-foot-link-danger { color: var(--color-danger); }

body.mobile-drawer-open { overflow: hidden; }

@keyframes drawerFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================
   断点系统
   ============================================ */

/* 大屏：≥1280 —— 桌面端默认布局 */
@media (min-width: 1281px) {
  .container { max-width: 1280px; }
}

/* 平板/中等屏：≤1024 折叠导航 */
@media (max-width: 1024px) {
  .container { padding: 18px 16px 32px; }
  .topbar { padding: 0 18px; height: var(--topbar-h); }
  .topbar .nav { display: none; }   /* 主导航进抽屉 */
  .topbar-hamburger { display: flex; }
  .topbar .user-info .logout-btn { display: none; }
  .topbar .user-info .user-name { max-width: 90px; }
  .user-subjects { display: none; }
  .user-role-badge { font-size: 10px; padding: 1px 6px; }

  /* 工作台 / 通用卡片 */
  .page-layout { flex-direction: column; gap: 14px; }
  .page-tree-panel { width: 100%; max-height: none; position: static; }
  .page-content { width: 100%; }
  .split { flex-direction: column; }
  .split-side { width: 100%; position: static; }
  .grid { grid-template-columns: repeat(2, 1fr); }

  /* 模态框收一收 */
  .modal { max-width: 96vw; max-height: 90vh; max-height: 90dvh; padding: 18px; }
  .modal-backdrop { padding: 10px; }
}

/* 手机竖屏：≤768 —— 单列、紧凑 */
@media (max-width: 768px) {
  .container { padding: 12px 12px 28px; }
  .topbar { padding: 0 10px; height: var(--topbar-h-mobile); }
  .topbar .brand { font-size: 15px; }
  .user-info { gap: 6px; }
  .user-name { display: none; }

  .panel { padding: 14px 14px; border-radius: var(--radius-md); margin-bottom: 14px; }
  .panel-header { flex-wrap: wrap; }
  .panel-title { font-size: 14px; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .field label { font-size: 11px; }

  /* 按钮触摸目标 */
  button, .btnlike, a.btnlike { min-height: var(--touch-target); padding: 8px 14px; }
  button.icon-btn { width: var(--touch-target); height: var(--touch-target); }

  /* 表格横向滚动 */
  .table-wrap { border-radius: var(--radius-md); }
  .table th, .table td { padding: 8px 10px; font-size: 12.5px; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12.5px; }

  /* 工具栏换行 */
  .toolbar { gap: 6px; }
  .toolbar button, .toolbar .btnlike { padding: 6px 10px; font-size: 12.5px; }

  /* 题目卡片 */
  .q-card { border-radius: var(--radius-md); }
  .q-card-head { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .q-card-body { width: 100%; order: 2; }
  .q-actions { order: 1; margin-left: auto; }
  .q-body { font-size: 13px; }
  .q-no { width: 26px; height: 26px; min-width: 26px; font-size: 11px; }

  /* 模态框全屏化 */
  .modal-backdrop { padding: 0; }
  .modal {
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 14px;
  }
}

/* 手机横屏：≤768 横屏 */
@media (max-width: 768px) and (orientation: landscape) {
  .topbar { height: 48px; }
  .modal { padding: 10px 14px; }
}

/* 超小屏：≤480 */
@media (max-width: 480px) {
  .container { padding: 8px 8px 20px; }
  .panel { padding: 12px; }
  .topbar-hamburger { width: 32px; height: 32px; padding: 6px 4px; }
  .modal-title { font-size: 15px; }
  .field input, .field select, .field textarea { font-size: 16px; }
  .panel-header { margin-bottom: 12px; padding-bottom: 10px; }
}

/* 横屏手机（短高）特化 */
@media (orientation: landscape) and (max-height: 500px) {
  /* 登录页品牌区进一步收 */
  .login-brand { padding: 24px 32px; min-height: 180px; }
  .brand-title { font-size: 24px; margin: 8px 0 6px; }
  .brand-subtitle { margin-bottom: 10px; font-size: 12px; }
  .topbar { height: 48px; }
}

/* 偏好减少动效 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- a11y: 焦点可见（仅键盘） ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .15);
}
html.is-dark button:focus-visible,
html.is-dark a:focus-visible,
html.is-dark input:focus-visible,
html.is-dark select:focus-visible,
html.is-dark textarea:focus-visible,
html.is-dark [tabindex]:focus-visible {
  outline-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, .25);
}

/* 跳过到主内容 */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* a11y: 屏幕阅读器专用 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- 移动端底部操作栏 ---- */
.mobile-actionbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  gap: 8px;
  justify-content: space-around;
}
.mab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch-target);
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.mab-btn:hover { background: var(--color-bg); }
.mab-btn.mab-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.mab-btn.mab-primary:hover { background: var(--color-primary-dark); }

@media (max-width: 1024px) {
  .mobile-actionbar { display: flex; }
  body.has-mab { padding-bottom: calc(72px + var(--safe-bottom)); }
}

@media (max-width: 768px) {
  .color-btn-group { flex-wrap: wrap; }
  .color-btn-group input[type="text"] { width: 100% !important; }
  .dist-item { padding: 10px 12px; font-size: 14px; }
  .q-adj-item { min-width: 30px; height: 30px; }
  .side-card { padding: 12px; }
  .side-title { font-size: 12.5px; }
  .panel-header .stats-row { width: 100%; justify-content: flex-start; }
}

/* ---- 细目表 #bpTable 移动端：表格转卡片 ---- */
@media (max-width: 768px) {
  #bpTable thead { display: none; }
  #bpTable, #bpTable tbody, #bpTable tr, #bpTable td { display: block; width: 100%; }
  #bpTable tr {
    margin-bottom: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px;
    background: var(--color-surface);
  }
  #bpTable td {
    border: none;
    border-bottom: 1px solid var(--color-bg);
    padding: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  #bpTable td:last-child { border-bottom: none; padding-top: 10px; justify-content: flex-end; }
  #bpTable td::before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 80px;
    font-size: 12px;
    color: var(--color-muted);
    font-weight: 600;
  }
  #bpTable td input, #bpTable td select { flex: 1; min-width: 0; font-size: 14px; }
  #bpTable td > button { min-height: 36px; padding: 6px 10px; }
}

/* ---- 通用 .data-table 移动端：表格转卡片 ---- */
@media (max-width: 768px) {
  .data-table-card thead { display: none; }
  .data-table-card, .data-table-card tbody, .data-table-card tr, .data-table-card td { display: block; width: 100%; }
  .data-table-card tr {
    margin-bottom: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    background: var(--color-surface);
  }
  .data-table-card td {
    border: none;
    border-bottom: 1px solid var(--color-bg);
    padding: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
  }
  .data-table-card td:last-child { border-bottom: none; padding-top: 8px; }
  .data-table-card td::before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 76px;
    font-size: 11.5px;
    color: var(--color-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .data-table-card td > .table-cell-actions { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; justify-content: flex-end; }
}

/* 横屏手机 / 窄高屏：表格以 2 列卡片网格显示 */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .data-table-card thead { display: none; }
  .data-table-card, .data-table-card tbody { display: grid; width: 100%; }
  .data-table-card tbody {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .data-table-card tr {
    display: flex;
    flex-direction: column;
    margin: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    background: var(--color-surface);
    width: auto;
  }
  .data-table-card td {
    border: none;
    border-bottom: 1px solid var(--color-bg);
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
  }
  .data-table-card td:last-child { border-bottom: none; padding-top: 6px; }
  .data-table-card td::before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 64px;
    font-size: 11px;
    color: var(--color-muted);
    font-weight: 600;
  }

  /* 横屏手机：stats 也变 4 列 */
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 页面通用 toolbar / row 在小屏更紧凑 */
@media (max-width: 480px) {
  .toolbar button, .toolbar .btnlike { font-size: 12px; padding: 6px 8px; }
  .row { gap: 6px; }
}

/* ---- 通用统计卡片（admin/dashboard 等） ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
  border: 1px solid #f1f5f9;
}
.stat-card-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon-blue   { background: #eff6ff; }
.stat-card-icon-green  { background: #f0fdf4; }
.stat-card-icon-amber  { background: #fffbeb; }
.stat-card-icon-amber-light { background: #fef3c7; }
.stat-card-icon-purple { background: #faf5ff; }
.stat-card-icon-cyan   { background: #ecfeff; }
.stat-card-icon-red    { background: #fef2f2; }
.stat-card-value {
  font-size: 26px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}
.stat-card-label {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 2px;
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-card-icon { width: 38px; height: 38px; }
  .stat-card-value { font-size: 22px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 12px; }
  .stat-card-icon { width: 32px; height: 32px; }
  .stat-card-value { font-size: 18px; }
  .stat-card-label { font-size: 11.5px; }
}

/* ---- 评卷页：底部操作栏（移动端 sticky） ---- */
.grading-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
@media (max-width: 768px) {
  .grading-actions {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 16px -12px -14px;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
    z-index: 50;
  }
  .grading-actions button { min-height: var(--touch-target); flex: 1; }
}

/* ---- 学生答题页：底部提交栏 ---- */
.exam-actions {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  background: var(--color-surface);
  padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  z-index: 50;
  margin: 16px -12px -14px;
}
.exam-actions button { min-height: var(--touch-target); flex: 1; }

/* ---- 考试状态条 ---- */
.exam-statusbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .04);
}
.exam-statusbar[hidden] { display: none; }
.esb-progress { flex: 1; height: 6px; background: var(--color-bg); border-radius: 99px; overflow: hidden; }
.esb-progress-bar { height: 100%; width: 0; background: var(--color-primary); transition: width 0.4s ease; border-radius: 99px; }
.esb-info { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.esb-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--color-tag-bg);
  color: var(--color-primary);
  border-radius: 99px;
}
.esb-tag-time {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  background: var(--color-bg);
  color: var(--color-text);
}
.esb-tag-time-warn {
  background: var(--color-danger);
  color: #fff;
  animation: esbPulse 1s ease-in-out infinite;
}
@keyframes esbPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
.esb-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}
.esb-btn:hover { background: var(--color-bg); color: var(--color-text); }

@media (max-width: 768px) {
  .exam-statusbar {
    top: var(--topbar-h-mobile);
    padding: 6px 10px;
    margin: 0 -10px 12px;
    border-radius: 0;
  }
}

/* ---- 切屏警告层 ---- */
.exam-blur-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(15, 23, 42, .85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.exam-blur-overlay[hidden] { display: none; }
.ebo-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.ebo-icon { font-size: 48px; margin-bottom: 12px; }
.ebo-title { font-size: 18px; font-weight: 700; color: #ef4444; margin-bottom: 8px; }
.ebo-msg { color: #475569; font-size: 14px; line-height: 1.6; margin-bottom: 16px; }
.ebo-stat { font-size: 13px; color: #94a3b8; margin-bottom: 20px; }
.ebo-stat strong { color: #ef4444; font-size: 18px; }
html.is-dark .ebo-box { background: var(--color-surface); color: var(--color-text); }

/* ---- 通用题干 / 选项在移动端适当放大触摸区 ---- */
@media (max-width: 768px) {
  .q-options label {
    padding: 12px 14px;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    margin-bottom: 6px;
  }
  .q-options label:active { background: var(--color-bg-soft); }
  .q-options input[type="radio"],
  .q-options input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    flex-shrink: 0;
  }
  .q-option-text { font-size: 15px; line-height: 1.55; }
  .q-textarea { font-size: 16px !important; }    /* iOS 16px 防止自动放大 */
  .q-input, .q-textarea {
    min-height: 44px;
    font-size: 16px !important;  /* iOS 16px 防止自动放大 */
  }
  /* 移动端数量步进器 */
  input[type="number"] {
    min-height: 40px;
    font-size: 16px !important;
  }
}

/* ---- 移动端左侧树 sheet（题目页用） ---- */
.mobile-tree-sheet { position: fixed; inset: 0; z-index: 250; }
.mobile-tree-sheet[hidden] { display: none; }
.mts-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  animation: drawerFadeIn 0.2s ease;
}
.mts-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80vh;
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.25s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-bottom);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.mts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  font-weight: 700;
}
.mts-close {
  width: 36px; height: 36px; border: none; background: transparent;
  font-size: 24px; line-height: 1; color: var(--color-muted); cursor: pointer; border-radius: var(--radius-sm);
}
.mts-close:hover { background: var(--color-bg); }
.mts-body { flex: 1; overflow-y: auto; padding: 8px 0; -webkit-overflow-scrolling: touch; }

/* ============================================
   暗色模式
   ============================================ */
:root.is-dark {
  --color-primary: #60a5fa;
  --color-primary-light: #93c5fd;
  --color-primary-dark: #3b82f6;
  --color-success: #34d399;
  --color-danger: #f87171;
  --color-warning: #fbbf24;
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-border-hover: #475569;
  --color-text: #e2e8f0;
  --color-muted: #94a3b8;
  --color-muted-light: #64748b;
  --color-tag-bg: #1e3a8a;
  --color-tag-text: #93c5fd;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.5), 0 4px 8px rgba(0,0,0,.4);
}

html.is-dark, html.is-dark body { background: var(--color-bg); color: var(--color-text); }
html.is-dark .topbar { background: var(--color-surface); border-bottom-color: var(--color-border); }
html.is-dark .brand { color: var(--color-primary); }
html.is-dark .panel { background: var(--color-surface); border-color: var(--color-border); }
html.is-dark .q-card,
html.is-dark .q-card-foot,
html.is-dark .side-card,
html.is-dark .stat-card,
html.is-dark .login-card,
html.is-dark .login-brand,
html.is-dark .workspace-hero,
html.is-dark .mobile-drawer,
html.is-dark .mts-panel,
html.is-dark .modal {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
html.is-dark input,
html.is-dark select,
html.is-dark textarea,
html.is-dark button {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
html.is-dark .q-card-foot { background: #0f172a; }
html.is-dark .q-meta-tag.muted { color: var(--color-muted); }
html.is-dark .q-body table { background: var(--color-bg); }
html.is-dark .mjx-container path,
html.is-dark .mjx-container g[data-mml-node] { fill: var(--color-text); }
html.is-dark .mjx-container line { stroke: var(--color-text); }
html.is-dark #actionStatus { background: #422006; border-color: #78350f; color: #fbbf24; }
html.is-dark #actionStatus.success { background: #064e3b; border-color: #065f46; color: #34d399; }
html.is-dark #actionStatus.error { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }
html.is-dark .skeleton { background: linear-gradient(90deg, #334155 0%, #475569 50%, #334155 100%); background-size: 200% 100%; }
html.is-dark .login-page { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
html.is-dark .login-brand { background: linear-gradient(135deg, #1e293b 0%, #312e81 100%); }

/* ---- 表单实时验证 ---- */
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--color-danger) !important;
  background: #fef2f2;
}
html.is-dark .field.has-error input,
html.is-dark .field.has-error select,
html.is-dark .field.has-error textarea {
  background: rgba(239, 68, 68, .1);
}
.field .field-error {
  color: var(--color-danger);
  font-size: 12px;
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 4px;
}
.field.has-error .field-error { display: flex; }
.field .field-error::before { content: '⚠'; font-size: 12px; }
.field input:invalid:not(:placeholder-shown) {
  border-color: var(--color-warning);
}

/* ---- 上下文菜单（long-press）---- */
.ctx-menu-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: transparent;
}
.ctx-menu {
  position: fixed; z-index: 301;
  background: var(--color-surface);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
  padding: 6px 0;
  min-width: 160px;
  max-width: 240px;
  transform-origin: top left;
  animation: ctxMenuIn 0.14s ease;
}
@keyframes ctxMenuIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.ctx-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.ctx-menu-item:active { background: var(--color-bg-soft); }
.ctx-menu-item.is-danger { color: var(--color-danger); }
.ctx-menu-item .ctx-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.ctx-menu-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

.q-card-mv { transition: transform 0.2s, opacity 0.2s; }
.q-card-mv.is-lifting { transform: scale(0.98); box-shadow: var(--shadow-md); }

/* ---- 通用 .field 错误状态 ---- */
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--color-danger);
}

/* ---- 触觉反馈标记（用于移动端点击按钮瞬间） ---- */
@keyframes hapticTap {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
.haptic-tap {
  animation: hapticTap 0.18s ease;
}

/* ---- 离线网络提示 banner ---- */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--color-warning);
  color: #fff;
  text-align: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ---- 下拉刷新指示器 ---- */
.pull-to-refresh {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
}
.pull-to-refresh.is-pulling { opacity: 1; }
.pull-to-refresh .ptr-icon {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  margin-right: 10px;
  transition: transform 0.2s;
}
.pull-to-refresh.is-loading .ptr-icon {
  animation: spin 0.7s linear infinite;
}
.pull-to-refresh .ptr-text { font-size: 13px; color: var(--color-muted); font-weight: 500; }

/* 加载更多触发器（在内容区底部） */
.load-more-sentinel {
  text-align: center;
  padding: 16px 0;
  color: var(--color-muted);
  font-size: 12px;
}
.load-more-sentinel.is-loading { color: var(--color-primary); }
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--color-danger) !important;
  background: #fef2f2;
}
html.is-dark .field.has-error input,
html.is-dark .field.has-error select,
html.is-dark .field.has-error textarea {
  background: rgba(239, 68, 68, .1);
}
.field .field-error {
  color: var(--color-danger);
  font-size: 12px;
  margin-top: 4px;
  display: none;
  align-items: center;
  gap: 4px;
}
.field.has-error .field-error { display: flex; }
.field .field-error::before { content: '⚠'; font-size: 12px; }
.field input:invalid:not(:placeholder-shown) {
  border-color: var(--color-warning);
}

/* 暗色模式切换按钮（顶栏右上） */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 14px;
  margin-left: 4px;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--color-bg); color: var(--color-text); }

/* 兼容旧规则（已合并到 1024 断点中） */
@media (max-width: 960px) {
  .container { padding: 16px; }
  .split { flex-direction: column; }
  .split-side { width: 100%; position: static; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .container { padding: 12px; }
  .panel { padding: 14px; }
  .grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
}

/* ---- 骨架屏（Skeleton）---- */
@keyframes skeletonShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  display: block;
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-line.short  { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long   { width: 90%; }
.skeleton-block { height: 80px; margin: 8px 0; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; }
.skeleton-card {
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: 10px;
}
.skeleton-card-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.skeleton-card-body { flex: 1; }

/* ---- 加载动画 ---- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---- Toast 通知 ---- */
#actionStatus {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  background: #fefce8;
  border: 1px solid #fef08a;
  color: #854d0e;
  display: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
#actionStatus.is-fading { opacity: 0; transform: translateY(-4px); }

#actionStatus.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

#actionStatus.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

@media (max-width: 768px) {
  /* 移动端：toast 钉在顶部，全宽，z 高 */
  #actionStatus {
    position: sticky;
    top: var(--topbar-h-mobile);
    z-index: 60;
    margin: 0 -12px 12px;
    border-radius: 0;
    padding: 10px 14px;
    font-size: 13.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
  }
}

/* ---- Drag placeholder ---- */
.sortable-ghost {
  opacity: 0.4;
  background: var(--color-tag-bg) !important;
  border: 2px dashed var(--color-primary) !important;
}

/* ---- 每日一练 ---- */
.badge { display:inline-block;padding:2px 8px;border-radius:12px;font-size:12px;font-weight:500; }
.badge-success { background:#d1fae5;color:#065f46; }
.badge-danger { background:#fee2e2;color:#991b1b; }
.badge-muted { background:#f1f5f9;color:#475569; }
.op-link { font-size:13px;color:var(--color-primary);cursor:pointer;text-decoration:none;white-space:nowrap; }
.op-link:hover { text-decoration:underline; }
.op-link.danger { color:var(--color-danger); }
.data-table { border-collapse:collapse; }
.data-table th,.data-table td { padding:10px 12px;border-bottom:1px solid var(--color-border);text-align:left; }
.data-table th { background:#f8fafc;font-weight:600;font-size:13px;color:#475569; }

/* ============================================
   登录页 - 全屏渐变分栏布局
   ============================================ */

.login-body {
  margin: 0;
  min-height: 100vh;
  background: #f1f5f9;
  font-family: "PingFang SC","Microsoft YaHei","Segoe UI",system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing: antialiased;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.login-brand {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(135deg, #6366f1 0%, #7c3aed 55%, #4f46e5 100%);
  color: #fff;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.deco-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(80% 60% at 70% 30%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(80% 60% at 70% 30%, #000 30%, transparent 80%);
}

.deco-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  filter: blur(2px);
}
.blob-1 { width: 320px; height: 320px; top: -90px; left: -110px; animation: floatA 9s ease-in-out infinite; }
.blob-2 { width: 220px; height: 220px; bottom: -60px; right: 10%; background: rgba(244,114,182,.35); animation: floatB 11s ease-in-out infinite; }
.blob-3 { width: 140px; height: 140px; top: 35%; right: 22%; background: rgba(56,189,248,.30); animation: floatA 13s ease-in-out infinite; }

@keyframes floatA {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(18px,-22px) scale(1.05); }
}
@keyframes floatB {
  0%,100% { transform: translate(0,0) scale(1); }
  50%     { transform: translate(-20px,18px) scale(0.95); }
}

.brand-content { position: relative; z-index: 1; }

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .3px;
}
.brand-logo svg { display: block; }

.brand-title {
  margin: 28px 0 14px;
  font-size: 40px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.5px;
  text-shadow: 0 2px 12px rgba(0,0,0,.12);
}

.brand-subtitle {
  margin: 0 0 36px;
  font-size: 14px;
  opacity: .88;
}

.brand-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  max-width: 460px;
}
.brand-features li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  padding: 12px 14px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.brand-features .feature-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,.18);
}
.brand-features strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.brand-features span {
  font-size: 13px;
  opacity: .82;
  line-height: 1.5;
}

.brand-footer {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  opacity: .72;
  letter-spacing: .5px;
}

/* 右侧卡片 */
.login-card-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  padding: 36px 36px 28px;
  box-shadow:
    0 30px 60px -20px rgba(79,70,229,.25),
    0 10px 30px -10px rgba(15,23,42,.10);
  border: 1px solid rgba(226,232,240,.8);
}

.login-card-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: -.3px;
}
.login-card-head p {
  margin: 0 0 22px;
  font-size: 13.5px;
  color: #64748b;
}

.login-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
  border-radius: 10px;
  animation: alertIn .25s ease;
}
@keyframes alertIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field { display: block; }
.lf-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
  letter-spacing: .2px;
}
.lf-input {
  position: relative;
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.lf-input:focus-within {
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99,102,241,.12);
}
.lf-icon {
  flex-shrink: 0;
  margin: 0 10px 0 12px;
  color: #94a3b8;
}
.lf-input:focus-within .lf-icon { color: #6366f1; }
.lf-input input {
  flex: 1;
  min-width: 0;
  padding: 12px 4px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #0f172a;
  font-family: inherit;
  outline: none;
}
.lf-input input::placeholder { color: #cbd5e1; }
.lf-toggle {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 8px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.lf-toggle:hover { color: #6366f1; }

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: #64748b;
  margin-top: 2px;
}
.login-remember { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.login-remember input { accent-color: #6366f1; width: 14px; height: 14px; }
.login-hint { color: #94a3b8; }

.login-submit {
  position: relative;
  margin-top: 6px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 4px;
  cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(99,102,241,.6);
  transition: transform .12s, box-shadow .15s, opacity .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}
.login-submit:hover { box-shadow: 0 12px 26px -8px rgba(99,102,241,.7); transform: translateY(-1px); }
.login-submit:active { transform: translateY(0); }
.login-submit:disabled { opacity: .7; cursor: wait; transform: none; }
.login-submit .ls-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.login-submit.is-loading .ls-spinner { display: inline-block; }
.login-submit.is-loading .ls-text { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
}
.login-foot a { color: #6366f1; text-decoration: none; }
.login-foot a:hover { text-decoration: underline; }

@media (max-width: 960px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { padding: 36px 28px; min-height: 220px; }
  .brand-title { font-size: 28px; margin: 18px 0 10px; }
  .brand-subtitle { margin-bottom: 18px; }
  .brand-features { display: none; }
  .login-card-wrap { padding: 32px 20px 48px; }
  .login-card { padding: 28px 24px 22px; border-radius: 16px; }
}
@media (max-width: 768px) and (orientation: portrait) {
  .login-brand { padding: 28px 24px; min-height: auto; }
  .brand-title { font-size: 22px; margin: 8px 0 8px; }
  .brand-subtitle { font-size: 13px; margin-bottom: 0; }
  .brand-deco .blob-1, .brand-deco .blob-2, .brand-deco .blob-3 { display: none; }
  .login-card-wrap { padding: 16px 16px 32px; }
  .login-card { padding: 22px 18px 18px; border-radius: 14px; }
  .login-card-head h2 { font-size: 20px; }
  .lf-input input { font-size: 16px; }     /* iOS 16px 防止自动放大 */
  .login-submit { min-height: var(--touch-target); }
}
@media (max-width: 480px) {
  .login-card { padding: 22px 16px 16px; }
  .login-card-head h2 { font-size: 18px; }
  .login-options { flex-direction: column; align-items: flex-start; gap: 4px; }
  .login-options .login-hint { display: none; }
  .login-brand { padding: 22px 18px; }
  .brand-logo { font-size: 16px; }
  .brand-logo svg { width: 28px; height: 28px; }
  .brand-title { font-size: 20px; }
  .brand-subtitle { font-size: 12px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .login-page { grid-template-columns: 1.1fr 1fr; }
  .login-brand { padding: 18px 28px; min-height: 100vh; min-height: 100dvh; }
  .brand-title { font-size: 18px; margin: 4px 0 4px; }
  .brand-subtitle { font-size: 11px; margin-bottom: 0; }
  .brand-features { display: none; }
  .brand-deco .blob-1, .brand-deco .blob-2, .brand-deco .blob-3 { display: none; }
  .login-card-wrap { padding: 16px 24px; align-self: center; }
  .login-card { padding: 18px 18px 14px; }
}

/* ============================================
   统一工作台 /workspace  (学生 + 教师 共用)
   ============================================ */

.workspace-hero {
  position: relative;
  margin-bottom: 24px;
  padding: 28px 32px;
  border-radius: 18px;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 50%),
    linear-gradient(135deg, #6366f1 0%, #7c3aed 60%, #4f46e5 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 16px 36px -18px rgba(79,70,229,.45);
}
.workspace-hero::after {
  content: "";
  position: absolute;
  right: -60px; top: -60px;
  width: 220px; height: 220px;
  background: rgba(255,255,255,.10);
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}
.ws-hero-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.ws-greet { font-size: 13px; opacity: .85; }
.ws-name  { font-size: 24px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; }
.ws-name .ws-emoji { margin-right: 6px; }
.ws-role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.22);
  font-size: 12px;
  font-weight: 500;
}
.ws-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-top: 18px;
}
.ws-stat {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ws-stat .ws-stat-num {
  font-size: 22px; font-weight: 700; line-height: 1.1;
}
.ws-stat .ws-stat-label {
  font-size: 12px; opacity: .85; margin-top: 4px;
}

.workspace-section {
  margin-top: 8px;
}
.workspace-section + .workspace-section { margin-top: 28px; }
.ws-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 12px;
}
.ws-section-title::before {
  content: "";
  display: inline-block;
  width: 3px; height: 14px;
  background: var(--color-primary);
  border-radius: 2px;
}
.ws-section-title .ws-section-sub {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
}

.ws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.ws-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 20px 18px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  transition: transform .15s, box-shadow .2s, border-color .15s;
  overflow: hidden;
  min-height: 144px;
}
.ws-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 32px -18px rgba(15,23,42,.18), 0 4px 10px -2px rgba(15,23,42,.06);
  border-color: #c7d2fe;
}
.ws-card .ws-card-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #4f46e5;
  flex-shrink: 0;
}
.ws-card .ws-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ws-card .ws-card-desc {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.5;
  flex: 1;
}
.ws-card .ws-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 12.5px;
  color: #64748b;
}
.ws-card .ws-card-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #4f46e5;
  font-weight: 600;
}
.ws-card .ws-card-go svg { transition: transform .15s; }
.ws-card:hover .ws-card-go svg { transform: translateX(3px); }

.ws-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #eef2ff;
  color: #4f46e5;
}
.ws-badge.success { background: #ecfdf5; color: #059669; }
.ws-badge.warn    { background: #fffbeb; color: #d97706; }
.ws-badge.danger  { background: #fef2f2; color: #dc2626; }
.ws-badge.muted   { background: #f1f5f9; color: #64748b; }

.ws-card.highlight {
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255,255,255,.12) 0%, rgba(255,255,255,0) 50%),
    linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  border-color: transparent;
  color: #fff;
}
.ws-card.highlight .ws-card-icon { background: rgba(255,255,255,.18); color: #fff; }
.ws-card.highlight .ws-card-title { color: #fff; }
.ws-card.highlight .ws-card-desc { color: rgba(255,255,255,.85); }
.ws-card.highlight .ws-card-foot { color: rgba(255,255,255,.85); }
.ws-card.highlight .ws-card-go   { color: #fff; }
.ws-card.highlight .ws-badge     { background: rgba(255,255,255,.22); color: #fff; }

.ws-card.disabled {
  pointer-events: none;
  background: #f8fafc;
  border-style: dashed;
}
.ws-card.disabled .ws-card-icon { background: #e2e8f0; color: #94a3b8; }
.ws-card.disabled .ws-card-title, .ws-card.disabled .ws-card-desc { color: #94a3b8; }

.ws-card-corner {
  position: absolute;
  top: 12px; right: 12px;
}

.workspace-empty {
  padding: 60px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  background: #fff;
  border: 1px dashed #e2e8f0;
  border-radius: 16px;
}

@media (max-width: 1024px) {
  .ws-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}
@media (max-width: 720px) {
  .workspace-hero { padding: 22px 20px; border-radius: 14px; }
  .ws-name { font-size: 20px; }
  .ws-stats { grid-template-columns: repeat(2, 1fr); }
  .ws-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .workspace-hero { padding: 16px 14px; border-radius: 12px; }
  .ws-name { font-size: 17px; }
  .ws-hero-title { font-size: 13px; }
  .ws-stats { gap: 8px; }
  .ws-stat { padding: 10px 12px; }
  .ws-stat-value { font-size: 18px; }
  .ws-card { padding: 14px; }
  .ws-card .ws-card-title { font-size: 15px; }
}

/* ==========================================================================
   角色端广告位：右侧可展开标签卡（student / teacher；admin 不渲染）
   ========================================================================== */
.floating-ad {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9500;
  display: flex;
  align-items: flex-end;
  gap: 0;
  /* 拖动时禁用过渡，否则会有延迟 */
  transition: top 0s, transform 0s;
}
.floating-ad[data-dragging="true"] {
  transition: none;
  transform: none;
}

/* ── 收起态小标签（可上下拖动） ── */
.floating-ad-tab {
  width: 48px;
  height: 120px;
  border: none;
  border-radius: 12px 0 0 12px;
  background: linear-gradient(160deg, #10b981, #059669);
  box-shadow: -3px 3px 12px rgba(5, 150, 105, 0.4), 0 2px 6px rgba(0,0,0,0.12);
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  transition: width 0.2s, background 0.2s, transform 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  user-select: none;
  touch-action: none;
}
.floating-ad-tab:active { cursor: grabbing; }
.floating-ad-tab:hover {
  background: linear-gradient(160deg, #059669, #047857);
  transform: scale(1.04);
}
.floating-ad-tab[data-expanded="true"] {
  width: 44px;
  background: linear-gradient(160deg, #6b7280, #4b5563);
  box-shadow: -2px 2px 8px rgba(107, 114, 128, 0.3);
  cursor: default;
}
/* 拖拽手柄（小红点） */
.floating-ad-tab-handle {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.55);
  pointer-events: none;
}
.floating-ad-tab-icon {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  flex-shrink: 0;
  pointer-events: none;
}
.floating-ad-tab-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 1px;
  line-height: 1.4;
  max-height: 90px;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.floating-ad-tab[data-expanded="true"] .floating-ad-tab-text {
  color: rgba(255,255,255,0.55);
}

/* ── 展开态卡片 ── */
.floating-ad-card {
  position: absolute;
  right: 52px;
  bottom: 0;
  width: 280px;
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15), 0 2px 8px rgba(15, 23, 42, 0.07);
  overflow: hidden;
  transform-origin: right bottom;
  animation: adCardSlideIn 0.25s ease-out both;
}
@keyframes adCardSlideIn {
  from { opacity: 0; transform: translateX(16px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.floating-ad-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  line-height: 20px;
  font-size: 18px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(255,255,255,0.8);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  z-index: 3;
  transition: color 0.15s, background 0.15s;
}
.floating-ad-close:hover { color: #ef4444; background: #fff; }

.floating-ad-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 38px 14px 14px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
  align-items: center;
}
.floating-ad-inner:hover { background: #f8fafc; }

/* 二维码图片占主：固定大方块 */
.floating-ad-media {
  flex-shrink: 0;
  width: 240px;
  height: 240px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 48px;
  overflow: hidden;
  margin: 4px auto 0;
}
.floating-ad-media img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* 二维码必须完整可见，不能 cover 裁切 */
  display: block;
  background: #fff;
}

.floating-ad-body { width: 100%; text-align: center; }
.floating-ad-title {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
  line-height: 1.4;
  word-break: break-word;
}
.floating-ad-content {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── 暗色模式 ── */
.is-dark .floating-ad-tab {
  background: linear-gradient(160deg, #10b981, #059669);
}
.is-dark .floating-ad-tab[data-expanded="true"] {
  background: linear-gradient(160deg, #374151, #1f2937);
}
.is-dark .floating-ad-card {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #334155;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
}
.is-dark .floating-ad-close {
  color: #64748b;
  background: rgba(30,41,59,0.8);
}
.is-dark .floating-ad-close:hover { color: #f87171; background: #1e293b; }
.is-dark .floating-ad-inner:hover { background: #273449; }
.is-dark .floating-ad-title { color: #f1f5f9; }
.is-dark .floating-ad-content { color: #94a3b8; }

/* ── 移动端 ── */
.is-mobile .floating-ad { top: 50%; }
.is-mobile .floating-ad-tab { width: 40px; height: 90px; }
.is-mobile .floating-ad-tab[data-expanded="true"] { width: 38px; }
.is-mobile .floating-ad-tab-icon { width: 22px; height: 22px; }
.is-mobile .floating-ad-tab-text { font-size: 11px; max-height: 68px; }
.is-mobile .floating-ad-card { right: 44px; width: 240px; }
.is-mobile .floating-ad-inner { padding: 12px 36px 12px 12px; }
.is-mobile .floating-ad-media { width: 200px; height: 200px; font-size: 40px; }
.is-mobile .floating-ad-title { font-size: 12px; }
.is-mobile .floating-ad-content { font-size: 11px; -webkit-line-clamp: 2; }

.is-landscape.is-mobile .floating-ad-tab { height: 72px; }
.is-landscape.is-mobile .floating-ad-tab-text { max-height: 54px; }
.is-landscape.is-mobile .floating-ad-media { width: 160px; height: 160px; font-size: 32px; }
