:root {
  --wq-primary: #3B8EA5;
  --wq-primary-light: #5BA8BC;
  --wq-primary-lighter: #B8DCE5;
  --wq-primary-lightest: #E8F4F8;
  --wq-primary-dark: #2D6E82;
  --wq-primary-darker: #1E5060;

  --wq-neutral-900: #2D2F33;
  --wq-neutral-800: #3E4147;
  --wq-neutral-700: #565A62;
  --wq-neutral-600: #6E737D;
  --wq-neutral-500: #8A8F9B;
  --wq-neutral-400: #ABADAD;
  --wq-neutral-300: #CDD0D1;
  --wq-neutral-200: #E2E4E5;
  --wq-neutral-100: #F0F1F2;
  --wq-neutral-50: #F7F8F8;

  --wq-bg-page: #F7F8F8;
  --wq-bg-card: #FFFFFF;
  --wq-bg-elevated: #FFFFFF;
  --wq-bg-overlay: rgba(0, 0, 0, 0.4);

  --wq-text-primary: #2D2F33;
  --wq-text-secondary: #6E737D;
  --wq-text-tertiary: #8A8F9B;
  --wq-text-inverse: #FFFFFF;
  --wq-text-link: #3B8EA5;

  --wq-border: #E2E4E5;
  --wq-border-light: #F0F1F2;

  --state-success: #4CAF50;
  --state-success-light: #E8F5E9;
  --state-warning: #FF9800;
  --state-warning-light: #FFF3E0;
  --state-error: #E53935;
  --state-error-light: #FFEBEE;
  --state-info: #3B8EA5;
  --state-info-light: #E8F4F8;

  --wq-child-accent: #FF9F43;
  --wq-child-accent-light: #FFECD2;
  --wq-child-success: #4CAF50;
  --wq-child-error: #E53935;

  --wq-background: var(--wq-bg-page);
  --wq-foreground: var(--wq-text-primary);
  --wq-card: var(--wq-bg-card);
  --wq-muted: var(--wq-text-tertiary);

  --wq-radius-sm: 4px;
  --wq-radius-md: 8px;
  --wq-radius-lg: 12px;
  --wq-radius-xl: 16px;
  --wq-radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.05);
  --shadow-float: 0 12px 40px rgba(0,0,0,0.10);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;

  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.02em;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
}

[data-mode="child"] {
  --wq-primary: #FF9F43;
  --wq-primary-light: #FFB76B;
  --wq-primary-lighter: #FFECD2;
  --wq-primary-lightest: #FFF6EB;
  --wq-primary-dark: #E8882E;
  --wq-text-primary: #2D2F33;
  --wq-radius-lg: 16px;
  --wq-radius-xl: 16px;
}

[data-mode="child"] .parent-only {
  display: none !important;
}

[data-mode="child"] .tab-bar #tab-capture,
[data-mode="child"] .tab-bar #tab-report {
  display: none;
}

[data-mode="child"] .tab-bar {
  justify-content: center;
  gap: 48px;
}

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

html, body {
  font-family: var(--font-sans);
  background: var(--wq-bg-page);
  color: var(--wq-text-primary);
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body::-webkit-scrollbar { display: none; }
body { -ms-overflow-style: none; scrollbar-width: none; }

.page {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
}

.page.active {
  display: flex;
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* 通用按钮样式 */
.btn-primary {
  width: 100%;
  height: 44px;
  padding: 0 24px;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  font-family: var(--font-sans);
  color: var(--wq-text-inverse);
  background: var(--wq-primary);
  border: none;
  border-radius: var(--wq-radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: scale(0.975);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  flex: 1;
  height: 44px;
  border-radius: var(--wq-radius-lg);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wq-border);
  background: var(--wq-bg-card);
  color: var(--wq-text-secondary);
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}

.btn-outline:active {
  background: var(--wq-neutral-50);
}

/* 掌握度圆点 */
.mastery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mastery-dot.level-0 { background: var(--state-error); }
.mastery-dot.level-1 { background: var(--state-warning); }
.mastery-dot.level-2 { background: #FFC107; }
.mastery-dot.level-3 { background: #8BC34A; }
.mastery-dot.level-4 { background: var(--state-success); }
.mastery-dot.inactive { background: var(--wq-neutral-200); }

/* 卡片样式 */
.section-card {
  background: var(--wq-bg-card);
  border: 1px solid var(--wq-border);
  border-radius: var(--wq-radius-lg);
  padding: 16px;
}

/* 标签样式 */
.tag-teal {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--state-info-light);
  color: var(--state-info);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--wq-radius-sm);
}

.tag-gray {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--wq-neutral-100);
  color: var(--wq-text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--wq-radius-sm);
}

.tag-knowledge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--wq-primary-lightest);
  color: var(--wq-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--wq-radius-full);
  border: 1px solid var(--wq-primary-lighter);
}

/* 底部标签栏 */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
  background: var(--wq-bg-card);
  border-top: 1px solid var(--wq-border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--wq-text-tertiary);
  font-size: 10px;
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.15s ease;
  background: none;
  border: none;
  font-family: var(--font-sans);
}

.tab-item.active {
  color: var(--wq-primary);
  font-weight: var(--weight-semibold);
}

.tab-item .tab-icon {
  font-size: 22px;
  line-height: 1;
}

/* 加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--wq-neutral-200);
  border-radius: 50%;
  border-top-color: var(--wq-primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--wq-bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--wq-bg-card);
  border-radius: var(--wq-radius-xl);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 12px 24px;
  border-radius: var(--wq-radius-md);
  font-size: var(--text-sm);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--wq-text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

/* iPad / 大屏适配 */
@media (min-width: 768px) {
  html, body {
    max-width: 720px;
  }

  .tab-bar {
    max-width: 720px;
  }

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

  .hero-card {
    padding: 32px 28px;
  }

  .home-main,
  .capture-main,
  .detail-main,
  .library-main {
    padding-left: 24px;
    padding-right: 24px;
  }

  .child-question-text {
    font-size: 32px;
  }

  .child-btn {
    min-height: 80px;
    font-size: 24px;
  }

  .filter-tabs {
    flex-wrap: wrap;
  }

  .question-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .library-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .batch-thumb-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }

  .form-section {
    padding: 20px 24px;
  }

  .related-questions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}
