/* ═══════════════════════════════════
   基础 & 主题
   ═══════════════════════════════════ */
:root {
  --bg: #fbfbf4;
  --card: #ffffff;
  --primary: #84b63c;
  --primary-light: #f6fae6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #2d331a;
  --text-secondary: #7a7d6e;
  --border: #e6e8d8;
  --radius: 20px;
  --shadow: 0 1px 3px rgba(132,182,60,.05), 0 1px 2px rgba(132,182,60,.05);
  --shadow-lg: 0 10px 25px rgba(132,182,60,.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg); color: var(--text);
  background-image:
    radial-gradient(ellipse at 85% 5%, rgba(218,240,164,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 15% 95%, rgba(240,152,28,.08) 0%, transparent 50%);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* 头部 */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.header h1 {
  font-size: 18px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #a8d960);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  user-select: none;
}
.header h1:hover { opacity: .8; }
.header-spacer { flex: 1; }
.header-right { display: flex; align-items: center; gap: 10px; position: relative; }
.student-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.student-badge:hover { background: var(--primary); color: white; }
.btn-header {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
  color: var(--text-secondary); transition: all .15s;
}
.btn-header:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
#btnLogin {
  background: var(--primary); color: white; border: none;
  padding: 6px 16px; font-weight: 600;
}
#btnLogin:hover { opacity: .85; background: var(--primary); }

/* 页面容器 */
.container {
  max-width: 960px; margin: 0 auto; padding: 24px 16px;
  width: 100%; flex: 1;
}
.page { display: none; }
.page.active { display: block; }
/* 非做题页限制宽度 */
.page:not(#pagePractice) { max-width: 720px; margin: 0 auto; }
#pageReport { max-width: 900px !important; }
/* 认知能力卡片网格 */
.report-cog-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
@media (max-width: 768px) {
  .report-cog-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
  margin-bottom: 16px;
}

/* 学生选择 */
.student-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr));
  gap: 12px; margin-top: 16px;
}
.domain-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr));
  gap: 14px;
}
.student-card {
  background: var(--card); border: 2px solid var(--border);
  border-radius: 12px; padding: 16px; text-align: center;
  cursor: pointer; transition: all .15s;
}
.student-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.domain-card {
  background: var(--card); border: 2px solid var(--border);
  border-radius: 14px; padding: 20px 16px; text-align: center;
  cursor: pointer; transition: all .15s;
}
.domain-card.type-card {
  display: flex; flex-direction: column;
  min-height: 210px;
}
.domain-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.domain-card .domain-icon { font-size: 36px; margin-bottom: 8px; }
.domain-card .domain-name { font-weight: 700; font-size: 16px; color: var(--text); }
.domain-card .domain-count { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.domain-card .domain-progress { font-size: 12px; color: var(--success); margin-top: 2px; }
/* 面包屑 */
.subject-breadcrumb {
  font-size: 13px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 4px;
}
.subject-breadcrumb-link {
  color: var(--primary); cursor: pointer; font-weight: 600;
}
.subject-breadcrumb-link:hover { text-decoration: underline; }
.subject-breadcrumb-sep { color: var(--text-secondary); font-size: 16px; }
.subject-breadcrumb-current { color: var(--text-secondary); font-weight: 500; }
.student-card .avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a8d960);
  color: white; font-size: 20px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
}
.student-card .name { font-weight: 600; font-size: 14px; }
.student-card .info { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.student-card { position: relative; }

/* 管理学生列表 */
.manage-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.manage-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.manage-toggle:hover { color: var(--text); }
.manage-toggle .arrow { transition: transform .2s; font-size: 10px; }
.manage-toggle.open .arrow { transform: rotate(90deg); }
.manage-student-list {
  display: none;
  margin-top: 8px;
}
.manage-student-list.open { display: block; }
.manage-student-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}
.manage-student-row:last-child { border-bottom: none; }
.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.new-student-form {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px;
  align-items: flex-end;
}
.new-student-form input {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--card);
}
.new-student-form input:focus { outline: none; border-color: var(--primary); }
.btn {
  padding: 10px 20px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
/* 做题页 - 双栏布局 */
.practice-layout {
  display: flex;
  gap: 12px;
  height: calc(100vh - 60px - 48px); /* header + container padding */
  max-height: calc(100vh - 108px);
}
/* 左侧 — 题目列表侧栏：始终固定在左侧，窄屏自动收缩 */
.practice-sidebar {
  width: 300px;
  min-width: 200px;
  max-width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}
.practice-sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(135deg, #f5fae8, #f6fae6);
}
.practice-sidebar-header h3 {
  font-size: 14px; font-weight: 700;
  margin-bottom: 4px;
}
.practice-sidebar-header .sidebar-progress {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
/* 进度条 */
.sidebar-progress-bar-wrap {
  flex: 1; height: 6px;
  background: #e6e8d8;
  border-radius: 3px;
  overflow: hidden;
}
.sidebar-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #a8d960);
  border-radius: 3px;
  transition: width .5s ease;
}
.sidebar-progress-text {
  font-weight: 700;
  white-space: nowrap;
  font-size: 13px;
  color: var(--primary);
}
.practice-sidebar-list {
  flex: 1; overflow-y: auto;
  padding: 6px;
}
.practice-sidebar-list::-webkit-scrollbar { width: 4px; }
.practice-sidebar-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ═══ 侧栏题目项 — 儿童友好卡片 ═══ */
.sidebar-question {
  display: flex; align-items: stretch; gap: 0;
  border-radius: 14px;
  cursor: pointer; transition: all .2s ease;
  margin-bottom: 8px;
  background: #f8f9fc;
  border: 2px solid transparent;
  overflow: hidden;
  position: relative;
  box-shadow: 0 1px 3px rgba(132,182,60,.05);
}
.sidebar-question:hover {
  transform: translateX(3px);
  box-shadow: 0 3px 8px rgba(79,70,229,.08);
}
.sidebar-question.active {
  border-color: var(--primary);
  box-shadow: 0 3px 12px rgba(79,70,229,.15);
  background: #ffffff;
}

/* 左侧序号数字区域 */
.sq-number-area {
  width: 44px; min-height: 58px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 16px;
  position: relative;
  background: #f1f5f9;
  transition: all .2s;
}
.sidebar-question.active .sq-number-area {
  background: var(--primary);
  color: white;
}
.sidebar-question.status-completed .sq-number-area {
  background: #d1fae5;
  color: #059669;
}
.sidebar-question.status-attempted .sq-number-area {
  background: #fee2e2;
  color: #dc2626;
}
.sidebar-question.status-in_progress .sq-number-area {
  background: #fef3c7;
  color: #d97706;
}

/* 进度小圆点 */
.sq-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 3px;
  transition: all .2s;
}
.sq-dot.completed { background: #10b981; }
.sq-dot.in_progress { background: #f59e0b; box-shadow: 0 0 4px rgba(245,158,11,.5); }
.sq-dot.attempted { background: #ef4444; }
.sq-dot.not_started { background: #cbd5e1; }
.sq-dot.pending { background: #cbd5e1; }

/* 中间信息区 */
.sq-info {
  flex: 1; min-width: 0;
  padding: 10px 0 10px 10px;
  display: flex; flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.sq-title {
  font-size: 14px; font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-question.active .sq-title {
  color: var(--primary);
}
.sq-level-row {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}

/* ═══ 难度标签改造 — 带颜色+文字 ═══ */
.sq-level-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.sq-level-tag.level-1 { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.sq-level-tag.level-2 { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.sq-level-tag.level-3 { background: #fefce8; color: #ca8a04; border: 1px solid #fde68a; }
.sq-level-tag.level-4 { background: #fdf2f8; color: #db2777; border: 1px solid #fbcfe8; }
.sq-level-tag.level-5 { background: #f4f8e8; color: #a8d960; border: 1px solid #d4e8b0; }

.sq-level-emoji { font-size: 12px; }

/* 已完成标记 */
.sq-completed-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 700; color: #059669;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ═══ 重新做题按钮 — 显眼文字按钮 ═══ */
.sidebar-question .sq-reset {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1.5px solid #e6e8d8;
  background: #ffffff;
  color: #94a3b8; cursor: pointer;
  font-size: 11px; font-weight: 600;
  transition: all .15s;
  flex-shrink: 0;
  margin-right: 8px;
  align-self: center;
}
.sidebar-question .sq-reset:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: var(--danger);
  transform: scale(1.05);
}
.sidebar-question .sq-reset:active {
  transform: scale(0.95);
}

/* 侧栏底部状态栏 */
.sidebar-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  background: #fafbfc;
  font-size: 11px; color: var(--text-secondary);
}
.sidebar-footer .footer-status {
  display: flex; align-items: center; gap: 6px;
}
.sidebar-footer .footer-legend {
  display: flex; align-items: center; gap: 8px;
}
.sidebar-footer .legend-dot {
  display: flex; align-items: center; gap: 2px;
}
/* 右侧 — 对话区域 */
.practice-chat {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}
/* 题目标题栏 — 固定在顶部，不随对话滚动 */
.chat-question-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #f5fae8, #f6fae6);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 12px;
}
.chat-question-header .q-level {
  font-size: 12px; font-weight: 700; color: var(--primary);
  margin-bottom: 4px; letter-spacing: 0.5px;
}
.chat-question-header .q-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-bottom: 2px;
}
.chat-question-header .q-text {
  font-size: 14px; color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}
/* 即时反馈闪动图标 */
.feedback-flash {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 64px; z-index: 500; pointer-events: none;
  animation: flashPop 1.2s ease-out forwards;
}
@keyframes flashPop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.3); }
  15%  { opacity: 1; transform: translate(-50%,-50%) scale(1.3); }
  30%  { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(0.8); }
}
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 0;
  display: flex; flex-direction: column;
  gap: 16px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-bubble {
  max-width: 88%; padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px; line-height: 1.6;
  animation: msgSlideIn 0.3s ease-out;
  white-space: pre-wrap; word-break: break-word;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* 里程碑消息脉冲金边 */
@keyframes milestonePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.4); border-color: var(--warning); }
  50%      { box-shadow: 0 0 0 6px rgba(245,158,11,0); border-color: var(--warning); }
}
.chat-bubble.milestone {
  border: 2px solid var(--warning) !important;
  animation: msgSlideIn 0.3s ease-out, milestonePulse 1.2s ease-in-out 4;
  background: #fffbeb !important;
}
.chat-bubble.tutor {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
  box-shadow: var(--shadow);
}
.chat-bubble.student {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble.system {
  align-self: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 13px;
  text-align: center;
  max-width: 70%;
}
.chat-bubble.congrats {
  align-self: center;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: none;
  color: #92400e;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  max-width: 80%;
  padding: 18px;
}
.chat-input-area {
  display: flex; gap: 10px;
  padding: 12px 0;
  align-items: flex-end;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.chat-input-area textarea {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  transition: border-color .15s;
  background: var(--card);
}
.chat-input-area textarea:focus { outline: none; border-color: var(--primary); }
.chat-input-area .btn {
  height: 44px; padding: 0 20px; flex-shrink: 0;
  border-radius: 10px;
}
.chat-typing {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  display: flex; gap: 4px;
  animation: fadeIn .2s ease;
}
.chat-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
/* 题目气泡特殊样式 */
.chat-bubble.question {
  background: #f5fae8;
  border: 2px solid var(--primary);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  font-weight: 500;
}

/* 空状态 */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }

/* 报告页 */
.report-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
/* 学科 Tab 切换 */
.report-subject-tabs {
  display: flex; gap: 6px; overflow-x: auto;
  margin-bottom: 16px; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.report-subject-tabs::-webkit-scrollbar { height: 2px; }
.report-subject-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.report-subject-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 24px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; user-select: none;
  background: var(--card); border: 1.5px solid var(--border);
  color: var(--text-secondary);
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.report-subject-tab:hover { border-color: #cbd5e1; color: var(--text); }
.report-subject-tab.active {
  background: var(--primary); border-color: var(--primary);
  color: white; box-shadow: 0 2px 8px rgba(79,70,229,.2);
}
.report-subject-tab .tab-icon { font-size: 18px; }
.report-subject-tab .tab-pct {
  font-size: 11px; opacity: .75; font-weight: 500;
}
.report-subject-tab.active .tab-pct { opacity: .85; }
/* 学科内容容器 */
.report-subject-content {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  min-height: 120px;
}
.stats-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card); border-radius: 12px; padding: 16px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-number { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-correct .stat-number { color: var(--success); }
.stat-wrong .stat-number { color: var(--danger); }
.stat-pending .stat-number { color: var(--warning); }

.knowledge-map { margin-bottom: 20px; }
.knowledge-node {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  margin-bottom: 6px; border: 1px solid var(--border);
}
.node-depth-indicator { width: 3px; border-radius: 2px; align-self: stretch; }
.node-depth-0 { background: #818cf8; }
.node-depth-1 { background: #a78bfa; }
.node-depth-2 { background: #c084fc; }
.node-depth-3 { background: #e879f9; }
.node-depth-4 { background: #f472b6; }
.node-depth-5 { background: #fb7185; }
.node-label { flex: 1; font-size: 14px; font-weight: 500; }
.node-mastery-bar { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.node-mastery-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.mastery-high { background: var(--success); }
.mastery-med { background: var(--warning); }
.mastery-low { background: var(--danger); }
.node-attempts { font-size: 12px; color: var(--text-secondary); min-width: 30px; text-align: right; }

/* 变体卡片 */
.variant-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}
.variant-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.variant-header:hover { background: #f8f9fc; }
.variant-header-left { display: flex; align-items: center; gap: 8px; }
.variant-name { font-size: 14px; font-weight: 600; }
.variant-level-badge {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px;
}
.variant-level-badge.lv3 { background: #d1fae5; color: #059669; }
.variant-level-badge.lv2 { background: #fef3c7; color: #d97706; }
.variant-level-badge.lv1 { background: #fee2e2; color: #dc2626; }
.variant-level-badge.lv0 { background: #f1f5f9; color: #94a3b8; }
.variant-toggle {
  font-size: 12px; color: var(--text-secondary);
  transition: transform .2s;
}
.variant-toggle.open { transform: rotate(90deg); }
.variant-nodes {
  border-top: 1px solid var(--border);
  padding: 6px 14px 10px 14px;
  display: none;
}
.variant-nodes.open { display: block; }
.variant-node-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
}
.variant-node-row .node-label { font-size: 13px; }
.attempt-tag {
  font-size: 11px; color: var(--text-secondary);
  white-space: nowrap;
}

/* 空状态 */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }

/* ═══════════════════════════════════════
   多模态输入 — 模式切换栏 & 手写板
   ═══════════════════════════════════════ */
.input-mode-bar {
  display: flex; gap: 8px;
  padding: 8px 0;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.mode-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 16px;
  border: 2px solid var(--border); border-radius: 24px;
  background: var(--card); color: var(--text-secondary);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s;
  user-select: none; -webkit-user-select: none;
}
.mode-btn:hover { border-color: var(--primary); color: var(--primary); }
.mode-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* 手写区域 — Drawer 式折叠设计 */
.draw-area {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--card);
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.draw-area.open {
  max-height: 380px;
}

/* 折叠态工具条 — 始终可见 */
.draw-collapsed-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.draw-collapsed-bar .nav-btn {
  min-width: 56px; height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .1s;
  white-space: nowrap;
}
.draw-collapsed-bar .nav-btn:hover {
  border-color: var(--primary); background: var(--primary-light);
}
.draw-collapsed-bar .nav-btn.primary {
  background: var(--primary); border-color: var(--primary); color: white;
}
.draw-collapsed-bar .nav-btn.primary:hover {
  opacity: .85;
}
.draw-collapsed-bar .nav-btn.disabled {
  opacity: .35; cursor: not-allowed;
}
.draw-collapsed-bar .nav-btn.disabled:hover {
  border-color: var(--border); background: var(--card);
}

/* 展开后的工具条 + 画板 + 底部栏 */
.draw-body {
  display: flex; flex-direction: column;
  max-height: 340px;
  overflow: hidden;
}
.draw-tools {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.tool-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .1s;
}
.tool-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.tool-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.tool-color { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; padding: 2px; }
.draw-area canvas {
  flex: 1; min-height: 120px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}
.draw-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.draw-footer .btn-collapse {
  margin-right: auto;
}

/* ═══════════════════════════════════════
   键盘区 — Drawer 式折叠（跟手写板一致）
   ═══════════════════════════════════════ */
.typing-drawer {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--card);
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.typing-drawer.open {
  max-height: 260px;
}
.typing-body {
  display: flex; flex-direction: column;
  gap: 12px;
  padding: 16px 12px;
  overflow: hidden;
}
.typing-body .typing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.typing-body .typing-header span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.typing-body textarea {
  width: 100%;
  min-height: 70px;
  max-height: 150px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  background: var(--bg);
  transition: border-color .15s;
}
.typing-body textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.typing-body .typing-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.typing-card .typing-actions .btn { height: 44px; padding: 0 24px; }

/* 语音录音脉冲动画 */
@keyframes voicePulse {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  70% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}
.nav-btn.recording {
  background: #ef4444 !important; color: white !important; border-color: #ef4444 !important;
  animation: voicePulse 1.2s infinite;
}
/* 聊天中的音频气泡 */
.chat-audio-player {
  display: flex; align-items: center; gap: 8px;
}
.chat-audio-player audio {
  height: 36px; max-width: 240px;
}
.chat-audio-label {
  font-size: 13px; color: var(--text-secondary);
}

/* 手写缩略图气泡 */
.img-bubble-student {
  max-width: 200px;
  max-height: 160px;
  border-radius: 12px;
  cursor: pointer;
  border: 2px solid var(--primary);
  display: block;
  background: #fff;
  transition: transform .15s;
}
.img-bubble-student:hover { transform: scale(1.03); }

/* 图片预览遮罩 */
.img-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 999;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.img-overlay.open { display: flex; }
.img-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}

/* iPad 下手写区更大 — 至少半个屏幕高度 */
@media (min-width: 769px) and (max-width: 1024px) {
  .draw-area.open { max-height: 55vh; }
  .draw-body { max-height: calc(55vh - 40px); }
  .draw-area canvas { min-height: 300px; }
  .mode-btn { padding: 8px 16px; font-size: 14px; }
  .tool-btn { width: 44px; height: 44px; font-size: 18px; }
  .draw-collapsed-bar .nav-btn { height: 44px; padding: 0 16px; font-size: 16px; }
  .tool-color { width: 44px; height: 44px; }
}

/* ═══════════════════════════════════════
   手机侧栏 — 浮动抽屉
   ═══════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  opacity: 0;
  transition: opacity .25s ease;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ═══════════════════════════════════════
   通用模态框
   ═══════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 300;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn .2s ease;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px 20px;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  animation: modalSlideUp .2s ease;
  text-align: center;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #2d331a;
  margin-bottom: 12px;
  line-height: 1.4;
}
.modal-body {
  font-size: 14px;
  color: #7a7d6e;
  margin-bottom: 24px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.modal-btn {
  flex: 1;
  max-width: 140px;
  padding: 10px 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s ease;
}
.modal-btn-cancel {
  background: #f1f5f9;
  color: #475569;
}
.modal-btn-cancel:hover { background: #e6e8d8; }
.modal-btn-confirm {
  background: #ef4444;
  color: #fff;
}
.modal-btn-confirm:hover { background: #dc2626; }
.modal-btn-primary {
  background: var(--primary);
  color: #fff;
}
.modal-btn-primary:hover { background: var(--primary-dark, #4338ca); }

/* 登录/注册 */
.auth-input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; outline: none; transition: border-color .15s;
  box-sizing: border-box;
}
.auth-input:focus { border-color: var(--primary); }
.password-wrapper { position: relative; display: flex; align-items: center; }
.password-wrapper .auth-input { padding-right: 36px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  cursor: pointer; font-size: 16px; user-select: none; opacity: .6; line-height: 1;
}
.pw-toggle:hover { opacity: 1; }
.auth-link { color: var(--primary); cursor: pointer; font-size: 13px; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-error { color: #dc2626; font-size: 13px; margin-top: 4px; display: none; }
.auth-error.show { display: block; }
.user-dropdown {
  position: absolute; top: 100%; right: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
  min-width: 120px; z-index: 200; display: none;
}
.user-dropdown.show { display: block; }
.user-dropdown-item {
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  color: var(--text-primary); display: block; width: 100%;
  border: none; background: none; text-align: left;
}
.user-dropdown-item:hover { background: var(--primary-light); color: var(--primary); }

/* 登录/注册弹窗 */
.auth-actions { flex-direction: column; align-items: stretch; gap: 8px; }
.auth-submit-btn { max-width: none; width: 100%; padding: 12px 0; font-size: 16px; }

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.btn-hamburger {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px; height: 40px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  transition: all .15s;
}
.btn-hamburger:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-hamburger:active { transform: scale(.92); }
#learnHamburger { display: none; }

/* ═══════════════════════════════════════
   iPad / 平板适配（768-1024px）
   竖屏时侧栏太宽，缩小但保持双栏布局
   ═══════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
  .container { padding: 20px 14px; max-width: 100%; }

  /* 做题页：缩小侧栏宽度，保持双栏 */
  .practice-sidebar {
    width: 220px;
    min-width: 180px;
    max-width: 260px;
  }
  .practice-layout {
    height: calc(100vh - 60px - 40px);
    max-height: calc(100vh - 100px);
    gap: 10px;
  }

  /* 侧栏题目项：加大触摸区域 */
  .sidebar-question { min-height: 56px; margin-bottom: 10px; }
  .sq-number-area { width: 48px; min-height: 56px; font-size: 16px; }
  .sq-title { font-size: 14px; }

  /* 聊天区域 */
  .chat-question-header { padding: 12px 16px; margin-bottom: 10px; }
  .chat-question-header .q-text { font-size: 15px; }
  .chat-bubble { font-size: 15px; max-width: 90%; }
  .chat-messages { padding: 12px 0; gap: 14px; }

  /* 输入区域触屏优化 */
  .chat-input-area { padding: 10px 0; gap: 10px; }
  .chat-input-area textarea {
    min-height: 48px; font-size: 16px;
    padding: 12px 14px;
  }
  .chat-input-area .btn {
    height: 48px; padding: 0 20px;
    font-size: 15px;
  }

  /* 卡片网格：竖屏下2列更合理 */
  .student-grid { grid-template-columns: repeat(2, 1fr); }
  .domain-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }

  /* 非做题页限制宽度 */
  .page:not(#pagePractice) { max-width: 660px; }

  /* 手机端 hamburger / 浮动抽屉在 iPad 上不启用 */
  .btn-hamburger { display: none; }
  .chat-topbar { display: none !important; }

  /* 输入按钮：文字变长后保持可读 */
  .draw-collapsed-bar .nav-btn { min-width: auto; padding: 0 14px; font-size: 14px; }

  /* ═══════════════════════════════════════
     学习页 — iPad 适配
   ═══════════════════════════════════════ */
  .learn-layout {
    height: calc(100vh - 60px - 40px);
    max-height: calc(100vh - 100px);
    gap: 0;
  }
  .learn-sidebar {
    width: 180px;
    min-width: 140px;
  }
  .learn-sidebar-item { font-size: 12px; padding: 8px 10px; }
  .learn-section-header {
    padding: 18px 28px 12px 28px;
    font-size: 20px;
  }
  .learn-section-body { padding: 0 28px 28px 28px; }
  .learn-main h2 { font-size: 18px; }
  .learn-main h3 { font-size: 15px; margin-top: 22px; }
  .learn-main p { font-size: 13px; }
  .learn-main img { border-radius: 10px; }
  .learn-main .learn-cta { margin: 22px 28px 32px 28px; padding: 11px 24px; font-size: 14px; }
}

/* 响应式（手机端） */
@media (max-width: 768px) {
  .container { padding: 12px 10px; }
  .card { padding: 14px; }
  .main-question-text { font-size: 16px; padding: 14px; }
  .main-question-title { font-size: 18px; }
  .stats-grid { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .student-grid { grid-template-columns: repeat(2,1fr); }

  .btn-hamburger { display: flex; }

  /* 做题页 — 手机端：侧栏变浮动抽屉 */
  .practice-layout {
    flex-direction: column;
    height: calc(100vh - 56px - 24px);
    max-height: calc(100vh - 80px);
  }

  .practice-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 300px;
    max-width: 80vw;
    min-width: 0;
    z-index: 210;
    border-radius: 0;
    border: none;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .practice-sidebar.open { transform: translateX(0); }

  .practice-sidebar-header { padding: 14px 14px 10px; }
  .practice-sidebar-list { padding: 4px; }

  .practice-chat {
    min-height: 0;
  }

  /* 聊天区域顶部导航行：汉堡按钮 + 题目标题 */
  .chat-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-bottom: 10px;
  }
  .chat-topbar-title {
    flex: 1; min-width: 0;
    font-size: 14px; font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chat-topbar .btn-hamburger { display: flex; }

  .chat-question-header { padding: 10px 14px; margin-bottom: 10px; }
  .chat-question-header .q-text { font-size: 14px; }
  .chat-question-header .q-title { font-size: 13px; }
  .chat-messages { padding: 8px 0; gap: 12px; }
  .chat-bubble {
    max-width: 92%;
    padding: 10px 14px;
    font-size: 15px;  /* iPhone 12 可读字号 */
    line-height: 1.6;
    border-radius: 16px;
  }
  .chat-input-area { padding: 10px 0; gap: 8px; }
  .chat-input-area textarea {
    font-size: 16px; /* iOS 防止自动缩放 */
    min-height: 48px;
    padding: 12px 14px;
  }
  .chat-input-area .btn {
    height: 48px; padding: 0 18px;
    font-size: 15px;
  }

  /* 侧栏题目项 — 更大触摸区域 */
  .sidebar-question {
    margin-bottom: 10px;
    min-height: 52px;
  }
  .sq-number-area { width: 48px; min-height: 52px; }
  .sq-title { font-size: 14px; }
  .sq-level-tag { font-size: 11px; padding: 3px 10px; }

  /* 返回/切换按钮 */
  .header { padding: 8px 10px; gap: 8px; }
  .header h1 { font-size: 15px; }
  .header-right { gap: 6px; }
  .btn-header { padding: 5px 8px; font-size: 11px; }
  .student-badge { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }

  /* ═══════════════════════════════════════
     学习页 — 手机端适配
     侧栏变为浮动抽屉 + 遮罩
   ═══════════════════════════════════════ */
  .learn-layout {
    flex-direction: column;
    height: calc(100vh - 56px - 24px);
    max-height: calc(100vh - 80px);
    position: relative;
  }
  .learn-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 300px;
    max-width: 80vw;
    min-width: 0;
    z-index: 210;
    border-radius: 0;
    border: none;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .learn-sidebar.open { transform: translateX(0); }
  .learn-sidebar-header { padding: 14px 14px 10px; }
  .learn-sidebar-list { padding: 4px; }
  .learn-sidebar-item { font-size: 13px; padding: 10px 12px; margin-bottom: 4px; }

  /* 遮罩 */
  .learn-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 200;
    background: rgba(0,0,0,.35);
    animation: fadeIn .2s;
  }
  .learn-sidebar-overlay.show { display: block; }

  /* hamburger — 靠左浮动 */
  #learnHamburger {
    display: flex;
    position: sticky;
    top: 0; left: 0;
    z-index: 11;
    margin-bottom: 4px;
    flex-shrink: 0;
  }

  .learn-main {
    margin-left: 0;
    min-height: 0;
  }
  .learn-section-header {
    padding: 16px 18px 12px 18px;
    font-size: 18px;
    margin-bottom: 14px;
  }
  .learn-section-body { padding: 0 18px 24px 18px; }
  .learn-main h2 { font-size: 17px; }
  .learn-main h3 { font-size: 15px; margin-top: 20px; padding: 5px 12px; }
  .learn-main h4 { font-size: 13px; }
  .learn-main p { font-size: 14px; line-height: 1.7; }
  .learn-main ul, .learn-main ol { font-size: 14px; margin: 4px 0 10px 18px; }
  .learn-main img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 12px 0;
  }
  .learn-main pre {
    padding: 14px 16px;
    font-size: 12px;
    margin: 12px 0;
  }
  .learn-main blockquote {
    margin: 12px 0;
    padding: 10px 14px;
    font-size: 13px;
  }
  .learn-main .learn-cta {
    margin: 20px 28px 28px 28px;
    padding: 12px 20px;
    font-size: 14px;
    width: auto;
  }
  .learn-breadcrumb { padding: 0 2px; font-size: 11px; }
  .learn-breadcrumb-current { font-size: 11px; }
}

@media (max-width: 420px) {
  .practice-sidebar { width: 85vw; }
  .sq-title { font-size: 13px; }
  .chat-bubble { font-size: 14px; }
  .draw-collapsed-bar .nav-btn { min-width: auto; padding: 0 10px; font-size: 13px; }
  .learn-sidebar { width: 85vw; }
  .learn-section-header { padding: 14px 14px 10px 14px; font-size: 16px; }
  .learn-section-body { padding: 0 14px 20px 14px; }
  .learn-main p { font-size: 14px; }
}
/* 题目列表（弃用，侧栏版见上方） */
/* 学习页 */
.learn-layout {
  display: flex; gap: 0; height: calc(100vh - 60px - 48px);
  max-height: calc(100vh - 108px);
}
.learn-sidebar {
  width: 200px; min-width: 160px; flex-shrink: 0;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.learn-sidebar-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.learn-sidebar-header h3 { font-size: 13px; font-weight: 700; }
.learn-sidebar-list {
  flex: 1; overflow-y: auto; padding: 6px;
}
.learn-sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: all .15s;
  margin-bottom: 2px; font-size: 12px;
  color: var(--text-secondary);
}
.learn-sidebar-item:hover { background: var(--primary-light); color: var(--text); }
.learn-sidebar-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.learn-main {
  flex: 1; overflow-y: auto; padding: 0;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  margin-left: 12px;
}
.learn-main h2 {
  font-size: 20px; font-weight: 700; margin-bottom: 16px;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
}
.learn-main h3 {
  font-size: 17px; font-weight: 700; margin-top: 28px; margin-bottom: 8px;
  color: var(--text);
  padding: 6px 14px;
  background: linear-gradient(90deg, var(--primary-light), transparent);
  border-radius: 6px;
}
.learn-main h4 {
  font-size: 14px; font-weight: 600; margin-top: 16px; margin-bottom: 6px;
  color: var(--text);
}
.learn-main p { line-height: 1.8; margin-bottom: 10px; color: var(--text-secondary); font-size: 13px; }
.learn-main ul, .learn-main ol { margin: 6px 0 12px 22px; line-height: 1.8; font-size: 13px; color: var(--text-secondary); }
.learn-main li { margin-bottom: 4px; }
.learn-main li::marker { color: var(--primary); }
.learn-main code {
  background: #f1f5f9; padding: 2px 7px; border-radius: 4px;
  font-size: 13px; color: #a8d960;
}
.learn-main pre {
  background: #2d331a; color: #e6e8d8;
  padding: 20px 24px; border-radius: 12px;
  overflow-x: auto; margin: 16px 0;
  font-size: 13px; line-height: 1.7;
  border: 1px solid #2d331a;
  font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
}
.learn-main pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.learn-main blockquote {
  margin: 16px 0; padding: 12px 16px;
  background: #fef9ef; border-left: 4px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  color: #92400e; font-size: 13px; line-height: 1.7;
}
.learn-main blockquote strong { color: #92400e; }
.learn-main .learn-cta {
  display: flex; align-items: center; justify-content: center;
  margin: 28px 40px 36px 40px; padding: 12px 28px;
  background: linear-gradient(135deg, var(--primary), #a8d960);
  color: white; gap: 8px;
  border-radius: 12px; font-weight: 700; cursor: pointer;
  font-size: 15px; transition: all .2s ease;
  box-shadow: 0 4px 14px rgba(79,70,229,.3);
  letter-spacing: .3px;
  position: relative;
}
.learn-main .learn-cta::before {
  content: '';
  position: absolute; top: -16px; left: 0; right: 0;
  height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.learn-main .learn-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,70,229,.45);
}
.learn-main .learn-cta:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}

/* 学习内容主体 */
.learn-section-body {
  padding: 0 40px 40px 40px;
}
.learn-section-body ol { list-style: none; }

/* 变体标题头 — 固定在最上方 */
.learn-section-header {
  font-size: 22px; font-weight: 700; color: var(--text);
  padding: 24px 40px 14px 40px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--primary);
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  isolation: isolate;
}

.learn-breadcrumb {
  font-size: 12px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 4px;
}
.learn-breadcrumb-link { color: var(--primary); cursor: pointer; font-weight: 600; }
.learn-breadcrumb-link:hover { text-decoration: underline; }
.learn-breadcrumb-sep { color: var(--text-secondary); font-size: 14px; }
.learn-breadcrumb-current { color: var(--text-secondary); font-weight: 500; font-size: 12px; }

/* ═══════════════════════════════════════
   交互式学习步骤
   ═══════════════════════════════════════ */
.learn-steps {
  display: flex; flex-direction: column;
  height: 100%;
}
.learn-steps-sidebar { display: none; }
.learn-steps-content {
  flex: 1; display: flex; flex-direction: column;
  padding: 0;
}

/* 步骤导航点 */
.step-dots {
  display: flex; align-items: center; gap: 4px;
  padding: 16px 28px 8px;
  border-bottom: 1px solid var(--border);
}
.step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--step-pending, #d4d8c8);
  cursor: pointer; transition: all .3s;
}
.step-dot.done { background: var(--primary); }
.step-dot.active { background: var(--warning); transform: scale(1.3); }

/* 步骤容器 */
.learn-step-card {
  display: none;
  flex: 1; overflow-y: auto;
  padding: 20px 28px 24px;
  animation: stepFadeIn .35s ease;
}
.learn-step-card.active { display: block; }
@keyframes stepFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-header {
  margin-bottom: 16px;
}
.step-header .step-num {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 2px;
}
.step-header h2 {
  font-size: 20px; font-weight: 700;
  margin-bottom: 4px;
  border: none; padding: 0;
}
.step-header p {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
}

/* 翻牌卡片 */
.flip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.flip-card {
  perspective: 600px;
  height: 110px;
  cursor: pointer;
}
.flip-card-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 12px;
  backface-visibility: hidden;
  text-align: center;
  font-size: 13px;
}
.flip-card-front {
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.flip-card-front:hover { background: #eaf3d4; }
.flip-card-back {
  background: var(--card);
  border: 2px solid var(--primary);
  transform: rotateY(180deg);
  line-height: 1.5;
  color: var(--text);
}

/* 讲解区域组件 */
.step-explanation-text {
  font-size: 15px; line-height: 1.8;
  margin: 12px 0;
  color: var(--text);
}
.step-explanation-text strong { color: var(--primary); font-weight: 700; }
.step-explanation-text em { font-style: italic; color: var(--text-secondary); }
.step-explanation-text code {
  background: #f0f2e6; padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: 'Menlo', 'Consolas', monospace;
}
.step-explanation-text br { content: ''; display: block; margin: 4px 0; }

.step-highlight {
  display: block;
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 0 10px 10px 0;
  font-size: 14px; font-weight: 600;
  color: var(--text);
  line-height: 1.6;
}

.step-formula {
  font-size: 16px; font-weight: 700;
  color: var(--primary);
  margin: 12px 0;
  padding: 14px;
  background: var(--primary-light);
  border-radius: 10px;
  text-align: center;
  line-height: 1.8;
  white-space: pre-line;
}

.step-image {
  margin: 16px 0;
  text-align: center;
}
.step-image img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* AI 气泡 */
.ai-bubble {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
  display: flex; gap: 10px;
  align-items: flex-start;
  box-shadow: 0 2px 8px rgba(245,158,11,.08);
}
.ai-bubble .avatar {
  width: 28px; height: 28px; min-width: 28px;
  background: var(--warning);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.ai-bubble .text { font-size: 13px; line-height: 1.6; color: #92400e; }

/* 互动验证 */
.quiz-area { margin: 12px 0; }
.quiz-question {
  font-size: 15px; font-weight: 600;
  margin-bottom: 12px;
}
.quiz-formula {
  text-align: center; font-size: 18px;
  margin-bottom: 14px;
  padding: 14px; background: var(--primary-light);
  border-radius: 10px;
}
.quiz-option {
  display: flex; align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .2s;
  font-size: 14px;
}
.quiz-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.quiz-option .check {
  width: 22px; height: 22px; min-width: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  transition: all .2s;
}
.quiz-option.correct {
  border-color: var(--success);
  background: #ecfdf5;
}
.quiz-option.correct .check { border-color: var(--success); background: var(--success); color: white; }
.quiz-option.wrong {
  border-color: var(--danger);
  background: #fef2f2;
}
.quiz-option.wrong .check { border-color: var(--danger); background: var(--danger); color: white; }

.quiz-feedback {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px; line-height: 1.6;
  display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.quiz-feedback.wrong { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* 小结 */
.summary-box {
  background: linear-gradient(135deg, var(--primary-light), #f0f7e0);
  border-radius: 14px;
  padding: 20px;
  margin: 12px 0;
  border: 1px solid var(--border);
}
.summary-box h3 {
  font-size: 15px; font-weight: 700;
  margin-bottom: 10px; margin-top: 0;
  display: flex; align-items: center; gap: 6px;
  background: none; padding: 0;
}
.summary-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0;
  font-size: 13px; line-height: 1.5;
}
.summary-item .icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* 步骤底部按钮 */
.step-footer {
  display: flex; justify-content: space-between;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.btn-step {
  padding: 8px 20px; border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-step:active { transform: scale(.97); }
.btn-step-primary { background: var(--primary); color: white; }
.btn-step-primary:hover { background: #7aaa30; }
.btn-step-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-step-outline {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-step-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-step-success { background: var(--success); color: white; }
.btn-step-success:hover { opacity: .9; }

.domain-card-actions {
  display: flex; gap: 8px; justify-content: center;
  margin-top: auto; padding-top: 10px;
}
.domain-card-btn {
  padding: 6px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all .15s;
  border: none;
}
.domain-card-btn.learn { background: #f6fae6; color: var(--primary); }
.domain-card-btn.learn:hover { background: var(--primary); color: white; }
.domain-card-btn.practice { background: var(--primary); color: white; }
.domain-card-btn.practice:hover { opacity: .85; }

/* ═══════════════════════════════════
   诊断页手写板样式
   ═══════════════════════════════════ */
#diagInputArea .draw-collapsed-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
#diagInputArea .draw-collapsed-bar .nav-btn {
  min-width: 56px; height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .1s;
  white-space: nowrap;
}
#diagInputArea .draw-collapsed-bar .nav-btn:hover {
  border-color: var(--primary); background: var(--primary-light);
}
#diagInputArea {
  display: none;
}

/* 诊断页手写板 — iPad 适配 */
@media (min-width: 769px) and (max-width: 1024px) {
  #diagInputArea .draw-area.open { max-height: 55vh; }
  #diagInputArea .draw-body { max-height: calc(55vh - 40px); }
  #diagInputArea canvas { min-height: 300px; }
  #diagInputArea .draw-collapsed-bar .nav-btn { height: 44px; padding: 0 16px; font-size: 16px; }
}

/* 诊断页手写板 — 手机适配 */
@media (max-width: 768px) {
  #diagInputArea .draw-collapsed-bar .nav-btn { min-width: auto; padding: 0 12px; font-size: 14px; }
  #diagInputArea canvas { min-height: 180px; }
}

/* 小屏手机 */
@media (max-width: 420px) {
  #diagInputArea .draw-collapsed-bar .nav-btn { min-width: auto; padding: 0 10px; font-size: 13px; }
}

