/* 备考复习小助手 */
:root {
  --bg: #22223a;
  --surface: #2e2e4a;
  --border: #4a4a6a;
  --text: #eeeef5;
  --text-secondary: #b0b0cc;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-light: #2d2518;
  --success: #4ade80;
  --success-light: #1a2e1a;
  --danger: #f87171;
  --danger-light: #2e1a1a;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.45);
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg: #fffbeb;
  --surface: #ffffff;
  --border: #fde68a;
  --text: #78350f;
  --text-secondary: #a16207;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-light: #fef3c7;
  --success: #65a30d;
  --success-light: #ecfccb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --shadow: 0 1px 3px rgba(217,119,6,0.06), 0 1px 2px rgba(217,119,6,0.04);
  --shadow-md: 0 4px 16px rgba(217,119,6,0.08);
  --shadow-lg: 0 8px 24px rgba(217,119,6,0.10);
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Navigation */
.nav {
  display: flex; gap: 0; justify-content: space-between; align-items: center;
  padding: 0 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.nav-left { display: flex; gap: 0; white-space: nowrap; align-items: center; }
.nav a, .nav-left a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.9rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s ease;
  border-radius: 4px 4px 0 0;
}
.nav a:hover, .nav-left a:hover { color: var(--accent-hover); background: var(--accent-light); }
.nav a.active, .nav-left a.active { color: var(--accent-hover); border-bottom-color: var(--accent); font-weight: 600; }
.theme-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.35rem 0.6rem;
  cursor: pointer; font-size: 1rem; line-height: 1;
  transition: all 0.2s ease; color: var(--text);
}
.theme-toggle:hover { background: var(--accent-light); }
.nav-bank-select {
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.3rem 1.8rem 0.3rem 0.6rem;
  color: var(--text); font-size: 0.82rem; font-family: var(--font);
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
}
.nav-bank-select:focus { outline: none; border-color: var(--accent); }
.nav-bank-select option { background: var(--surface); color: var(--text); }

/* Main */
.main { max-width: 800px; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }

h1 { font-size: 1.75rem; font-weight: 700; color: var(--text); margin-bottom: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 600; color: var(--text); margin-bottom: 0.75rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }

/* Form */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; color: var(--text); }

select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a16207' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }

.title-row { display: block; margin-bottom: 1.5rem; }
.title-row h2 { margin-bottom: 0; white-space: nowrap; }
.title-row select { width: auto; max-width: 300px; }

.bank-filter { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; }
.bank-filter label { font-weight: 600; color: var(--text); }
.bank-filter select { width: auto; max-width: 200px; }

.type-filter {
  padding: 0.35rem 1.5rem 0.35rem 0.5rem; font-size: 0.85rem; font-family: var(--font);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer; max-width: 100px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a16207' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.35rem center;
}

/* Mode Cards */
.mode-section {
  background: var(--surface);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.mode-section h2 { margin-bottom: 1.25rem; }
.mode-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.mode-card {
  display: block;
  padding: 1.2rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg);
}
.mode-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.mode-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(245,158,11,0.2);
  border-left: 4px solid var(--accent);
}
.mode-card input[type="radio"] { accent-color: var(--accent); vertical-align: middle; margin-right: 0.35rem; }
.mode-card strong { display: inline; font-size: 0.95rem; font-weight: 600; margin-bottom: 0.15rem; }
.mode-card p { color: var(--text-secondary); font-size: 0.82rem; margin: 0.1rem 0 0 1.1rem; }

/* Buttons */
.btn-primary {
  display: inline-block;
  padding: 0.7rem 1.8rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #b45309);
  box-shadow: 0 4px 12px rgba(217,119,6,0.3);
  transform: translateY(-1px);
}

/* Quiz */
.quiz-container { max-width: 760px; }
.quiz-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.mode-badge {
  background: var(--accent-light); color: var(--accent-hover);
  padding: 0.35rem 0.9rem; border-radius: 100px;
  font-size: 0.95rem; font-weight: 600;
}
.progress-text { flex: 1; text-align: center; font-weight: 500; color: var(--text-secondary); font-size: 0.9rem; }
.btn-back { color: var(--text-secondary); text-decoration: none; font-size: 0.88rem; transition: color 0.2s; }
.btn-back:hover { color: var(--accent-hover); }

