* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f7f8fb;
  color: #1f2933;
  line-height: 1.6;
}

a { color: inherit; }

/* =====================================================
   SITE-WIDE MATHEMATICAL GRAPH STANDARD
===================================================== */
:root {
  --graph-axis: #171717;
  --graph-label: #171717;
  --graph-point: #171717;
  --graph-grid: #d9dde2;
  --graph-guide: #555b61;
  --graph-blue: #496f8a;
  --graph-rust: #9a6754;
  --graph-green: #617b6b;
  --graph-grey: #727980;
}

.lesson-content svg {
  color: var(--graph-label);
  overflow: visible;
}
.lesson-content svg text {
  fill: var(--graph-label) !important;
}
/* Filled points are the default. Explicit white SVG circles remain hollow. */
.lesson-content svg circle:not([fill="#fff"]):not([fill="#ffffff"]):not(.open-point) {
  fill: var(--graph-point) !important;
}
.lesson-content svg circle[fill="#fff"],
.lesson-content svg circle[fill="#ffffff"],
.lesson-content svg circle.open-point {
  fill: #ffffff !important;
  stroke: var(--graph-point) !important;
}
.lesson-content svg circle.closed-point {
  fill: var(--graph-point) !important;
  stroke: var(--graph-point) !important;
}
.lesson-content svg line {
  stroke: var(--graph-axis) !important;
}
.lesson-content svg line[stroke-dasharray] {
  stroke: var(--graph-guide) !important;
}

/* Ordinary graph curves must never acquire a filled area accidentally. */
.lesson-content svg path:not([fill]),
.lesson-content svg polyline:not([fill]) {
  fill: none !important;
}
.lesson-content svg path[fill="none"],
.lesson-content svg polyline[fill="none"] {
  fill: none !important;
  stroke: var(--graph-blue) !important;
}

/* Only explicitly declared mathematical regions are shaded. */
.lesson-content svg .graph-region {
  fill: var(--graph-blue) !important;
  opacity: .12;
  stroke: none !important;
}

.math-graph {
  max-width: 720px;
  margin: 30px auto;
}
.math-graph svg {
  width: 100%;
  height: auto;
  display: block;
}
.graph-axis { stroke: var(--graph-axis) !important; stroke-width: 1.6; }
.graph-grid { stroke: var(--graph-grid) !important; stroke-width: .7; opacity: .7; }
.graph-guide { stroke: var(--graph-guide) !important; stroke-width: 1.4; stroke-dasharray: 7 6; }
.graph-curve { fill: none !important; stroke: var(--graph-blue) !important; stroke-width: 3; }
.graph-curve-secondary { fill: none !important; stroke: var(--graph-rust) !important; stroke-width: 3; }
.graph-curve-tertiary { fill: none !important; stroke: var(--graph-green) !important; stroke-width: 2.6; }
.graph-point { fill: var(--graph-point) !important; }
.graph-label { fill: var(--graph-label) !important; font-size: 15px; }
.graph-region { fill: var(--graph-blue) !important; opacity: .12; stroke: none !important; }

