:root {
  --ink: #172033;
  --muted: #667085;
  --paper: #fbfaf7;
  --card: #ffffff;
  --line: #e4e7ec;
  --navy: #17365d;
  --blue: #2e75b6;
  --teal: #167d8d;
  --gold: #b07d12;
  --red: #a33a3a;
  --soft-blue: #eaf2f8;
  --soft-teal: #e9f6f6;
  --soft-gold: #fff6dc;
  --soft-red: #fcebec;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(46,117,182,.13), transparent 34rem),
    linear-gradient(180deg, #fff 0, var(--paper) 22rem);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-end;
  padding: 2.4rem clamp(1rem, 4vw, 3rem) 1.6rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--gold);
  letter-spacing: .12em;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, h3, h4 { line-height: 1.18; }
.topbar h1 { margin: 0; font-size: clamp(1.75rem, 4vw, 3rem); color: var(--navy); }
.subtitle { margin: .55rem 0 0; color: var(--muted); }
.version {
  min-width: 9rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  box-shadow: 0 10px 30px rgba(23,54,93,.08);
}
.version strong, .version span { display: block; }
.version span { margin-top: .2rem; color: var(--muted); font-size: .9rem; }

.layout {
  display: grid;
  grid-template-columns: minmax(16rem, 21rem) minmax(0, 1fr);
  gap: 2rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.4rem clamp(1rem, 3vw, 2rem) 4rem;
}

.sidebar {
  position: sticky;
  top: 8.4rem;
  height: calc(100vh - 9rem);
  overflow: auto;
  align-self: start;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(255,255,255,.86);
  box-shadow: 0 14px 42px rgba(23,54,93,.07);
}

.search-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
#search {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: .9rem;
  padding: .75rem .85rem;
  font: inherit;
  outline: none;
  background: #fff;
}
#search:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,117,182,.14); }
.search-results { margin: .65rem 0; display: grid; gap: .45rem; }
.search-results a {
  display: block;
  color: var(--navy);
  text-decoration: none;
  font-size: .88rem;
  padding: .55rem .65rem;
  border-radius: .75rem;
  background: var(--soft-blue);
}

.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0 1rem; }
.filters button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .45rem .7rem;
  cursor: pointer;
  color: var(--muted);
}
.filters button.active { background: var(--navy); color: white; border-color: var(--navy); }

.toc { display: grid; gap: .2rem; }
.toc a {
  color: #344054;
  text-decoration: none;
  padding: .48rem .6rem;
  border-radius: .65rem;
  font-size: .92rem;
}
.toc a:hover { background: #f2f4f7; color: var(--navy); }

main { min-width: 0; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(14rem, .7fr);
  gap: 1.25rem;
  align-items: stretch;
  margin-bottom: 1.3rem;
}
.hero > div {
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: rgba(255,255,255,.86);
  padding: clamp(1.1rem, 3vw, 1.8rem);
  box-shadow: 0 14px 40px rgba(23,54,93,.08);
}
.hero h2 { margin: .1rem 0 .75rem; color: var(--navy); font-size: clamp(1.35rem, 3vw, 2.15rem); }
.hero p:last-child { color: var(--muted); margin-bottom: 0; font-size: 1.05rem; }
.triage { display: grid; gap: .7rem; align-content: center; }
.triage span {
  display: block;
  padding: .9rem 1rem;
  border-radius: 1rem;
  font-weight: 800;
}
.triage .cl { background: var(--soft-blue); color: var(--blue); }
.triage .ucc { background: var(--soft-teal); color: var(--teal); }
.triage .eq { background: var(--soft-gold); color: var(--gold); }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .85rem;
  margin-bottom: 1.3rem;
}
.chapter-card {
  display: grid;
  gap: .45rem;
  text-decoration: none;
  color: var(--ink);
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  transition: transform .16s ease, box-shadow .16s ease;
}
.chapter-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(23,54,93,.08); }
.chapter-card strong { color: var(--navy); }
.chapter-card small { color: var(--muted); line-height: 1.45; }
.chapter-card span {
  display: inline-block;
  margin: .25rem .25rem 0 0;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  font-size: .75rem;
}

