:root {
  --ink: #252220;
  --muted: #6f6259;
  --paper: #fffaf1;
  --panel: #ffffff;
  --line: #ddd1c3;
  --green: #1b7f79;
  --blue: #3f5f8f;
  --red: #d94f3d;
  --gold: #c8932e;
  --shadow: 0 18px 50px rgba(38, 32, 26, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

nav {
  display: flex;
  gap: 18px;
  font-size: 0.95rem;
}

nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
}

nav a:hover {
  color: var(--ink);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  min-height: calc(100vh - 64px);
  padding: clamp(44px, 8vw, 90px) clamp(18px, 4vw, 56px) 38px;
}

.hero-copy {
  max-width: 700px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.4rem, 5vw, 5.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 10px;
  font-size: clamp(1.55rem, 2.4vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
}

.hero-actions,
.drill-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
.icon-button.active {
  background: var(--ink);
  color: #fff;
}

.hero-visual svg {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.notice,
.section {
  padding: clamp(40px, 7vw, 80px) clamp(18px, 4vw, 56px);
}

.notice {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(0, 1.15fr);
  gap: 32px;
  background: #e9f2ef;
  border-block: 1px solid #c7dcd7;
}

.notice p,
.section-head p,
.panel p,
footer p {
  color: var(--muted);
}

.notice ul,
.topic-card ul,
.check-list {
  margin: 0;
  padding-left: 20px;
}

.section-head {
  max-width: 790px;
  margin-bottom: 28px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.topic-card,
.panel,
.timeline article {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(38, 32, 26, 0.08);
}

.topic-card {
  min-height: 350px;
  padding: 20px;
  border-radius: 8px;
}

.topic-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  color: #fff;
  background: var(--blue);
  font-weight: 900;
}

.topic-card:nth-child(2n) .topic-icon {
  background: var(--green);
}

.topic-card:nth-child(3n) .topic-icon {
  background: var(--red);
}

.topic-card:nth-child(5n) .topic-icon {
  background: var(--gold);
}

code {
  padding: 0.08rem 0.28rem;
  background: #f0e7da;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
}

math {
  display: inline math;
  math-style: compact;
  font-family: "Cambria Math", "STIX Two Math", "Times New Roman", serif;
  font-size: 1.08em;
  vertical-align: -0.12em;
}

.drill math,
.topic-card math {
  margin-inline: 0.08rem;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 18px;
  background: #f4f7fb;
}

.panel {
  padding: clamp(20px, 3vw, 32px);
  border-radius: 8px;
}

.panel.compact {
  align-self: start;
}

.drill-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.helper-link {
  margin: 16px 0 0;
  font-weight: 800;
}

.helper-link a {
  color: var(--blue);
}

.drill {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fffaf1;
}

.drill strong {
  color: var(--blue);
}

.drill p {
  margin: 0;
}

.method-list {
  padding-left: 22px;
}

.method-list li + li,
.check-list li + li,
.topic-card li + li {
  margin-top: 8px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.timeline article {
  min-height: 220px;
  padding: 20px;
  border-radius: 8px;
}

.timeline span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 22px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
}

.exam-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  background: #fbf5ec;
}

.solution-list {
  display: grid;
  gap: 16px;
}

.lesson-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: end;
  padding: clamp(46px, 8vw, 86px) clamp(18px, 4vw, 56px) clamp(34px, 5vw, 58px);
  background: #fbf5ec;
  border-bottom: 1px solid var(--line);
}

.lesson-summary {
  display: grid;
  gap: 10px;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.lesson-summary strong {
  font-size: clamp(1.45rem, 2.4vw, 2.25rem);
  line-height: 1.05;
}

.lesson-summary span {
  color: var(--muted);
  font-weight: 800;
}

.lesson-band {
  background: #eef4f8;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.lesson-card {
  min-height: 260px;
  padding: clamp(18px, 2.5vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(38, 32, 26, 0.08);
}

.lesson-card.wide {
  grid-column: 1 / -1;
}

.lesson-card ol,
.lesson-card ul {
  padding-left: 22px;
}

.lesson-card li + li,
.lesson-card details + details {
  margin-top: 10px;
}

.lesson-card summary {
  cursor: pointer;
  font-weight: 900;
}

.time-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 18px;
  padding: 5px 10px;
  color: #fff;
  background: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.station-grid div {
  display: grid;
  gap: 4px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid #c8d8e1;
  background: #f8fbfd;
}

.station-grid-detailed div {
  min-height: 180px;
}

.station-grid strong {
  color: var(--blue);
}

.station-grid span {
  color: var(--muted);
}

.resource-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--ink);
  background: #fff;
  font-weight: 900;
  text-decoration: none;
}

.resource-link:hover {
  background: var(--ink);
  color: #fff;
}

.homework-section {
  background: #eef4f8;
}

.homework-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.homework-card {
  min-height: 330px;
  padding: clamp(18px, 2.5vw, 26px);
  border: 1px solid #c8d8e1;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(38, 32, 26, 0.08);
}

.homework-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
}

.homework-meta span {
  color: var(--blue);
}

.homework-card ol,
.reflection-list {
  padding-left: 22px;
}

.homework-card li + li,
.reflection-list li + li {
  margin-top: 10px;
}

.reflection-card {
  background: #fffaf1;
}

.worksheet {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 64px) clamp(18px, 4vw, 44px);
  background: #fff;
}

.worksheet-cover {
  padding-bottom: 28px;
  border-bottom: 2px solid var(--ink);
}

.worksheet-cover h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
}

.student-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin: 28px 0;
}

.student-fields span {
  min-height: 42px;
  border-bottom: 1px solid var(--ink);
  font-weight: 800;
}

.worksheet-block {
  break-inside: avoid;
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}

.worksheet-block h2 {
  font-size: 1.45rem;
}

.worksheet-block li + li {
  margin-top: 10px;
}

.work-space {
  margin-top: 18px;
  border: 1px dashed #9c9188;
  background-image: linear-gradient(#fff 31px, #e8dfd5 32px);
  background-size: 100% 32px;
}

.work-space.short {
  min-height: 120px;
}

.work-space.medium {
  min-height: 210px;
}

.work-space.tall {
  min-height: 300px;
}

.solution-card {
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(38, 32, 26, 0.08);
}

.solution-card h2 {
  font-size: 1.45rem;
}

.solution-card summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
}

.solution-card summary::marker {
  color: var(--green);
}

.solution-card ol {
  padding-left: 24px;
}

.solution-card li + li {
  margin-top: 8px;
}

.solution-wizard {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #c8d8e1;
  border-radius: 8px;
  background: #f8fbfd;
}

.wizard-head {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.wizard-head h4,
.wizard-panel h4 {
  margin: 0;
}

.wizard-head p,
.wizard-panel p {
  margin: 0;
}

.wizard-panel {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.wizard-count {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.wizard-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

footer {
  padding: 26px clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background: var(--ink);
}

footer p {
  margin: 0;
  color: #f7efe3;
}

@media (max-width: 1050px) {
  .topic-grid,
  .timeline,
  .homework-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero,
  .lesson-hero,
  .notice,
  .split,
  .exam-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topic-grid,
  .timeline,
  .homework-grid,
  .lesson-grid,
  .station-grid {
    grid-template-columns: 1fr;
  }

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

  .hero-visual {
    margin-top: 8px;
  }
}

@media print {
  @page {
    margin: 14mm;
  }

  body {
    background: #fff;
  }

  .no-print {
    display: none;
  }

  .worksheet {
    max-width: none;
    padding: 0;
  }

  .worksheet-block {
    page-break-inside: avoid;
  }
}
