:root {
  --bg: #111318;
  --panel: #191c23;
  --panel2: #222630;
  --border: #2d323d;
  --text: #f5f7fa;
  --muted: #a8b0bd;
  --brand: #4c92ff;
  --accent: #4c92ff;
  --accent2: #55d6be;
  --code-bg: #0b1220;
  --code-text: #d7e7ff;
}

body.light {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel2: #f2f4f6;
  --border: #e5e8eb;
  --text: #191f28;
  --muted: #6b7684;
  --brand: #3182f6;
  --accent: #3182f6;
  --accent2: #008c78;
  --code-bg: #101828;
  --code-text: #e8f1ff;
}

html { scroll-padding-top: 72px; }
body {
  letter-spacing: -.012em;
  background:
    radial-gradient(circle at 85% -8%, rgba(49,130,246,.13), transparent 30rem),
    var(--bg);
  transition: background-color .2s, color .2s;
}
button, input { font: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(49,130,246,.32);
  outline-offset: 3px;
}

/* Home */
.wrap { max-width: 1200px; padding: 0 32px 120px; }
.wrap > .top {
  min-height: 430px;
  align-items: center;
  margin-bottom: 22px;
  padding: 72px 0 48px;
}
.hero { max-width: 820px; }
.hero h1 {
  max-width: 720px;
  margin-bottom: 24px;
  font-size: clamp(38px, 5.2vw, 66px);
  line-height: 1.08;
  letter-spacing: -.055em;
  word-break: keep-all;
}
.hero p { max-width: 700px; font-size: 17px; line-height: 1.75; }
.hero .meta { gap: 10px; margin-top: 28px; }
.hero .meta span, .badges span {
  padding: 7px 13px;
  border: 0;
  background: var(--panel2);
  color: var(--muted);
  font-weight: 600;
}
.theme-btn {
  border: 0;
  border-radius: 999px;
  background: var(--panel2);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background .15s, transform .15s;
}
.theme-btn:hover { background: var(--border); transform: translateY(-1px); }
.section-title { margin-top: 28px; font-size: 25px; letter-spacing: -.035em; }
.section-sub { margin-bottom: 26px; font-size: 15px; }
.grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.card {
  min-height: 260px;
  padding: 30px;
  border: 0;
  border-radius: 26px;
  box-shadow: 0 2px 10px rgba(15,23,42,.05), 0 18px 45px rgba(15,23,42,.04);
  transition: transform .25s ease, box-shadow .25s ease;
}
.card:hover {
  border-color: transparent;
  transform: translateY(-7px);
  box-shadow: 0 18px 48px rgba(49,130,246,.14);
}
.card h3 { margin-bottom: 12px; font-size: 21px; letter-spacing: -.03em; }
.card p { font-size: 14px; line-height: 1.72; }
.card .status { margin-bottom: 18px; padding: 5px 10px; }
.status.done { background: rgba(49,130,246,.1); color: var(--brand); }
.card .tags { margin-top: 18px; }
.card .tags span { padding: 4px 9px; border-radius: 999px; }
.card.todo { box-shadow: none; }
.howto {
  margin-top: 70px;
  padding: 38px 40px;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 12px 38px rgba(15,23,42,.06);
}
.howto h2 { font-size: 22px; }
.steps { gap: 18px; }
.steps li { padding-left: 44px; font-size: 14px; }
.steps li::before { width: 30px; height: 30px; border: 0; background: rgba(49,130,246,.1); }

