:root {
  color-scheme: light;
  --ink: #1b1f2a;
  --muted: #5f6675;
  --line: #d9dee8;
  --paper: #fffdf8;
  --surface: #f5f7fb;
  --accent: #176b87;
  --accent-2: #9b4d1b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

main,
nav,
header,
footer,
section,
aside,
div {
  min-width: 0;
}

p,
li,
label,
button,
summary,
figcaption,
th,
td {
  overflow-wrap: anywhere;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(8px);
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 24px;
}

.topbar span {
  color: var(--muted);
  margin-left: 12px;
}

.toplinks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 0.95rem;
  white-space: normal;
}

.toplinks a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.toplinks .strong {
  color: var(--ink);
  font-weight: 800;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 32px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.disclaimer {
  border-bottom: 1px solid var(--line);
  background: #fbf8ef;
  color: #695331;
  font-size: 0.9rem;
  line-height: 1.35;
  padding: 8px 24px;
}

.disclaimer strong {
  color: #4f3a17;
}

.site-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  background: #f8fbfc;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  justify-content: space-between;
  margin-top: 24px;
  padding: 18px 24px;
}

.site-footer div {
  display: grid;
  gap: 2px;
}

.site-footer strong {
  color: var(--ink);
}

.site-footer span {
  font-size: 0.95rem;
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-link {
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 750;
  padding: 7px 11px;
  text-decoration: none;
}

.index {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 24px 72px;
}

.index-lead {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 720px;
}

.home-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 28px 0 18px;
}

.home-choice {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: #ffffff;
  color: var(--ink);
  display: grid;
  gap: 8px;
  min-height: 156px;
  padding: 18px;
  text-decoration: none;
}

.home-choice span {
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
}

.home-choice strong {
  color: var(--ink);
  font-size: 1.22rem;
  line-height: 1.25;
}

.home-choice small {
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.4;
}

.index-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 18px 0 34px;
}

.index-links a {
  color: var(--accent);
}

