 @import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

  :root {
    --ink: #1a1a18;
    --ink-2: #3d3d38;
    --ink-3: #6b6b63;
    --ink-4: #9b9b92;
    --paper: #fdfcf7;
    --paper-2: #f5f3ec;
    --paper-3: #ede9df;
    --accent: #7c3c0c;
    --accent-light: #c4631e;
    --blue: #1a3f6e;
    --blue-light: #e8f0fa;
    --green: #1a4a2e;
    --green-light: #e6f5ec;
    --red: #6e1a1a;
    --red-light: #faeaea;
    --amber: #5c3d00;
    --amber-light: #fdf3dc;
    --border: #d4cfc0;
    --border-2: #c4bfae;
    --serif: 'Libre Baskerville', Georgia, serif;
    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', monospace;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: var(--serif);
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.75;
    padding: 0;
  }

  /* ── Cover ── */
  .cover {
    background: var(--ink);
    color: var(--paper);
    padding: 4rem 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
  }
  .cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      0deg, transparent, transparent 39px,
      rgba(255,255,255,0.04) 39px, rgba(255,255,255,0.04) 40px
    );
  }
  .cover-label {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #b0a890;
    margin-bottom: 1.5rem;
  }
  .cover h1 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    position: relative;
  }
  .cover h2 {
    font-size: 1.1rem;
    font-weight: 400;
    font-style: italic;
    color: #b0a890;
    margin-bottom: 2rem;
    position: relative;
  }
  .cover-tags {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
  }
  .cover-tag {
    font-family: var(--sans);
    font-size: 11px;
    padding: 4px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    color: #b0a890;
    letter-spacing: 0.05em;
  }

  /* ── Layout ── */
  .container {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 2.5rem;
  }

  /* ── TOC ── */
  .toc {
    background: var(--paper-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem 2rem;
    margin-bottom: 3rem;
  }
  .toc-title {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 1rem;
  }
  .toc ol {
    list-style: none;
    counter-reset: toc;
    columns: 2;
    column-gap: 2rem;
  }
  .toc li {
    counter-increment: toc;
    font-family: var(--sans);
    font-size: 13px;
    padding: 3px 0;
    color: var(--ink-2);
  }
  .toc li::before {
    content: counter(toc, decimal-leading-zero) ".  ";
    color: var(--ink-4);
    font-weight: 500;
  }
  .toc a { color: var(--blue); text-decoration: none; }
  .toc a:hover { text-decoration: underline; }

  /* ── Section headings ── */
  .ch-number {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: 0.35rem;
  }
  h2.section-title {
    font-size: 2rem;
    font-weight: 700;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
  }
  h3.sub-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2rem 0 0.75rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--accent-light);
  }
  h4.concept-title {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-2);
    margin: 1.5rem 0 0.5rem;
  }

  /* ── Prose ── */
  p { margin-bottom: 0.85rem; }

  /* ── Definition box ── */
  .def-box {
    background: var(--blue-light);
    border-left: 3px solid var(--blue);
    padding: 0.85rem 1.1rem;
    border-radius: 0 4px 4px 0;
    margin: 1rem 0;
  }
  .def-box strong {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--blue);
    display: block;
    margin-bottom: 0.25rem;
  }

  /* ── Formula box ── */
  .formula-box {
    background: var(--amber-light);
    border: 1px solid #e8c97a;
    border-radius: 4px;
    padding: 0.75rem 1.1rem;
    margin: 0.75rem 0;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--amber);
  }
  .formula-box .flabel {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a07030;
    display: block;
    margin-bottom: 0.2rem;
  }

  /* ── Key point / warning ── */
  .key-point {
    background: var(--green-light);
    border-left: 3px solid var(--green);
    padding: 0.75rem 1.1rem;
    border-radius: 0 4px 4px 0;
    margin: 0.75rem 0;
    font-family: var(--sans);
    font-size: 13.5px;
  }
  .key-point .klabel {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--green);
    display: block;
    margin-bottom: 0.2rem;
  }
  .warning {
    background: var(--red-light);
    border-left: 3px solid var(--red);
    padding: 0.75rem 1.1rem;
    border-radius: 0 4px 4px 0;
    margin: 0.75rem 0;
    font-family: var(--sans);
    font-size: 13.5px;
  }
  .warning .wlabel {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--red);
    display: block;
    margin-bottom: 0.2rem;
  }

  /* ── Tables ── */
  .data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--sans);
    font-size: 13px;
    margin: 1rem 0;
  }
  .data-table th {
    background: var(--ink);
    color: var(--paper);
    font-weight: 500;
    padding: 8px 12px;
    text-align: left;
    font-size: 12px;
    letter-spacing: 0.04em;
  }
  .data-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  .data-table tr:nth-child(even) td { background: var(--paper-2); }
  .data-table tr:hover td { background: var(--paper-3); }

  /* ── Graph / diagram ── */
  .graph-wrap {
    background: var(--paper-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    margin: 1.25rem 0;
    overflow-x: auto;
  }
  .graph-title {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 1rem;
    text-align: center;
  }
  .graph-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  @media (max-width: 640px) { .graph-grid { grid-template-columns: 1fr; } }

  /* ── Bullet lists ── */
  ul.note-list {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0;
  }
  ul.note-list li {
    font-family: var(--sans);
    font-size: 14px;
    padding: 3px 0 3px 1.4rem;
    position: relative;
    color: var(--ink-2);
  }
  ul.note-list li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--ink-4);
  }
  ol.note-list {
    padding-left: 1.4rem;
    margin: 0.5rem 0;
  }
  ol.note-list li {
    font-family: var(--sans);
    font-size: 14px;
    padding: 3px 0;
    color: var(--ink-2);
  }

  /* ── Section divider ── */
  .section-break {
    border: none;
    border-top: 1px solid var(--border);
    margin: 3rem 0;
  }

  /* ── Relationship cards ── */
  .rel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
  }
  .rel-card {
    background: var(--paper-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
  }
  .rel-card h5 {
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
  }
  .rel-card ul { padding-left: 1.2rem; font-family: var(--sans); font-size: 13px; color: var(--ink-2); }
  .rel-card li { margin: 3px 0; }

  /* ── Exam section ── */
  .exam-section {
    background: var(--ink);
    color: var(--paper);
    padding: 3rem 2.5rem;
    margin: 3rem -2.5rem;
  }
  .exam-section h2 {
    color: #f0ead8;
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
  }
  .exam-label {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #a09a88;
    margin-bottom: 1rem;
  }

  /* ── Question cards ── */
  .q-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
  @media (max-width: 640px) { .q-grid { grid-template-columns: 1fr; } }
  .q-card {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 1rem;
  }
  .q-card .qtype {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #b0a890;
    margin-bottom: 0.4rem;
  }
  .q-card p { font-family: var(--sans); font-size: 13px; color: #e8e2d4; margin: 0; line-height: 1.55; }

  /* ── Quick revision ── */
  .revision-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
  }
  .rev-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 1rem 1rem 0.75rem;
  }
  .rev-card h4 {
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #c4b898;
    margin-bottom: 0.75rem;
  }
  .rev-card ul { list-style: none; padding: 0; }
  .rev-card li {
    font-family: var(--mono);
    font-size: 12px;
    color: #d4cdb8;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .rev-card li:last-child { border: none; }

  /* ── MCQ bank ── */
  .mcq-item {
    background: var(--paper-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    font-family: var(--sans);
    font-size: 13.5px;
  }
  .mcq-item .ans {
    display: inline-block;
    background: var(--green);
    color: white;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: 0.5rem;
    text-transform: uppercase;
  }

  /* ── Badge ── */
  .badge {
    display: inline-block;
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: 6px;
  }
  .badge-exam { background: #ffeedd; color: #8b3e00; border: 1px solid #e8b070; }
  .badge-imp  { background: #fff0dc; color: #6b3a00; border: 1px solid #e8c060; }

  /* ── SVG graph styles ── */
  svg { overflow: visible; }
  .axis { stroke: var(--ink); stroke-width: 1.5; }
  .axis-label { font-family: var(--sans); font-size: 11px; fill: var(--ink-2); }
  .curve-label { font-family: var(--sans); font-size: 11px; font-weight: 600; }
  .grid-line { stroke: var(--border); stroke-width: 0.5; stroke-dasharray: 3,3; }
  .annotation { font-family: var(--sans); font-size: 10px; fill: var(--ink-3); }

  /* print */
  @media print {
    .cover { background: #000; -webkit-print-color-adjust: exact; }
    .exam-section { background: #1a1a18; -webkit-print-color-adjust: exact; }
    .container { padding: 1.5rem; }
  }
