@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Noto+Sans+SC:wght@400;500;600;700;800;900&display=swap');

/* =========================================================
   题玉 TiYu · UI 主题
   主色：indigo→violet 渐变，浅色玻璃卡片，深色文字
   ========================================================= */

:root {
  --c-indigo: #6366F1;
  --c-violet: #A855F7;
  --c-emerald: #10B981;
  --c-emerald-light: #34D399;
  --c-amber: #F59E0B;
  --c-amber-light: #FBBF24;
  --c-rose: #F43F5E;
  --c-orange: #EA580C;

  --c-bg: #F8FAFC;
  --c-surface: #FFFFFF;
  --c-surface-2: rgba(255, 255, 255, 0.7);
  --c-border: #E2E8F0;
  --c-border-soft: #EEF2F6;

  --c-text: #0F172A;
  --c-text-2: #475569;
  --c-text-mute: #94A3B8;

  --grad-primary: linear-gradient(135deg, #6366F1 0%, #A855F7 100%);
  --grad-success: linear-gradient(135deg, #10B981 0%, #34D399 100%);
  --grad-warn: linear-gradient(135deg, #F59E0B 0%, #FBBF24 100%);
  --grad-rose: linear-gradient(135deg, #F43F5E 0%, #FB7185 100%);
  --grad-card: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(168,85,247,0.08) 100%);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -16px rgba(99, 102, 241, 0.18), 0 4px 12px -2px rgba(15, 23, 42, 0.05);
  --shadow-glow: 0 0 0 1px rgba(99,102,241,0.08), 0 20px 60px -20px rgba(99,102,241,0.35);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Noto Sans SC', -apple-system, "Helvetica Neue", system-ui, sans-serif;
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(900px circle at 0% 0%, rgba(99,102,241,0.10), transparent 60%),
    radial-gradient(800px circle at 100% 100%, rgba(168,85,247,0.10), transparent 60%),
    var(--c-bg);
  min-height: 100vh;
}

a {
  color: var(--c-indigo);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.01em; color: var(--c-text); }
h1 { font-size: 28px; margin: 0; line-height: 1.2; }
h2 { font-size: 22px; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 0 0 10px; }
p { line-height: 1.65; color: var(--c-text-2); margin: 0 0 8px; }
small { color: var(--c-text-mute); }

code {
  background: #F1F5F9;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.muted { color: var(--c-text-mute); }
.small { font-size: 12px; }

/* =========================================================
   App shell
   ========================================================= */

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  color: var(--c-text);
  text-decoration: none;
  border-bottom: 1px solid var(--c-border-soft);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--grad-primary);
  color: white;
  font-weight: 900;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px -8px rgba(99,102,241,0.5);
}
.brand strong {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--c-text-mute);
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--c-text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover {
  background: var(--c-border-soft);
  color: var(--c-text);
}
.nav a.active {
  background: var(--grad-card);
  color: var(--c-indigo);
  font-weight: 700;
}

/* =========================================================
   Main + Topbar
   ========================================================= */

.main {
  padding: 28px 36px 60px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--c-border-soft);
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-indigo);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--grad-card);
  color: var(--c-indigo);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.user-pill:hover { text-decoration: none; }
