/* ============================================================
   错题整理智能体 - Web 配套端 全局样式
   专业简洁风 | 响应式 | 设计 Token 体系
   ============================================================ */

/* ----- CSS Custom Properties (Design Tokens) ----- */
:root {
  /* Primary */
  --color-primary: #4A90D9;
  --color-primary-dark: #3576B5;
  --color-primary-light: #6BA5E7;
  --color-primary-bg: #e8f2fc;
  --color-primary-bg-hover: #d1e5fa;

  /* Semantic */
  --color-success: #52C41A;
  --color-success-bg: #f0fbe9;
  --color-success-dark: #3da015;
  --color-warning: #FA8C16;
  --color-warning-bg: #fff7e6;
  --color-error: #F5222D;
  --color-error-bg: #fef0f0;
  --color-error-dark: #cf1322;
  --color-info: #1890ff;
  --color-info-bg: #e6f7ff;

  /* Neutral */
  --color-bg: #F5F7FA;
  --color-bg-alt: #EDF1F5;
  --color-card: #FFFFFF;
  --color-divider: #F0F0F0;
  --color-border: #E5E7EB;
  --color-border-hover: #D1D5DB;
  --color-text-primary: #1F2937;
  --color-text-secondary: #6B7280;
  --color-text-muted: #9CA3AF;
  --color-text-inverse: #FFFFFF;

  /* Subject Colors */
  --subject-math: #4A90D9;
  --subject-chinese: #52C41A;
  --subject-english: #FA8C16;
  --subject-physics: #722ED1;
  --subject-chemistry: #13C2C2;
  --subject-biology: #A0D911;
  --subject-history: #EB2F96;
  --subject-geography: #2F54EB;
  --subject-politics: #F5222D;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  --space-4xl: 48px;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;
  --font-size-4xl: 30px;
  --font-size-hero: 36px;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.08), 0 8px 10px rgba(0,0,0,0.04);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-button: 0 2px 8px rgba(74,144,217,0.25);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 56px;
  --max-content-width: 1280px;
}

/* ----- Reset ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-dark); }

img { max-width: 100%; height: auto; display: block; }

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  font-size: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--color-text-primary);
  background: var(--color-card);
  transition: border-color var(--transition-fast);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}
input::placeholder, textarea::placeholder { color: var(--color-text-muted); }

table {
  border-collapse: collapse;
  width: 100%;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

/* ============================================================
   Layout
   ============================================================ */

/* App shell: sidebar + main */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-card);
  border-right: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-brand {
  padding: var(--space-xl) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid var(--color-divider);
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px;
}
.sidebar-brand h1 {
  font-size: var(--font-size-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
}
.nav-section-title {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-md) var(--space-sm) var(--space-sm);
  font-weight: var(--weight-semibold);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-md);
  font-weight: var(--weight-normal);
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}
.nav-item.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: var(--weight-medium);
}
.nav-item .nav-icon { font-size: 18px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--color-error);
  color: #fff;
  font-size: var(--font-size-xs);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: var(--weight-medium);
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* Top Header Bar */
.top-header {
  height: var(--header-height);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-2xl);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}
.top-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}
.page-title {
  font-size: var(--font-size-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

/* Child Switcher */
.child-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
}
.child-switcher:hover { border-color: var(--color-primary); color: var(--color-primary); }
.child-switcher .child-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-primary-bg);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: var(--weight-bold);
}

/* Content Area */
.content-area {
  padding: var(--space-2xl);
  max-width: var(--max-content-width);
}

/* Page Sections */
.page-section {
  margin-bottom: var(--space-2xl);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}
.section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.section-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ============================================================
   Components
   ============================================================ */

/* ----- Cards ----- */
.card {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-divider);
  transition: box-shadow var(--transition-fast);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-flat { box-shadow: none; border: 1px solid var(--color-divider); }
