/* ══════════════════════════════════════
   Alpha 题库 · 全局样式
   风格：温暖米白 · 现代 SaaS 质感
   ══════════════════════════════════════ */

/* ── 变量 ── */
:root {
  --bg:          #faf9f7;
  --bg-alt:      #ffffff;
  --bg-hover:    #f5f3f0;
  --surface:     #f0ede8;
  --surface-alt: #e8e4de;
  --border:      rgba(30,20,10,0.08);
  --border-md:   rgba(30,20,10,0.13);
  --border-lg:   rgba(30,20,10,0.2);

  --accent:      #5b5bd6;
  --accent-dim:  #4747c0;
  --accent-lite: rgba(91,91,214,0.1);
  --accent-glow: rgba(91,91,214,0.2);

  --green:    #16a34a;
  --green-bg: rgba(22,163,74,0.08);
  --red:      #dc2626;
  --red-bg:   rgba(220,38,38,0.08);
  --orange:   #ea580c;
  --orange-bg:rgba(234,88,12,0.08);
  --blue:     #2563eb;
  --blue-bg:  rgba(37,99,235,0.08);
  --teal:     #0f766e;
  --teal-bg:  rgba(15,118,110,0.08);
  --purple:   #7c3aed;
  --purple-bg:rgba(124,58,237,0.08);

  --text:        #1c1917;
  --text-sub:    #44403c;
  --text-muted:  #78716c;
  --text-faint:  #a8a29e;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.09), 0 2px 8px rgba(0,0,0,0.04);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;

  --font-sans: 'PingFang SC', 'Microsoft YaHei UI', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', ui-monospace, 'Courier New', monospace;
}

/* ── 重置 ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── 背景微纹理 ── */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(91,91,214,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 85%, rgba(234,88,12,0.03) 0%, transparent 50%);
}

/* ── 顶栏 ── */
.topbar {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: rgba(250,249,247,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--font-sans);
  font-size: 0.95rem; font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex; align-items: center; gap: 9px;
  letter-spacing: -0.01em;
}
.logo-gem {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── 导航 ── */
.nav { display: flex; gap: 1px; }
.nav a {
  padding: 5px 12px;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem; font-weight: 500;
  transition: all 0.15s;
  position: relative;
  display: flex; align-items: center; gap: 6px;
}
.nav a:hover { color: var(--text-sub); background: var(--surface); }
.nav a.active {
  color: var(--accent);
  background: var(--accent-lite);
}
.nav a.active::after {
  content: '';
  position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* ── 用户信息（topbar右侧） ── */
.topbar-user {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.82rem; color: var(--text-muted);
}
.topbar-user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-lite);
  border: 1px solid rgba(91,91,214,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: var(--accent);
}
.topbar-logout {
  background: none; border: 1px solid var(--border-md);
  border-radius: 6px; padding: 3px 10px;
  color: var(--text-muted); font-size: 0.78rem;
  cursor: pointer; font-family: var(--font-sans);
  transition: all 0.15s;
}
.topbar-logout:hover { border-color: var(--border-lg); color: var(--text); background: var(--surface); }

/* ── 通用卡片 ── */
.card {
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-md); }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.15s;
  text-decoration: none;
  font-family: var(--font-sans);
  white-space: nowrap;
  line-height: 1;
}
.btn-grad {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px var(--accent-glow);
}
.btn-grad:hover { background: var(--accent-dim); box-shadow: 0 2px 10px var(--accent-glow); }
.btn-soft {
  background: var(--accent-lite);
  color: var(--accent);
  border: 1px solid rgba(91,91,214,0.2);
}
.btn-soft:hover { background: rgba(91,91,214,0.15); border-color: rgba(91,91,214,0.35); }
.btn-white {
  background: var(--bg-alt);
  color: var(--text-sub);
  border: 1px solid var(--border-md);
  box-shadow: var(--shadow-sm);
}
.btn-white:hover { background: var(--surface); border-color: var(--border-lg); color: var(--text); }
.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(220,38,38,0.18);
}
.btn-danger:hover { background: rgba(220,38,38,0.14); border-color: rgba(220,38,38,0.3); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 章节色标 ── */
.ch-colors { --c1:#5b5bd6; --c2:#7c3aed; --c3:#0891b2; --c4:#0f766e; --c5:#2563eb; --c6:#16a34a; --c7:#9333ea; --c8:#ea580c; }

/* ── 题型徽章 ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 5px;
  font-size: 0.72rem; font-weight: 600;
  font-family: var(--font-mono);
}
.badge-single { background: var(--blue-bg);   color: #1d4ed8; border: 1px solid rgba(37,99,235,0.18); }
.badge-judge  { background: var(--teal-bg);   color: #0f766e; border: 1px solid rgba(15,118,110,0.2); }
.badge-fill   { background: var(--orange-bg); color: #c2410c; border: 1px solid rgba(234,88,12,0.2); }
.badge-code   { background: var(--purple-bg); color: #6d28d9; border: 1px solid rgba(124,58,237,0.2); }

/* ── 代码 ── */
code:not(pre code) {
  background: var(--surface);
  color: #6d28d9;
  padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  border: 1px solid var(--border-md);
}
pre {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
}
pre code { font-family: var(--font-mono); font-size: 0.83rem; }

/* ── 分节标题 ── */
.section-label {
  font-size: 0.68rem; font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin-bottom: 0.85rem;
  display: flex; align-items: center; gap: 10px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── 分隔线 ── */
.divider { height: 1px; background: var(--border); margin: 0.5rem 0; }

/* ── 动画 ── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(12px);} to { opacity:1; transform:translateY(0);} }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes shake    { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-5px)} 60%{transform:translateX(5px)} }
@keyframes popIn    { 0%{transform:scale(0.94);opacity:0} 60%{transform:scale(1.01)} 100%{transform:scale(1);opacity:1} }
@keyframes slideRight { from{transform:translateX(-100%)} to{transform:translateX(0)} }

.anim-up  { animation: fadeUp  0.35s cubic-bezier(.22,1,.36,1) both; }
.anim-in  { animation: fadeIn  0.25s ease both; }
.anim-pop { animation: popIn   0.3s cubic-bezier(.22,1,.36,1) both; }

/* ── 进度条 ── */
.progress-track {
  height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.7s cubic-bezier(.4,0,.2,1);
}

/* ── 侧边栏通用 ── */
.sidebar {
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 1.2rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-alt); border-radius: 3px; }

.sidebar-title {
  font-size: 0.65rem; font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.4rem 0.6rem 0.2rem;
  margin-top: 0.25rem;
}
.filter-btn {
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.855rem; font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
  transition: all 0.13s;
  display: flex; justify-content: space-between; align-items: center;
  width: 100%;
}
.filter-btn:hover { background: var(--surface); color: var(--text-sub); }
.filter-btn.active {
  background: var(--accent-lite);
  border-color: rgba(91,91,214,0.2);
  color: var(--accent);
  font-weight: 600;
}
.filter-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  background: var(--surface);
  padding: 1px 5px; border-radius: 4px;
}
.filter-btn.active .filter-count {
  background: var(--accent-lite);
  color: var(--accent);
}

/* ── Toggle ── */
.toggle { position: relative; width: 34px; height: 18px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border-md);
  border-radius: 9px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0.6rem;
}
.toggle-row span { font-size: 0.855rem; font-weight: 500; color: var(--text-sub); }

/* ── 响应式 ── */
@media (max-width: 768px) {
  .topbar { padding: 0 1rem; }
  .sidebar { position: relative; top: 0; height: auto; flex-direction: row; flex-wrap: wrap; gap: 0.35rem; }
}
