:root {
  /* Anki 极简风格:内容优先,去阴影 / 大圆角,黑白灰 + Anki 蓝 + 四评分色 */
  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --surface-2: #F1F3F4;
  --border: #E0E0E0;
  --text: #212121;
  --text-2: #424242;
  --text-3: #757575;
  --primary: #2196F3;
  --primary-dark: #1E88E5;
  --primary-bg: #E3F2FD;
  --danger: #E57373;
  --danger-bg: #FDEBEB;
  --success: #81C784;
  --success-bg: #EAF4EC;
  --warn: #FFB74D;
  --warn-bg: #FFF3E0;
  --info: #64B5F6;
  --info-bg: #EAF3FC;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(33, 33, 33, 0.08);

  --imp-1: #757575; --imp-1-bg: #F5F5F5; --imp-1-badge-bg: #EEEEEE; --imp-1-badge-fg: #424242; --imp-1-badge-bd: #BDBDBD;
  --imp-2: #1E88E5; --imp-2-bg: #EAF3FC; --imp-2-badge-bg: #E3F2FD; --imp-2-badge-fg: #1565C0; --imp-2-badge-bd: #64B5F6;
  --imp-3: #FB8C00; --imp-3-bg: #FFF3E0; --imp-3-badge-bg: #FFE0B2; --imp-3-badge-fg: #E65100; --imp-3-badge-bd: #FFB74D;
  --imp-4: #F4511E; --imp-4-bg: #FBE9E7; --imp-4-badge-bg: #FFCCBC; --imp-4-badge-fg: #BF360C; --imp-4-badge-bd: #FF8A65;
  --imp-5: #E53935; --imp-5-bg: #FFEBEE; --imp-5-badge-bg: #FFCDD2; --imp-5-badge-fg: #B71C1C; --imp-5-badge-bd: #EF9A9A;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 防止 display:flex 等类样式覆盖 hidden 属性导致视图同时渲染 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 72px;
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-top: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.topbar .back-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar .topbar-actions { display: flex; gap: 8px; align-items: center; }

/* 顶部竖向三点下拉菜单 */
.topbar-menu-wrap { position: relative; display: flex; align-items: center; }
.topbar-menu-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font: inherit; cursor: pointer;
}
.topbar-menu-btn .icon { width: 22px; height: 22px; }
.topbar-menu {
  position: absolute; top: 46px; right: 0; z-index: 40;
  min-width: 168px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.topbar-menu[hidden] { display: none; }
.topbar-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--text-1);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  width: 100%; margin: 0;
}
.topbar-menu-item:hover { background: var(--surface-2); }
.topbar-menu-item .icon { width: 18px; height: 18px; color: var(--text-2); flex: none; }