.card-flat:hover { box-shadow: var(--shadow-sm); }

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}
.stat-card {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: all var(--transition-fast);
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.stat-card.clickable { cursor: pointer; }
.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-card-icon.blue { background: var(--color-primary-bg); color: var(--color-primary); }
.stat-card-icon.green { background: var(--color-success-bg); color: var(--color-success); }
.stat-card-icon.orange { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-card-icon.red { background: var(--color-error-bg); color: var(--color-error); }
.stat-card-icon.purple { background: #f3f0ff; color: #722ED1; }
.stat-card-value {
  font-size: var(--font-size-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  line-height: 1.2;
}
.stat-card-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}
.stat-card-trend {
  font-size: var(--font-size-xs);
  display: flex; align-items: center; gap: 4px;
}
.stat-card-trend.up { color: var(--color-success); }
.stat-card-trend.down { color: var(--color-error); }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: var(--weight-medium);
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.5;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-button);
}
.btn-primary:hover { background: var(--color-primary-dark); }

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

.btn-success {
  background: var(--color-success);
  color: #fff;
}
.btn-success:hover { background: var(--color-success-dark); }

.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover { background: var(--color-error-dark); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text-primary); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-bg); }

.btn-sm { padding: 4px 12px; font-size: var(--font-size-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 10px 24px; font-size: var(--font-size-lg); border-radius: var(--radius-lg); }
.btn-xl { padding: 14px 32px; font-size: var(--font-size-xl); border-radius: var(--radius-xl); }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* ----- Chips / Badges ----- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.chip-primary { background: var(--color-primary-bg); color: var(--color-primary); }
.chip-success { background: var(--color-success-bg); color: var(--color-success); }
.chip-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.chip-error { background: var(--color-error-bg); color: var(--color-error); }
.chip-neutral { background: var(--color-bg); color: var(--color-text-secondary); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: #fff;
}
.badge-primary { background: var(--color-primary); }
.badge-success { background: var(--color-success); }
.badge-error { background: var(--color-error); }
.badge-warning { background: var(--color-warning); }

/* ----- Subject Color Bar ----- */
.subject-bar {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.subject-bar.math { background: var(--subject-math); }
.subject-bar.chinese { background: var(--subject-chinese); }
.subject-bar.english { background: var(--subject-english); }
.subject-bar.physics { background: var(--subject-physics); }
.subject-bar.chemistry { background: var(--subject-chemistry); }
.subject-bar.biology { background: var(--subject-biology); }
.subject-bar.history { background: var(--subject-history); }
.subject-bar.geography { background: var(--subject-geography); }
.subject-bar.politics { background: var(--subject-politics); }

/* ----- Mastery Status Dot ----- */
.mastery-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.mastery-dot.mastered { background: var(--color-success); }
.mastery-dot.unmastered { background: var(--color-error); }
.mastery-dot.reviewing { background: var(--color-warning); }

/* ----- Progress Bar ----- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}
.progress-fill.primary { background: var(--color-primary); }
.progress-fill.success { background: var(--color-success); }
.progress-fill.warning { background: var(--color-warning); }
.progress-fill.error { background: var(--color-error); }

/* ----- Subject Pills (Filter) ----- */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.filter-pill {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.filter-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.filter-pill.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ----- Empty State ----- */
.empty-state {
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
}
.empty-icon { font-size: 64px; margin-bottom: var(--space-lg); opacity: 0.5; }
.empty-title {
  font-size: var(--font-size-lg);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  font-weight: var(--weight-medium);
}
.empty-text { font-size: var(--font-size-md); color: var(--color-text-muted); }
.empty-action { margin-top: var(--space-lg); }

/* ----- Loading ----- */
.loading-section {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4xl);
  color: var(--color-text-muted);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--color-bg);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-bg-alt) 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ----- Table ----- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-divider);
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
}
.data-table tr:hover td { background: var(--color-bg); }
.data-table tr.selected td { background: var(--color-primary-bg); }
.data-table .col-check { width: 40px; text-align: center; }
.data-table .col-actions { width: 120px; text-align: right; }