/* Lecture pages */
.site-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  border-color: var(--border);
  font-size: 13px;
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}
.site-topbar > a {
  flex: none;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.site-topbar > a:hover { color: var(--brand); }
.site-topbar .crumb-sep { flex: none; color: var(--border); }
.site-topbar .crumb-cur {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-topbar .top-theme {
  flex: none;
  width: auto;
  height: 34px;
  margin-left: auto;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 750;
}
.layout { display: flex; min-height: calc(100vh - 54px); }
.sidebar {
  width: 286px;
  top: 54px;
  height: calc(100vh - 54px);
  padding: 28px 18px;
  background: color-mix(in srgb, var(--panel) 74%, transparent);
}
.sidebar h1 { font-size: 18px; letter-spacing: -.03em; }
.sidebar .sub { margin-top: 6px; line-height: 1.55; }
.search {
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.sidebar .toolbar { margin-bottom: 14px; }
.sidebar .day-group, .sidebar .part-group { margin: 0 0 18px; }
.sidebar .day-title, .sidebar .part-title {
  margin: 0 0 6px;
  padding: 12px 10px 5px;
  color: var(--muted) !important;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .075em;
  line-height: 1.45;
  text-transform: uppercase;
}
.sidebar .navlink {
  display: block;
  margin: 1px 0;
  padding: 8px 10px 8px 12px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}
.sidebar .navlink:hover { background: var(--panel2); color: var(--text); }
.sidebar .navlink.active {
  background: rgba(49,130,246,.09);
  box-shadow: inset 3px 0 0 var(--brand);
  color: var(--brand);
  font-weight: 750;
}
main { min-width: 0; max-width: 980px; margin: 0 auto; padding: 70px 54px 180px; }
.page-head {
  margin-bottom: 56px;
  padding: 22px 4px 8px;
  border: 0;
}
.page-head h1 {
  max-width: 780px;
  margin-bottom: 20px;
  font-size: clamp(38px, 4.5vw, 58px);
  line-height: 1.12;
  letter-spacing: -.055em;
  word-break: keep-all;
}
.page-head p { max-width: 760px; font-size: 17px; line-height: 1.75; }
.badges { margin-top: 24px; }
.sec, .quiz-wrap {
  padding: 38px 40px 42px;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 2px 10px rgba(15,23,42,.04), 0 20px 50px rgba(15,23,42,.035);
}
.sec { margin-bottom: 32px; scroll-margin-top: 72px; }
.sec[id^="part-"] {
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 12%, var(--panel)), var(--panel) 68%);
  box-shadow: none;
}
.sec-head { gap: 12px; }
.sec h2 { font-size: 25px; line-height: 1.3; letter-spacing: -.035em; }
.sec h3 { margin-top: 30px; font-size: 19px; letter-spacing: -.025em; }
.sec h4 { margin-top: 22px; }
.subtitle { margin-top: 10px; padding-bottom: 20px; border-bottom-style: solid; }
.sec p, .b li { font-size: 15px; line-height: 1.78; }
.sec p > code, .sec li > code, .sec td > code { white-space: normal; overflow-wrap: anywhere; }
.part-badge { padding: 5px 10px; border-radius: 999px; }
.tldr, .prof, .confuse { padding: 18px 20px; border: 0; border-radius: 18px; }
.tldr { background: rgba(49,130,246,.09); }
.prof { background: rgba(0,140,120,.09); }
.confuse { background: rgba(238,95,128,.08); }
.note { padding: 12px 15px; border-radius: 10px; }
.flow { gap: 12px; }
.flow div { padding: 15px 12px; border: 0; border-radius: 15px; }
.codebox {
  margin: 18px 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,.12);
}
.codehead { padding: 10px 16px; border-color: rgba(255,255,255,.09); color: #9baabd; }
.codebox pre { padding: 18px; }
.codebox code { color: var(--code-text); }
table.t { display: block; max-width: 100%; margin: 18px 0; border-collapse: separate; border-spacing: 0; overflow-x: auto; }
table.t th, table.t td { padding: 11px 13px; border-width: 0 0 1px 0; }
table.t tr:last-child td { border-bottom: 0; }
table.t th:first-child { border-radius: 13px 0 0 0; }
table.t th:last-child { border-radius: 0 13px 0 0; }
.quiz-wrap { margin: 42px 0 68px; }
.quiz-wrap h2 { font-size: 25px; letter-spacing: -.035em; }
.quiz-score { padding: 6px 14px; border: 0; background: rgba(49,130,246,.1); color: var(--brand); }
.quiz-q { padding: 22px 0; border-color: var(--border); }
.quiz-qtext { font-size: 15px; }
.qtype { padding: 4px 8px; border-radius: 999px; }
.quiz-opt, .quiz-check, .quiz-short input { min-height: 42px; border-radius: 12px; }
.quiz-opt { padding: 9px 16px; transition: background .15s, border-color .15s, transform .15s; }
.quiz-opt:hover { background: rgba(49,130,246,.08); transform: translateY(-1px); }
.quiz-check { background: var(--brand); color: #fff; }
.top-btn { background: var(--brand); color: #fff; box-shadow: 0 10px 30px rgba(49,130,246,.3); }
footer { margin-top: 76px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 38%, transparent); border-radius: 999px; }

/* Container pre-study page */
body.container-study {
  --bg-alt: var(--panel);
  --card: var(--panel);
  --card-hi: var(--panel2);
  --line: var(--border);
  --ink: var(--text);
  --ink-dim: var(--muted);
  --ink-faint: var(--muted);
  --amber: var(--brand);
  --amber-dim: color-mix(in srgb, var(--brand) 34%, transparent);
  --teal: var(--accent2);
  --teal-dim: color-mix(in srgb, var(--accent2) 32%, transparent);
  --red: #e85d75;
  --green: #26a98b;
}
.container-study .site-topbar { position: sticky; top: 0; z-index: 40; }
.container-study .sidebar { top: 54px; height: calc(100vh - 54px); }
.container-study .hero h1 { max-width: 760px; }
.container-study details.chapter, .container-study .confuse-card, .container-study .qcard, .container-study .quiz-footer {
  border: 0;
  border-radius: 22px;
  box-shadow: 0 12px 38px rgba(15,23,42,.055);
}
.container-study details.chapter > summary { padding: 24px 26px; }
.container-study .ch-body { padding: 8px 28px 30px; }
.container-study .ch-num { border-radius: 999px; color: #fff; }
.container-study .callout, .container-study .previewbox { border: 0; border-radius: 16px; }
.container-study pre { border: 0; border-radius: 14px; }
.container-study .btn { background: var(--brand); color: #fff; border-radius: 12px; }
.container-study .opt { border-radius: 12px; }

@media (max-width: 900px) {
  .wrap { padding: 0 20px 80px; }
  .wrap > .top { min-height: 0; padding: 58px 0 32px; align-items: flex-start; }
  .hero h1 { font-size: 42px; }
  .wrap > .top > .theme-btn { margin-top: 4px; }
  .grid { grid-template-columns: 1fr; }
  .card { min-height: 0; padding: 25px; }
  .howto { padding: 28px 24px; }
  main { width: 100%; padding: 38px 18px 110px; }
  .page-head { margin-bottom: 36px; padding: 12px 4px; }
  .page-head h1 { font-size: 38px; }
  .page-head p { font-size: 15px; }
  .sec, .quiz-wrap { padding: 27px 22px 30px; border-radius: 22px; }
  .sec { overflow: hidden; }
  .sec-head { align-items: flex-start; flex-wrap: wrap; }
  .sec h2 { font-size: 22px; }
  .sec h2, .sec h3, .sec li, .cp, .cap, .formula { overflow-wrap: anywhere; word-break: break-word; }
  .codebox code, .sqlbox code { overflow-wrap: anywhere; }
  .container-study .sidebar { display: none; }
  .container-study .hero h1 { font-size: 36px; }
  .container-study details.chapter > summary { padding: 20px 18px; }
  .container-study .ch-body { padding: 6px 18px 24px; }
  .container-study table { display: block; max-width: 100%; overflow-x: auto; }
  table.t { display: block; max-width: 100%; overflow-x: auto; }
}

@media (max-width: 560px) {
  .wrap > .top { display: block; }
  .wrap > .top > .theme-btn { margin-top: 24px; }
  .hero h1 { font-size: 36px; }
  .section-title { font-size: 22px; }
  .site-topbar { gap: 8px; padding: 0 14px; }
  .site-topbar .crumb-sep, .site-topbar .crumb-cur { display: none; }
  .site-topbar .top-theme { height: 32px; padding: 0 10px; }
  .page-head h1 { font-size: 33px; }
  .sec, .quiz-wrap { padding: 24px 18px 27px; }
  .flow { grid-template-columns: 1fr; }
}

/* Global readability scale */
html body {
  font-size: 17px;
  line-height: 1.78;
}
html body .site-topbar { font-size: 14px; }
html body .site-topbar .top-theme { font-size: 13px; }
html body .sidebar h1 { font-size: 20px; }
html body .sidebar .sub { font-size: 13.5px; }
html body .sidebar .day-title,
html body .sidebar .part-title { font-size: 12px; }
html body .sidebar .navlink {
  padding-block: 9px;
  font-size: 14px;
  line-height: 1.5;
}

html body .hero p,
html body .page-head p,
html body p.lead { font-size: 18px; }
html body .card p,
html body .howto p,
html body .steps li { font-size: 16px; }
html body .section-sub { font-size: 16px; }

html body .sec p {
  font-size: 17px;
  line-height: 1.82;
}
html body .sec li {
  font-size: 17px;
  line-height: 1.82;
}
html body .ch-body p {
  font-size: 17px;
  line-height: 1.82;
}
html body .ch-body li {
  font-size: 17px;
  line-height: 1.82;
}
html body .subtitle { font-size: 15.5px; line-height: 1.7; }
html body .sec h2,
html body .ch-title h2 { font-size: 25px; }
html body .sec h3,
html body .ch-body h3 { font-size: 20px; }
html body .sec h4,
html body .confuse-card h4 { font-size: 17px; }

html body table { font-size: 15px; }
html body table th { font-size: 14px; line-height: 1.55; }
html body table td { font-size: 15px; line-height: 1.7; }
html body pre code {
  font-size: 14px;
  line-height: 1.75;
}
html body .codebox code,
html body .sqlbox code { font-size: 14px; }

html body .tldr .txt,
html body .prof p,
html body .confuse p,
html body .callout p,
html body .callout li,
html body .previewbox p,
html body .previewbox li,
html body .stackbox .desc { font-size: 16px; line-height: 1.75; }
html body .quiz-qtext,
html body .qtext { font-size: 17px; }
html body .quiz-opt { font-size: 15px; }
html body .opt,
html body .explain,
html body .quiz-feedback { font-size: 15px; line-height: 1.65; }
html body .cp li { font-size: 16px; line-height: 1.75; }
html body .cphead,
html body .callout .ctitle { font-size: 14px; }
html body .faq .fq,
html body .faq .fa { font-size: 16px; line-height: 1.75; }
html body .formula .cap { font-size: 14px; }
html body .overview-card p,
html body .compare-card p,
html body .quiz-wrap > p,
html body .day-header p { font-size: 16px; line-height: 1.7; }
html body .note,
html body .quiz-short input,
html body .quiz-check { font-size: 15px; }
html body .quiz-score { font-size: 14px; }
html body .codehead,
html body .flow-step .k { font-size: 12.5px; }
html body .flow-step .v { font-size: 15px; }
html body .ch-title .sub { font-size: 14px; }
html body .stackbox .tag,
html body .qnum,
html body #scoreDetail { font-size: 13.5px; }
html body .badges span,
html body .card .tags span,
html body .part-badge,
html body .qtype,
html body .lbl { font-size: 12.5px; }
html body figcaption { font-size: 14px !important; line-height: 1.6; }
html body footer,
html body .pagefoot { font-size: 13.5px; }

/* Shared concept diagrams */
.learning-viz { margin: 22px 0; }
.viz-flow {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.viz-node,
.viz-panel,
.viz-layer,
.viz-step {
  flex: 1;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel2);
}
.viz-node span,
.viz-layer span,
.viz-step span,
.viz-panel span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 750;
}
.viz-node strong,
.viz-layer strong,
.viz-step strong,
.viz-panel strong { display: block; }
.viz-node p,
.viz-panel p,
.viz-layer p,
.viz-step p { margin: 7px 0 0; }
.viz-node.is-accent,
.viz-panel.is-accent,
.viz-layer.is-accent,
.viz-step.is-accent {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  background: color-mix(in srgb, var(--brand) 10%, var(--panel2));
}
.viz-arrow {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
}
.viz-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.viz-stack { display: grid; gap: 7px; }
.viz-timeline {
  display: grid;
  gap: 10px;
  padding-left: 18px;
  border-left: 3px solid var(--brand);
}
.flow.learning-viz { overflow-x: visible; }
.flow.learning-viz .flow-step { min-width: 0; }

@media (max-width: 680px) {
  .viz-flow { flex-direction: column; }
  .viz-flow .viz-arrow { transform: rotate(90deg); }
  .viz-compare { grid-template-columns: 1fr; }
  .flow.learning-viz { flex-direction: column; }
  .flow.learning-viz .flow-arrow { transform: rotate(90deg); }
}