/* 权限管理(分享)页 */
.share-form { display: flex; flex-direction: column; gap: 12px; }
/* /shares 权限管理:选择框避免占满整行,保持紧凑合适大小 */
.share-form .form-field select { width: auto; min-width: 200px; max-width: 100%; min-height: 40px; }
.share-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.share-user {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); cursor: pointer; font-size: 14px;
}
.share-user input { accent-color: var(--primary); width: 15px; height: 15px; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.share-row:last-child { border-bottom: none; }
.share-row-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-row-user { font-size: 13px; color: var(--text-2); flex-shrink: 0; }

.page { max-width: 720px; margin: 0 auto; padding: 12px 16px 16px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 60px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}
.tab .tab-icon { font-size: 20px; line-height: 1; }
.tab.active { color: var(--primary); }
.tab.tab-study .tab-icon {
  width: 44px; height: 44px; margin-top: -22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
body.no-tabbar .tabbar { display: none; }
body.no-tabbar { padding-bottom: 0; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn.secondary { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.danger-outline { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.btn.success { background: var(--success); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.panel-title a { font-size: 13px; font-weight: 500; }

.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 48px 24px;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- 图标(内联 SVG,替代 emoji) ---------- */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.btn .icon { width: 1.1em; height: 1.1em; }
.tab-icon .icon { width: 22px; height: 22px; }
.tab-study .tab-icon .icon { width: 24px; height: 24px; }

.toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 41, 59, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  line-height: 1.5;
  text-align: center;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.breadcrumb span.sep { color: var(--border); }

/* ---------- 星级徽章 ---------- */
.importance-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.importance-badge .star-ic { width: 12px; height: 12px; }
.importance-badge-1 { color: var(--imp-1-badge-fg); background: var(--imp-1-badge-bg); border: 1px solid var(--imp-1-badge-bd); }
.importance-badge-2 { color: var(--imp-2-badge-fg); background: var(--imp-2-badge-bg); border: 1px solid var(--imp-2-badge-bd); }
.importance-badge-3 { color: var(--imp-3-badge-fg); background: var(--imp-3-badge-bg); border: 1px solid var(--imp-3-badge-bd); }
.importance-badge-4 { color: var(--imp-4-badge-fg); background: var(--imp-4-badge-bg); border: 1px solid var(--imp-4-badge-bd); }
.importance-badge-5 { color: var(--imp-5-badge-fg); background: var(--imp-5-badge-bg); border: 1px solid var(--imp-5-badge-bd); }

/* ---------- 星级色条列表项 ---------- */
.starred-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.starred-item.importance-1 { border-left: 4px solid var(--imp-1); background: var(--imp-1-bg); }
.starred-item.importance-2 { border-left: 4px solid var(--imp-2); background: var(--imp-2-bg); }
.starred-item.importance-3 { border-left: 4px solid var(--imp-3); background: var(--imp-3-bg); }
.starred-item.importance-4 { border-left: 5px solid var(--imp-4); background: var(--imp-4-bg); }
.starred-item.importance-5 { border-left: 6px solid var(--imp-5); background: var(--imp-5-bg); }

.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.item-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--text-2); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-right: 4px;
}
a.tag.node-link { color: var(--primary); background: var(--primary-bg); border-color: var(--primary-bg); text-decoration: none; }
a.tag.node-link:active { opacity: 0.7; }

/* ---------- 通用弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: modal-fade 0.15s ease;
}
.modal-card {
  background: var(--surface);
  border-radius: 16px;
  width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 20px;
  animation: modal-pop 0.18s ease;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-message { font-size: 14px; color: var(--text-2); line-height: 1.6; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; min-height: 42px; }
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-pop { from { opacity: 0; transform: scale(0.96) translateY(10px); } }

.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.form-hint { font-size: 12px; color: var(--text-3); margin: 4px 0 0; line-height: 1.5; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 15px;
  color: var(--text);
}
.form-field textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.form-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 勾选行 ---------- */
.check-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-2);
  padding: 8px 2px; cursor: pointer; user-select: none;
}
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }

/* ---------- 课程卡（按导入顺序） ---------- */
.lesson-order {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 24px; padding: 0 8px;
  border-radius: 999px;
  background: var(--primary-bg); color: var(--primary);
  font-size: 12px; font-weight: 700;
}
.lesson-card.learned .lesson-order { background: var(--success-bg); color: var(--success); }
.learned-tag { color: var(--success); background: var(--success-bg); border-color: var(--success-bg); font-weight: 600; }
.learned-tag .icon { width: 13px; height: 13px; vertical-align: -2px; }
.lesson-progress { margin: 10px 0 4px; }
.lesson-progress .progress-bar { height: 6px; }
.lesson-progress-text { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.lesson-progress-text b { color: var(--success); font-weight: 700; }

/* ---------- 首页 ---------- */
.hero {
  background: linear-gradient(135deg, #1E293B, #334155);
  color: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 16px;
}
.hero h2 { font-size: 20px; margin-bottom: 4px; }
.hero p { font-size: 13px; color: #CBD5E1; }
.hero .hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.hero .btn { flex: 1; }
.streak-line {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn);
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 999px;
  display: inline-block;
  padding: 4px 14px;
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
/* 手机端 5 张统计卡的落单一张占满整行 */
@media (max-width: 599px) {
  .stat-grid .stat-box:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (min-width: 600px) { .stat-grid { grid-template-columns: repeat(5, 1fr); } }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.stat-box .stat-num { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-box .stat-label { font-size: 12px; color: var(--text-3); }
.stat-box.alert .stat-num { color: var(--danger); }

.log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.log-item:last-child { border-bottom: none; }
.log-item .log-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.log-item .log-dot.again { background: var(--danger); }
.log-item .log-dot.good, .log-item .log-dot.easy { background: var(--success); }
.log-item .log-dot.hard { background: var(--imp-3); }
.log-item .log-time { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.log-item .log-main { flex: 1; min-width: 0; }
.log-item .log-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-item .log-sub { font-size: 12px; color: var(--text-3); }
a.log-item { color: inherit; }
a.log-item:active { opacity: 0.7; }
.text-danger { color: var(--danger); }

/* ---------- 导入页 ---------- */
.import-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.import-tabs .btn { flex: 1; }
.prompt-box {
  margin: 0 0 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.75;
  font-family: inherit;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}
.prompt-box.collapsed { max-height: 148px; overflow: hidden; }
.prompt-actions { display: flex; gap: 8px; }
.prompt-actions .btn { flex: 1; }
.manage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.manage-row:last-child { border-bottom: none; }
.manage-info { flex: 1; min-width: 0; }
.manage-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.manage-row .btn { flex-shrink: 0; }
.manage-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 480px) {
  .manage-row { flex-wrap: wrap; }
  .manage-actions { width: 100%; }
  .manage-actions .btn { flex: 1; }
}
.import-area {
  width: 100%;
  min-height: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text-2);
  resize: vertical;
}
.import-area:focus { outline: none; border-color: var(--primary); }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  background: var(--surface);
  color: var(--text-3);
  margin-bottom: 12px;
}
.upload-zone.has-file { border-color: var(--success); color: var(--success); }
.import-result .ok-line { color: var(--success); font-weight: 600; }
.error-list { list-style: none; }
.error-list li {
  background: var(--danger-bg);
  color: #991B1B;
  border: 1px solid #FCA5A5;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
}
.error-list li code { font-family: Consolas, monospace; word-break: break-all; }
.warn-box {
  background: var(--imp-3-bg);
  border: 1px solid var(--imp-3-badge-bd);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.warn-box .warn-title { color: var(--imp-3-badge-fg); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.warn-list { list-style: none; }
.warn-list li {
  color: #92400E;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 4px;
}

/* ---------- 知识库 ---------- */
.library-layout { display: block; }
@media (min-width: 720px) { .library-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; } }

.tree { font-size: 14px; }
.node-tree-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  max-height: 280px;
  overflow-y: auto;
}
.tree ul { list-style: none; padding-left: 14px; border-left: 1px solid var(--border); margin-left: 6px; }
.tree > ul { padding-left: 0; border-left: none; margin-left: 0; }
.tree-node { margin: 2px 0; }
.tree-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
}
.tree-link:hover { background: var(--surface-2); }
.tree-link.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.tree-link .tree-arrow { font-size: 10px; transition: transform 0.15s; }
.tree-link .tree-arrow.open { transform: rotate(90deg); }

/* 课程思维导图页 */
.mm-tree { padding: 4px 0; }
.mm-node {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 2px 0;
  cursor: default;
}
details > summary.mm-node { cursor: pointer; font-weight: 600; }
details > summary.mm-node::marker { color: var(--text-3); }
.mm-leaf { background: var(--surface); }
.mm-leaf a { color: var(--primary); text-decoration: none; }
.mindmap-panel .md-body { margin-top: 8px; }
.tree-count { margin-left: auto; font-size: 12px; color: var(--text-3); }

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.subject-select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
}
.subject-select:focus { outline: none; border-color: var(--primary); }
.subject-inline {
  min-height: 32px;
  padding: 0 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
}
.search-bar input {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.search-bar input:focus { outline: none; border-color: var(--primary); }
.search-bar select {
  min-height: 44px;
  max-width: 46%;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- 知识点详情 ---------- */
.node-detail h2 { font-size: 20px; margin-bottom: 8px; }
.node-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.node-summary { color: var(--text-2); margin-bottom: 16px; }
.node-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
:is(.node-content, .md-body) h2 { margin: 18px 0 8px; font-size: 17px; }
:is(.node-content, .md-body) h3 { margin: 14px 0 6px; font-size: 16px; }
:is(.node-content, .md-body) h4 { margin: 12px 0 6px; font-size: 14px; color: var(--text-2); }
:is(.node-content, .md-body) h2:first-child, :is(.node-content, .md-body) h3:first-child, :is(.node-content, .md-body) h4:first-child { margin-top: 0; }
:is(.node-content, .md-body) p { margin: 6px 0; }
:is(.node-content, .md-body) a { color: var(--primary); }
:is(.node-content, .md-body) code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
:is(.node-content, .md-body) pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
:is(.node-content, .md-body) pre code { background: none; border: none; padding: 0; }
:is(.node-content, .md-body) blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text-2); }
:is(.node-content, .md-body) hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
:is(.node-content, .md-body) del { color: var(--text-3); }
:is(.node-content, .md-body) img.md-img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
:is(.node-content, .md-body) .md-list { list-style: none; padding-left: 18px; margin: 6px 0; }
:is(.node-content, .md-body) .md-list li { padding: 2px 0; position: relative; }
:is(.node-content, .md-body) .md-list li::before { content: "•"; position: absolute; left: -14px; color: var(--primary); }
:is(.node-content, .md-body) .md-list li.md-task::before { content: none; }
:is(.node-content, .md-body) li.md-task { display: flex; align-items: flex-start; gap: 8px; }
:is(.node-content, .md-body) li.md-task input[type="checkbox"] { margin-top: 4px; accent-color: var(--primary); width: 15px; height: 15px; flex: none; }
:is(.node-content, .md-body) .md-olist { padding-left: 22px; margin: 6px 0; }
:is(.node-content, .md-body) .md-olist li { padding: 2px 0; }
:is(.node-content, .md-body) table.md-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; }
:is(.node-content, .md-body) .md-table th, :is(.node-content, .md-body) .md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
:is(.node-content, .md-body) .md-table th { background: var(--surface-2); font-weight: 600; }
.key-points { list-style: none; }
.key-points li { padding: 6px 0 6px 22px; position: relative; }
.key-points li::before { content: "•"; position: absolute; left: 8px; color: var(--primary); }

.relation-grid { display: grid; gap: 8px; }
.relation-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.relation-type {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--primary-bg);
  color: var(--primary);
  white-space: nowrap;
}
.occurrence-quote {
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 14px;
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}
.occurrence-quote .occ-tag { font-size: 12px; color: var(--text-3); }