/* ----- Form ----- */
.form-group {
  margin-bottom: var(--space-lg);
}
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  transition: all var(--transition-fast);
}
.form-textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  line-height: 1.8;
}
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  background: var(--color-card);
  cursor: pointer;
}

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-dialog {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}
.modal-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: var(--font-size-lg); font-weight: var(--weight-semibold); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.modal-close:hover { background: var(--color-bg); }
.modal-body { padding: var(--space-xl); }
.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--color-divider);
  display: flex; justify-content: flex-end; gap: var(--space-md);
}

/* ----- Toast ----- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text-primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}
.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-error); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ----- Tags ----- */
.tag-group {
  display: flex; flex-wrap: wrap; gap: var(--space-sm);
}

/* ----- Tooltip ----- */
.tooltip {
  position: relative;
}
.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: var(--color-text-primary);
  color: #fff;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}
.tooltip:hover::after { opacity: 1; }

/* ============================================================
   Page Specific: Dashboard
   ============================================================ */

/* Chart containers */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.chart-card {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-divider);
}
.chart-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-lg);
}
.chart-card-title {
  font-size: var(--font-size-md);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}
.chart-container {
  position: relative;
  width: 100%;
}
.chart-container canvas { width: 100% !important; }

/* Activity Heatmap */
.heatmap {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--color-bg);
  transition: all var(--transition-fast);
  cursor: default;
}
.heatmap-cell:hover { transform: scale(1.3); }
.heatmap-cell.level-0 { background: var(--color-bg); }
.heatmap-cell.level-1 { background: #C6E48B; }
.heatmap-cell.level-2 { background: #7BC96F; }
.heatmap-cell.level-3 { background: #239A3B; }
.heatmap-cell.level-4 { background: #196127; }

.heatmap-legend {
  display: flex; align-items: center; gap: var(--space-sm);
  margin-top: var(--space-md);
  font-size: var(--font-size-xs); color: var(--color-text-muted);
}

/* ============================================================
   Page Specific: Questions List
   ============================================================ */

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  padding: var(--space-lg);
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-lg);
}
.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  background: var(--color-bg);
}
.filter-bar .search-input:focus { background: var(--color-card); }

/* Batch Actions Bar */
.batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-primary-bg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Question Row */
.q-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-md);
  border: 1px solid var(--color-divider);
  transition: all var(--transition-fast);
  cursor: pointer;
}
.q-row:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.q-row.selected { border-color: var(--color-primary); background: var(--color-primary-bg); }
.q-row-left { display: flex; align-items: flex-start; gap: var(--space-md); flex-shrink: 0; }
.q-row-bar { width: 4px; min-height: 60px; border-radius: 2px; flex-shrink: 0; }
.q-row-body { flex: 1; min-width: 0; }
.q-row-title {
  font-size: var(--font-size-md);
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.q-row-meta {
  display: flex; align-items: center; gap: var(--space-md);
  flex-wrap: wrap;
}
.q-row-actions {
  display: flex; gap: var(--space-sm);
  flex-shrink: 0;
}

/* ============================================================
   Page Specific: Detail
   ============================================================ */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-xl);
}
.detail-main {
  min-width: 0;
}
.detail-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.question-display {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
}
.question-image-wrapper {
  text-align: center;
  margin-bottom: var(--space-xl);
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}
.question-image-wrapper img {
  max-height: 480px;
  margin: 0 auto;
  object-fit: contain;
}
.question-image-wrapper.zoomed img {
  max-height: none;
  cursor: zoom-out;
}
.question-text-content {
  font-size: var(--font-size-lg);
  line-height: 1.8;
  color: var(--color-text-primary);
  white-space: pre-wrap;
}

/* Metadata Tags */
.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

