/* ============================================================
   CMC 网络题库 · 公共样式
   主板 5 块 + 讨论版 2 块，统一视觉与布局
   ============================================================ */
:root {
  --bg: #f5f7fa; --panel: #fff; --border: #e3e8ef; --text: #1f2937;
  --muted: #6b7280; --primary: #2563eb; --primary-d: #1d4ed8;
  --ok: #16a34a; --warn: #f59e0b; --err: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 顶栏 ---------------- */
header.topbar {
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; flex-wrap: wrap;
}
header.topbar .brand { font-size: 18px; font-weight: 700; margin-right: 4px; }
header.topbar .brand a { color: var(--text); }
header.topbar .brand a:hover { text-decoration: none; }
header.topbar .sub { color: var(--muted); font-size: 12px; margin-right: 8px; }
header.topbar .spacer { margin-left: auto; }
.nav-group { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.nav-group .group-label { font-size: 11px; color: #9ca3af; margin: 0 4px 0 10px; }
.nav-btn {
  font-size: 13px; padding: 6px 13px; border-radius: 8px; text-decoration: none;
  color: var(--text); border: 1px solid transparent; background: transparent; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.nav-btn:hover { background: #f3f4f6; text-decoration: none; }
.nav-btn.active { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; font-weight: 600; }
.topbar .badge {
  font-size: 12px; padding: 4px 10px; border-radius: 20px;
  background: #eef2ff; color: var(--primary); font-weight: 500; white-space: nowrap;
}
.topbar .logout, .topbar .login-link {
  font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-family: inherit; white-space: nowrap;
}
.topbar .login-link { color: var(--primary); border-color: #bfdbfe; }

/* ---------------- 页面容器 ---------------- */
.container { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.container.wide { max-width: 1240px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head .more { margin-left: auto; font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------------- 统计块 ---------------- */
.stat-strip { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 110px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.stat-box .n { font-size: 24px; font-weight: 700; }
.stat-box .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- 列表条目 ---------------- */
.list-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 4px;
  border-bottom: 1px solid #eef0f4;
}
.list-item:last-child { border-bottom: none; }
.list-item .main-col { flex: 1; min-width: 0; }
.list-item .ti { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.list-item .ti .katex-display { display: inline-block; margin: 0; }   /* 题面里的公式在标题行内渲染，别换行成块 */
.list-item .ti a { color: var(--text); }
.list-item .ti a:hover { color: var(--primary); }
.list-item .meta { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.list-item .excerpt { font-size: 13px; color: #64748b; margin-top: 6px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* 题解/讨论摘要里的行间公式：压成一行内联，避免块级公式把两行摘要顶掉 */
.list-item .excerpt .katex-display { display: inline-block; margin: 0 2px; vertical-align: middle; max-width: 100%; overflow: hidden; }

.tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: #f3f4f6; color: var(--muted); white-space: nowrap; }
.tag.fill { background: #dcfce7; color: #15803d; }
.tag.essay { background: #fef3c7; color: #b45309; }
.tag.proof { background: #ede9fe; color: #6d28d9; }
.tag.easy { background: #dcfce7; color: #15803d; }
.tag.medium { background: #fef3c7; color: #b45309; }
.tag.hard { background: #fee2e2; color: #b91c1c; }
.tag.upcoming { background: #e0e7ff; color: #4338ca; }
.tag.running { background: #dcfce7; color: #15803d; }
.tag.ended { background: #f3f4f6; color: #9ca3af; }
.tag.pin { background: #fef3c7; color: #b45309; }

/* ---------------- 难度徽章：9 档颜色分级 ---------------- */
/* 色相由绿→蓝→紫→红递进表示难度加深；未评级与无解是特殊档（灰 / 黑）。 */
.diff {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.5;
}
.diff-basic        { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.diff-prelim-minus { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.diff-prelim       { background: #cffafe; color: #0e7490; border-color: #a5f3fc; }
.diff-prelim-plus  { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.diff-final-minus  { background: #e0e7ff; color: #4338ca; border-color: #c7d2fe; }
.diff-final        { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.diff-final-plus   { background: #fae8ff; color: #a21caf; border-color: #f5d0fe; }
.diff-unsolvable   { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.diff-unrated      { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

/* ---------------- 按钮 ---------------- */
button, .btn { font-family: inherit; }
button.primary, .btn.primary {
  background: var(--primary); color: #fff; border: none; padding: 9px 20px; border-radius: 8px;
  font-size: 14px; cursor: pointer; font-weight: 500; transition: background .15s;
}
button.primary:hover, .btn.primary:hover { background: var(--primary-d); }
button.primary:disabled { background: #94a3b8; cursor: not-allowed; }
button.ghost, .btn.ghost {
  background: transparent; border: 1px solid var(--border); padding: 9px 16px;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text);
}
button.ghost:hover, .btn.ghost:hover { background: #f9fafb; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.mini-btn {
  font-size: 12px; padding: 5px 11px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; color: var(--primary); font-family: inherit; white-space: nowrap;
}
.mini-btn:hover { background: #eff6ff; border-color: #bfdbfe; }
a.mini-btn { display: inline-block; text-decoration: none; }
.mini-btn.solid { background: var(--primary); color: #fff; border-color: var(--primary); }
.mini-btn.solid:hover { background: var(--primary-d); }

/* ---------------- 表单 ---------------- */
label.field { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local],
select, textarea, input:not([type]) {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; }
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > label { flex: 1; min-width: 180px; }

/* ---------------- 空态 / 提示 ---------------- */
.empty { color: var(--muted); text-align: center; padding: 48px 0; font-size: 14px; }
.spinner {
  display: inline-block; width: 15px; height: 15px; border: 2px solid #cbd5e1;
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 12px 0; }
.err-box { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 12px 0; }
.ok-box { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 12px 0; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px;
  opacity: 0; transition: opacity .25s; z-index: 999; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px; cursor: pointer; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab .cnt { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ---------------- 表格 ---------------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
/* 窄屏：表格允许自身横向滚动，避免撑破整页 */
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { width: 100%; border-collapse: collapse; }
@media (max-width: 720px) { .table-scroll table { min-width: 520px; } }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #eef0f4; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; }
table.data tr:hover td { background: #f9fafb; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 徽标圆点 ---------------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.no { background: var(--err); } .dot.part { background: var(--warn); }
.score-tag { font-size: 15px; font-weight: 700; white-space: nowrap; }
.score-tag.ok { color: var(--ok); } .score-tag.part { color: var(--warn); } .score-tag.no { color: var(--err); }

/* 富文本正文（讨论/文章） */
.rich-body { line-height: 1.9; font-size: 15px; word-break: break-word; }
.rich-body h1, .rich-body h2, .rich-body h3 { margin: 18px 0 8px; }
.rich-body p { margin: 10px 0; }
.rich-body code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.rich-body pre { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.rich-body ul, .rich-body ol { padding-left: 22px; }