/* ---------- 刷卡学习页 ---------- */
/* 横滑手势归页面接管:禁止浏览器把卡片横滑当成前进/后退翻页 */
body.study-mode { background: var(--bg); overscroll-behavior: none; }
.study-layout {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  touch-action: pan-y;
}
.study-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.study-meta .study-node-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.study-meta .study-node-link:active { opacity: 0.7; }
.study-edit-btn { flex-shrink: 0; min-height: 32px; padding: 0 8px; font-size: 13px; }

/* min-width:0 打断内容宽度向上传导:flex item 默认 min-width:auto,
   内部任何 nowrap/超长单词都会把卡片撑出屏幕宽度(手机上题目被顶出可视区)。 */
.card-scene { perspective: 1200px; flex: 1; display: flex; min-width: 0; }
.card-dragger {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  touch-action: pan-y;
}
.card-dragger.dragging { transition: none; }
.card-dragger.fly-left { transform: translateX(-120vw) rotate(-12deg) !important; opacity: 0; }
.card-dragger.fly-right { transform: translateX(120vw) rotate(12deg) !important; opacity: 0; }
/* 入场动画不带 scale:祖先缩放动画会让部分手机浏览器对内部文本量高失败,
   曾导致整张卡片表头塌缩成一条 4px 灰带(按钮点击进入才触发,直接打开链接正常)。 */
@keyframes card-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.study-card.entering { animation: card-in 0.22s ease-out; }
.study-card {
  position: relative;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 360px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border); /* Anki 书页风格:细边框替代阴影 */
  display: flex;
  flex-direction: column;
}
/* 3D 翻面只作用于被包裹的 faces 区域;底部操作栏作为卡片的页脚不参与翻转。
   注意:此处不能设 overflow(非 visible 会把 transform-style:preserve-3d 展平,
   导致 rotateY 翻面失效),内容由 .card-face 自身滚动承载。 */