/* Progress Bar */
.progress-bar-container { margin-bottom: 1.25rem; }
.progress-bar-info { display: flex; justify-content: space-between; margin-bottom: 0.4rem; font-size: 0.82rem; color: var(--text-secondary); }
.progress-bar-track { height: 6px; background: var(--accent-light); border-radius: 3px; overflow: hidden; }
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 3px; transition: width 0.4s ease;
}

/* Question Card */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--accent);
}
.question-type {
  font-size: 0.75rem; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; margin-bottom: 0.75rem;
}
.question-stem { font-size: 1.1rem; line-height: 1.75; margin-bottom: 1.25rem; font-weight: 500; }

pre {
  background: #1e1e2e; color: #e2e4e9;
  padding: 1rem; border-radius: var(--radius-sm);
  overflow-x: auto; margin-bottom: 1rem;
  font-size: 0.88rem; line-height: 1.6;
}
[data-theme="light"] pre {
  background: var(--accent-light); color: var(--text);
}

/* Options */
.options { display: flex; flex-direction: column; gap: 0.5rem; }
.option-btn {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  font-family: var(--font);
  transition: all 0.2s ease;
}
.option-btn:hover { border-color: var(--accent); background: var(--accent-light); transform: translateX(2px); }
.option-btn.selected { border-color: var(--accent); background: var(--accent-light); box-shadow: 0 0 0 2px rgba(245,158,11,0.2); }
.option-btn.correct-pick { border-color: var(--success); background: var(--success-light); }
.option-btn.wrong-pick { border-color: var(--danger); background: var(--danger-light); }
.option-label {
  background: var(--bg); width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0; border: 2px solid var(--border);
  transition: all 0.2s ease;
}
.option-btn:hover .option-label { border-color: var(--accent); color: var(--accent-hover); }
.option-btn.correct-pick .option-label { border-color: var(--success); color: var(--success); }
.option-btn.wrong-pick .option-label { border-color: var(--danger); color: var(--danger); }

/* Fill-in-blank & Short Answer */
.blank-group { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.blank-group label { font-weight: 600; min-width: 60px; }
.blank-input, .shortanswer-input, #topic-input, #followup-input {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.blank-input:focus, .shortanswer-input:focus, #topic-input:focus, #followup-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}
.blank-input { flex: 1; }
.shortanswer-input { width: 100%; resize: vertical; min-height: 120px; margin-bottom: 0.75rem; }

/* Results */
.result-box { margin-top: 1.5rem; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.result-icon {
  font-weight: 600; padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm); margin-bottom: 0.75rem;
  font-size: 0.95rem; display: flex; align-items: center; gap: 0.5rem;
}
.result-correct { background: var(--success-light); color: var(--success); border: 1px solid rgba(101,163,13,0.2); }
.result-wrong { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(220,38,38,0.15); }
.result-info { background: var(--accent-light); color: var(--accent-hover); border: 1px solid rgba(245,158,11,0.15); }

.explanation-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 0.65rem;
  border-left: 3px solid var(--border);
}
.explanation-box h4 { margin-bottom: 0.4rem; font-size: 0.9rem; color: var(--text); }
.explanation-box.targeted { border-left: 3px solid var(--accent); background: var(--accent-light); }

/* Markdown rendered content */
.markdown-body {
  color: var(--text); font-size: 0.92rem; line-height: 1.7;
  background: var(--surface); border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  border: 1px solid var(--border);
}
.markdown-body p { margin: 0.5rem 0; padding-left: 1em; }
.markdown-body ul, .markdown-body ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.markdown-body ol { list-style-type: decimal; }
.markdown-body li { margin: 0.2rem 0; }
.markdown-body code {
  font-family: 'SimSun', 'Songti SC', 'Noto Serif CJK SC', serif;
  background: var(--accent-light); color: var(--accent-hover); font-weight: 600;
  padding: 0.1rem 0.35rem; border-radius: 3px;
}
[data-theme="light"] .markdown-body code {
  background: var(--accent); color: #1a1a2e;
}
.markdown-body pre {
  background: #1e1e2e; color: #e2e4e9; padding: 0.75rem 1rem;
  border-radius: var(--radius-sm); overflow-x: auto; margin: 0.6rem 0; line-height: 1.5;
}
[data-theme="light"] .markdown-body pre {
  background: var(--accent-light); color: var(--text);
}
.markdown-body pre code { background: none; color: inherit; padding: 0; font-size: 0.85rem; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; }
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left;
}
.markdown-body th { background: var(--accent-light); font-weight: 600; }
.markdown-body blockquote {
  border-left: 3px solid var(--accent); margin: 0.5rem 0;
  padding: 0.25rem 0.75rem; color: var(--text);
}
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.markdown-body h2, .markdown-body h3 { margin: 0.75rem 0 0.25rem; color: var(--text); font-weight: 600; }
.markdown-body h2 { font-size: 1rem; } .markdown-body h3 { font-size: 0.94rem; }
.markdown-body strong { color: var(--text); }
.markdown-body em { color: var(--text-secondary); }