/* Explanation Box */
.explanation-box {
  background: linear-gradient(135deg, #f6f9fc, #eef4fb);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  border-left: 4px solid var(--color-primary);
}
.explanation-box h4 {
  font-size: var(--font-size-md);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
}
.explanation-box p {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  line-height: 1.8;
}

/* Notes Area */
.notes-box {
  background: #FFFDE7;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  border: 1px dashed #E6E0B3;
}
.notes-box h4 {
  font-size: var(--font-size-md);
  color: #8D6E00;
  margin-bottom: var(--space-md);
}
.notes-content {
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
  line-height: 1.8;
  white-space: pre-wrap;
}
.notes-empty {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ============================================================
   Page Specific: Export
   ============================================================ */

.export-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
.export-option {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
  border: 2px solid var(--color-divider);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.export-option:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.export-option.selected { border-color: var(--color-primary); background: var(--color-primary-bg); }
.export-option-icon { font-size: 48px; margin-bottom: var(--space-md); }
.export-option-title { font-size: var(--font-size-md); font-weight: var(--weight-semibold); margin-bottom: var(--space-sm); }
.export-option-desc { font-size: var(--font-size-xs); color: var(--color-text-muted); }

.preview-pane {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  max-height: 600px;
  overflow-y: auto;
  font-size: var(--font-size-sm);
  line-height: 2;
}

/* Print styles */
@media print {
  .sidebar, .top-header, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  body { background: #fff; }
  .card, .question-display { box-shadow: none; border: 1px solid #ddd; }
}

/* ============================================================
   Page Specific: Knowledge Graph
   ============================================================ */

.kg-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-xl);
}
.kg-main {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
  min-height: 500px;
  position: relative;
}
.kg-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.kg-node-detail {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-card);
}
.kg-node-detail h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-lg);
}
.kg-stat-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--font-size-sm);
}
.kg-stat-row:last-child { border-bottom: none; }
.kg-stat-label { color: var(--color-text-muted); }
.kg-stat-value { font-weight: var(--weight-medium); }

/* ============================================================
   Auth / Bind
   ============================================================ */

.bind-prompt {
  text-align: center;
  padding: var(--space-4xl);
  max-width: 440px;
  margin: 120px auto;
}
.bind-icon { font-size: 64px; margin-bottom: var(--space-xl); }
.bind-title { font-size: var(--font-size-2xl); font-weight: var(--weight-bold); margin-bottom: var(--space-md); }
.bind-desc { font-size: var(--font-size-md); color: var(--color-text-secondary); margin-bottom: var(--space-xl); line-height: 1.8; }
.bind-input {
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-lg);
  text-align: center;
  letter-spacing: 2px;
}
.bind-input:focus { border-color: var(--color-primary); }
.bind-hint { font-size: var(--font-size-sm); color: var(--color-text-muted); margin-top: var(--space-md); }

/* QR Code Bind */
.bind-qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: var(--space-lg);
  min-height: 220px;
  justify-content: center;
}
.bind-qr-loading { text-align: center; color: var(--color-text-secondary); }
.bind-qr-image {
  width: 220px; height: 220px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 8px;
  background: #fff;
}
.bind-qr-fallback {
  color: var(--color-warning);
  font-size: var(--font-size-sm);
  text-align: center;
}

/* Bind Spinners */
.bind-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: bind-spin 0.8s linear infinite;
  margin: 0 auto 12px auto;
}
.bind-spinner-sm {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: bind-spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes bind-spin {
  to { transform: rotate(360deg); }
}

/* Polling Status */
.bind-polling {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  padding: var(--space-md);
}

/* Manual Mode */
.bind-manual { margin-top: var(--space-lg); }

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

@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { order: -1; }
  .kg-container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-content { margin-left: 0; }
  .content-area { padding: var(--space-lg); }

  .top-header {
    padding: 0 var(--space-lg);
  }

  .menu-toggle {
    display: flex;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text-secondary);
  }
  .menu-toggle:hover { background: var(--color-bg); }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .filter-bar { flex-direction: column; }
  .filter-bar .search-input { width: 100%; }

  .q-row { flex-direction: column; }
  .q-row-actions { margin-top: var(--space-md); align-self: flex-end; }

  .export-options { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card-value { font-size: var(--font-size-3xl); }
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease; }
.slide-up { animation: slideUp 0.3s ease; }