.study-card-faces {
  position: relative;
  flex: 1;
  min-height: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.study-card.flipped .study-card-faces { transform: rotateY(180deg); }
/* 重要度只保留 2px 的细侧边提示,克制不喧宾夺主 */
.study-card.importance-1 { border-left: 2px solid var(--imp-1); }
.study-card.importance-2 { border-left: 2px solid var(--imp-2); }
.study-card.importance-3 { border-left: 2px solid var(--imp-3); }
.study-card.importance-4 { border-left: 2px solid var(--imp-4); }
.study-card.importance-5 { border-left: 2px solid var(--imp-5); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* 圆角由卡片表头(上)与操作区按钮(下)承接,faces 区保持直角 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; /* 滚动到边界即止,不触发整页回弹/下拉刷新,内容在卡内滚动 */
  scrollbar-width: none; /* Firefox 隐藏滚动条 */
  -ms-overflow-style: none; /* IE / Edge 隐藏滚动条 */
  padding: 16px 16px 20px;
  display: flex;
  flex-direction: column;
  touch-action: pan-y; /* 允许垂直滚动,避免与卡片横滑手势冲突 */
}
.card-face::-webkit-scrollbar { display: none; } /* WebKit 隐藏滚动条 */
.card-face .front,
.card-face .back { scrollbar-width: none; -ms-overflow-style: none; }
.card-face .front::-webkit-scrollbar,
.card-face .back::-webkit-scrollbar { display: none; }
@media (min-width: 720px) {
  .card-face { padding: 22px 24px; }
}
.card-face.front { background: var(--surface); }
.study-card.importance-1 .card-face.back { background: var(--imp-1-bg); }
.study-card.importance-2 .card-face.back { background: var(--imp-2-bg); }
.study-card.importance-3 .card-face.back { background: var(--imp-3-bg); }
.study-card.importance-4 .card-face.back { background: var(--imp-4-bg); }
.study-card.importance-5 .card-face.back { background: var(--imp-5-bg); }
.card-face.back { transform: rotateY(180deg); }
/* 未翻面时背面虽被 backface-visibility 藏住,但它自带 rotateY(180deg) 独立合成层,
   且与正面共面、DOM 靠后仍参与命中测试,会把正面内容上的滚轮/触摸滚动整个吞掉
   (表现为正面超高滚不动、背面却正常)。让当前不可见的面退出命中测试,
   滚动与点击只作用于可见面;pointer-events 无视觉效果,不影响翻转动画。 */
.study-card:not(.flipped) .card-face.back { pointer-events: none; }
.study-card.flipped .card-face.front { pointer-events: none; }

.card-front-question {
  font-size: 21px;
  line-height: 1.55;
  font-weight: 600;
  flex: none; /* 固定自身高度:不因选项(尤其提交后的反馈)增多而被压缩或遮挡,超高时由 .card-face 自身滚动承载 */
}
.card-front-type {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--primary);
  background: var(--primary-bg);
  white-space: nowrap;
}
.card-front-hint { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--text-3); margin-top: 12px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; flex: none; min-height: 0; }
.card-front-hint .cfh-icon { flex: none; color: var(--warn); }
.card-front-hint .cfh-icon .icon { width: 15px; height: 15px; margin-top: 2px; }
.card-back-answer { font-size: 18px; line-height: 1.7; font-weight: 600; margin-bottom: 10px; }
.card-back-explanation { font-size: 15px; line-height: 1.8; color: var(--text-2); margin-bottom: 10px; }
.card-back-label { font-size: 13px; font-weight: 700; color: var(--text-3); margin: 10px 0 4px; }
.card-back-list { list-style: none; }
.card-back-list li { font-size: 14px; padding: 3px 0 3px 18px; position: relative; color: var(--text-2); }
.card-back-list li::before { content: "–"; position: absolute; left: 4px; }

/* 卡片内共享样式(收拢内联样式,便于统一调整) */
.study-path { flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.card-action {
  margin-top: 14px;
  min-height: 0;
  /* 与 tf-btn(正确/错误)风格一致:灰色底、细边框,视觉上与选项操作统一 */
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}
.card-action:active { opacity: 0.8; }
.fill-result { margin-top: 10px; font-weight: 600; min-height: 0; }

/* 卡片内代码块格式化(参照 Anki Styling 代码块做法) */
.card-face code {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  word-break: break-word;
}
.card-face pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.card-face pre code { background: none; border: none; padding: 0; font-size: 13px; line-height: 1.5; }
.card-mnemonic {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-2);
  margin-top: 10px;
}

/* 滑动提示层 */
.swipe-banner {
  position: absolute;
  top: 14px;
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.1s;
  pointer-events: none;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
}
.swipe-banner.left { left: 14px; color: #fff; background: var(--danger); }
.swipe-banner.right { right: 14px; color: #fff; background: var(--success); }

/* 选择题选项 */
.options-list { list-style: none; margin-top: 16px; display: grid; gap: 10px; min-height: 0; flex-shrink: 0; /* 不被 .card-face 压缩,超高时由卡片自身滚动承载 */ }
.option-item {
  position: relative;
  padding: 12px 14px 12px 52px; /* 左侧为圆圈 key 预留空间 */
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  min-height: 50px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.option-item .option-key {
  position: absolute;
  left: 14px; top: 12px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.option-item .option-text { display: block; overflow-wrap: anywhere; word-break: break-word; }
.option-item:active { background: var(--surface-2); }
.option-item.selected { border-color: var(--primary); background: var(--primary-bg); }
.option-item.correct { border-color: var(--success); background: var(--success-bg); }
.option-item.wrong { border-color: var(--danger); background: var(--danger-bg); }
.option-item.disabled { pointer-events: none; }
.option-feedback { display: block; font-size: 13px; color: var(--text-2); margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--border); overflow-wrap: anywhere; word-break: break-word; }

.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; min-height: 0; }
.tf-btn {
  min-height: 56px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
}
.tf-btn.correct { border-color: var(--success); background: var(--success-bg); }
.tf-btn.wrong { border-color: var(--danger); background: var(--danger-bg); }
.tf-btn .icon { width: 18px; height: 18px; vertical-align: -3px; }
.res-ic { display: inline-flex; vertical-align: -2px; margin-right: 2px; }
.res-ic .icon { width: 15px; height: 15px; }
.res-ic.ok { color: var(--success); }
.res-ic.bad { color: var(--danger); }

.fill-input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  margin-top: 16px;
  font-size: 16px;
}
.fill-input:focus { outline: none; border-color: var(--primary); }
.answer-correct { color: var(--success); font-weight: 700; }
.answer-wrong { color: var(--danger); font-weight: 700; }

/* 学习页底部操作:作为卡片页脚;移除独立"显示答案"按钮后,正面无操作控件,页脚收起
   把完整高度让给正文(含选项),翻面展示四档评分时才展开页脚。 */
.study-card > .study-actions {
  flex-shrink: 0;
  min-height: 48px; /* 与卡片表头等高,保证上下对称 */
  display: none; /* 默认(正面)收起,不占空间、不遮挡正面尾部内容 */
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: transparent; /* 透明背景,让底部按钮圆角外的卡片弧度透出,不被白色挡住 */
  border-top: 1px solid var(--border);
  /* 不设底部边角,由评分按钮/卡面自身承担卡片圆角 */
}
.study-card.flipped > .study-actions { display: flex; }
/* 卡片高度固定,正面内容超高时在卡片内向上下滚动。用 ID 显式点名 #face-front,确保这条必定生效、不依赖其他规则。
   与背面共用同一套滚动方式。 */
#face-front,
.card-face.front {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}
/* 四个评分按钮:连排、无圆角无间距、高度撑满操作区,序号与文字同一行;首尾按钮下角承接卡片圆角 */
.study-card > .study-actions .grade-grid {
  flex: 1;
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  width: 100%;
  margin-top: 0;
}
.study-card > .study-actions .grade-grid .btn {
  flex: 1;
  min-width: 0;
  height: 100%;
  font-size: 14px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 0;
}
.study-card > .study-actions .grade-grid .btn:first-child { border-bottom-left-radius: 10px; }
.study-card > .study-actions .grade-grid .btn:last-child { border-bottom-right-radius: 10px; }
.grade-num {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
}
.btn.warn { background: var(--warn); }
.btn.info { background: var(--info); }

/* 费曼复述(学习科学:先自我输出,再对照答案) */
.feynman-box { min-height: 0;
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 4px 10px;
}
.feynman-box summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.feynman-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  min-height: 60px;
  background: var(--surface);
  color: var(--text);
}
.feynman-input:focus { outline: none; border-color: var(--primary); }
.my-note-block { margin-bottom: 6px; }
.my-note-tip { font-weight: 400; font-size: 12px; margin-left: 8px; }