.quiz-actions { margin-top: 1.5rem; position: relative; display: flex; justify-content: center; }
.quiz-actions .btn-primary { min-width: 120px; }

.btn-deep-analysis {
  display: inline-block;
  padding: 0.55rem 1.25rem;
  background: var(--accent-light);
  color: var(--accent-hover);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-deep-analysis:hover {
  background: var(--accent);
  color: #fff;
}
#deep-analysis-btn { position: absolute; left: 0; }
.question-loading { text-align: center; color: var(--text-secondary); padding: 3rem 0; }

/* Stats */
.stats-tabs { display: flex; margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.6rem 1.5rem; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-size: 0.9rem; font-family: var(--font); font-weight: 500;
  color: var(--text-secondary); transition: all 0.2s ease;
}
.tab-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.tab-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-btn:hover:not(.active) { background: var(--accent-light); color: var(--accent-hover); }

.chart-container { margin-bottom: 1.5rem; max-width: 400px; }
.chart-container.wide { max-width: 100%; }
.chart-skeleton {
  width: 100%; height: 250px;
  background: linear-gradient(90deg, var(--bg) 25%, var(--accent-light) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.stats-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stats-table th {
  background: var(--accent-light); padding: 0.75rem 1rem;
  text-align: left; font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent-hover); border-bottom: 2px solid var(--border);
}
.stats-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.93rem; }
.stats-table tbody tr:hover { background: var(--accent-light); }
.type-tag {
  background: var(--accent-light); padding: 0.2rem 0.6rem;
  border-radius: 4px; font-size: 0.78rem; font-weight: 600;
  color: var(--accent-hover);
}
.stats-table .col-type { min-width: 70px; padding-left: 0 !important; }
.stats-table .col-type .type-tag { padding-left: 0; }
.stats-table .col-num { min-width: 60px; }
.wrong-count { color: var(--danger); font-weight: 700; }
.question-preview { max-width: 300px; color: var(--text-secondary); }

.empty-msg { text-align: center; color: var(--text-secondary); padding: 4rem 0; line-height: 2; }
.empty-msg a { color: var(--accent-hover); text-decoration: none; font-weight: 600; }
.empty-msg a:hover { text-decoration: underline; }

/* Advice */
.advice-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
  box-shadow: var(--shadow); line-height: 1.85;
}