/* ============================================================
   Utility Classes
   ============================================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }

.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.w-full { width: 100%; }

.hidden { display: none !important; }
.visible { display: block !important; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a2e;
    --color-bg-alt: #16213e;
    --color-card: #222244;
    --color-divider: #2a2a4a;
    --color-border: #333366;
    --color-border-hover: #444488;
    --color-text-primary: #e8e8f0;
    --color-text-secondary: #a0a0c0;
    --color-text-muted: #7070a0;
    --color-primary-bg: #1a2a4a;
    --color-primary-bg-hover: #1e3460;
    --color-success-bg: #1a2a1a;
    --color-warning-bg: #2a2010;
    --color-error-bg: #2a1515;
  }
  .notes-box { background: #2a2810; border-color: #4a4520; }
  .notes-box h4 { color: #c0a030; }
  .explanation-box { background: linear-gradient(135deg, #1a2030, #1a2a40); }
  .data-table th { background: var(--color-bg-alt); }
  .data-table tr:hover td { background: var(--color-bg-alt); }
  .filter-pill { background: var(--color-bg-alt); }
  .child-switcher { background: var(--color-bg-alt); }
}

/* September 2026: shared, quiet task-first surfaces. */
:root{--color-primary:#285bce;--color-primary-dark:#204baa;--color-primary-bg:#edf3ff;--color-bg:#f3f6fb;--color-text-primary:#172942;--color-text-secondary:#52657c;--color-text-muted:#607187;--color-border:#dee6ef;--font-size-md:1rem;--font-size-sm:.875rem;--font-size-xs:.8125rem;--sidebar-width:208px;--shadow-card:none;--shadow-button:none}
.sidebar-brand-icon{background:var(--color-primary);color:#fff;border-radius:10px;font-size:18px}
.nav-item{min-height:48px;border-radius:10px}.nav-item.active{background:var(--color-primary-bg);color:var(--color-primary)}
.btn{min-height:44px;border-radius:10px}.btn:focus-visible,a:focus-visible,[role=button]:focus-visible{outline:3px solid var(--color-primary);outline-offset:3px}
.content-area{padding:32px;max-width:1400px}.top-header{min-height:72px}.card,.chart-card,.stat-card{box-shadow:none;border:1px solid var(--color-border);border-radius:16px}
.workspace-start{background:var(--color-card);border:1px solid var(--color-border);border-top:4px solid var(--color-primary);border-radius:16px;padding:28px;display:flex;align-items:center;justify-content:space-between;gap:24px}.workspace-start h2{font-size:24px;margin:8px 0 12px;line-height:1.4}.workspace-actions{display:flex;gap:12px;flex-wrap:wrap;flex-shrink:0}
.stat-card-icon{display:none}.stat-card-value{font-size:28px}.stat-card{padding:20px}.stat-card-trend{font-size:14px}.chart-grid{margin-top:24px}
.question-workspace{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(260px,.85fr);gap:24px;align-items:start}.question-preview{position:sticky;top:96px;background:var(--color-card);border:1px solid var(--color-border);border-radius:16px;padding:24px;min-width:0}.question-preview h3{margin:16px 0}.question-preview .btn{margin-top:24px}.preview-question{font-size:20px;line-height:1.8;white-space:pre-wrap;overflow-wrap:anywhere;margin:24px 0}.q-row{border:1px solid var(--color-border);border-radius:14px;box-shadow:none;margin-bottom:12px}.q-row-bar{display:none}.q-row-title{font-size:16px;line-height:1.65}.q-row:hover{box-shadow:none;background:var(--color-primary-bg)}.q-row:focus-visible{outline:3px solid var(--color-primary)}.filter-bar{gap:12px;flex-wrap:wrap}.filter-bar input,.filter-bar select{min-height:44px}.batch-bar{flex-wrap:wrap;gap:12px}.batch-bar .flex{flex-wrap:wrap}
@media(max-width:1100px){.workspace-start{align-items:flex-start;flex-direction:column}.content-area{padding:24px}}
@media(max-width:999px){.question-workspace{display:block}.question-preview{display:none}}
@media(max-width:600px){.content-area{padding:16px}.workspace-start{padding:20px}.workspace-actions{width:100%;flex-direction:column}.workspace-actions .btn{width:100%}.stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.filter-bar .search-input{width:100%;min-width:0}.q-row-meta{flex-wrap:wrap}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