.study-progress { margin-top: 10px; }
/* 学习页进度条:文字内嵌在条内,进度填充用低透明主色铺底,保证底部稳定显示 */
.study-progress .progress-bar {
  position: relative;
  height: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.study-progress .progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--primary);
  opacity: 0.16;
  border-radius: inherit;
  transition: width 0.3s;
}
.study-progress .progress-nums {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  margin-top: 0; /* 绝对定位铺满,不再叠加通用 margin */
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  z-index: 1;
}
.study-progress .progress-nums .nums-center { font-weight: 700; color: var(--primary); }

/* 学习进行中:锁定视口高度为应用式布局,卡片区内部滚动,底部工具栏常驻固定。
   移动端优先用 svh(浏览器收起/展开工具栏时都稳定显示的最小可见高度),
   保证底部进度条始终可见,不会因 100vh 过高被顶出屏幕。 */
body.studying {
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  overflow: hidden; /* 整页不滚动:meta/卡片/进度条全部固定在可视区内 */
  display: flex;
  flex-direction: column;
  padding-bottom: 0; /* 覆盖 no-tabbar 页面全局预留的底部去留白 */
}
body.studying .topbar { flex-shrink: 0; }
body.studying #study-view {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 内部不再滚动,进度条固定在底部 */
  /* 底部预留足够避让,保证进度条完整显示、不被浏览器底栏/白边压住 */
  padding: 8px 14px calc(46px + env(safe-area-inset-bottom, 0px));
}
body.studying #study-view .study-actions,
body.studying #study-view .study-progress { flex-shrink: 0; }
body.studying #study-view .card-scene,
body.studying #study-view .card-dragger { flex: 1; min-height: 0; }
/* 卡片高度随可用空间自适应:底部操作栏页脚始终在卡片内可见 */
body.studying #study-view .study-card { min-height: 0; }
/* 锁定布局下用间距替代上下边距,压缩纵向占用。
注意:touch-action 必须允许纵向(pan-y)而不能是 none——否则祖先链上的 none 会
取消 .card-face 内部的纵向滚动,手机上长内容(如很多选项)就划不动了。
页面本身仍由 overflow:hidden 锁死不滚动,纵向手势只作用于卡片内部滚动。 */
body.studying #study-view { touch-action: pan-y; overflow: hidden; }
body.studying #study-view .study-progress { margin-top: 8px; }
.progress-bar { height: 8px; background: #CBD5E1; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }
.progress-nums { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.progress-nums .nums-center { font-weight: 700; color: var(--text); }

.study-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.study-filters select {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.session-done { text-align: center; padding: 48px 16px; }
.session-done .done-icon { font-size: 48px; margin-bottom: 12px; }
.session-done h2 { font-size: 20px; margin-bottom: 8px; }
.session-done .done-sub { font-size: 13px; color: var(--text-3); margin-bottom: 4px; }
.session-done .done-stats { display: flex; justify-content: center; gap: 24px; margin: 20px 0; }
.session-done .done-stats .ds-num { font-size: 26px; font-weight: 700; }
.session-done .done-stats .ds-label { font-size: 12px; color: var(--text-3); }

/* ---------- Anki 式牌组列表(学习设置页) ---------- */
.panel-title-sub { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 8px; }
.deck-list { display: grid; gap: 10px; margin: 10px 0 12px; }
.deck-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: transform 0.12s, border-color 0.12s;
  font: inherit;
  color: var(--text);
  overflow: hidden;
}
.deck-item:active { transform: scale(0.98); border-color: var(--primary); }
/* 牌组头:徽章一行、课程标题独占下一行(最多两行),右侧"学习>"跨两行垂直居中。
   原单行布局里徽章(不换行不收缩)与"学习>"按钮会把标题挤到只剩三两个字。 */
.deck-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
}
.deck-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-bg); color: var(--primary); white-space: nowrap;
  grid-column: 1; grid-row: 1; justify-self: start;
}
.deck-title {
  font-weight: 700; font-size: 15px; line-height: 1.4;
  grid-column: 1; grid-row: 2;
  max-height: 42px; /* 15px*1.4*2 行:不用 line-clamp,用固定高度封顶两行 */
  overflow: hidden;
  overflow-wrap: anywhere;
}
.deck-go {
  font-size: 12px; color: var(--text-3); white-space: nowrap;
  grid-column: 2; grid-row: 1 / span 2;
}
.deck-counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin: 8px 0; }
.deck-counts b { font-weight: 700; }
.deck-counts .cnt-new b { color: var(--info); }
.deck-counts .cnt-due b { color: var(--warn); }
.deck-counts .cnt-done b { color: var(--success); }
.deck-bar { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.deck-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width 0.3s; }
.deck-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 2px 0 12px;
}
.deck-page-info { font-size: 13px; color: var(--text-2); }
.deck-hidden-note { font-size: 12px; color: var(--text-3); margin-top: 8px; text-align: center; }