/* Study */
.study-setup {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
  box-shadow: var(--shadow);
}
.topic-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.topic-tag-btn {
  padding: 0.5rem 1rem; background: var(--accent-light);
  color: var(--accent-hover); border: 1px solid rgba(245,158,11,0.25);
  border-radius: 100px; cursor: pointer; font-size: 0.85rem;
  font-family: var(--font); font-weight: 500;
  transition: all 0.2s ease;
}
.topic-tag-btn:hover { background: var(--accent); color: #fff; transform: translateY(-1px); }
.manual-topic { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.manual-topic form { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }
#topic-input { width: 260px; flex: none; }
#followup-input { flex: 1; }
.generated-tag {
  background: rgba(245,158,11,0.12); color: var(--accent-hover);
  font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 8px;
  margin-left: 0.5rem; font-weight: 600; vertical-align: middle;
}

.followup-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem;
  margin-top: 1rem; box-shadow: var(--shadow);
}
#deep-analysis-result h3 { margin-bottom: 0.5rem; font-size: 1rem; }
#deep-analysis-result .markdown-body ul { list-style: none !important; padding-left: 0.5rem; }
#deep-analysis-result .markdown-body ul li { margin-bottom: 0.3rem; }
#deep-analysis-result .markdown-body ul li:last-child { margin-bottom: 0; }

.advice-content.markdown-body { background: none; border: none; padding: 0; }
.advice-content.markdown-body ul {
  list-style: disc !important;
  padding-left: 1.2rem;
}
.advice-content.markdown-body ul li::marker { color: var(--text-secondary); }
.advice-content.markdown-body ul li {
  padding-left: 0.25rem;
  margin-bottom: 0.3rem;
}
.advice-content.markdown-body ul li:last-child { margin-bottom: 0; }

.followup-section h4 { margin-bottom: 0.75rem; }
.followup-input-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
#followup-input, #deep-followup-input { flex: 1; }
.followup-msg { padding: 0.55rem 0.8rem; margin-bottom: 0.4rem; border-radius: var(--radius-sm); width: 100%; box-sizing: border-box; }
.followup-msg.user { background: var(--bg); border: 1px solid var(--border); }
.followup-msg.ai { background: var(--accent-light); border-left: 3px solid var(--accent); }
.followup-msg.ai.markdown-body { background: var(--accent-light); border: none; border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 0.55rem 0.8rem; }

/* Custom mode */
.custom-types { margin-bottom: 1.5rem; }
.custom-types h3, .custom-questions h3 { margin-bottom: 0.75rem; }
.custom-type-cards { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.custom-type-card {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1rem; background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s ease; user-select: none;
}
.custom-type-card.checked { border-color: var(--accent); background: var(--accent-light); }
.custom-type-card input[type=checkbox] { display: none; }
.custom-type-name { font-weight: 600; color: var(--text); }
.custom-type-count { font-size: 0.82rem; color: var(--text-secondary); }
.custom-questions { margin-bottom: 1.5rem; }
.custom-select-all { color: var(--accent-hover); cursor: pointer; font-size: 0.85rem; font-weight: 500; }
.custom-select-all:hover { text-decoration: underline; }
.custom-type-group { margin-bottom: 0.75rem; }
.custom-type-group h4 { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.custom-num-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; user-select: none; }
.custom-num-tag {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 32px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer; transition: all 0.15s ease; user-select: none;
  font-size: 0.85rem; color: var(--text-secondary);
}
.custom-num-tag.checked { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.custom-num-tag:hover { border-color: var(--accent); }
.custom-num-tag input[type=checkbox] { display: none; }

.hint { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.88rem; }
.tab-content { animation: fadeIn 0.2s ease; }

/* Concept Card */
.concept-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow); border-left: 4px solid var(--accent);
}
.concept-card h3 { color: var(--accent-hover); margin-bottom: 0.75rem; }
.concept-body { line-height: 1.8; }

/* Form error */
.form-error-msg {
  color: var(--danger); background: var(--danger-light);
  border: 1px solid var(--danger); border-radius: var(--radius-sm);
  padding: 0.6rem 1rem; margin-bottom: 1rem; font-size: 0.9rem;
}

/* Additional followup inputs */
#study-followup-input, #advice-followup-input,
#deep-followup-input { flex: 1; }

/* Small button */
.btn-small {
  padding: 0.35rem 0.75rem; font-size: 0.8rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-secondary);
  cursor: pointer; font-family: var(--font); transition: all 0.2s ease;
}
.btn-small:hover { border-color: var(--accent); color: var(--accent-hover); }

/* Study quiz / blank */
.study-quiz { margin-top: 1rem; }
.manual-topic-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.manual-topic-form input { flex: 1; min-width: 200px; }

/* Chart variants */
.chart-bar, .chart-pie { width: 100%; }
.charts-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.charts-row > * { flex: 1; min-width: 300px; }
.charts-row .chart-bar { flex: 1; min-width: 100%; }
.charts-pie-row > * { flex: 1; min-width: 280px; max-width: 50%; }

