/* ===== CSS Variables (复用简历蓝色系) ===== */
:root {
  --primary: #2b4c7e;
  --primary-light: #3b6dad;
  --primary-dark: #1e3656;
  --accent-bg: #edf2f8;
  --text: #2d3748;
  --text-secondary: #4a5568;
  --text-muted: #a0aec0;
  --border: #e2e8f0;
  --bg: #f7fafc;
  --bg-card: #fff;
  --success: #2e7d6f;
  --warning: #d69e2e;
  --sidebar-width: 220px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
}

body {
  font-family:
    "Noto Sans SC",
    "PingFang SC",
    "Microsoft YaHei",
    -apple-system,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.8;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-light);
}

/* ===== Index Page: Cards ===== */
.index-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 24px;
}

.index-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: center;
  margin-bottom: 8px;
}

.index-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 48px;
  font-size: 15px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  transition: all 0.25s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(43, 76, 126, 0.12);
  border-color: var(--primary-light);
}

.card-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--accent-bg);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-period {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--accent-bg);
  padding: 2px 12px;
  border-radius: 10px;
}

/* ===== Project Page: Layout ===== */
.project-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--primary-dark);
  color: #fff;
  padding: 24px 0;
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}

.sidebar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 12px;
  transition: color 0.2s;
}
.sidebar-back:hover {
  color: #fff;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.sidebar-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
}

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

.sidebar-nav a {
  display: block;
  padding: 8px 20px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  border-left: 3px solid transparent;
  transition: all 0.2s;
}
.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--primary-light);
}
.sidebar-nav a:target,
.sidebar-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-left-color: #fff;
}

.sidebar-nav .nav-num {
  display: inline-block;
  width: 20px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 600;
}
.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-nav ul a {
  padding: 5px 20px 5px 36px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  border-left: 3px solid transparent;
}
.sidebar-nav ul a:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.03);
  border-left-color: rgba(255, 255, 255, 0.3);
}
.sidebar-nav ul a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-left-color: rgba(255, 255, 255, 0.7);
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px 48px 80px;
  max-width: 960px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.page-meta {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* ===== Module Section ===== */
.module {
  margin-bottom: 40px;
  scroll-margin-top: 24px;
}

.module-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  position: relative;
}

.module-title::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 64px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

.module-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== Content Elements ===== */
.module-body {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 120px;
}

.module-body p {
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.note-list {
  list-style: none;
  padding: 0;
}

.note-list > li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 8px;
  line-height: 1.75;
}

.note-list > li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

code {
  display: inline-block;
  background: #f1f5f9;
  color: #c7254e;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-all;
}
pre[class*="language-"] {
  border-radius: 8px;
  padding: 16px 20px;
  margin: 8px 0;
  line-height: 1.7;
}
pre code {
  display: block;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 12.5px;
  word-break: normal;
  white-space: pre;
}

.sub-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.sub-heading:first-child {
  margin-top: 0;
}

.sub-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin: 12px 0 4px;
}

/* ===== 我会怎么讲 — h4 主标题 ===== */
.module-body h4 {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 28px 0 10px;
  padding: 6px 0 6px 12px;
  border-left: 3px solid var(--primary);
  background: linear-gradient(90deg, var(--accent-bg) 0%, transparent 100%);
  border-radius: 0 4px 4px 0;
}
.module-body h4:first-child {
  margin-top: 8px;
}

/* ===== 我会怎么讲 — 层级子标题（第一层/第二层 等） ===== */
.layer-title {
  font-size: 14px;
  font-weight: 700;
  color: #334155;
  margin: 20px 0 6px;
  padding-left: 2px;
  letter-spacing: 0.3px;
}

.collapse-section {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.collapse-section summary {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}
.collapse-section summary:hover {
  color: var(--primary);
}
.collapse-section .note-list {
  padding: 8px 14px 8px 30px;
}
.collapse-inner {
  padding: 4px 20px 12px 20px;
}
.collapse-inner h4 {
  margin: 14px 0 6px;
  padding: 0;
  border-left: none;
  background: none;
  font-size: 14px;
  color: #475569;
}
.collapse-inner .note-list {
  padding: 4px 0 4px 18px;
}

.qa-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin: 16px 0 6px;
}

.qa-label--ask {
  background: #fce7f3;
  color: #9d174d;
}

.qa-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: #9d174d;
}

.qa-divider::before,
.qa-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #f9a8d4;
}

.qa-divider span {
  background: #fce7f3;
  padding: 3px 12px;
  border-radius: 4px;
  white-space: nowrap;
}

.highlight-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  padding: 14px 18px;
  margin: 12px 0;
  font-size: 13.5px;
  line-height: 1.9;
  color: #78350f;
  position: relative;
}
.highlight-box b {
  color: #92400e;
}

.todo-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 13px;
  color: #991b1b;
}

/* ===== Sidebar: Quick Switch ===== */
.sidebar-switch {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-switch-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.sidebar-switch a {
  display: block;
  padding: 6px 12px;
  margin-bottom: 4px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  transition: all 0.2s;
}
.sidebar-switch a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.sidebar-switch a.current {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.12);
  font-weight: 600;
  pointer-events: none;
}