.adv-filters {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
}
.adv-filters summary {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; user-select: none;
}
.adv-filters[open] summary { margin-bottom: 10px; }
.select-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-2); }
.select-row select { width: 130px; min-height: 40px; padding: 0 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }

/* ---------- Anki 式学习操作区 ---------- */
.queue-chips { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.queue-chips[hidden] { display: none; } /* 否则上面的 display:flex 会压过 hidden 属性,JS 的隐藏开关失效 */
.queue-chip { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.queue-chip.new { background: var(--primary-bg); color: var(--primary); }
.queue-chip.due { background: rgba(217, 119, 6, 0.14); color: var(--warn); }
.queue-chip.later { background: var(--surface-2); color: var(--text-2); }

/* 卡片表头:队列信息 + 中间知识点 + 右上角三点。固定不随翻转移动,颜色略深于卡片以示区分。 */
.card-header {
  flex-shrink: 0;
  min-height: 48px; /* 与底部操作区等高,上下对称 */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
.card-header .queue-chips { pointer-events: none; flex: none; min-width: 0; }
/* 表头中间的 study-meta:标题与路径融合成一段流式文字,自动换行。
   不用 nowrap/省略号(路径最深层的节点名会被吃掉,且手机浏览器收缩链失效时
   nowrap 宽度会把整张卡片撑出屏幕、题目被顶出可视区);
   也不用 line-clamp(手机浏览器配合动画会量高失败导致表头塌缩)。
   行内排布 + anywhere 断行,永不水平溢出,内容完整可见。 */
.card-header .study-meta {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  line-height: 1.45;
  text-align: left;
  display: block;
}
.card-header .study-meta .study-node-link { display: inline; }
.card-header .study-meta .study-path {
  display: inline;
  white-space: normal;
  overflow-wrap: anywhere;
}
.card-header .study-meta .study-node-link + .study-path::before {
  content: "· ";
  color: var(--text-3);
}
.card-header .card-dots { flex: none; }

/* 卡片右上角"三个点"按钮:位于表头右侧,始终正立、不随翻转左右移动 */
.card-dots {
  flex: none;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font: inherit;
}
.card-dots .icon { width: 20px; height: 20px; }
.card-dots:hover { background: var(--surface); color: var(--text-1); }
.card-dots:active { background: var(--surface); }
.card-menu {
  position: absolute;
  top: 48px; right: 10px; /* 锚定在卡片表头下方 */
  z-index: 8;
  min-width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--text-1);
  font: inherit; font-size: 14px; font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.card-menu-item:hover { background: var(--surface-2); }
.card-menu-item .icon { width: 16px; height: 16px; color: var(--text-2); }

/* header(topbar)里的当前卡片信息:标题优先展示,星级用"星图标 × 数量",不含题型标签 */
.topbar-card-info { display: flex; align-items: center; gap: 6px; min-width: 0; margin-left: 2px; }
.topbar-card-info[hidden] { display: none; }
.topbar-card-rating {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
}
.topbar-card-rating .icon { width: 15px; height: 15px; color: var(--warn); }

.study-actions .grade-grid .btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  border-radius: 0;
  font-size: 14px;
  line-height: 1.2;
}
.grade-interval { font-size: 11px; font-weight: 400; opacity: 0.88; }

/* ---------- 统计页 ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .bar-label { width: 86px; font-size: 13px; color: var(--text-2); flex-shrink: 0; display: flex; align-items: center; gap: 1px; }
.bar-row .bar-label .star-ic { width: 13px; height: 13px; flex: none; }
.bar-row .bar-track { flex: 1; height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 6px; min-width: 2px; }
.bar-row .bar-value { width: 64px; font-size: 13px; color: var(--text-2); text-align: right; flex-shrink: 0; }

.rank-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.rank-item:last-child { border-bottom: none; }
.rank-item .rank-no { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-item .rank-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-item .rank-rate { font-weight: 700; }

/* ---------- 登录页 ---------- */
/* 卡片用 margin:auto 居中:屏幕过矮(横屏手机等)内容超高时顶部不会被裁掉 */
.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  padding-top: 24px;
}
.auth-card {
  margin: auto;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 4px;
}
.auth-slogan { font-size: 13px; color: var(--text-3); margin-top: 6px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs .btn { flex: 1; }

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-field input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.form-field input:focus { outline: none; border-color: var(--primary); }

.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.captcha-row input:focus { outline: none; border-color: var(--primary); }
.captcha-box {
  flex: none;
  width: 132px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface-2);
}
.captcha-box svg { display: block; width: 100%; height: 100%; }
.captcha-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  color: var(--text-3);
}

.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.auth-tip { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 12px; }

/* ---------- 设置页 ---------- */
.setting-username {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}
.setting-username-icon { font-size: 22px; }
.form-field input, .captcha-row input { background: var(--surface-2); }
.card-panel form { margin-top: 4px; }