.grade-pill { background: linear-gradient(135deg, #ECFDF5, #EEF2FF); border: 1px solid #C7D2FE; }
.grade-pill.warn {
  background: linear-gradient(135deg, #FEF3C7, #FFEDD5);
  color: #B45309;
  border-color: #FCD34D;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 28px;
}

/* AI 模块 */
.ai-organize-panel {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(168,85,247,0.06));
  border-color: #C7D2FE;
  margin-bottom: 18px;
}
.ai-organize-panel textarea {
  width: 100%;
  font-family: inherit;
}

/* AI 助手折叠面板（替代旧 panel） */
.ai-organize-details {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(168,85,247,0.06));
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.ai-organize-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  user-select: none;
}
.ai-organize-summary::-webkit-details-marker { display: none; }
.ai-summary-title { font-weight: 800; color: var(--c-indigo); }
.ai-summary-hint { color: var(--c-text-mute); font-size: 12px; flex: 1; }
.ai-summary-chev {
  color: var(--c-text-mute);
  font-size: 14px;
  transition: transform 0.2s;
}
.ai-organize-details[open] .ai-summary-chev { transform: rotate(180deg); }
.ai-organize-content {
  padding: 0 16px 16px;
}
.ai-organize-content textarea {
  width: 100%;
  font-family: inherit;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
}

/* 移动端隐藏：电脑专用的辅助 CTA */
@media (max-width: 720px) {
  .hide-on-mobile { display: none !important; }
  .ai-summary-hint { display: none; }  /* 手机屏幕窄，隐藏说明 */
}

/* AI 自动识别横幅 */
.ai-auto-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  margin: 0 0 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #EEF2FF, #FAF5FF);
  border: 1px solid #C7D2FE;
  color: #4338CA;
  font-size: 14px;
  font-weight: 600;
  flex-wrap: wrap;
}
.ai-auto-banner small { color: #6366F1; font-weight: 500; font-size: 12px; }
.ai-auto-banner.ok {
  background: linear-gradient(135deg, #ECFDF5, #F0FDF4);
  border-color: #6EE7B7;
  color: #065F46;
}
.ai-auto-banner.ok small { color: #047857; }
.ai-auto-banner.err {
  background: linear-gradient(135deg, #FEF2F2, #FFE4E6);
  border-color: #FECACA;
  color: #991B1B;
}
.ai-auto-banner.err small { color: #BE123C; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #C7D2FE;
  border-top-color: #6366F1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Dashboard 开始今日复习大按钮 */
.review-cta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  background: var(--grad-primary);
  color: white;
  box-shadow: 0 16px 32px -10px rgba(99,102,241,0.40);
  position: relative;
  overflow: hidden;
}
.review-cta::before {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.review-cta::after {
  content: '';
  position: absolute;
  right: 40px; bottom: -60px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.review-cta-left { position: relative; }
.review-cta-eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
  opacity: 0.85;
  margin: 0;
  text-transform: uppercase;
}
.review-cta-count {
  font-size: 32px;
  font-weight: 900;
  margin: 4px 0 2px;
  letter-spacing: -0.02em;
}
.review-cta-hint {
  font-size: 13px;
  opacity: 0.9;
  margin: 0;
}
.review-cta-btn {
  position: relative;
  background: white !important;
  color: var(--c-indigo) !important;
  font-size: 15px;
  padding: 14px 22px;
  box-shadow: 0 8px 18px -6px rgba(0,0,0,0.2);
  white-space: nowrap;
}
.review-cta-btn:hover { transform: translateY(-2px); }

/* 复习模式横幅（在 question_detail 顶部） */
.review-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--grad-card);
  border: 1px solid #C7D2FE;
  color: var(--c-indigo);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
.review-banner-skip {
  font-size: 12px;
  color: var(--c-text-mute);
  text-decoration: none;
  font-weight: 600;
}
.review-banner-skip:hover { color: var(--c-indigo); text-decoration: none; }

@media (max-width: 720px) {
  .review-cta { flex-direction: column; align-items: stretch; text-align: center; }
  .review-cta-btn { width: 100%; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.ai-block summary {
  cursor: pointer;
  font-weight: 700;
  padding: 6px 0;
  list-style: none;
  color: var(--c-indigo);
}
.ai-block summary::-webkit-details-marker { display: none; }
.ai-block summary::before {
  content: '▸';
  margin-right: 6px;
  display: inline-block;
  transition: transform 0.15s;
}
.ai-block[open] summary::before { transform: rotate(90deg); }

.derived-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.derived-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-indigo);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.derived-tag {
  display: inline-block;
  background: var(--grad-card);
  color: var(--c-indigo);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 999px;
  margin: 0 0 8px;
}
.derived-content { font-size: 14px; color: var(--c-text); }
.derived-card details { margin-top: 8px; }
.derived-card details summary { font-size: 12px; color: var(--c-text-mute); cursor: pointer; }
.derived-card.derived-correct { border-left-color: #10B981; background: linear-gradient(180deg, #ECFDF5 0%, #FFFFFF 60%); }
.derived-card.derived-wrong { border-left-color: #EF4444; background: linear-gradient(180deg, #FEF2F2 0%, #FFFFFF 60%); }
.derived-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
}
.derived-badge.ok { background: #D1FAE5; color: #065F46; }
.derived-badge.err { background: #FEE2E2; color: #991B1B; }
.derived-badge.wait { background: #F1F5F9; color: var(--c-text-mute); }
.derived-grade-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.derived-grade-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
}
.derived-feedback {
  margin-top: 8px;
}
.derived-feedback summary { color: var(--c-indigo); }
.derived-feedback pre {
  margin-top: 6px;
  padding: 10px;
  background: var(--c-border-soft);
  border-radius: 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============ 图片编辑器 (Cropper.js) ============ */
.image-editor {
  margin-top: 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.image-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.image-editor-toolbar button {
  border: 1px solid var(--c-border);
  background: white;
  color: var(--c-text);
  font-size: 14px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 38px;
}
.image-editor-toolbar button:hover { background: var(--c-border-soft); }
.image-editor-toolbar .btn-edit-save {
  margin-left: auto;
  background: var(--grad-primary);
  color: white;
  border: 0;
  padding: 6px 16px;
  box-shadow: 0 6px 14px -4px rgba(99,102,241,0.5);
}
.image-editor-canvas {
  background: #0F172A;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 480px;
}
.image-editor-canvas img {
  display: block;
  max-width: 100%;
}
.image-editor-hint {
  margin-top: 8px;
  text-align: center;
}
.image-editor-status {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
  min-height: 18px;
}

.quick-rotate {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(99,102,241,0.04), rgba(168,85,247,0.04));
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-md);
}
.quick-rotate-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-indigo);
  letter-spacing: 0.05em;
}
.quick-rotate form { margin: 0; }
.quick-rotate .btn-mini { font-size: 13px; padding: 6px 12px; }
.quick-inpaint {
  margin-top: 8px;
  background: linear-gradient(135deg, rgba(16,185,129,0.06), rgba(99,102,241,0.04));
  border-color: #6EE7B7;
}
.cleaned-preview {
  margin-top: 12px;
  padding: 10px;
  background: linear-gradient(135deg, #ECFDF5, #F0FDF4);
  border: 1px solid #6EE7B7;
  border-radius: var(--radius-md);
}
.cleaned-preview img {
  width: 100%;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  display: block;
}

/* ============ 错题卡片网格 (mockup style) ============ */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.filter-chip {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-2);
  text-decoration: none;
}
.filter-chip:hover { text-decoration: none; border-color: #C7D2FE; }
.filter-chip.active { background: var(--grad-primary); color: white; border-color: transparent; box-shadow: 0 6px 14px -4px rgba(99,102,241,0.45); }
.filter-chip.filter-mastered.active { background: var(--grad-success); }
.filter-chip.filter-unmastered.active { background: var(--grad-rose); }
.filter-chip.filter-reviewing.active { background: var(--grad-warn); }
.filter-divider {
  width: 1px;
  height: 24px;
  background: var(--c-border);
  margin: 0 4px;
}
.kp-filter-form, .search-form { margin: 0; }
.kp-filter-form select, .search-form input { padding: 6px 12px; font-size: 13px; max-width: 220px; }

.filter-active-banner {
  background: var(--grad-card);
  border: 1px solid #C7D2FE;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 14px;
}
.filter-active-banner a {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 700;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.question-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.06s, box-shadow 0.15s, border-color 0.15s;
}
.question-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #C7D2FE;
}
.question-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/10;
  background: var(--c-border-soft);
  overflow: hidden;
}
.question-card-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.question-card-thumb .thumb-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 36px; opacity: 0.4;
}
.question-card-thumb .wrong-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--c-rose);
  color: white;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 10px -2px rgba(244,63,94,0.4);
}
.question-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.question-card-title { font-size: 14px; font-weight: 700; color: var(--c-text); margin: 0; }
.question-card-text { font-size: 12px; color: var(--c-text-2); margin: 0; line-height: 1.5; }
.question-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.question-card-tags .tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.tag-subject { background: #EEF2FF; color: #4338CA; }
.tag-kp { background: #FAF5FF; color: #7C3AED; }
.tag-diff { background: #FEF3C7; color: #92400E; }
.tag-diff.diff-easy { background: #D1FAE5; color: #065F46; }
.tag-diff.diff-hard { background: #FEE2E2; color: #991B1B; }
.tag-status.status-mastered { background: #D1FAE5; color: #065F46; }
.tag-status.status-reviewing { background: #FEF3C7; color: #92400E; }
.tag-status.status-unmastered { background: #FEE2E2; color: #991B1B; }
.question-card-foot {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--c-border);
  font-size: 11px;
  color: var(--c-text-mute);
}
.question-card.status-mastered { border-top: 3px solid var(--c-emerald); }
.question-card.status-reviewing { border-top: 3px solid var(--c-amber); }
.question-card.status-unmastered { border-top: 3px solid var(--c-rose); }

/* ============ Dashboard 增强 ============ */
.thumb-empty {
  display: flex !important; align-items: center; justify-content: center;
  font-size: 28px; opacity: 0.4; background: var(--c-border-soft);
}
.question-row p {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--c-text-mute);
}
.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.recent-list li {
  border-bottom: 1px dashed var(--c-border-soft);
}
.recent-list li:last-child { border-bottom: 0; }
.recent-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  color: var(--c-text);
  text-decoration: none;
}
.recent-list a:hover { color: var(--c-indigo); }
.recent-list .recent-title { font-size: 13px; font-weight: 600; }
.recent-list small { font-size: 11px; color: var(--c-text-mute); }

/* 打卡热力图 */
.heatmap {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  overflow-x: auto;
  padding: 8px 0;
}
.heat-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.heat-cell {
  width: 14px; height: 14px;
  border-radius: 3px;
  display: inline-block;
}
.heat-l0 { background: var(--c-border-soft); }
.heat-l1 { background: #BBF7D0; }
.heat-l2 { background: #6EE7B7; }
.heat-l3 { background: #10B981; }
.heat-l4 { background: #047857; }
.heat-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}
.heat-legend small { margin-right: 4px; }
.settings-grid h3 { margin-top: 0; }
@media (max-width: 1000px) {
  .settings-grid { grid-template-columns: 1fr; }
}
.top-actions form { margin: 0; }

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  transition: transform 0.06s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 10px 24px -8px rgba(99,102,241,0.45);
}
.btn-primary:hover { box-shadow: 0 14px 28px -10px rgba(99,102,241,0.55); }

.btn-ghost {
  background: var(--c-surface);
  color: var(--c-text-2);
  border-color: var(--c-border);
}
.btn-ghost:hover {
  background: var(--c-border-soft);
  color: var(--c-text);
}

.btn-mini {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 10px;
}

.btn-block, .btn-full { width: 100%; }

/* 危险操作（删除） */
.btn-ghost.danger {
  color: var(--c-rose);
  border-color: #FECACA;
}
.btn-ghost.danger:hover {
  background: #FEF2F2;
  color: #991B1B;
  border-color: var(--c-rose);
}

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

.status-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =========================================================
   Cards / Panels
   ========================================================= */

.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.panel-heading h2,
.panel-heading h3 { margin: 0; }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}
.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
}

/* =========================================================
   Messages
   ========================================================= */

.messages {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--c-surface);
  border-left: 4px solid var(--c-indigo);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  color: var(--c-text);
}
.message.success { border-left-color: var(--c-emerald); background: #ECFDF5; }
.message.error,
.message.warning { border-left-color: var(--c-rose); background: #FEF2F2; }
.message.info { border-left-color: var(--c-indigo); background: #EEF2FF; }

/* =========================================================
   Forms
   ========================================================= */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-stack p { margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field-wide { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-2);
}

input[type=text],
input[type=email],
input[type=password],
input[type=url],
input[type=number],
input[type=datetime-local],
input[type=date],
input[type=file],
select,
textarea,
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--c-text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=url]:focus,
input[type=number]:focus,
input[type=datetime-local]:focus,
input[type=date]:focus,
input[type=file]:focus,
select:focus,
textarea:focus,
.form-control:focus {
  border-color: var(--c-indigo);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}

textarea { min-height: 88px; resize: vertical; font-family: inherit; }

.field-error {
  color: var(--c-rose);
  font-size: 12px;
}

/* 密码可见切换 */
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input { padding-right: 44px !important; }
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 8px;
  font-size: 16px;
  line-height: 1;
  color: var(--c-text-mute);
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.password-toggle:hover {
  background: var(--c-border-soft);
  color: var(--c-indigo);
}
.password-toggle:focus { outline: 2px solid rgba(99,102,241,0.3); outline-offset: 2px; }

.note-input {
  margin-top: 12px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* Django form auto p */
form p { margin: 0 0 12px; }
form p label { display: block; font-size: 13px; font-weight: 600; color: var(--c-text-2); margin-bottom: 6px; }
.helptext { color: var(--c-text-mute); font-size: 12px; }
.errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--c-rose); font-size: 12px; }

/* =========================================================
   Auth (login / register)
   ========================================================= */

.auth-card {
  max-width: 460px;
  margin: 20px auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 280px; height: 280px;
  background: var(--grad-primary);
  filter: blur(80px);
  opacity: 0.18;
  border-radius: 50%;
}
.auth-card .form-stack,
.auth-card form { position: relative; }

/* =========================================================
   Capture / Question form
   ========================================================= */

.capture-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: flex-start;
}

.capture-phone { display: flex; flex-direction: column; gap: 14px; }

.phone-frame {
  background: linear-gradient(180deg, #EEF2FF 0%, #FAF5FF 100%);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  padding: 14px;
  position: relative;
}
.phone-top {
  width: 80px;
  height: 5px;
  background: var(--c-border);
  border-radius: 999px;
  margin: 0 auto 10px;
}

.camera-card {
  position: relative;
  background: var(--c-surface);
  border: 2px dashed #C7D2FE;
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
}
.camera-card strong { display: block; margin-top: 12px; font-size: 14px; color: var(--c-text); }
.camera-card small { display: block; margin-top: 4px; font-size: 12px; color: var(--c-text-mute); }
.camera-card input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.camera-icon {
  display: inline-flex;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--grad-primary);
  color: white;
  font-size: 26px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px -8px rgba(99,102,241,0.5);
}

.phone-preview {
  width: 100%;
  border-radius: var(--radius-md);
  display: block;
  margin-top: 12px;
  box-shadow: var(--shadow-md);
}
.photo-placeholder {
  margin-top: 12px;
  padding: 36px 12px;
  border-radius: var(--radius-md);
  background: var(--c-border-soft);
  text-align: center;
}
.photo-placeholder p { margin: 0; color: var(--c-text-mute); font-size: 13px; }
.photo-placeholder span {
  display: inline-block;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: white;
  border: 1px dashed var(--c-border);
}

.capture-main { display: flex; flex-direction: column; gap: 18px; }

.capture-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.capture-steps .step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--c-border-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-mute);
}
.capture-steps .step span {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: white;
  color: var(--c-text-mute);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}
.capture-steps .step.active {
  background: var(--grad-card);
  color: var(--c-indigo);
}
.capture-steps .step.active span {
  background: var(--grad-primary);
  color: white;
}

.capture-note {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #FEFCE8;
  border: 1px solid #FDE68A;
  color: #854D0E;
  font-size: 13px;
}

.capture-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px 20px;
  background: var(--grad-card);
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-md);
  color: var(--c-indigo);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.capture-cta:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15));
  text-decoration: none;
}