.study-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1.4rem;
}
.study-strip div {
  padding: 1rem;
  border-radius: 1rem;
  background: #172033;
  color: #fff;
}
.study-strip strong, .study-strip span { display: block; }
.study-strip span { margin-top: .35rem; color: rgba(255,255,255,.75); font-size: .9rem; line-height: 1.45; }

.subject-roadmap {
  margin-bottom: 1.4rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(255,255,255,.82);
}
.subject-roadmap h2 {
  margin: 0 0 .8rem;
  color: var(--navy);
  font-size: 1.2rem;
}
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .65rem;
}
.subject {
  display: block;
  text-decoration: none;
  border: 1px dashed #cbd5e1;
  border-radius: .9rem;
  padding: .8rem .9rem;
  color: var(--muted);
  background: #f8fafc;
}
.subject strong, .subject span { display: block; }
.subject span { margin-top: .2rem; font-size: .86rem; }
.subject.current {
  color: var(--navy);
  border-style: solid;
  border-color: rgba(46,117,182,.3);
  background: var(--soft-blue);
}
.issue-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .65rem;
}
.issue-map div {
  border: 1px solid var(--line);
  border-radius: .9rem;
  padding: .85rem .95rem;
  background: #fff;
}
.issue-map strong, .issue-map span { display: block; }
.issue-map strong { color: var(--navy); }
.issue-map span { margin-top: .28rem; color: var(--muted); font-size: .9rem; line-height: 1.45; }

.content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  padding: clamp(1rem, 3vw, 2.2rem);
  box-shadow: 0 14px 40px rgba(23,54,93,.06);
}
.content + .content { margin-top: 1.5rem; }
.content.secondary { background: #fffdf8; }
.lead { color: var(--muted); font-size: 1.05rem; }

.note-section {
  scroll-margin-top: 9rem;
  padding: 1.2rem 0;
  border-top: 1px solid var(--line);
}
.note-section:first-child { border-top: 0; padding-top: 0; }
.note-section h2 {
  color: var(--navy);
  font-size: clamp(1.35rem, 3vw, 2rem);
  margin: .2rem 0 1rem;
}
h3 { color: var(--blue); margin-top: 1.45rem; }
h4 { color: var(--teal); margin-top: 1.1rem; }
p, li { line-height: 1.72; }
li + li { margin-top: .22rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f2f4f7;
  border-radius: .35rem;
  padding: .12rem .3rem;
  color: #6b4c9a;
}
.formula {
  padding: .8rem 1rem;
  border-radius: .9rem;
  background: #f3eff9;
  color: #6b4c9a;
  font-weight: 800;
}

.callout {
  margin: 1rem 0;
  padding: .9rem 1rem;
  border-left: .32rem solid var(--blue);
  border-radius: .9rem;
  background: var(--soft-blue);
  line-height: 1.7;
}
.callout.tip { border-color: var(--gold); background: var(--soft-gold); }
.callout.exam { border-color: #6b4c9a; background: #f3eff9; }
.callout.note { border-color: var(--teal); background: var(--soft-teal); }

.table-wrap { overflow-x: auto; margin: 1rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: .94rem;
}
th, td { border: 1px solid var(--line); padding: .72rem .75rem; vertical-align: top; line-height: 1.55; }
th { background: var(--navy); color: white; text-align: left; }
tr:nth-child(even) td { background: #f8fafc; }

pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 1rem;
  background: #101828;
  color: #e4e7ec;
  line-height: 1.55;
}
pre.diagram { background: #f8fafc; color: var(--muted); border: 1px dashed #cbd5e1; }

#toTop {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 999px;
  border: 0;
  background: var(--navy);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(23,54,93,.26);
}

.hidden { display: none !important; }

@media (max-width: 980px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .hero, .study-strip { grid-template-columns: 1fr; }
  .toc { max-height: 16rem; overflow: auto; }
}

@media (max-width: 640px) {
  .topbar { padding: 1.5rem 1rem 1rem; }
  .layout { padding-inline: .8rem; }
  .content { border-radius: 1rem; }
  table { min-width: 620px; }
}