/* ---------- 用户管理页 ---------- */
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.user-row-icon { font-size: 20px; flex-shrink: 0; }
.user-row-main { flex: 1; min-width: 0; }
.user-row-name { font-size: 15px; font-weight: 700; color: var(--text); word-break: break-all; }
.user-row-self { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.user-row-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.user-role-badge {
  flex-shrink: 0;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.user-role-badge.admin { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.user-role-btn { flex-shrink: 0; }
/* 窄屏下角色徽章与按钮信息重复,隐藏徽章保证行内空间 */
@media (max-width: 480px) {
  .user-role-badge { display: none; }
}

/* ---------- 超窄屏(≤374px)适配 ---------- */
@media (max-width: 374px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .topbar-actions { flex-wrap: wrap; }
}

/* ---------- 平板/桌面适配(≥720px) ---------- */
@media (min-width: 720px) {
  .page { padding: 24px; }

  /* 顶栏内容与页面 720px 栏对齐 */
  .topbar {
    padding-left: max(16px, calc((100% - 720px) / 2 + 24px));
    padding-right: max(16px, calc((100% - 720px) / 2 + 24px));
  }

  /* 底部导航在宽屏收成居中 dock,不再整行拉伸 */
  .tabbar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(100%, 520px);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
  }
}

/* ---------- 桌面宽栏(≥1024px) ---------- */
/* 知识库双栏受益于更宽的版心 */
@media (min-width: 1024px) {
  body.page-wide .page { max-width: 960px; }
}
@media (min-width: 1056px) {
  body.page-wide .topbar {
    padding-left: max(16px, calc((100% - 960px) / 2 + 24px));
    padding-right: max(16px, calc((100% - 960px) / 2 + 24px));
  }
}

/* ---------- 快捷学习:可点击统计卡 ---------- */
.stat-box[data-href] { cursor: pointer; transition: background 0.12s ease; }
.stat-box[data-href]:hover { background: var(--surface-2); }
.stat-box[data-href]:active { background: var(--border); }
.stat-box .stat-hint { font-size: 11px; color: var(--primary); margin-top: 2px; }

/* ---------- 框架背诵 ---------- */
.fw-topic-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fw-chip.active { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.fw-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.fw-recite-count { font-size: 12px; color: var(--primary); font-weight: 600; margin-left: auto; }

.fw-tree { font-size: 14px; }
.fw-node { margin: 2px 0; }
.fw-node > .fw-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin: 4px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; user-select: none;
}
.fw-node > .fw-row:hover { background: var(--surface-2); }
.fw-node[data-depth="1"] > .fw-row {
  background: var(--primary-bg); border-color: var(--primary-bg); font-weight: 700;
}
.fw-arrow { width: 14px; text-align: center; color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.fw-node[data-depth="1"] > .fw-row .fw-arrow { color: var(--primary); }
.fw-title { flex: 1; overflow-wrap: anywhere; }
.fw-title.emphasis-high { color: var(--danger); font-weight: 600; }
.fw-title.emphasis-low { color: var(--success); }
.fw-count {
  font-size: 11px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; flex-shrink: 0;
}
.fw-edit {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  opacity: 0.55;
}
.fw-node:hover .fw-edit, .fw-edit:active { opacity: 1; color: var(--primary); background: var(--primary-bg); }
.fw-note { font-size: 12px; color: var(--text-3); margin: 0 0 4px 32px; overflow-wrap: anywhere; }
.fw-node > .fw-children {
  margin-left: 18px; padding-left: 10px;
  border-left: 2px solid var(--border);
}
.fw-node.collapsed > .fw-children { display: none; }

/* 背诵自测:遮挡待回想节点,点击揭示 */
.fw-node.fw-masked > .fw-row .fw-title,
.fw-node.fw-masked > .fw-note {
  filter: blur(6px); opacity: 0.85; transition: filter 0.15s ease;
}
.fw-node.fw-masked > .fw-row:hover .fw-title { filter: blur(6px); }

.fw-card { margin-bottom: 14px; }
.fw-meta-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.fw-card-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ---------- 知识卡片分享(生成图片) ---------- */
/* 离屏渲染容器:截图时挂到 body 之外不可见区域 */
.share-render-holder { position: fixed; left: -9999px; top: 0; z-index: -1; }

.share-card {
  background: linear-gradient(160deg, #EAF1FB 0%, #E6EDF6 100%);
  padding: 28px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  box-sizing: border-box;
}
.share-card-inner {
  background: var(--surface);
  border-radius: 20px;
  padding: 26px 28px 24px;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.14);
}
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.share-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 800; color: var(--primary);
}
.share-brand-ic { display: inline-flex; color: var(--primary); }
.share-brand-ic .icon { width: 24px; height: 24px; }
.share-brand-sub { font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: 2px; align-self: flex-end; padding-bottom: 3px; }
.share-badges { display: flex; align-items: center; gap: 6px; }
.share-badges .tag { margin-right: 0; }
.share-node-title { margin-top: 16px; font-size: 22px; font-weight: 700; line-height: 1.45; }
.share-path { margin-top: 4px; font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.share-path .icon { width: 15px; height: 15px; flex: none; }

.share-question-block {
  margin-top: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
}
.share-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: var(--primary-dark); letter-spacing: 2px; margin-bottom: 8px;
}
.share-label-ic { display: inline-flex; }
.share-label-ic .icon { width: 16px; height: 16px; color: var(--primary); }
.share-question { font-size: 20px; line-height: 1.6; font-weight: 600; }
.share-options { list-style: none; margin-top: 14px; display: grid; gap: 9px; }
.share-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}
.share-option.right { background: var(--success-bg); border-color: var(--success); font-weight: 600; }
.share-option-key {
  flex: none; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text-2);
}
.share-option.right .share-option-key { background: var(--success); border-color: var(--success); color: #fff; }
.share-option-text { flex: 1; }
.share-option-check { flex: none; color: var(--success); font-weight: 800; display: inline-flex; }
.share-option-check .icon { width: 15px; height: 15px; }
.share-hint { margin-top: 14px; font-size: 14px; color: var(--text-3); display: flex; align-items: flex-start; gap: 6px; }
.share-hint .icon { width: 16px; height: 16px; color: var(--warn); flex: none; margin-top: 2px; }

.share-answer-block {
  margin-top: 16px;
  border-radius: 16px;
  padding: 18px 20px;
  border-left: 6px solid var(--imp-3);
}
.share-answer-block.importance-1 { background: var(--imp-1-bg); border-left-color: var(--imp-1); }
.share-answer-block.importance-2 { background: var(--imp-2-bg); border-left-color: var(--imp-2); }
.share-answer-block.importance-3 { background: var(--imp-3-bg); border-left-color: var(--imp-3); }
.share-answer-block.importance-4 { background: var(--imp-4-bg); border-left-color: var(--imp-4); }
.share-answer-block.importance-5 { background: var(--imp-5-bg); border-left-color: var(--imp-5); }
.share-answer { font-size: 19px; line-height: 1.7; font-weight: 600; }
.share-answer-empty { font-weight: 400; color: var(--text-3); font-size: 15px; }
.share-explanation { font-size: 15px; line-height: 1.8; color: var(--text-2); }
.share-answer-block .share-label { margin-top: 12px; }
.share-answer-block .share-label:first-child { margin-top: 0; }
.share-list { list-style: none; display: grid; gap: 4px; }
.share-list li { display: flex; gap: 8px; font-size: 15px; color: var(--text-2); }
.share-list-dot { flex: none; color: var(--primary); font-weight: 800; }
.share-list-text { flex: 1; }
.share-mnemonic {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text-2);
  display: flex; align-items: flex-start; gap: 6px;
}
.share-mnemonic .icon { width: 17px; height: 17px; color: var(--warn); flex: none; margin-top: 2px; }
.share-foot {
  margin-top: 18px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text-3);
}
.share-foot .icon { width: 14px; height: 14px; color: var(--primary); vertical-align: -2px; }