/* =========================================================
   QR / Capture upload page
   ========================================================= */

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 18px;
  background: white;
  border-radius: var(--radius-lg);
  margin: 16px 0;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--c-border);
}
.qr-wrap img {
  width: 260px; height: 260px;
  image-rendering: pixelated;
}

.dot-dot-dot {
  display: inline-block;
  animation: dots 1.4s infinite;
}
@keyframes dots {
  0%, 20% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

.phone-preview-wrap {
  margin: 14px 0;
  padding: 12px;
  background: var(--c-border-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
}
.phone-preview-wrap img {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.capture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.capture-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.06s;
}
.capture-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #C7D2FE;
  transform: translateY(-1px);
}
.capture-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--c-border-soft);
}
.capture-card .capture-meta { padding: 12px 14px; flex: 1; }
.capture-card .capture-meta small { color: var(--c-text-mute); font-size: 11px; }
.capture-card .capture-meta p { margin: 4px 0 0; font-size: 13px; color: var(--c-text); }
.capture-card form { padding: 0 14px 14px; }

.waiting-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--c-text-2);
}
.waiting-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--c-border);
}

.expired-box {
  background: #FFFBEB;
  border: 1px solid #FCD34D;
  border-radius: var(--radius-lg);
  padding: 24px;
  color: #92400E;
  text-align: center;
}