/* ===== Bagu: Frequency Badge ===== */
.freq-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  margin-top: 8px;
}
.freq-badge--s { background: #fef2f2; color: #dc2626; }
.freq-badge--a { background: #fffbeb; color: #d97706; }
.freq-badge--b { background: #f0fdf4; color: #16a34a; }

/* ===== Bagu: Q&A card inside module ===== */
.qa-card {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.qa-card summary {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.qa-card summary::-webkit-details-marker { display: none; }
.qa-card summary::before {
  content: "▸ ";
  color: var(--primary);
  font-size: 12px;
}
.qa-card[open] summary::before { content: "▾ "; }
.qa-card[open] summary {
  border-bottom: 1px solid var(--border);
}
.qa-card .qa-inner {
  padding: 12px 20px 16px;
  font-size: 13.5px;
  line-height: 1.8;
}
.qa-card .qa-inner p {
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.qa-card .qa-answer {
  background: #f0f9ff;
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin: 8px 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.8;
}

/* ===== Bagu: Section divider ===== */
.bagu-section-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}
.bagu-section-label--s { background: #fef2f2; color: #dc2626; }
.bagu-section-label--a { background: #fffbeb; color: #d97706; }
.bagu-section-label--b { background: #f0fdf4; color: #16a34a; }

/* ===== 题干 ===== */
.qa-stem {
  background: #f0f4ff;
  border-left: 3px solid #4f6df5;
  padding: 8px 12px;
  margin: 0 0 12px 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: #334155;
  border-radius: 0 6px 6px 0;
}

/* ===== Leetcode 题目链接标识 ===== */
.module-title a[target="_blank"]::after {
  content: "LC ↗";
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  vertical-align: middle;
  text-decoration: none;
  line-height: 1.6;
}
.module-title a[target="_blank"] {
  text-decoration: none;
  color: inherit;
}
.module-title a[target="_blank"]:hover {
  color: #d97706;
  text-decoration: underline;
}

/* ===== Progress tracker: ring chart ===== */
.progress-ring {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  /* Fallback ring; conic-gradient overridden by JS when set */
  background: conic-gradient(#e2e8f0 0turn, #e2e8f0 1turn);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-secondary);
  text-align: center;
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--bg-card);
  z-index: 0;
}

.progress-ring > * {
  position: relative;
  z-index: 1;
}

.progress-ring--lg {
  width: 48px;
  height: 48px;
  font-size: 11px;
}

.progress-ring--lg::after {
  inset: 7px;
}

/* ===== Progress tracker: module status toggle ===== */
.status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.3;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.status-btn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-btn--none {
  color: #94a3b8;
}

.status-btn--none::before {
  background: #cbd5e1;
}

.status-btn--familiar {
  color: #d97706;
}

.status-btn--familiar::before {
  background: #f59e0b;
}

.status-btn--mastered {
  color: #16a34a;
}

.status-btn--mastered::before {
  background: #22c55e;
}

.module-title--familiar {
  background: #fffbeb;
  padding: 6px 10px 8px;
  margin-left: -10px;
  margin-right: -10px;
  border-radius: 6px;
}

.module-title--mastered {
  background: #f0fdf4;
  padding: 6px 10px 8px;
  margin-left: -10px;
  margin-right: -10px;
  border-radius: 6px;
}

/* ===== Progress tracker: sidebar status dot ===== */
.sidebar-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
}

.sidebar-dot--none {
  background: #cbd5e1;
}

.sidebar-dot--familiar {
  background: #f59e0b;
}

.sidebar-dot--mastered {
  background: #22c55e;
}

/* ===== Progress tracker: sync status bar ===== */
@keyframes pulse-sync {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.72;
  }
}

.sync-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 8px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.sync-bar--disconnected {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.sync-bar--synced {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.sync-bar--error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.sync-bar--saving {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  animation: pulse-sync 1.4s ease-in-out infinite;
}

.sync-bar button {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid;
  background: var(--bg-card);
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.sync-bar--disconnected button {
  color: #92400e;
  border-color: #f59e0b;
  background: #fff;
}

.sync-bar--disconnected button:hover {
  background: #fffbeb;
  border-color: #d97706;
}

.sync-bar--synced button,
.sync-bar--saving button {
  color: #166534;
  border-color: #22c55e;
  background: #fff;
}

.sync-bar--synced button:hover,
.sync-bar--saving button:hover {
  background: #f0fdf4;
  border-color: #16a34a;
}

.sync-bar--error button {
  color: #991b1b;
  border-color: #f87171;
  background: #fff;
}

.sync-bar--error button:hover {
  background: #fef2f2;
  border-color: #dc2626;
}

/* ===== Progress tracker: stats bar ===== */
.progress-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
}

.progress-stats__text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.progress-stats__counts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

/* ===== Progress tracker: reset confirmation ===== */
.reset-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

.reset-dialog {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.reset-dialog__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.reset-dialog__message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.reset-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.reset-dialog__btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.reset-dialog__btn--cancel {
  background: #f1f5f9;
  color: var(--text-secondary);
  border-color: var(--border);
}

.reset-dialog__btn--cancel:hover {
  background: #e2e8f0;
  color: var(--text);
}

.reset-dialog__btn--confirm {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
}

.reset-dialog__btn--confirm:hover {
  background: #b91c1c;
  border-color: #991b1b;
}

/* ===== Progress tracker: index mini-card ring position ===== */
.mini-card {
  position: relative;
}

.mini-card .progress-ring {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
  }
  .main-content {
    margin-left: 0;
    padding: 24px;
  }
}