/* 预览弹窗:放宽容器,图片可滚动查看 */
.modal-card:has(.share-preview) { max-width: 560px; }
.share-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; max-height: 60vh; overflow: auto; }
.share-preview-img {
  width: 100%; max-width: 480px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.share-preview-tip { font-size: 12px; color: var(--text-3); }


/* ================= 学习卡片:基础排版与响应式 ================= */
/* 卡片整体统一字体栈与文字渲染,保证多端一致 */
.card-face {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.card-face.front .card-front-question { color: var(--text); }
.card-face.back { color: var(--text); }

/* 手机端字号微调:窄屏下保证题干与答案可读(参照 Anki .mobile 差异化) */
@media (max-width: 480px) {
  .card-front-question { font-size: 19px; line-height: 1.5; }
  .card-front-question.md-body { font-size: 16px; }
  .card-back-answer { font-size: 17px; }
}
/* 大屏与桌面:题干略放大,留白更舒展 */
@media (min-width: 720px) {
  .card-front-question { font-size: 23px; line-height: 1.55; }
}

/* ================= 学习卡片:夜间模式适配(跟随系统) =================
   参照 Anki 的 .card.nightMode 思路:仅对学习卡片正/背面做暗色适配,
   不影响站点其余页面配色。 */
@media (prefers-color-scheme: dark) {
  body.study-mode { background: #000000; overscroll-behavior: none; }
  body.studying #study-view .study-meta { color: #9E9E9E; }

  .study-card { box-shadow: none; border-color: #333333; background: #121212; }
  .study-card > .study-actions { background: transparent; border-top-color: #333333; }
  .card-header { background: #1E1E1E; border-bottom-color: #333333; padding: 2px 12px; }
  .card-header .study-meta { color: #BDBDBD; }
  .card-header .study-meta .study-node-link { color: #4FC3F7; }
  .card-dots:hover,
  .card-dots:active { background: #242424; color: #BDBDBD; }

  .card-face.front { background: #121212; }
  .study-card.importance-1 .card-face.back { background: #1A1A1A; }
  .study-card.importance-2 .card-face.back { background: #141d29; }
  .study-card.importance-3 .card-face.back { background: #231a12; }
  .study-card.importance-4 .card-face.back { background: #261a14; }
  .study-card.importance-5 .card-face.back { background: #271515; }

  .card-face.front .card-front-question,
  .card-back-answer,
  .card-back-label { color: #E0E0E0; }
  .card-back-explanation,
  .card-back-list li,
  .option-feedback,
  .my-note-tip { color: #BDBDBD; }

  .card-face code,
  .card-face pre { background: #000000; border-color: #333333; }

  .card-front-hint,
  .card-mnemonic,
  .feynman-box,
  .fill-input,
  .tf-btn,
  .option-item,
  .option-item .option-key,
  .card-action { background: #1C1C1C; border-color: #333333; color: #E6E6E6; }

  .card-front-hint .cfh-icon { color: #FFB74D; }
  .option-item:active { background: #242424; }
  .option-item.selected { border-color: #2196F3; background: rgba(33, 150, 243, 0.16); }
  .option-item.correct { border-color: #81C784; background: rgba(129, 199, 132, 0.14); }
  .option-item.wrong { border-color: #E57373; background: rgba(229, 115, 115, 0.14); }
  .tf-btn.correct { border-color: #81C784; background: rgba(129, 199, 132, 0.12); }
  .tf-btn.wrong { border-color: #E57373; background: rgba(229, 115, 115, 0.12); }
  .fill-input:focus { border-color: #2196F3; }
  .option-feedback { border-top-color: #333333; }
}