/* =====================================================
   HEADER
===================================================== */
.site-header { position: sticky; top: 0; z-index: 100; display: flex; justify-content: space-between; align-items: center; padding: 14px 7%; background: rgba(255,255,255,.97); border-bottom: 1px solid #e6e8ec; backdrop-filter: blur(8px); }
.brand a { text-decoration: none; font-size: 1.7rem; font-weight: 700; letter-spacing: -.04em; color: #153e75; }
.top-nav { display: flex; gap: 24px; }
.top-nav a { text-decoration: none; font-size: .92rem; color: #34495e; }
.top-nav a:hover { color: #153e75; }
main { width: 100%; }

/* =====================================================
   HERO FOR CHAPTER INDEX PAGES
===================================================== */
.hero { text-align: center; padding: 70px 20px 55px; background: radial-gradient(circle at top left,#edf5ff,transparent 35%),radial-gradient(circle at top right,#eefbf7,transparent 35%),#fff; }
.eyebrow,.section-label { margin: 0 0 10px; font-size: .76rem; font-weight: 700; letter-spacing: .15em; color: #52708f; }
.hero h1 { max-width: 850px; margin: 0 auto; font-size: clamp(2.4rem,5vw,4.5rem); line-height: 1.05; letter-spacing: -.04em; color: #102a43; }
.hero-text { max-width: 760px; margin: 18px auto 0; font-size: 1.08rem; color: #52606d; }
.hero-math { max-width: 900px; margin: 28px auto; padding: 18px; background: rgba(255,255,255,.8); border: 1px solid #e6e8ec; border-radius: 14px; overflow-x: auto; }

/* =====================================================
   BUTTONS
===================================================== */
.primary-button { display: inline-block; margin-top: 8px; padding: 13px 22px; border-radius: 9px; background: #153e75; color: white; text-decoration: none; font-weight: 700; }
.primary-button:hover { background: #0f2f59; }

/* =====================================================
   GENERAL SECTIONS
===================================================== */
.intro,.learning-path,.principle { max-width: 1180px; margin: 0 auto; padding: 55px 28px; }
.intro>h2,.learning-path>h2,.principle>h2 { margin-top: 0; font-size: clamp(1.8rem,3vw,2.6rem); letter-spacing: -.03em; color: #102a43; }
.intro>p,.principle>p { max-width: 760px; font-size: 1.02rem; color: #52606d; }

/* =====================================================
   METHOD GRID
===================================================== */
.method-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; margin-top: 30px; }
.method-card { padding: 25px; background: white; border: 1px solid #e5e7eb; border-radius: 14px; }
.method-card h3 { margin-top: 0; color: #153e75; }

/* =====================================================
   CHAPTER INDEX GRID
===================================================== */
.learning-path { max-width: none; background: #eef2f6; }
.learning-path>.section-label,.learning-path>h2,.chapter-grid { max-width: 1180px; margin-left: auto; margin-right: auto; }
.chapter-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; margin-top: 32px; }
.chapter-card { display: block; min-height: 240px; padding: 26px; text-decoration: none; background: white; border: 1px solid #dde3ea; border-radius: 15px; transition: transform .18s ease,box-shadow .18s ease; }
.chapter-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(15,35,55,.08); }
.chapter-number { display: inline-block; margin-bottom: 18px; font-size: .82rem; font-weight: 700; color: #6b8298; }
.chapter-card h3 { margin: 0 0 10px; font-size: 1.35rem; color: #102a43; }
.chapter-card p { margin: 0 0 20px; color: #5d6b78; }
.chapter-link { font-weight: 700; color: #153e75; }

/* =====================================================
   PRINCIPLE SECTIONS
===================================================== */
.principle { text-align: center; }
.principle>p { margin-left: auto; margin-right: auto; }
.principle-math { margin: 28px auto; padding: 22px; max-width: 900px; background: white; border: 1px solid #e3e8ee; border-radius: 14px; overflow-x: auto; }

/* =====================================================
   LESSON PAGES
===================================================== */
.lesson-header { max-width: 960px; margin: 0 auto; padding: 38px 28px 20px; }
.lesson-header .eyebrow { margin-bottom: 5px; }
.lesson-header h1 { margin: 0 0 6px; font-size: clamp(2.1rem,4vw,3.2rem); line-height: 1.08; letter-spacing: -.035em; color: #102a43; }
.lesson-intro { margin: 0; max-width: 720px; font-size: 1.02rem; color: #52606d; }
.lesson-content { max-width: 960px; margin: 0 auto; padding: 12px 28px 55px; background: #fff; }
.lesson-content h2 { margin: 22px 0 10px; font-size: 1.55rem; color: #102a43; }
.lesson-content h3 { margin: 28px 0 7px; font-size: 1.22rem; color: #153e75; }
.lesson-content p { max-width: 760px; margin: 7px 0 12px; font-size: 1rem; color: #34495e; }
.lesson-math { max-width: 760px; margin: 12px 0 16px; padding: 12px 18px; background: #f7f9fb; border-left: 3px solid #c8d6e5; overflow-x: auto; }

/* =====================================================
   LESSON NAVIGATION
===================================================== */
.lesson-navigation { display: flex; justify-content: space-between; gap: 20px; margin-top: 42px; padding-top: 20px; border-top: 1px solid #e4e8ed; }
.lesson-navigation a { text-decoration: none; font-weight: 700; color: #153e75; }
.lesson-navigation a:hover { text-decoration: underline; }

/* =====================================================
   FOOTER
===================================================== */
footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; padding: 30px 7%; background: #102a43; color: white; }
footer strong { font-size: 1.45rem; }
footer p { margin: 3px 0 0; }
.footer-note { color: #c7d3df; }

@media (max-width:900px) { .chapter-grid { grid-template-columns: repeat(2,1fr); } .method-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width:650px) { .site-header { align-items:flex-start; flex-direction:column; gap:8px; padding-top:12px; padding-bottom:12px; } .top-nav { flex-wrap:wrap; gap:10px 18px; } .hero { padding:50px 20px 40px; } .chapter-grid,.method-grid { grid-template-columns:1fr; } .lesson-header { padding:28px 20px 15px; } .lesson-content { padding:8px 20px 40px; } .lesson-navigation { flex-direction:column; } footer { flex-direction:column; align-items:flex-start; } }