:root {
  --bg: #17191d;
  --sidebar-bg: #101216;
  --sidebar-text: #b9c1cd;
  --accent: #e05a52;
  --accent-soft: #36201e;
  --ink: #e8eaee;
  --ink-soft: #9aa3b0;
  --card: #202328;
  --line: #2e3238;
  --green: #5cb85c;
  --green-soft: #1f2c22;
  --amber: #d99a3d;
  --amber-soft: #2f2718;
  --blue: #6ba8d8;
  --blue-soft: #1d2834;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --font: "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 15px;
}

.app { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  font-family: "KaiTi", "STKaiti", serif;
}
.brand-title { color: #fff; font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; opacity: .7; }

.nav { padding: 4px 10px; flex: 1; }
.nav-group-label {
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  opacity: .5; padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 14px; transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { width: 20px; text-align: center; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.streak-chip {
  background: rgba(255,255,255,.1); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; text-align: center;
}

/* ===== 主区 ===== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: rgba(23,25,29,.88);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.today { color: var(--ink-soft); font-size: 13px; }

.content { padding: 24px 28px 60px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ===== 通用组件 ===== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section-h { font-size: 18px; font-weight: 700; margin: 26px 0 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; cursor: pointer; border-radius: 8px;
  font-family: var(--font); font-size: 14px;
  padding: 9px 16px; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-amber { background: var(--amber); color: #1a1a1a; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

.badge {
  display: inline-block; font-size: 12px; padding: 2px 9px;
  border-radius: 999px; background: var(--blue-soft); color: var(--blue);
  margin-right: 6px; white-space: nowrap;
}
.badge-type { background: var(--accent-soft); color: var(--accent); }
.badge-cat { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #2a2e34; color: var(--ink-soft); }

/* 标签页 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 18px; }
.tab {
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); font-size: 14px;
  color: var(--ink-soft); transition: all .15s; font-family: var(--font);
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 题目/解析块 */
.q-block { border-left: 4px solid var(--accent); padding: 4px 14px; margin: 12px 0; }
.q-material { background: var(--amber-soft); border-radius: 8px; padding: 12px 16px; font-size: 14px; margin: 10px 0; }
.q-question { font-weight: 600; }
.q-answer { background: var(--green-soft); border-radius: 8px; padding: 12px 16px; margin: 10px 0; }
.q-analysis { background: var(--blue-soft); border-radius: 8px; padding: 12px 16px; margin: 10px 0; }
.q-skill { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; margin: 8px 0; font-size: 14px; }
.label { font-weight: 700; color: var(--green); }
.label-a { font-weight: 700; color: var(--blue); }
.label-t { font-weight: 700; color: var(--accent); }

/* 折叠卡片 */
details.collapse { border: 1px solid var(--line); border-radius: 10px; background: var(--card); margin-bottom: 10px; overflow: hidden; }
details.collapse summary {
  cursor: pointer; padding: 13px 18px; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.collapse summary::-webkit-details-marker { display: none; }
details.collapse summary::before { content: "▸"; color: var(--accent); transition: transform .15s; }
details.collapse[open] summary::before { transform: rotate(90deg); }
details.collapse .collapse-body { padding: 2px 18px 16px; border-top: 1px dashed var(--line); }

/* 练习区 */
textarea.answer-input {
  width: 100%; min-height: 120px; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; font-family: var(--font); font-size: 14px;
  resize: vertical; background: #14161a; color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.type-chip {
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  font-family: var(--font);
}
.type-chip:hover { border-color: var(--accent); color: var(--accent); }
.type-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 记忆条目 */
.mem-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 4px; border-bottom: 1px dashed var(--line); }
.mem-item:last-child { border-bottom: none; }
.mem-title { font-weight: 700; min-width: 96px; color: var(--accent); }
.mem-body { flex: 1; }
.mem-body .note { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.learn-flag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); white-space: nowrap; }

/* 仪表盘 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

.progress-bar { height: 10px; border-radius: 999px; background: #2e3238; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.progress-fill.green { background: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.empty { color: var(--ink-soft); text-align: center; padding: 30px 10px; }

/* markdown 简单渲染 */
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 2px 0; }
.md h3 { margin: 14px 0 6px; font-size: 15px; color: var(--ink); }
.md strong { color: var(--accent); }

/* 复习卡片 */
.review-card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); margin-bottom: 10px; }
.review-card .rv-title { font-weight: 700; flex: 1; }
.review-actions { display: flex; gap: 8px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3f47; border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 记忆卡片 ===== */
.btn-blue { background: var(--blue); color: #fff; }
.memory-stage { max-width: 640px; margin: 0 auto; }
.memory-progress { margin-bottom: 18px; }
.flashcard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 32px 28px; text-align: center; margin-bottom: 20px;
  min-height: 220px; display: flex; flex-direction: column; justify-content: center;
}
.flash-top { margin-bottom: 14px; display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.flash-title { font-size: 30px; font-weight: 800; letter-spacing: 1px; color: var(--accent); margin: 6px 0 12px; }
.flash-front-hint { color: var(--ink-soft); font-size: 14px; }
.flash-back { text-align: left; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 16px; }
.flash-note { margin-top: 12px; background: var(--amber-soft); border-radius: 8px; padding: 10px 14px; font-size: 14px; color: var(--amber); }
.memory-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.grade-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.grade-buttons .btn { min-width: 120px; justify-content: center; }

/* ===== 进度同步按钮 ===== */
.footer-actions { display: flex; gap: 8px; margin-top: 10px; }
.footer-actions .btn { flex: 1; justify-content: center; }

/* ===== 移动端 ===== */
.hamburger {
  display: none; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink); font-size: 18px; line-height: 1;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 40;
}
@media (max-width: 860px) {
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; height: 100dvh;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 50; width: 262px; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar-title { font-size: 17px; flex: 1; }
  .today { display: none; }
  .content { padding: 16px 14px 64px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-num { font-size: 24px; }
  .flash-title { font-size: 24px; }
  .flashcard { padding: 22px 16px; min-height: 180px; }
  .card { padding: 16px; }
  .q-material, .q-answer, .q-analysis { padding: 10px 12px; }
}
