:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --page: #ffffff;
  --surface: #f8fafc;
  --surface-strong: #f1f5f9;
  --border: #d8dee8;
  --border-soft: #e8edf3;
  --text: #172033;
  --text-muted: #64748b;
  --text-soft: #334155;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --info: #0369a1;
  --code-bg: #f3f6fa;
  --code-text: #0f172a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

.container {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 36px 32px 72px;
  background: var(--page);
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  min-height: 100vh;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.28;
  letter-spacing: 0;
}

h1 {
  margin: 12px 0 10px;
  font-size: 2rem;
  font-weight: 750;
}

h1 + h1 {
  margin-top: 0;
  color: var(--text-soft);
  font-size: 1.25rem;
  font-weight: 650;
}

h2 {
  margin: 44px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 1.35rem;
  font-weight: 720;
}

h3 {
  margin: 30px 0 10px;
  font-size: 1.08rem;
  font-weight: 700;
}

h4 {
  margin: 20px 0 8px;
  font-size: 0.98rem;
  font-weight: 700;
}

p {
  margin: 0 0 13px;
}

ul,
ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

li {
  margin: 4px 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

strong {
  color: var(--text);
  font-weight: 700;
}

code {
  padding: 2px 6px;
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  background: var(--code-bg);
  color: #9f1239;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

pre {
  margin: 16px 0 18px;
  padding: 16px 18px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.62;
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

table {
  display: block;
  width: 100%;
  margin: 16px 0 20px;
  overflow-x: auto;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page);
  font-size: 0.94rem;
}

thead,
tbody,
tr {
  width: 100%;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.breadcrumb {
  margin-bottom: 24px;
}

.breadcrumb a,
.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 650;
  box-shadow: var(--shadow);
}

.breadcrumb a:hover,
.nav-links a:hover {
  border-color: #b7c6dc;
  background: #eef5ff;
  color: var(--accent-strong);
  text-decoration: none;
}

.module-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 14px 0 28px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.meta-item {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-must {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.badge-should {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: var(--warning);
}

.badge-nice {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--accent-strong);
}

.card,
.qa,
.exercise,
.solution,
.concept,
.deep-dive,
.learn-guide,
.resource,
.checklist,
.leetcode-item {
  margin: 14px 0 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-accent,
.concept {
  border-left: 4px solid var(--accent);
}

.card-warning {
  border-left: 4px solid var(--warning);
  background: #fffaf0;
}

.card-success {
  border-left: 4px solid var(--success);
  background: #f0fdf4;
}

.card-info {
  border-left: 4px solid var(--info);
  background: #f0f9ff;
}

.card-danger {
  border-left: 4px solid var(--danger);
  background: #fff1f2;
}

.qa {
  border-left: 4px solid #7c3aed;
  background: #fbfaff;
}

.qa .q {
  margin-bottom: 8px;
  color: #4c1d95;
  font-weight: 720;
}

.qa .a {
  color: var(--text-soft);
}

.exercise {
  border-left: 4px solid var(--success);
  background: #f8fbf8;
}

.exercise strong {
  color: #166534;
}

.solution {
  border-left: 4px solid var(--info);
  background: #f8fbff;
}

.deep-dive {
  border-left: 4px solid #475569;
  background: #f8fafc;
}

.learn-guide {
  border-left: 4px solid var(--success);
}

.learn-guide h3:first-child,
.learn-guide h4:first-child {
  margin-top: 0;
}

.learn-step {
  position: relative;
  margin: 12px 0;
  padding: 14px 16px 14px 50px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--page);
}

.learn-step .step-num {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 750;
}

.resource {
  padding: 12px 14px;
  background: var(--page);
}

.resource + .resource {
  margin-top: -8px;
}

.checklist {
  background: var(--page);
}

.checklist label {
  display: block;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-soft);
  cursor: pointer;
}

.checklist label:last-child {
  border-bottom: 0;
}

.checklist input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  accent-color: var(--accent);
  vertical-align: -2px;
}

.leetcode-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.difficulty,
.leetcode-item .difficulty {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
}

.difficulty-easy {
  background: #dcfce7;
  color: var(--success);
}

.difficulty-medium {
  background: #fef3c7;
  color: var(--warning);
}

.difficulty-hard {
  background: #fee2e2;
  color: var(--danger);
}

.divider {
  height: 1px;
  margin: 38px 0;
  background: var(--border);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 16px 0 24px;
}

.module-card {
  display: block;
  min-height: 156px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page);
  color: var(--text);
  box-shadow: var(--shadow);
}

.module-card:hover {
  border-color: #b7c6dc;
  background: #fbfdff;
  text-decoration: none;
}

.mc-num {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mc-title {
  margin-top: 5px;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 760;
}

.mc-desc {
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.mc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.week-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 28px 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.week-badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e0ecff;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 750;
}

.nav-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.nav-links a:last-child {
  margin-left: auto;
}

.progress-bar {
  width: 100%;
  height: 8px;
  margin: 8px 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.intro-note,
.muted-note {
  color: var(--text-muted);
}

.intro-note {
  margin-bottom: 30px;
}

.muted-note {
  font-size: 0.92rem;
}

.footer-note {
  margin-top: 30px;
  color: var(--text-muted);
  font-size: 0.86rem;
  text-align: center;
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  .container {
    padding: 24px 16px 52px;
    border: 0;
  }

  h1 {
    font-size: 1.65rem;
  }

  h1 + h1 {
    font-size: 1.08rem;
  }

  h2 {
    margin-top: 34px;
    font-size: 1.18rem;
  }

  h3 {
    font-size: 1rem;
  }

  pre {
    margin-left: -2px;
    margin-right: -2px;
    padding: 14px;
    font-size: 0.82rem;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    min-height: auto;
  }

  .week-header,
  .module-meta,
  .nav-links {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-links a,
  .breadcrumb a {
    justify-content: center;
  }

  .nav-links a:last-child {
    margin-left: 0;
  }

  .card,
  .qa,
  .exercise,
  .solution,
  .concept,
  .deep-dive,
  .learn-guide,
  .resource,
  .checklist {
    padding: 14px;
  }

  .learn-step {
    padding-right: 14px;
  }
}

@media print {
  html,
  body,
  .container {
    background: #ffffff;
  }

  body {
    color: #111827;
    font-size: 10.5px;
    line-height: 1.5;
  }

  .container {
    width: 100%;
    max-width: none;
    padding: 14px;
    border: 0;
  }

  h1,
  h2,
  h3,
  h4 {
    color: #111827;
    page-break-after: avoid;
  }

  .breadcrumb,
  .nav-links {
    display: none;
  }

  .card,
  .qa,
  .exercise,
  .solution,
  .concept,
  .deep-dive,
  .learn-guide,
  .resource,
  .checklist,
  .module-card,
  pre,
  table {
    box-shadow: none;
    page-break-inside: avoid;
  }
}
