* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f0f2f5; color: #333; line-height: 1.6; }

/* Topbar */
.topbar { background: linear-gradient(135deg, #1a3a5c, #2980b9); color: white; padding: 0 24px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.topbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-size: 18px; font-weight: bold; letter-spacing: 1px; }
.topbar-stats { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.progress-bar-mini { width: 120px; height: 6px; background: rgba(255,255,255,0.3); border-radius: 3px; overflow: hidden; }
.progress-bar-mini .fill { height: 100%; background: #a8e6cf; border-radius: 3px; transition: width 0.6s ease; }
.pct { font-weight: bold; color: #a8e6cf; }
.btn-wrong { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); padding: 4px 12px; border-radius: 14px; font-size: 13px; cursor: pointer; text-decoration: none; transition: background 0.2s; }
.btn-wrong:hover { background: rgba(255,255,255,0.25); }

/* Container */
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

/* Hero Card */
.hero-card { background: white; border-radius: 16px; padding: 32px; display: flex; align-items: center; gap: 24px; box-shadow: 0 4px 20px rgba(0,0,0,0.06); margin-bottom: 24px; }
.hero-icon { font-size: 56px; }
.hero-text h1 { font-size: 26px; margin-bottom: 6px; color: #1a3a5c; }
.hero-text p { color: #777; font-size: 14px; }
.hero-progress-ring { width: 100px; height: 100px; margin-left: auto; flex-shrink: 0; position: relative; }
.hero-progress-ring svg { width: 100%; height: 100%; }
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: bold; color: #2980b9; }

/* Tabs */
.mode-tabs { display: flex; gap: 4px; background: white; padding: 6px; border-radius: 12px; margin-bottom: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.tab-btn { flex: 1; padding: 10px 16px; border: none; background: transparent; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; color: #666; transition: all 0.2s; }
.tab-btn:hover { background: #f0f7ff; color: #2980b9; }
.tab-btn.active { background: #2980b9; color: white; box-shadow: 0 2px 8px rgba(41,128,185,0.4); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Category Cards */
.category-list { display: flex; flex-direction: column; gap: 16px; }
.cat-card { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.05); transition: box-shadow 0.2s; }
.cat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.cat-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: #fafafa; }
.cat-num { font-size: 12px; background: #e8f4fd; color: #2980b9; padding: 2px 8px; border-radius: 10px; margin-right: 10px; font-weight: bold; }
.cat-info h2 { font-size: 16px; margin-bottom: 4px; }
.cat-desc { font-size: 13px; color: #888; }
.cat-stats { text-align: right; }
.cat-pct { font-size: 24px; font-weight: bold; display: block; }
.cat-count { font-size: 12px; color: #999; }
.cat-progress { height: 4px; background: #f0f0f0; }
.cat-progress .fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.cat-actions { display: flex; gap: 10px; padding: 12px 20px; border-top: 1px solid #f0f0f0; }
.btn-study { padding: 7px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; background: #2980b9; color: white; }
.btn-study:hover { background: #1a6a9a; }
.btn-random { padding: 7px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: #f0f0f0; color: #555; transition: all 0.2s; }
.btn-random:hover { background: #e0e0e0; }

/* Question List */
.question-list { padding: 0 20px 16px; border-top: 1px solid #f0f0f0; }
.q-item { border: 1px solid #e8e8e8; border-radius: 10px; margin: 10px 0; overflow: hidden; transition: border-color 0.2s; }
.q-item:hover { border-color: #2980b9; }
.q-item.done { border-color: #a8e6cf; background: #faffff; }
.q-item.wrong { border-color: #ff9a9a; background: #fff8f8; }
.q-item-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none; }
.q-item-header:hover { background: #f8f9fa; }
.q-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: bold; white-space: nowrap; }
.q-badge.choice { background: #e8f5e9; color: #2e7d32; }
.q-badge.multi { background: #fff3e0; color: #e65100; }
.q-badge.fill { background: #e3f2fd; color: #1565c0; }
.q-badge.sa { background: #f3e5f5; color: #6a1b9a; }
.q-preview { font-size: 13px; color: #444; flex: 1; }
.tag-wrong { font-size: 11px; color: #d32f2f; background: #ffebee; padding: 2px 6px; border-radius: 4px; }
.tag-done { font-size: 11px; color: #2e7d32; background: #e8f5e9; padding: 2px 6px; border-radius: 4px; }
.q-item-body { padding: 0 14px 14px; display: none; }
.q-item-body:not(.hidden) { display: block; }
.q-text-full { font-size: 14px; margin-bottom: 12px; line-height: 1.8; }
.q-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.opt-label { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border-radius: 8px; background: #f8f9fa; font-size: 14px; cursor: pointer; transition: background 0.2s; }
.opt-label:hover { background: #e3f2fd; }
.opt-label.opt-correct { background: #e8f5e9; border: 1px solid #a5d6a7; }
.opt-key { font-weight: bold; color: #2980b9; min-width: 20px; }
.answer-box { background: #fffde7; border: 1px solid #fff59d; border-radius: 8px; padding: 12px; margin-bottom: 10px; font-size: 13px; line-height: 1.8; }
.q-footer { display: flex; justify-content: space-between; align-items: center; }
.btn-mark-wrong { font-size: 12px; padding: 5px 12px; background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; border-radius: 6px; cursor: pointer; }
.btn-next { padding: 6px 16px; background: #2980b9; color: white; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.btn-next:hover { background: #1a6a9a; }

/* Quiz Controls */
.quiz-controls { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.quiz-controls select { padding: 9px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: white; cursor: pointer; }
.btn-start-quiz { padding: 9px 20px; background: linear-gradient(135deg, #2980b9, #6c5ce7); color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: bold; cursor: pointer; margin-left: auto; }
.btn-start-quiz:hover { opacity: 0.9; }

/* Quiz Area */
.quiz-area { display: flex; flex-direction: column; gap: 16px; }
.quiz-progress { text-align: center; font-size: 13px; color: #888; background: white; padding: 8px; border-radius: 8px; }
.quiz-card { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.q-type-tag { font-size: 11px; background: #e3f2fd; color: #1565c0; padding: 2px 10px; border-radius: 10px; display: inline-block; margin-bottom: 12px; }
.quiz-q { font-size: 16px; margin-bottom: 16px; line-height: 1.8; }
.quiz-opt { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1.5px solid #e0e0e0; border-radius: 8px; margin-bottom: 8px; cursor: pointer; transition: all 0.2s; font-size: 14px; }
.quiz-opt:hover { border-color: #2980b9; background: #f0f7ff; }
.quiz-opt.selected { border-color: #2980b9; background: #e3f2fd; }
.quiz-opt input { display: none; }
.opt-letter { font-weight: bold; color: #2980b9; min-width: 24px; }
.quiz-textarea { width: 100%; min-height: 100px; padding: 12px; border: 1.5px solid #ddd; border-radius: 8px; font-size: 14px; resize: vertical; font-family: inherit; }
.quiz-btns { display: flex; justify-content: space-between; gap: 10px; }
.btn-quiz-prev, .btn-quiz-next { padding: 10px 24px; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-quiz-prev { background: #f0f0f0; color: #555; }
.btn-quiz-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-quiz-next { background: #2980b9; color: white; flex: 1; }
.btn-quiz-next:hover { background: #1a6a9a; }

/* Quiz Result */
.quiz-result { display: flex; flex-direction: column; gap: 16px; }
.result-card { text-align: center; padding: 32px; border-radius: 16px; color: white; }
.result-card.great { background: linear-gradient(135deg, #2e7d32, #388e3c); }
.result-card.ok { background: linear-gradient(135deg, #e65100, #ef6c00); }
.result-card.fail { background: linear-gradient(135deg, #c62828, #d32f2f); }
.result-score { font-size: 48px; font-weight: bold; }
.result-pct { font-size: 24px; margin-top: 4px; }
.result-msg { font-size: 16px; margin-top: 8px; opacity: 0.9; }
.btn-again { margin-top: 16px; padding: 10px 24px; background: rgba(255,255,255,0.25); border: 2px solid rgba(255,255,255,0.5); border-radius: 8px; color: white; font-size: 15px; cursor: pointer; }
.btn-again:hover { background: rgba(255,255,255,0.35); }
.result-detail { display: flex; flex-direction: column; gap: 12px; }
.rd-item { background: white; border-radius: 10px; padding: 14px; border-left: 4px solid; }
.rd-item.right { border-color: #2e7d32; }
.rd-item.wrong { border-color: #c62828; }
.rd-item p { margin-bottom: 4px; font-size: 14px; line-height: 1.7; }

/* Wrong/All List */
.wrong-list, .all-list { display: flex; flex-direction: column; gap: 12px; }
.wrong-item { background: white; border-radius: 10px; padding: 16px; border-left: 4px solid #c62828; }
.wrong-item h3 { font-size: 15px; margin-bottom: 8px; }
.wrong-item button { margin-top: 8px; padding: 5px 12px; background: #e8f5e9; color: #2e7d32; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; }

/* Search */
.search-box { margin-bottom: 16px; }
#search-input { width: 100%; padding: 12px 16px; border: 1.5px solid #ddd; border-radius: 10px; font-size: 15px; outline: none; transition: border-color 0.2s; }
#search-input:focus { border-color: #2980b9; }

/* Misc */
.empty-msg { text-align: center; padding: 48px; color: #aaa; font-size: 16px; }
.hidden { display: none !important; }
.footer { text-align: center; padding: 32px; color: #bbb; font-size: 13px; margin-top: 40px; }

/* Responsive */
@media (max-width: 640px) {
  .hero-card { flex-direction: column; text-align: center; }
  .hero-progress-ring { margin-left: 0; }
  .mode-tabs { flex-wrap: wrap; }
  .cat-header { flex-direction: column; gap: 10px; align-items: flex-start; }
  .quiz-controls { flex-direction: column; }
  .btn-start-quiz { margin-left: 0; }
  .topbar-stats .progress-bar-mini { display: none; }
}
