/* === 双马一矿 · 煤矿技术工具箱 === */
:root {
  --primary: #1a3a5c;
  --primary-light: #2c5f8a;
  --accent: #e8741a;
  --accent-light: #f5a623;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dce1e8;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 10px;
  --sidebar-w: 220px;
  --header-h: 60px;
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* === Layout === */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .logo {
  font-size: 24px;
}

.sidebar-header h1 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.sidebar-header h1 small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: .7;
}

.nav-list {
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 10px;
  cursor: pointer;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  transition: all .2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover, .nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: var(--accent);
}

.nav-item .icon { font-size: 16px; width: 22px; text-align: center; }

/* === Main Content === */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 20px 24px;
  min-height: 100vh;
}

.page {
  display: none;
  animation: fadeIn .25s ease;
}

.page.active { display: block; }

@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
}

.page-header p {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 4px;
}

/* === Cards === */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}

.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #d46618; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-outline { background: transparent; color: var(--primary-light); border: 1px solid var(--primary-light); }
.btn-outline:hover { background: var(--primary-light); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* === Form Controls === */
input[type="text"], input[type="number"], input[type="file"], textarea, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border .2s;
  background: #fff;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(44,95,138,.12);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row > * { flex: 1; min-width: 120px; }

/* === Question Card === */
.question-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.question-number {
  display: inline-block;
  background: var(--primary-light);
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 10px;
}

.question-text {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.question-options { display: flex; flex-direction: column; gap: 8px; }

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  font-size: 14px;
  line-height: 1.5;
}

.option-item:hover { border-color: var(--primary-light); background: #f7f9fc; }
.option-item.selected { border-color: var(--primary-light); background: #eef3fa; }
.option-item.correct { border-color: var(--success); background: #eafaf1; }
.option-item.wrong { border-color: var(--danger); background: #fdedec; }
.option-item.show-correct { border-color: var(--success); background: #eafaf1; }
.option-item input[type="radio"] { margin-top: 2px; }

.option-label { font-weight: 600; color: var(--primary); }

.answer-feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
}

.answer-feedback.correct { background: #eafaf1; color: #1e8449; border-left: 4px solid var(--success); }
.answer-feedback.wrong { background: #fdedec; color: #922b21; border-left: 4px solid var(--danger); }

/* === Quiz Controls === */
.quiz-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-light);
  border-radius: 4px;
  transition: width .3s;
}

/* === Stats === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  text-align: center;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* === Tabs === */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }

.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  font-weight: 500;
}

.tab:hover { color: var(--primary-light); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }

/* === Regulation Tree === */
.reg-tree { font-size: 14px; }

.reg-chapter {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.reg-chapter-header {
  padding: 10px 14px;
  background: #f7f9fc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--primary);
}

.reg-chapter-header:hover { background: #eef3fa; }

.reg-chapter-body { display: none; padding: 0; }
.reg-chapter-body.open { display: block; }

.reg-article {
  padding: 8px 14px 8px 28px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  font-size: 13px;
  line-height: 1.5;
}

.reg-article:hover { background: #f7f9fc; }
.reg-article .article-num { font-weight: 600; color: var(--primary-light); }
.reg-article .article-title { color: var(--text-light); margin-left: 6px; }

.reg-article-content {
  display: none;
  padding: 12px 16px 12px 40px;
  background: #fafbfc;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.reg-article-content.open { display: block; }

/* === Search === */
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-box input { flex: 1; }
.search-box input:focus { border-color: var(--accent); }

.search-results .result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.6;
}

.search-results .result-item:hover { background: #f7f9fc; }

.search-highlight { background: #fff3cd; padding: 0 2px; }

/* === Danger Judgment === */
.danger-category {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.danger-category-header {
  padding: 12px 14px;
  background: #fef9e7;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #856404;
  border-left: 4px solid var(--warning);
}

.danger-item {
  display: none;
  padding: 10px 14px 10px 28px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
}

.danger-item.open { display: block; }

.danger-item .danger-code {
  font-weight: 600;
  color: var(--danger);
  margin-right: 6px;
}

/* === Calculator Grid === */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.calc-card {
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  border: 1px solid var(--border);
}

.calc-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.12); border-color: var(--primary-light); }

.calc-card .calc-icon { font-size: 32px; margin-bottom: 8px; }
.calc-card .calc-name { font-size: 14px; font-weight: 600; }
.calc-card .calc-desc { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
  justify-content: center;
  align-items: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; color: var(--primary); }

.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  background: none;
  border: none;
  padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

/* === Badge === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-danger { background: #fdedec; color: var(--danger); }
.badge-warning { background: #fef9e7; color: #856404; }
.badge-success { background: #eafaf1; color: var(--success); }
.badge-info { background: #eef3fa; color: var(--info); }

/* === Answer Sheet === */
.answer-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.answer-sheet-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}

.answer-sheet-item.answered { border-color: var(--primary-light); background: #eef3fa; color: var(--primary-light); }
.answer-sheet-item.correct { border-color: var(--success); background: #eafaf1; color: var(--success); }
.answer-sheet-item.wrong { border-color: var(--danger); background: #fdedec; color: var(--danger); }
.answer-sheet-item.current { border-width: 2px; border-color: var(--accent); }

.answer-sheet-item:hover { transform: scale(1.1); }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-bottom: 8px; }

/* === Scrollbar === */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 12px; }
  .hamburger { display: flex !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.hamburger {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* === Expert Mode === */
.expert-btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.chat-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  line-height: 1.6;
  font-size: 14px;
}

.chat-message.user { background: #eef3fa; }
.chat-message.assistant { background: #f0f4f8; border-left: 3px solid var(--accent); }

/* === Exam Timer === */
.exam-timer {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.exam-timer .timer-display {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* === Keyword Tags === */
.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.keyword-tag {
  padding: 4px 10px;
  background: #eef3fa;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  color: var(--primary-light);
  border: 1px solid transparent;
}

.keyword-tag:hover { background: var(--primary-light); color: #fff; }
.keyword-tag.active { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }

/* === Import Area === */
.import-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafbfc;
}

.import-area:hover { border-color: var(--primary-light); background: #f0f4f8; }
.import-area.dragover { border-color: var(--accent); background: #fef9e7; }
.import-area .import-icon { font-size: 40px; margin-bottom: 12px; }
.import-area p { font-size: 14px; color: var(--text-light); }

/* === Exam Result === */
.exam-result {
  text-align: center;
  padding: 40px 20px;
}

.exam-result .score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  margin: 0 auto 16px;
  border: 4px solid;
}

.exam-result .score-circle.pass { border-color: var(--success); color: var(--success); }
.exam-result .score-circle.fail { border-color: var(--danger); color: var(--danger); }
