/* 温故 · 刷题复习系统 */
:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #8a919e;
  --accent: #4f6ef7;
  --accent-dark: #3d5be0;
  --accent-soft: #eef1fe;
  --ok: #2e9e5b;
  --warn: #d97a06;
  --err: #d24545;
  --bd: #e4e7ec;
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

main { max-width: 980px; margin: 24px auto 40px; padding: 0 16px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

h1, h2, h3 { line-height: 1.3; margin: 0 0 10px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin-top: 18px; color: #3c4250; }
.card h3:first-child { margin-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.spacer { flex: 1; }
.inline { display: inline; }

/* 顶部导航 */
.topnav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  background: var(--card);
  border-bottom: 1px solid var(--bd);
  padding: 0 20px; height: 52px;
}
.topnav a { color: #4a5060; padding: 4px 2px; border-bottom: 2px solid transparent; }
.topnav a.active, .topnav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.topnav .brand { font-weight: 700; font-size: 17px; color: var(--ink); border: none; }
.nav-email { color: var(--muted); font-size: 13px; }
.topnav .nav-sub { color: var(--muted); font-size: 13px; }
.topnav .nav-sub:hover { color: var(--accent); }

footer {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 18px 0 30px;
}

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20, 24, 40, 0.04);
}

/* 提示条 */
.flash {
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid;
}
.flash.ok { background: #ecfaf1; color: #1f7a45; border-color: #bfe8cf; }
.flash.error { background: #fdf0f0; color: #a63636; border-color: #f2cfcf; }
.flash.message { background: var(--accent-soft); color: var(--accent-dark); border-color: #d5ddf9; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--bd);
  background: var(--card); color: var(--ink);
  border-radius: 9px; padding: 8px 16px;
  font-size: 14px; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #c9cfda; background: #f8f9fb; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #f0d3d3; }
.btn.danger:hover { background: #fdf3f3; border-color: #e5b8b8; }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn.big { padding: 12px 26px; font-size: 16px; }
.btn.block { width: 100%; }

/* 徽章与标签 */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; background: #eef0f4; color: #5b6270;
  vertical-align: middle;
}
.badge-approach { background: var(--accent-soft); color: var(--accent-dark); }
.badge-full { background: #fdf1e3; color: #b0620a; }
.badge-new { background: #e8f8ee; color: #22794a; }
.badge-early { background: #f3eefa; color: #7a4fd0; }

.tag {
  display: inline-block; padding: 0 8px; border-radius: 6px;
  font-size: 12px; background: #f0f2f6; color: #5b6270;
  margin-right: 4px;
}

/* 概览 */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.hero-label { color: var(--muted); font-size: 14px; }
.hero-num { font-size: 52px; font-weight: 700; line-height: 1.15; color: var(--ink); }
.hero-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat { text-align: center; padding: 14px 8px; margin-bottom: 0; }
.stat-num { font-size: 26px; font-weight: 700; }

/* 未来 7 天柱状 */
.bars { display: flex; gap: 14px; align-items: flex-end; padding: 6px 4px 0; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 44px; }
.bar {
  width: 26px; background: #ccd6fb; border-radius: 5px 5px 2px 2px;
  min-height: 3px;
}
.bar-col.today .bar { background: var(--accent); }
.bar-n { font-size: 12px; color: var(--ink); min-height: 16px; font-weight: 600; }
.bar-d { font-size: 11px; color: var(--muted); }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 6px 8px; border-bottom: 1px solid var(--bd);
}
td { padding: 8px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
.row-due td { background: #fdfaf6; }
.due-text { color: var(--warn); font-weight: 600; }
.ptitle { font-weight: 500; }
.ops { white-space: nowrap; text-align: right; }
.ops form { margin-left: 4px; }
.table-card { padding: 6px 16px; }

/* 列表页 */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; }
.search input[type="search"] { width: 240px; }
.filters { display: flex; gap: 8px; margin: 4px 0 14px; }
.filters a {
  padding: 3px 12px; border-radius: 999px; font-size: 13px;
  color: #5b6270; background: #eef0f4;
}
.filters a.on { background: var(--accent); color: #fff; }
.empty { padding: 40px 20px; }

/* 表单 */
label { display: block; font-size: 13px; color: #3c4250; margin: 14px 0 5px; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input:not([type]), select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--bd); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.14);
}
textarea { resize: vertical; }
.code-input, textarea#code { font-family: var(--mono); font-size: 13.5px; tab-size: 4; line-height: 1.55; }
.form-card { max-width: 760px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* 登录页 */
.login-card { max-width: 400px; margin: 60px auto 0; padding: 30px 32px; }
.brand-big { text-align: center; font-size: 30px; }
.hint {
  background: var(--accent-soft); color: var(--accent-dark);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 14px 0 2px;
}
.login-card .btn { margin-top: 18px; }

/* 复习页 */
.review-wrap { max-width: 780px; margin: 0 auto; }
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.review-card { padding: 26px 28px; }
.review-title { font-size: 24px; margin-bottom: 4px; }
.review-meta { margin-bottom: 18px; }
.phase { text-align: center; padding: 26px 0 10px; }
.phase p { font-size: 15.5px; }
.card-inner { border-top: 1px dashed var(--bd); padding-top: 4px; margin-top: 14px; }
#phase-body .card-inner:first-child { border-top: none; margin-top: 0; padding-top: 0; }

textarea#code {
  min-height: 320px; margin-bottom: 12px;
  background: #fbfcfe;
}

.postpone { text-align: center; margin: 4px 0 20px; }

/* 评分 */
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.btn.rating {
  flex-direction: column; gap: 2px;
  padding: 12px 8px;
  border-width: 1.5px;
}
.r-label { font-size: 15px; font-weight: 600; }
.r-next { font-size: 11.5px; font-weight: 400; opacity: .75; }
.r-again { color: var(--err); border-color: #eec7c7; background: #fef9f9; }
.r-again:hover { background: #fdeeee; border-color: #e0a8a8; }
.r-hard { color: var(--warn); border-color: #efd6b3; background: #fffdf7; }
.r-hard:hover { background: #fdf5e7; border-color: #e2bd85; }
.r-good { color: var(--ok); border-color: #bfe3cd; background: #f9fdfa; }
.r-good:hover { background: #eef8f1; border-color: #9dd2b2; }
.r-easy { color: var(--accent-dark); border-color: #c9d4fa; background: #fafbff; }
.r-easy:hover { background: #eff2fe; border-color: #a8b8f5; }

.rating-0 { color: var(--err); font-weight: 600; }
.rating-1 { color: var(--warn); font-weight: 600; }
.rating-2 { color: var(--ok); font-weight: 600; }
.rating-3 { color: var(--accent-dark); font-weight: 600; }

/* 完成页 */
.done-card { padding: 44px 24px; }
.done-card h2 { font-size: 24px; }
.done-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.later-table { max-width: 460px; margin: 16px auto 0; text-align: left; }

/* 详情页 */
.detail-head { margin-bottom: 14px; }
.detail-head h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

/* Markdown 渲染 */
.md { font-size: 14.5px; overflow-wrap: break-word; }
.md h1, .md h2, .md h3 { font-size: 15px; margin: 14px 0 6px; }
.md code {
  font-family: var(--mono); font-size: 13px;
  background: #f0f2f6; border-radius: 5px; padding: 1px 5px;
}
.md pre {
  background: #0f172a; color: #e2e8f0;
  border-radius: 9px; padding: 13px 15px;
  overflow-x: auto; line-height: 1.55;
}
.md pre code { background: none; padding: 0; color: inherit; font-size: 13px; }
.md ul, .md ol { padding-left: 22px; margin: 8px 0; }
.md blockquote {
  margin: 8px 0; padding: 4px 12px; color: #5b6270;
  border-left: 3px solid var(--bd);
}
.md table { margin: 8px 0; }
.md a { text-decoration: underline; }

pre.code {
  background: #0f172a; color: #e2e8f0;
  border-radius: 9px; padding: 13px 15px;
  overflow-x: auto; line-height: 1.55;
  font-family: var(--mono); font-size: 13px;
  margin: 8px 0;
}
pre.code code { font-family: inherit; background: none; }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; }
details pre.code { margin-top: 8px; }

/* 移动端 */
@media (max-width: 640px) {
  .hero { flex-direction: column; align-items: stretch; text-align: center; }
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { flex: 1; }
  .ratings { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topnav { padding: 0 10px; gap: 10px; overflow-x: auto; }
  .nav-email { display: none; }
  main { margin-top: 16px; }
}

/* ---------------- 目录式题库（LeetCode 风格） ---------------- */
.catalog { display: grid; grid-template-columns: 232px 1fr; gap: 16px; align-items: start; }

.cat-side { padding: 10px 8px; position: sticky; top: 68px; }
.cat-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 8px;
  color: #4a5060; font-size: 13.5px; line-height: 1.35;
}
.cat-item:hover { background: #f3f5f9; color: var(--ink); }
.cat-item.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.cat-item .cnt { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cat-item .cnt.done { color: var(--ok); }
.cat-side-title {
  padding: 14px 12px 4px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.cat-side-sync { padding: 12px 8px 4px; border-top: 1px solid var(--bd); margin-top: 10px; }
.cat-side-sync p { margin: 8px 4px 0; }

.cat-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.cat-head h2 { margin-bottom: 2px; }
.cat-group { margin-top: 4px; }
.group-title { font-size: 14px; color: #3c4250; margin: 14px 4px 8px; display: flex; gap: 8px; align-items: baseline; }

/* 状态图标 */
.st { font-size: 15px; display: inline-block; width: 1.2em; text-align: center; }
.st-todo { color: #b6bcc7; }
.st-due { color: var(--err); }
.st-new { color: var(--accent); }
.st-ok { color: var(--ok); }
.row-due td { background: #fdfaf6; }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }

/* 面包屑 + 逐题翻页 */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); }
.crumb .crumb-num { margin-right: 8px; color: var(--accent-dark); font-weight: 600; }
.pager {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 18px;
}
.pager .btn { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 未解决卡片 */
.todo-card { border-style: dashed; text-align: center; }
.todo-card .done-actions { justify-content: center; }

/* 导航复习角标 */
.nav-badge {
  display: inline-block; min-width: 18px; padding: 0 5px;
  background: var(--err); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 17px; vertical-align: 2px;
}
.stat-sub { font-size: 15px; color: var(--muted); font-weight: 500; }

/* 目录页移动端：侧边栏变成横向滚动条 */
@media (max-width: 860px) {
  .catalog { grid-template-columns: 1fr; }
  .cat-side {
    position: static; display: flex; gap: 6px; overflow-x: auto;
    padding: 8px; margin-bottom: 2px;
  }
  .cat-item { flex: 0 0 auto; white-space: nowrap; }
  .cat-side-title, .cat-side-sync { display: none; }
  .pager .btn { max-width: 100%; }
}