.status-msg {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  display: none;
}
.status-msg.ok { background: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }
.status-msg.err { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* =========================================================
   Dashboard / Question list
   ========================================================= */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.metric {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.metric > small {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.metric > strong {
  display: block;
  font-size: 28px;
  font-weight: 900;
  margin-top: 6px;
  color: var(--c-text);
}
.metric.accent {
  background: var(--grad-primary);
  color: white;
  border: 0;
  box-shadow: 0 16px 28px -10px rgba(99,102,241,0.35);
}
.metric.accent > small { color: rgba(255,255,255,0.85); }
.metric.accent > strong { color: white; }

.question-list { display: flex; flex-direction: column; gap: 12px; }
.question-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.06s;
}
.question-row:hover {
  box-shadow: var(--shadow-md);
  border-color: #C7D2FE;
  transform: translateY(-1px);
}
.question-image {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background: var(--c-border-soft);
  object-fit: cover;
}
.question-row strong { font-size: 15px; }
.question-row p { margin: 4px 0 0; font-size: 12px; color: var(--c-text-mute); }

.compact-list { display: flex; flex-direction: column; gap: 8px; padding: 0; list-style: none; margin: 0; }
.compact-list li {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--c-border-soft);
  font-size: 13px;
}

.empty-state {
  padding: 36px 24px;
  text-align: center;
  color: var(--c-text-mute);
  font-size: 14px;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-md);
}

