/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f0f2f5; --surface: #ffffff; --surface-hover: #f8f9fb; --surface-2: #f1f5f9;
  --text: #1e293b; --text-secondary: #64748b; --text-muted: #94a3b8;
  --border: #e2e8f0; --border-light: #f1f5f9;
  --primary: #1e3a5f; --primary-light: #3b82f6; --primary-bg: #dbeafe;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius: 14px; --radius-sm: 8px; --radius-xs: 6px;
  --header-grad: linear-gradient(135deg, #1a3a6c 0%, #2d5aa0 50%, #1e3a5f 100%);
}
[data-theme="dark"] {
  --bg: #0f172a; --surface: #1e293b; --surface-hover: #334155; --surface-2: #334155;
  --text: #f1f5f9; --text-secondary: #94a3b8; --text-muted: #64748b;
  --border: #334155; --border-light: #1e293b;
  --primary: #60a5fa; --primary-light: #93c5fd; --primary-bg: #1e3a5f;
  --shadow: 0 1px 3px rgba(0,0,0,0.3); --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.75; padding: 0;
  transition: background 0.3s, color 0.3s;
}
/* === Header === */
.header {
  background: var(--header-grad); color: #fff; padding: 40px 20px 32px;
  text-align: center; position: relative; overflow: hidden;
}
.header::before {
  content: ""; position: absolute; top: -50%; right: -20%; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  border-radius: 50%;
}
.header::after {
  content: ""; position: absolute; bottom: -30%; left: -10%; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.header-content { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; }
.header h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; letter-spacing: 1px; }
.header h1 .emoji { font-size: 30px; }
.header .subtitle { font-size: 14px; opacity: 0.85; margin-bottom: 20px; }
.stats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.stat-card {
  background: rgba(255,255,255,0.12); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15); border-radius: var(--radius-sm);
  padding: 12px 20px; min-width: 90px; text-align: center;
}
.stat-num { font-size: 28px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.theme-toggle {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.25); transform: scale(1.1); }
/* === Toolbar === */
.toolbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 16px; box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}
.toolbar-inner { max-width: 860px; margin: 0 auto; }
.search-wrap { position: relative; margin-bottom: 10px; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 16px; pointer-events: none;
}
.search-input {
  width: 100%; padding: 11px 14px 11px 42px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 14px;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}
.search-input:focus {
  border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  background: var(--surface);
}
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.filter-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; margin-right: 2px; min-width: 42px; }
.btn {
  padding: 6px 14px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); border-radius: 20px; cursor: pointer;
  font-size: 12px; font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary-light); color: var(--primary-light); background: var(--surface-hover); }
.btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .btn.active { background: var(--primary-light); border-color: var(--primary-light); color: var(--bg); }
.action-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.action-btn {
  padding: 7px 14px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-secondary); border-radius: var(--radius-xs); cursor: pointer;
  font-size: 12px; font-weight: 500; transition: all 0.15s;
}
.action-btn:hover { background: var(--surface-hover); color: var(--primary); border-color: var(--primary-light); }
.result-count { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.result-count strong { color: var(--primary); font-weight: 700; }
[data-theme="dark"] .result-count strong { color: var(--primary-light); }
/* === Main === */
.main { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }
.year-section { margin-bottom: 24px; }
.year-title {
  font-size: 18px; font-weight: 700; color: var(--primary);
  padding: 8px 0 12px; border-bottom: 2px solid var(--primary);
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
[data-theme="dark"] .year-title { color: var(--primary-light); border-bottom-color: var(--primary-light); }
.year-count {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  background: var(--surface-2); padding: 2px 10px; border-radius: 12px;
}
/* === Card === */
.card {
  background: var(--surface); border-radius: var(--radius); margin-bottom: 12px;
  box-shadow: var(--shadow); overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s; border: 1px solid var(--border-light);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 16px 18px; cursor: pointer; display: flex; justify-content: space-between;
  align-items: flex-start; gap: 12px; transition: background 0.15s;
}
.card-header:hover { background: var(--surface-hover); }
.card-left { flex: 1; min-width: 0; }
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.badge {
  padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 3px; line-height: 1.4;
}
.badge-type-zhfx { background: #dbeafe; color: #2563eb; }
.badge-type-yjyb { background: #fee2e2; color: #dc2626; }
.badge-type-zzgl { background: #dcfce7; color: #16a34a; }
.badge-type-zwrz { background: #ede9fe; color: #7c3aed; }
.badge-type-rjgt { background: #cffafe; color: #0891b2; }
[data-theme="dark"] .badge-type-zhfx { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-type-yjyb { background: #3b1414; color: #fca5a5; }
[data-theme="dark"] .badge-type-zzgl { background: #14241a; color: #86efac; }
[data-theme="dark"] .badge-type-zwrz { background: #2d1b4e; color: #c4b5fd; }
[data-theme="dark"] .badge-type-rjgt { background: #0c2730; color: #67e8f9; }
.badge-year { background: var(--surface-2); color: var(--text-secondary); }
.badge-session { background: var(--surface-2); color: var(--text-muted); font-weight: 500; font-size: 10px; }
.tag-badge { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.tag-gp { background: #fee2e2; color: #dc2626; }
.tag-sz { background: #dbeafe; color: #2563eb; }
.tag-rd { background: #ffedd5; color: #ea580c; }
.tag-bs { background: #ffe4e6; color: #be123c; }
[data-theme="dark"] .tag-gp { background: #3b1414; color: #fca5a5; }
[data-theme="dark"] .tag-sz { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .tag-rd { background: #3b2410; color: #fdba74; }
[data-theme="dark"] .tag-bs { background: #3b0f1a; color: #fda4c0; }
.card-title { font-size: 14.5px; color: var(--text); line-height: 1.7; font-weight: 500; }
.card-title mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 2px; }
[data-theme="dark"] .card-title mark { background: #854d0e; color: #fef9c3; }
.arrow {
  color: var(--text-muted); transition: transform 0.25s ease;
  font-size: 14px; flex-shrink: 0; margin-top: 4px;
}
.card.open .arrow { transform: rotate(180deg); }
.card-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease;
}
.card.open .card-body { max-height: 6000px; }
.card-body-inner { padding: 0 18px 18px; border-top: 1px solid var(--border-light); margin-top: 0; }
.hint-bar {
  padding: 10px 14px; margin: 12px 0; background: var(--surface-2);
  border-radius: var(--radius-xs); font-size: 13px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.answer-section {
  border-left: 3px solid var(--primary-light); padding: 12px 16px;
  background: var(--surface-2); border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
[data-theme="dark"] .answer-section { border-left-color: var(--primary); }
.answer-title {
  font-size: 13px; font-weight: 700; color: var(--primary);
  margin-bottom: 8px; display: flex; align-items: center; gap: 5px;
}
[data-theme="dark"] .answer-title { color: var(--primary-light); }
.answer-content { font-size: 13.5px; line-height: 1.85; color: var(--text); }
.answer-content mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 2px; }
[data-theme="dark"] .answer-content mark { background: #854d0e; color: #fef9c3; }
.no-result { text-align: center; color: var(--text-muted); padding: 60px 20px; font-size: 15px; }
/* === Back to Top === */
.back-to-top {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  font-size: 20px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(20px);
  transition: all 0.3s ease; display: flex; align-items: center; justify-content: center;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { transform: scale(1.1); }
[data-theme="dark"] .back-to-top { background: var(--primary-light); color: var(--bg); }
/* === Footer === */
.footer { text-align: center; color: var(--text-muted); padding: 24px 20px; font-size: 12px; }
.footer a { color: var(--primary-light); text-decoration: none; }
/* === Responsive === */
@media (max-width: 640px) {
  .header { padding: 30px 16px 24px; }
  .header h1 { font-size: 20px; }
  .header h1 .emoji { font-size: 24px; }
  .stat-card { padding: 10px 14px; min-width: 72px; }
  .stat-num { font-size: 22px; }
  .toolbar { padding: 12px 12px; }
  .filter-label { min-width: 0; }
  .card-header { padding: 14px 14px; }
  .card-body-inner { padding: 0 14px 14px; }
  .card-title { font-size: 14px; }
  .main { padding: 16px 12px 32px; }
  .back-to-top { bottom: 20px; right: 20px; width: 42px; height: 42px; }
}
/* === Print === */
@media print {
  .toolbar, .back-to-top, .theme-toggle, .random-modal-overlay { display: none !important; }
  .card-body { max-height: none !important; overflow: visible !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: white; color: black; }
  .header { background: #1a3a6c !important; -webkit-print-color-adjust: exact; }
}
/* === Random Modal === */
.random-modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 500; display: none; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; transition: opacity 0.25s ease;
}
.random-modal-overlay.show { display: flex; opacity: 1; }
.random-modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 580px;
  max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(30px) scale(0.96); transition: transform 0.3s ease;
  border: 1px solid var(--border);
}
.random-modal-overlay.show .random-modal { transform: translateY(0) scale(1); }
.random-modal-header {
  padding: 16px 20px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-light); background: var(--header-grad); color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
}
.random-modal-header h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.random-modal-close {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); color: #fff;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: background 0.2s, transform 0.2s;
}
.random-modal-close:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); }
.random-modal-body { padding: 20px; }
.random-modal-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.random-modal-question {
  font-size: 16px; line-height: 1.8; color: var(--text); font-weight: 500;
  padding: 16px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 16px;
}
.random-modal-hint {
  text-align: center; padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.random-modal-answer {
  border-left: 3px solid var(--primary-light); padding: 14px 16px; background: var(--surface-2);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0; display: none;
}
.random-modal-answer.show { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.random-modal-answer-title { font-size: 14px; font-weight: 700; color: var(--primary); margin-bottom: 10px; display: flex; align-items: center; gap: 5px; }
[data-theme="dark"] .random-modal-answer-title { color: var(--primary-light); }
.random-modal-answer-content { font-size: 14px; line-height: 1.9; color: var(--text); }
.random-modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-light); display: flex; gap: 8px; }
.random-modal-btn {
  flex: 1; padding: 10px 16px; border: none; border-radius: var(--radius-xs); cursor: pointer;
  font-size: 14px; font-weight: 600; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 5px;
}
.random-modal-btn-reveal { background: var(--primary); color: #fff; }
.random-modal-btn-reveal:hover { background: var(--primary-light); }
.random-modal-btn-next { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.random-modal-btn-next:hover { background: var(--surface-hover); border-color: var(--primary-light); color: var(--primary); }
.random-modal-btn-close { background: transparent; color: var(--text-muted); border: 1px solid var(--border); flex: 0 0 auto; width: 44px; }
.random-modal-btn-close:hover { color: var(--text); }
[data-theme="dark"] .random-modal-btn-reveal { background: var(--primary-light); color: var(--bg); }