.class-books {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.book-list {
  list-style: none;
  padding: 0;
}

.book-list li {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.book-list a {
  color: var(--accent);
}

.book-list span {
  color: var(--muted);
}

.chapter-list {
  list-style: none;
  padding: 0;
}

.reference-group {
  margin: 30px 0 0;
}

.reference-group > h2 {
  border-bottom: 2px solid var(--line);
  color: var(--accent);
  font-size: 1.3rem;
  margin: 0;
  padding: 0 0 8px;
}

.reference-filter {
  align-items: end;
  border: 1px solid var(--line);
  background: #f8fbfc;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, auto) minmax(140px, auto) auto;
  gap: 8px 12px;
  margin: 24px 0 16px;
  padding: 14px;
}

.reference-field {
  display: grid;
  gap: 4px;
}

.reference-field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.reference-filter input,
.reference-filter select {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
}

.reference-filter output {
  color: var(--muted);
  font-weight: 650;
  min-width: 74px;
  padding: 8px 0;
  text-align: right;
}

.chapter-list li {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr);
  gap: 16px;
  align-items: baseline;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.chapter-list a,
.breadcrumbs a {
  color: var(--accent);
}

.chapter-list span {
  color: var(--muted);
  font-size: 0.95rem;
}

.book-intro {
  border-left: 4px solid var(--accent);
  background: #eef7f8;
  margin: 22px 0 30px;
  padding: 14px 18px;
}

.book-intro h2 {
  font-size: 1.25rem;
  margin: 0 0 8px;
}

.book-intro h3 {
  font-size: 1rem;
  margin: 14px 0 6px;
}

.book-intro p {
  margin: 0;
}

.book-intro ol {
  margin: 10px 0 0;
  padding-left: 1.35rem;
}

.intro-details {
  border-top: 1px solid var(--line);
  margin: 8px 0 0;
  padding: 9px 2px 2px;
}

.intro-details summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.intro-details .curriculum-map {
  margin-top: 10px;
}

.student-start-check,
.parent-summary,
.teacher-summary {
  background: #f3f6ed;
  border-left: 4px solid #8aa65b;
  margin: 20px 0;
  padding: 12px 16px;
}

.book-intro > .student-start-check,
.book-intro > .parent-summary,
.book-intro > .teacher-summary {
  margin: 8px 0;
}

.student-start-check {
  background: #fff8e7;
  border-left-color: #c28a2c;
}

.teacher-summary {
  background: #eef3f8;
  border-left-color: #537ca1;
}

.student-start-check summary,
.parent-summary summary,
.teacher-summary summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.student-start-check p,
.parent-summary p,
.teacher-summary p {
  margin: 8px 0;
}

.student-start-check p:first-of-type,
.parent-summary p:first-of-type,
.teacher-summary p:first-of-type {
  margin-top: 12px;
}

.student-start-check ol {
  margin: 10px 0;
}

.curriculum-map {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
  margin: 0;
}

.curriculum-map dt {
  font-weight: 700;
}

.curriculum-map dd {
  margin: 0;
}

.class-review {
  border-top: 3px solid var(--accent);
  background: #f8fbfc;
  padding: 6px 18px 18px;
}

.review-skills li {
  margin: 8px 0;
}

.review-answer {
  border-left: 4px solid var(--accent-2);
  background: #fff6ea;
  margin: 16px 0 22px;
  padding: 10px 14px;
}

.review-answer summary {
  cursor: pointer;
  font-weight: 750;
}

.review-answer p {
  margin: 8px 0 0;
}

.learning-path {
  border-left: 4px solid var(--accent-2);
  background: #fff6ea;
  color: #5c3518;
  font-size: 0.98rem;
  line-height: 1.45;
  margin: 14px 0 20px;
  padding: 10px 14px;
}

.learning-path ul {
  margin: 0;
  padding-left: 20px;
}

.learning-path-title {
  color: var(--text);
  font-weight: 750;
  margin: 0 0 6px;
}

.learning-path li {
  margin: 4px 0;
}

.learning-path li + li {
  border-top: 1px solid #e4d2bd;
  margin-top: 7px;
  padding-top: 7px;
}

.learning-path a,
.module-meta a {
  color: var(--accent-2);
  font-weight: 600;
}

.chapter-pager {
  border-top: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin: 44px 0 8px;
  padding-top: 18px;
}

.chapter-pager a {
  border: 1px solid var(--line);
  color: var(--accent);
  flex: 1 1 0;
  padding: 12px 14px;
  text-decoration: none;
}

.chapter-pager a.next {
  text-align: right;
}

.chapter-pager span {
  color: var(--muted);
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.chapter-pager strong {
  color: var(--ink);
  display: block;
  font-size: 1rem;
}

.breadcrumbs {
  border-bottom: 1px solid var(--line);
  background: #fffefa;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 7px 24px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.breadcrumbs a {
  font-weight: 600;
  text-decoration: none;
}

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

.breadcrumbs .strong,
.breadcrumbs .current {
  color: var(--ink);
  font-weight: 850;
}

.breadcrumbs .current {
  background: #f1f6f8;
  border: 1px solid #d8e5ea;
  padding: 1px 7px;
}

.skip-link {
  background: var(--ink);
  color: #ffffff;
  font-weight: 750;
  left: 12px;
  padding: 10px 14px;
  position: fixed;
  text-decoration: none;
  top: 12px;
  transform: translateY(-180%);
  z-index: 1000;
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid #0b66c3;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

body:has(.breadcrumbs) .topbar {
  display: none;
}

.history {
  padding-left: 1.4rem;
}

.history li {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

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

.toc {
  position: sticky;
  top: 70px;
  align-self: start;
  border-right: 1px solid var(--line);
  max-height: calc(100vh - 86px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 18px;
  scrollbar-gutter: stable;
}

.toc a {
  color: var(--accent);
  text-decoration: none;
}

.toc-group {
  list-style: none;
  margin: 0 0 14px;
}

.toc-group-title {
  display: block;
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.toc-group ol {
  margin: 0;
  padding-left: 20px;
}

.no-toc .layout {
  display: block;
  max-width: 980px;
}

.no-toc .toc {
  display: none;
}

.no-toc main {
  max-width: none;
}

main {
  max-width: 820px;
  min-width: 0;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 1.4em 0 0.45em;
}

h1 {
  font-size: 2.4rem;
  color: var(--accent);
}

h2 {
  font-size: 1.65rem;
}

h3 {
  font-size: 1.22rem;
}

p, li {
  font-size: 1.04rem;
}

code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.08em 0.28em;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
}

th, td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

th {
  background: var(--surface);
}

tbody th {
  background: #ffffff;
  font-weight: 700;
}

.figure {
  margin: 26px 0;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 14px;
  max-width: 100%;
}

.figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.figure figcaption {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 12px;
  padding-top: 10px;
}

.math {
  overflow-x: auto;
  padding: 10px 0;
}

.module-meta {
  border-left: 4px solid var(--accent);
  background: #eef7f8;
  color: #274850;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 18px 0;
  padding: 10px 14px;
}

.callout {
  border: 1px solid var(--line);
  background: #ffffff;
  margin: 18px 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.callout summary {
  color: var(--accent-2);
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
  line-height: 1.35;
}

.callout-body {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 0 14px 12px;
}

.callout-body p:last-child {
  margin-bottom: 0;
}

.callout-teacher {
  background: #fffaf1;
}

.callout-student-hint {
  background: #eef8fb;
  border-color: #b9dce6;
}

.callout-student-hint summary {
  color: #0f6f86;
}

.callout-parent {
  background: #f3f6ed;
  border-color: #cbd8b6;
}

  .callout-parent summary {
    color: #4f6f24;
  }

.print-hide-teacher .callout-teacher,
.print-hide-parent .callout-parent,
.print-hide-role-notes .callout-teacher,
.print-hide-role-notes .callout-parent {
  display: none !important;
}

.practice-goal {
  background: #f6f8fb;
  border-left: 4px solid #6a8fb8;
  color: var(--muted);
  font-size: 0.96rem;
  margin: 24px 0 12px;
  padding: 10px 14px;
}

.practice-goal strong {
  color: var(--ink);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 48px 0;
}

body.slides {
  background: #f7f6f1;
  overflow: hidden;
}

body.slides .topbar,
body.slides .toc,
body.slides .site-footer {
  display: none;
}

body.slides .layout {
  display: block;
  max-width: none;
  padding: 0;
}

body.slides main {
  max-width: none;
}

.slide {
  display: none;
  width: 100vw;
  height: 100vh;
  padding: 7vh 9vw;
  overflow: auto;
  background: var(--paper);
}

.slide.active {
  display: block;
}

body.slides:not(.slides-ready) .slide:first-of-type {
  display: block;
}

.slide::after {
  content: var(--slide-index);
  position: fixed;
  right: 28px;
  bottom: 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

.slide h1 {
  font-size: 4rem;
  max-width: 980px;
}

.slide h2 {
  font-size: 3rem;
  color: var(--accent);
}

.slide p,
.slide li {
  font-size: 1.45rem;
  max-width: 980px;
}

.slide table {
  max-width: 840px;
}

.slide .figure {
  max-width: 900px;
}

.slide .module-meta {
  max-width: 980px;
  font-size: 1.05rem;
}

.slide-hint {
  color: var(--muted);
}

.slide-controls {
  position: fixed;
  right: 24px;
  bottom: 20px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  padding: 8px 10px;
}

.slide-controls button {
  width: 38px;
  height: 34px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--accent);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.slide-controls button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.45;
}

.slide-controls span {
  min-width: 68px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 22px 16px 56px;
  }

  .breadcrumbs {
    padding: 10px 16px;
    font-size: 0.98rem;
  }

  .chapter-pager {
    flex-direction: column;
  }

  .chapter-pager a.next {
    text-align: left;
  }

  main,
  p,
  li,
  code {
    overflow-wrap: anywhere;
  }

  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }

  .figure {
    padding: 8px;
  }

  .book-intro {
    margin: 14px 0 22px;
    padding: 12px;
  }

  .book-intro > details {
    padding-left: 10px;
    padding-right: 10px;
  }

  .book-intro > .intro-details {
    padding-left: 2px;
    padding-right: 2px;
  }

  .class-review {
    padding: 4px 12px 16px;
  }

  .class-review h1 {
    font-size: 1.75rem;
  }

  .review-skills {
    padding-left: 1.2rem;
  }

  .toc {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .topbar span {
    display: block;
    margin-left: 0;
  }

  .toplinks {
    white-space: normal;
  }

  .site-footer {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .feedback-link {
    text-align: center;
  }

  .chapter-list li,
  .book-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .reference-filter {
    grid-template-columns: 1fr;
  }

  .curriculum-map {
    grid-template-columns: 1fr;
  }

  .reference-filter output {
    text-align: left;
  }

  .home-choices {
    grid-template-columns: 1fr;
  }

  .slide {
    padding: 6vh 7vw;
  }

  .slide h1 {
    font-size: 2.6rem;
  }

  .slide h2 {
    font-size: 2rem;
  }

  .slide p,
  .slide li {
    font-size: 1.15rem;
  }
}

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

  body {
    background: #ffffff;
    color: #000000;
  }

  .topbar,
  .toc,
  .breadcrumbs,
  .site-footer,
  .slide-controls,
  .reference-filter {
    display: none !important;
  }

  .disclaimer {
    border: 1px solid #bbb;
    background: #ffffff;
    color: #333333;
    font-size: 0.85rem;
    margin: 0 0 10mm;
    padding: 4mm;
  }

  .layout,
  .no-toc .layout,
  main,
  .no-toc main {
    display: block;
    max-width: none;
    padding: 0;
  }

  a {
    color: #000000;
    text-decoration: underline;
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  p,
  li,
  table,
  pre,
  .math,
  .figure,
  .callout,
  .module-meta,
  .learning-path {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .book-intro,
  .class-review {
    break-inside: auto;
    page-break-inside: auto;
  }

  .book-intro > details,
  .review-skills li,
  .review-answer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .book-intro details > :not(summary),
  .class-review details > :not(summary) {
    display: block !important;
  }

  .class-review {
    break-before: page;
    page-break-before: always;
  }

  .callout-teacher,
  .callout-parent {
    border-style: dashed;
    border-width: 1px 1px 1px 4px;
  }

  .callout-teacher summary::before {
    content: "Print: õpetajale · ";
    color: #555555;
    font-weight: 600;
  }

  .callout-parent summary::before {
    content: "Print: lapsevanemale · ";
    color: #555555;
    font-weight: 600;
  }

  .print-hide-teacher .callout-teacher,
  .print-hide-parent .callout-parent,
  .print-hide-role-notes .callout-teacher,
  .print-hide-role-notes .callout-parent {
    display: none !important;
  }

  table,
  .math {
    overflow: visible;
  }

  .figure {
    border-color: #bbb;
    background: #ffffff;
    max-width: 100%;
  }

  .figure img {
    max-height: 170mm;
  }

  .chapter-list li,
  .book-list li {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