.hint {
  background: #EEF2FF;
  border: 1px solid #C7D2FE;
  color: #3730A3;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin: 0 0 16px;
}

.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline-item {
  padding: 12px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.content-block { margin-bottom: 18px; }
.content-block:last-child { margin-bottom: 0; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.preview img { max-width: 100%; border-radius: var(--radius-sm); }

/* =========================================================
   Knowledge tree
   ========================================================= */

.knowledge-atlas { display: flex; flex-direction: column; gap: 22px; }

.subject-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.subject-tabs a {
  padding: 8px 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-2);
}
.subject-tabs a:hover { text-decoration: none; border-color: #C7D2FE; }
.subject-tabs a.active {
  background: var(--grad-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 20px -6px rgba(99,102,241,0.5);
}

.knowledge-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.progress-card {
  padding: 14px 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}
.progress-card small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-text-mute);
}
.progress-card strong {
  display: block;
  font-size: 24px;
  font-weight: 900;
  margin-top: 4px;
}

.tree-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--c-text-2);
  align-items: center;
}
.legend-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}
.legend-dot.state-lit { background: var(--grad-success); box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.legend-dot.state-active { background: var(--grad-warn); }
.legend-dot.state-withered { background: #9A3412; }
.legend-dot.state-locked { background: #CBD5E1; }

.branch-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.branch-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--c-border);
}
.branch-card.state-lit::before { background: var(--grad-success); }
.branch-card.state-active::before { background: var(--grad-warn); }
.branch-card.state-withered::before { background: #9A3412; }
.branch-card.state-locked::before { background: #CBD5E1; }

.branch-spine {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.branch-spine strong { font-size: 16px; }
.branch-spine small { color: var(--c-text-mute); font-size: 12px; }

.leaf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.leaf-card {
  position: relative;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.06s, box-shadow 0.15s, border-color 0.15s;
}
.leaf-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.leaf-shape {
  width: 42px; height: 42px;
  border-radius: 50% 0 50% 50%;
  transform: rotate(45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 800;
}
.leaf-shape span { transform: rotate(-45deg); }
.leaf-card.state-lit { background: linear-gradient(180deg, #ECFDF5 0%, #FFFFFF 100%); border-color: #6EE7B7; }
.leaf-card.state-lit .leaf-shape { background: var(--grad-success); box-shadow: 0 0 0 4px rgba(16,185,129,0.18); }
.leaf-card.state-active { background: linear-gradient(180deg, #FFFBEB 0%, #FFFFFF 100%); border-color: #FCD34D; }
.leaf-card.state-active .leaf-shape { background: var(--grad-warn); }
.leaf-card.state-withered { background: linear-gradient(180deg, #FFF7ED 0%, #FFFFFF 100%); border-color: #FDBA74; }
.leaf-card.state-withered .leaf-shape { background: linear-gradient(135deg, #9A3412, #C2410C); }
.leaf-card.state-locked .leaf-shape { background: #CBD5E1; }
.leaf-card strong { font-size: 13px; }
.leaf-card small { font-size: 11px; color: var(--c-text-mute); }

/* ============ 新知识树 SVG ============ */
.tree-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 12px;
}
.tree-stat {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tree-stat small {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--c-text-mute);
}
.tree-stat strong { font-size: 22px; font-weight: 900; }
.tree-stat span.muted { font-size: 11px; }
.tree-stat.lit { background: linear-gradient(135deg, #ECFDF5, #F0FDF4); border-color: #6EE7B7; }
.tree-stat.lit strong { color: #047857; }
.tree-stat.active { background: linear-gradient(135deg, #FFFBEB, #FEF3C7); border-color: #FCD34D; }
.tree-stat.active strong { color: #B45309; }
.tree-stat.withered { background: linear-gradient(135deg, #FFF7ED, #FFEDD5); border-color: #FB923C; }
.tree-stat.withered strong { color: #9A3412; }
.tree-stat.dropped { background: linear-gradient(135deg, #F1F5F9, #E2E8F0); border-color: #94A3B8; }
.tree-stat.dropped strong { color: #1E293B; }
.tree-stat.combo { background: var(--grad-warn); color: white; border: 0; box-shadow: 0 10px 24px -8px rgba(245,158,11,0.45); }
.tree-stat.combo small,
.tree-stat.combo span { color: rgba(255,255,255,0.9); }
.tree-stat.combo strong { color: white; }

.combo-bar {
  position: relative;
  height: 34px;
  border-radius: 999px;
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  overflow: hidden;
  margin: 0 0 18px;
}
.combo-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: var(--grad-warn);
  transition: width 0.4s ease;
}
.combo-bar-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 13px;
  font-weight: 700;
  color: #78350F;
}
.combo-bar-label strong { color: #FB923C; margin: 0 4px; }

.wither-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
  border: 1px solid #FCA5A5;
  margin: 0 0 16px;
}
.wither-icon { font-size: 28px; }
.wither-text strong { color: #9A3412; display: block; }
.wither-text small { color: #B45309; font-size: 12px; }
.wither-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.wither-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wither-pill.state-withered { background: rgba(154,52,18,0.12); color: #7C2D12; border: 1px solid rgba(154,52,18,0.3); }
.wither-pill.state-dropped { background: rgba(31,41,55,0.10); color: #1F2937; border: 1px solid rgba(31,41,55,0.3); }
.wither-pill em { font-style: normal; opacity: 0.85; font-weight: 600; }
.wither-pill:hover { text-decoration: none; transform: translateY(-1px); }

.wither-alert {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FFF7ED, #FEF3C7);
  border: 1px solid #FB923C;
  color: #9A3412;
  font-size: 12px;
  font-weight: 700;
}
.wither-alert strong { font-size: 14px; color: #DC2626; }
.wither-alert.dropped {
  background: linear-gradient(135deg, #F1F5F9, #E2E8F0);
  border-color: #64748B;
  color: #1F2937;
}
.wither-alert.warning {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border-color: #F59E0B;
  color: #92400E;
}
.progress-state-withered { background: #FFF7ED; border-color: #FDBA74; }
.progress-state-dropped { background: #F1F5F9; border-color: #94A3B8; }
.progress-state-lit { background: #ECFDF5; border-color: #6EE7B7; }

.tree-canvas-wrap {
  margin-top: 10px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 0%, rgba(186,230,253,0.5) 0%, transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(187,247,208,0.5) 0%, transparent 55%),
    linear-gradient(180deg, #E0F2FE 0%, #F0FDF4 60%, #FEFCE8 100%);
  border: 1px solid var(--c-border);
}
.tree-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 620px;
}
.tree-canvas a { cursor: pointer; }
.tree-canvas a:hover circle { stroke: #6366F1; stroke-width: 3; }

.tree-canvas-wrap .tree-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--c-text-2);
  padding: 12px 14px 4px;
  align-items: center;
}
.tree-canvas-wrap .tree-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tree-canvas-wrap .leg {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
}
.leg-lit { background: var(--grad-success); box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.leg-active { background: var(--grad-warn); }
.leg-withered { background: #9A3412; }
.leg-dropped { background: #44403C; }
.leg-locked { background: #CBD5E1; }
.leg-fruit { color: #DC2626; font-weight: 700; }

/* =========================================================
   Print sheet
   ========================================================= */

.print-controls { margin-bottom: 18px; }

.paper {
  background: white;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 18mm 16mm;
  box-shadow: 0 8px 30px -10px rgba(0,0,0,0.2);
  border-radius: 6px;
  color: #0F172A;
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
}

.paper-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 2px solid #0F172A;
  padding-bottom: 10px;
  margin-bottom: 18px;
}
.paper-brand strong {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.paper-brand small {
  display: block;
  font-size: 11px;
  color: #64748B;
  letter-spacing: 0.1em;
  margin-top: 2px;
}
.paper-meta p {
  margin: 0;
  font-size: 12px;
  color: #1E293B;
  line-height: 1.8;
}
.paper-meta u {
  display: inline-block;
  min-width: 80px;
  text-decoration: none;
  border-bottom: 1px solid #94A3B8;
  padding: 0 4px;
}

.paper-question {
  margin-bottom: 22px;
  page-break-inside: avoid;
  break-inside: avoid;
}
.paper-question-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 6px;
}
.paper-question-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}
.paper-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 6px;
  background: #F1F5F9;
  color: #475569;
}
.paper-tag-subject { background: #EEF2FF; color: #4338CA; }
.paper-tag-diff { background: #FEF3C7; color: #92400E; }

.paper-qr {
  text-align: center;
  flex-shrink: 0;
}
.paper-qr img {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  display: block;
  margin: 0 auto;
}
.paper-qr small {
  font-size: 9px;
  color: #475569;
  display: block;
  margin-top: 2px;
}

.paper-stem {
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.paper-answer-area {
  margin-top: 4px;
}
.answer-line {
  border-bottom: 1px solid #94A3B8;
  height: 22px;
  margin-bottom: 4px;
}

.paper-footer {
  margin-top: 28px;
  text-align: center;
  border-top: 1px dashed #CBD5E1;
  padding-top: 10px;
}

/* =========================================================
   Misc
   ========================================================= */

img { max-width: 100%; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 999px; border: 2px solid var(--c-bg); }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
    padding: 10px 12px;
    gap: 12px;
  }
  .brand { border-bottom: 0; padding: 0; }
  .nav { flex-direction: row; }
  .main { padding: 20px 18px 40px; }
  .capture-layout,
  .split-layout,
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .form-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .messages, .print-controls { display: none; }
  .app-shell, .main { display: block; padding: 0; }
  .paper { width: auto; min-height: 0; padding: 0; border: 0; box-shadow: none; }
}
