* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
}

header h1 {
  font-size: 28px;
  margin-bottom: 12px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.knowledge-link {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 10px;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
  border: 1px solid rgba(255,255,255,0.3);
}

.knowledge-link:hover {
  background: rgba(255,255,255,0.45);
  transform: translateY(-1px);
}

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.stat {
  background: rgba(255,255,255,0.2);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  backdrop-filter: blur(4px);
}

.stat strong {
  color: #ffd700;
}

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: rgba(255,255,255,0.25);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.tab:hover {
  background: rgba(255,255,255,0.4);
}

.tab.active {
  background: #fff;
  color: #667eea;
  font-weight: bold;
}

.question-card {
  background: #fff;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  min-height: 300px;
}

.question-type {
  display: inline-block;
  background: #e8f4fd;
  color: #2980b9;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 16px;
}

.question-text {
  font-size: 20px;
  color: #2c3e50;
  line-height: 1.6;
  margin-bottom: 24px;
  min-height: 60px;
}

.answer-area {
  margin-bottom: 20px;
}

#answer-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 18px;
  border: 2px solid #ddd;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s;
  font-family: "Times New Roman", serif;
}

#answer-input:focus {
  border-color: #667eea;
}

#answer-input:disabled {
  background: #f5f5f5;
}

#answer-input.correct {
  border-color: #27ae60;
  background: #eafaf1;
}

#answer-input.wrong {
  border-color: #e74c3c;
  background: #fdedec;
}

.hint-area {
  margin-top: 10px;
  color: #e67e22;
  font-size: 14px;
  min-height: 20px;
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.btn-secondary {
  background: #3498db;
  color: #fff;
}

.btn-hint {
  background: #f39c12;
  color: #fff;
}

.btn-warn {
  background: #e67e22;
  color: #fff;
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
  font-size: 12px;
  padding: 8px 16px;
}

.feedback {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.5;
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.correct {
  background: #eafaf1;
  border: 1px solid #27ae60;
  color: #27ae60;
}

.feedback.wrong {
  background: #fdedec;
  border: 1px solid #e74c3c;
  color: #c0392b;
}

.question-meta {
  margin-top: 12px;
  font-size: 12px;
  color: #95a5a6;
}

.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding: 0 10px;
}

.version-info {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
}

/* 化学式上下标样式 */
.chem sub { font-size: 0.75em; }
.chem sup { font-size: 0.75em; }

/* 正确答案显示样式 */
.correct-answer {
  font-family: "Times New Roman", serif;
  font-size: 18px;
  color: #27ae60;
  font-weight: bold;
  margin-top: 8px;
}

/* 手写画板样式 */
.handwriting-panel {
  margin-bottom: 16px;
  display: none;
}

.handwriting-panel.show {
  display: block;
}

.hw-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.hw-title {
  font-size: 14px;
  font-weight: bold;
  color: #2c3e50;
}

.hw-tools {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.hw-btn {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.hw-btn:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

.hw-btn.active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

.hw-btn.hw-recognize {
  background: #27ae60;
  color: #fff;
  border-color: #27ae60;
  font-size: 12px;
  padding: 4px 12px;
}

.hw-btn.hw-recognize:hover {
  background: #219a52;
}

.hw-select {
  padding: 4px 6px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 12px;
}

#hw-canvas {
  width: 100%;
  height: 200px;
  border: 2px solid #ddd;
  border-radius: 10px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  display: block;
}

#hw-canvas.drawing {
  border-color: #667eea;
}

.hw-result {
  margin-top: 8px;
  padding: 6px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 14px;
  color: #2c3e50;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-result:empty {
  display: none;
}

.hw-result .hw-use-btn {
  padding: 2px 10px;
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.hw-result .hw-use-btn:hover {
  background: #5a6fd6;
}

.btn-outline {
  background: transparent;
  color: #667eea;
  border: 2px solid #667eea;
}

.btn-outline:hover {
  background: #667eea;
  color: #fff;
}

.btn-outline-sm {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.4);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
}

.btn-outline-sm:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.question-detail {
  background: #fef9e7;
  border-left: 4px solid #f39c12;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #7d6608;
  line-height: 1.8;
  word-break: break-all;
}

/* 响应式 */
@media (max-width: 600px) {
  body { padding: 10px; }
  header h1 { font-size: 22px; }
  .question-card { padding: 20px; }
  .question-text { font-size: 17px; }
  .stats-bar { gap: 8px; }
  .stat { padding: 4px 10px; font-size: 12px; }
  .tab { padding: 6px 12px; font-size: 12px; }
  .btn { padding: 10px 18px; font-size: 14px; }
  #hw-canvas { height: 160px; }
  .hw-tools { gap: 2px; }
  .hw-btn { padding: 3px 6px; font-size: 12px; }
}