/* Legend */
.legend-dot, .legend-line { display: inline-block; vertical-align: middle; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; margin-right: 0.35rem; }
.legend-line { width: 28px; height: 0; margin-right: 0.35rem; }
.legend-item { display: inline-flex; align-items: center; margin-right: 1.25rem; font-size: 0.85rem; color: var(--text); }
.legend-line.solid { border-top: 3px solid var(--text-secondary); }
.legend-line.dashed { border-top: 3px dashed var(--text-secondary); }
.legend-line.dotted { border-top: 3px dotted var(--text-secondary); }
.cold { background: #64b496; }
.hot { background: #f59e0b; }

/* Topics Page */
.topics-toolbar { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; align-items: center; }
.topics-search {
  width: 180px; padding: 0.5rem 0.75rem; font-size: 0.9rem; font-family: var(--font);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); outline: none; transition: border-color 0.2s;
}
.topics-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,0.12); }
.topics-sort { font-size: 0.85rem; font-family: var(--font); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 0.45rem 1.6rem 0.45rem 0.5rem; cursor: pointer; width: 120px; appearance: auto; }

.topics-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}
.topic-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow); transition: all 0.2s ease;
  cursor: pointer;
}
.topic-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.topic-card.expanded { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(245,158,11,0.25); grid-column: 1 / -1; }
.topic-card-header { display: flex; justify-content: space-between; align-items: center; }
.topic-name { font-weight: 600; font-size: 0.95rem; color: var(--text); flex: 1; padding-right: 0.5rem; }
.topic-count { font-size: 0.72rem; color: var(--accent-hover); background: var(--accent-light); padding: 0.2rem 0.55rem; border-radius: 100px; font-weight: 600; white-space: nowrap; }
.topic-card-header::after { content: "▾"; color: var(--text-secondary); font-size: 0.65rem; margin-left: 0.5rem; transition: transform 0.2s; flex-shrink: 0; }
.topic-card.expanded .topic-card-header::after { transform: rotate(180deg); }

.topic-questions { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.topic-questions-loading { color: var(--text-secondary); font-size: 0.85rem; }
.topic-q-item {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0;
  border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.topic-q-item:last-child { border-bottom: none; }
.topic-q-type {
  font-size: 0.7rem; background: var(--accent-light); color: var(--accent-hover);
  padding: 0.1rem 0.4rem; border-radius: 3px; font-weight: 600; flex-shrink: 0;
}
.topic-q-empty { color: var(--text-secondary); font-size: 0.85rem; padding: 0.5rem 0; }

/* Knowledge Graph */
.graph-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 1.5rem;
  height: 500px;
}
.graph-container:fullscreen {
  height: 100vh; border-radius: 0; background: var(--bg);
  padding: 1rem;
}
.graph-legend { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.user-graph-section { margin-top: 2rem; }
.graph-user { margin-top: 0.5rem; }

/* Admin */
.admin-charts { display: flex; flex-direction: column; gap: 1rem; }
.admin-chart-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.admin-chart-row > * { flex: 1; min-width: 350px; }
.admin-chart-row-split { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.admin-chart-row-split > * { flex: 1; min-width: 300px; }

/* Responsive */
@media (max-width: 640px) {
  html { font-size: 15px; }
  .nav { padding: 0 0.75rem; gap: 0; }
  .nav a, .nav-left a { padding: 0.75rem 0.65rem; font-size: 0.82rem; }
  .main { padding: 1.5rem 0.75rem 3rem; }
  .mode-cards { grid-template-columns: 1fr; }
  .quiz-header { flex-wrap: wrap; gap: 0.5rem; }
  .stats-table th, .stats-table td { padding: 0.5rem; font-size: 0.8rem; }
  .chart-container { max-width: 100%; }
  .topics-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-chart-row, .admin-chart-row-split { flex-direction: column; }
  .admin-chart-row > *, .admin-chart-row-split > * { min-width: 100%; }
  .charts-row { flex-direction: column; }
  .charts-row > * { min-width: 100%; }
  .charts-pie-row > * { max-width: 100%; }
}

/* Footer */
.footer {
  text-align: center;
  padding: 0.25rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 8rem;
}
.footer a {
  color: #666680;
  text-decoration: none;
  font-size: 0.75rem;
}
[data-theme="light"] .footer a {
  color: #c4b5a0;
}
.footer a:hover {
  color: var(--accent-hover);
}
