:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #5f6f7d;
  --paper: #ffffff;
  --page: #f7f9fb;
  --line: #d7dee8;
  --line-strong: #b9c5d3;
  --neutral: #f6f8fa;
  --neutral-strong: #eef2f6;
  --teal: #245c73;
  --teal-soft: #e5f1f4;
  --purple: #6d4bb3;
  --blue: #2d5d9f;
  --theory-blue: #4b7fbd;
  --blue-soft: #edf4ff;
  /* Deeper, indigo-leaning blue (H231.7 S50.3 L33.9): distinct in hue from
     --teal (H197.5 -- navigation semantics, see LESSON_PAGE_CONVENTIONS.md)
     and in both hue and lightness/saturation from --theory-blue (H212.6
     L51.8), landing between --blue (H214.7) and --purple (H259.6). Changed
     from #2f6f8f (H200.0, ~2.5deg from teal) per a Design Comment on
     4-unit-mathematics/lessons/euclidean-geometry/exercise-triangle-similarity.html. */
  --exercise-blue: #2b3782;
  --amber: #9a6a00;
  --amber-soft: #fff5d6;
  --amber-line: #e6c467;
  --formula-bg: #fffcf3;
  --formula-line: #e7d7aa;
  --formula-ink: #302a1f;
  --green: #247246;
  --green-soft: #e8f5ed;
  --green-line: #97c9a9;
  --red: #b42318;
  --red-soft: #fff1f0;
  /* Faint washes for lightweight wayfinding panels: quieter than the *-soft
     fills so a stack of asides reads as rhythm, not a wall of loud boxes.
     See the panel-hierarchy block below. */
  --teal-wash: #f1f7f9;
  --neutral-wash: #f6f8fa;
  /* Comfortable Hebrew reading measure for running prose. */
  --measure: 40rem;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, "Noto Sans Hebrew", "Noto Sans", sans-serif;
  line-height: 1.75;
}

[hidden] {
  display: none !important;
}

main {
  /* Gutters scale with viewport instead of a flat 16px: ~20px on phones,
     growing toward ~96px before the 1040px content cap kicks in (Teacher
     feedback: no margins on windows under ~1070px). */
  width: min(1040px, calc(100% - 2 * clamp(20px, 6vw, 96px)));
  margin: 0 auto;
  padding: 36px 0 60px;
}

nav {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 28px;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 2.75rem;
  line-height: 1.15;
}

.page-title {
  color: var(--title-color, var(--ink));
  border-inline-start: 7px solid var(--title-accent, currentColor);
  padding-inline-start: 14px;
}

.page-title-courses {
  --title-color: var(--purple);
  --title-accent: var(--purple);
}

.page-title-course {
  --title-color: var(--teal);
  --title-accent: var(--teal);
}

.page-title-theory {
  --title-color: var(--theory-blue);
  --title-accent: var(--theory-blue);
}

.page-title-solution {
  --title-color: var(--amber);
  --title-accent: var(--amber);
  font-size: 2.25rem;
}

.page-title-exercise {
  --title-color: var(--exercise-blue);
  --title-accent: var(--exercise-blue);
}

h2 {
  margin: 36px 0 12px;
  font-size: 1.6rem;
  line-height: 1.3;
}

h3 {
  margin: 26px 0 8px;
  font-size: 1.26rem;
  line-height: 1.35;
}

p {
  margin: 0 0 14px;
  max-width: var(--measure);
}

ul,
ol {
  margin: 0 0 16px;
  padding-inline-start: 1.4rem;
}

li {
  margin-bottom: 8px;
}

a {
  color: var(--teal);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
  color: var(--blue);
}

.subtitle,
.kicker,
figcaption,
.status {
  color: var(--muted);
}

.subtitle {
  margin: 10px 0 0;
  max-width: var(--measure);
  font-size: 1.18rem;
  line-height: 1.55;
}

.study-resource-link {
  margin: 12px 0 0;
}

.study-resource-link a {
  display: inline-block;
  padding-inline-start: 10px;
  border-inline-start: 3px solid var(--amber);
  color: var(--amber);
}

.formula-sheet-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 18px;
  margin: 0 0 28px;
  padding: 16px 0;
  border-block: 1px solid var(--line);
}

.formula-sheet-nav a {
  min-width: 0;
}

.formula-sheet-page .method-block {
  padding: 30px 0 6px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 18px;
}

.formula-sheet-page .method-block:first-of-type {
  border-top: 0;
  padding-top: 4px;
}

.formula-sheet-page .method-block > h2 {
  color: var(--blue);
}

.formula-sheet-page .method-summary {
  color: var(--muted);
  font-weight: 700;
}

.formula-sheet-page .answer-check {
  margin: 18px 0 24px;
  padding: 11px 13px;
  border-inline-start: 4px solid var(--green);
  background: var(--green-soft);
}

.formula-sheet-page .warning-check {
  margin: 18px 0 24px;
  padding: 11px 13px;
  border-inline-start: 4px solid var(--red);
  background: var(--red-soft);
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--teal);
  text-decoration: none;
}

.view-tab:hover,
.view-tab:focus-visible {
  border-color: var(--teal);
}

.view-tab.is-active,
.view-tab[aria-current="page"] {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.lesson-view {
  scroll-margin-top: 18px;
}

.kicker {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 22px;
  font-size: 1rem;
}

th,
td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
}

th {
  background: var(--blue-soft);
  border-bottom-color: #c8d9f2;
  font-weight: 700;
}

.table-overview th {
  background: var(--teal-soft);
  border-bottom-color: #c8dfe7;
}

.table-calculation th {
  background: var(--amber-soft);
  border-bottom-color: var(--amber-line);
}

/* Proof table (טבלת טענה-נימוק) for Euclidean geometry proofs */
.proof-table {
  border: 1px solid var(--green-line);
  border-right: 4px solid var(--green);
  border-radius: 0 6px 6px 0;
}

.proof-table th {
  background: var(--green-soft);
  border-bottom-color: var(--green-line);
  color: var(--green);
}

.proof-table td {
  vertical-align: top;
  padding: 11px 12px;
  line-height: 1.6;
}

.proof-table td:first-child {
  font-weight: 700;
  white-space: nowrap;
  color: var(--teal);
  width: 3em;
  text-align: center;
}

.proof-table td:nth-child(2) {
  width: 40%;
}

.proof-table tbody tr:nth-child(even) {
  background: var(--green-soft);
}

.proof-table-caption {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.93rem;
  font-weight: 700;
}

.bond-cashflow-table {
  direction: ltr;
  table-layout: fixed;
  text-align: center;
}

.bond-cashflow-table th,
.bond-cashflow-table td {
  text-align: center;
  vertical-align: middle;
}

.bond-cashflow-table th:first-child {
  width: 24%;
  direction: rtl;
}

.transportation-table {
  min-width: 660px;
  table-layout: fixed;
}

.transportation-table th,
.transportation-table td {
  text-align: center;
  vertical-align: middle;
}

.transportation-table .transportation-cell {
  position: relative;
  height: 68px;
  padding: 25px 8px 8px;
  background: var(--paper);
}

.transportation-table .cell-cost {
  position: absolute;
  top: 4px;
  left: 7px;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 700;
}

.transportation-table .cell-allocation {
  color: var(--green);
  font-size: 1.08rem;
  font-weight: 700;
}

.cell-reduced-cost {
  color: var(--muted);
  font-weight: 700;
}

.cell-reduced-cost.is-negative {
  color: var(--red);
}

.transportation-table .margin-cell {
  background: var(--teal-soft);
  font-weight: 700;
}

.transportation-table .cycle-plus {
  box-shadow: inset 0 0 0 2px var(--green-line);
}

.transportation-table .cycle-minus {
  box-shadow: inset 0 0 0 2px var(--amber-line);
}

tbody tr:nth-child(even) {
  background: #fafbfd;
}

.truth-table {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}

.truth-table th,
.truth-table td {
  text-align: center;
  white-space: nowrap;
}

.algorithm-walkthrough {
  border: 0;
  border-inline-start: 4px solid var(--teal);
  border-radius: 0 6px 6px 0;
  background: var(--teal-wash);
  padding: 14px 18px;
  margin: 18px 0 26px;
}

.algorithm-walkthrough h3,
.algorithm-walkthrough h4 {
  margin-top: 0;
}

.walkthrough-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.walkthrough-button {
  min-height: 38px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--teal);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.walkthrough-button:hover,
.walkthrough-button:focus-visible {
  border-color: var(--teal);
  background: #f8fcfd;
}

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

.walkthrough-counter {
  color: var(--muted);
  font-weight: 700;
}

.walkthrough-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  padding: 12px 14px;
}

.walkthrough-phase {
  width: fit-content;
  margin: 0 0 8px;
  padding: 2px 7px;
  border: 1px solid #c8d9f2;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 700;
}

.walkthrough-step-title {
  margin-bottom: 6px;
}

.walkthrough-bubble {
  margin-bottom: 10px;
}

.walkthrough-expression {
  width: 100%;
}

table.walkthrough-has-focus tbody tr.walkthrough-row-muted td {
  color: #8a97a3;
  background: #f5f7fa;
}

.truth-table tbody tr.walkthrough-highlight-true td {
  background: var(--green-soft);
}

.truth-table tbody tr.walkthrough-highlight-false td {
  background: var(--amber-soft);
}

.truth-table tbody tr.walkthrough-highlight-neutral td,
tbody tr.walkthrough-highlight-neutral td {
  background: var(--blue-soft);
}

tbody tr.walkthrough-highlight-true td {
  background: var(--green-soft);
}

tbody tr.walkthrough-highlight-false td {
  background: var(--amber-soft);
}

.truth-table .walkthrough-column-active {
  background: var(--blue-soft);
}

.truth-table .walkthrough-cell-active,
.walkthrough-cell-active {
  box-shadow: inset 0 0 0 2px var(--blue);
}

figure.diagram {
  margin: 20px auto 28px;
  padding: 0;
  text-align: center;
}

figure.diagram img {
  max-width: 75%;
  height: auto;
  display: block;
  margin: 0 auto;
}

figcaption {
  margin-top: 8px;
  font-size: 0.95rem;
}

.course-list,
.topic-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.course,
.topic {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--teal);
  border-radius: 0 6px 6px 0;
  background: var(--neutral);
}

/* Course-index topic view: topics are grouped by Subject (see the course
   index's #topics section), so each topic card stacks its lesson link over a
   quiet descriptor instead of the course list's name|status two-column row. */
.subject-group {
  margin: 0 0 20px;
}

.subject-heading {
  margin: 24px 0 10px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--teal-soft);
  color: var(--teal);
  font-size: 1.2rem;
}

.topic {
  grid-template-columns: 1fr;
  gap: 2px;
  align-items: start;
}

.topic-name {
  font-size: 1.08rem;
}

.topic .status {
  white-space: normal;
}

.course-name,
.topic-name {
  font-weight: 700;
}

.status {
  font-size: 0.95rem;
  white-space: nowrap;
}

.exam-list {
  display: grid;
  gap: 22px;
}

.exam-group {
  padding-top: 4px;
}

.exam-question-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exam-question {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-right: 4px solid var(--teal);
  border-radius: 6px;
  background: var(--neutral);
}

.exam-question.is-pending {
  border-right-color: var(--amber);
}

.exam-question-number {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.exam-question-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.exam-question-title {
  font-weight: 700;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 2px 7px;
  border: 1px solid #c8d9f2;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 700;
}

.pending-status {
  width: fit-content;
  padding: 2px 7px;
  border: 1px solid var(--amber-line);
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 700;
}

/* --- Panel hierarchy (de-chaos) -------------------------------------------
   Two tiers, so a page reads as ranked instead of a stack of identical boxes
   (Teacher: "too much repeating elements ... creates chaos"):

   * Wayfinding / aside panels (related questions, theory links, progress,
     ordinary notes) are FLAT -- a colored inline-start rule over a faint
     wash, no full border. They label a group without shouting.
   * Content panels the Student must locate (exam question, exercise prompt,
     readiness notes, final answer) keep a real filled box further down, so
     they now visibly outrank the flat asides.

   Semantic color stays per LESSON_PAGE_CONVENTIONS.md: teal = navigation,
   neutral gray = ordinary note, amber = readiness, green = answers,
   blue = the problem statement. */
.related,
.theory-links,
.exam-progress,
.note {
  border: 0;
  border-inline-start: 4px solid var(--panel-accent, var(--teal));
  border-radius: 0 6px 6px 0;
  background: var(--panel-wash, var(--teal-wash));
  padding: 12px 18px;
  margin: 18px 0 24px;
}

.note {
  --panel-accent: var(--line-strong);
  --panel-wash: var(--neutral-wash);
}

.related > h2,
.theory-links > h2,
.exam-progress > h2 {
  color: var(--teal);
}

.related h2,
.theory-links h2,
.exam-progress h2,
.note h2,
.question h2,
.final-answer h2 {
  margin-top: 0;
}

/* Start-here strip (course index): the one wayfinding panel that should read
   as a lead-in, so it keeps a touch more presence than the other teal asides. */
.start-here {
  --panel-wash: #e6f1f4;
  border-inline-start-width: 5px;
  padding: 16px 20px;
}

.start-here-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.question {
  border: 1px solid var(--line);
  border-right: 4px solid var(--line-strong);
  border-radius: 6px;
  background: var(--neutral);
  padding: 16px;
  margin: 12px 0 24px;
}

.question-parts {
  list-style: none;
  padding: 0;
  margin-top: 18px;
}

.question-parts li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.question-parts li:first-child {
  border-top: 0;
}

.solution-roadmap {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 20px 0 8px;
  padding: 14px 0;
  border-block: 1px solid var(--line);
  list-style: none;
}

.solution-roadmap li {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 0 16px;
  border-inline-start: 1px solid var(--line);
}

.solution-roadmap li:first-child {
  border-inline-start: 0;
}

.solution-roadmap strong {
  color: var(--teal);
}

.solution-roadmap span {
  color: var(--muted);
  font-size: 0.93rem;
}

.solution-part {
  padding: 30px 0 8px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 18px;
}

.solution-part:first-of-type {
  margin-top: 8px;
}

.solution-part h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1.3rem;
}

.solution-part-label {
  display: inline-grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--amber-line);
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  line-height: 1;
  padding-bottom: 3px;
  text-align: center;
}

.subpart-prompt {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--line-strong);
  background: var(--neutral);
}

.solution-cue {
  margin-bottom: 18px;
}

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

.symbol-list,
.result-breakdown {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 14px;
  margin: 16px 0 20px;
}

.symbol-list dt,
.result-breakdown dt {
  color: var(--muted);
  font-weight: 700;
}

.symbol-list dd,
.result-breakdown dd {
  margin: 0;
}

.result-breakdown {
  padding-block: 12px;
  border-block: 1px solid var(--line);
}

.part-result {
  margin: 20px 0 4px;
  padding: 11px 13px;
  border-inline-start: 4px solid var(--green);
  background: var(--green-soft);
}

.worked-examples {
  margin-top: 38px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.worked-example {
  padding: 24px 0 8px;
  border-top: 1px solid var(--line);
}

.worked-example:first-of-type {
  border-top: 0;
}

.worked-example h4 {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 1.08rem;
}

.example-source {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.exercise-prompt {
  margin: 12px 0 0;
  padding: 15px 17px;
  border: 1px solid #c9d9ee;
  border-inline-start: 4px solid var(--blue);
  border-radius: 6px;
  background: var(--blue-soft);
}

.exercise-prompt > :last-child,
.example-solution > :last-child {
  margin-bottom: 0;
}

.try-first {
  min-height: 92px;
  margin: 14px 0 24px;
  padding: 12px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--muted);
  font-weight: 700;
}

/* Ruled writing-space lines sit below the prompt text, never behind it
   (Design Comment dc-935d8d040764: a rule line struck through the prompt).
   A plain block ::after — NOT flex on .try-first, which would turn each
   inline math span into its own flex row and shred the prompt sentence
   (Design Comments dc on div-2/div-8: "completely off", "new line for AD"). */
.try-first::after {
  content: "";
  display: block;
  min-height: 64px;
  margin-top: 10px;
  background:
    repeating-linear-gradient(
      to bottom,
      var(--paper) 0,
      var(--paper) 31px,
      var(--line) 32px
    );
}

.example-solution {
  padding-top: 18px;
  border-top: 2px solid var(--teal);
}

.example-solution::before {
  display: block;
  margin-bottom: 12px;
  color: var(--teal);
  content: "פתרון";
  font-size: 1.02rem;
  font-weight: 700;
}

.readiness {
  background: var(--amber-soft);
  border: 1px solid var(--amber-line);
  border-right: 4px solid var(--amber);
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 14px;
}

.final-answer {
  border: 1px solid var(--green-line);
  border-right: 4px solid var(--green);
  border-radius: 6px;
  background: var(--green-soft);
  margin-top: 34px;
  padding: 16px;
}

.exam-progress {
  margin-top: 24px;
}

.exam-progress-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--teal);
  border-radius: 6px;
  background: var(--paper);
  text-decoration: none;
}

.formula,
.math {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: "Times New Roman", "Noto Serif", serif;
}

.formula {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 14px 0 18px;
  padding: 10px 14px;
  border: 0;
  border-block: 1px solid var(--formula-line);
  border-radius: 0;
  background: var(--formula-bg);
  color: var(--formula-ink);
  overflow-x: auto;
  white-space: nowrap;
  text-align: left;
  font-size: 1.1rem;
}

.formula-stack {
  display: grid;
  width: fit-content;
  gap: 4px;
  white-space: normal;
}

.formula-stack > span {
  display: block;
  direction: ltr;
  unicode-bidi: isolate;
  overflow-x: auto;
  white-space: nowrap;
}

.given-data {
  margin: 18px 0 26px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.given-data h3 {
  margin: 0 0 6px;
  color: var(--blue);
}

.given-data-list {
  display: grid;
  gap: 6px;
  margin: 0;
}

.given-data-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 1.25rem;
  direction: rtl;
  margin: 0;
  padding: 7px 10px;
  border-bottom: 1px solid #c8d9f2;
  line-height: 1.55;
}

.given-data-row:last-child {
  border-bottom: 0;
}

.given-data-symbol {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  direction: ltr;
  unicode-bidi: isolate;
  flex: 0 0 6.25rem;
  min-width: 6.25rem;
  margin: 0;
  padding: 2px 8px;
  border-radius: 4px;
  background: #eef4fb;
  font-family: "Times New Roman", "Noto Serif", serif;
  font-weight: 700;
  white-space: nowrap;
}

.given-data-symbol::after {
  content: "";
}

.given-data-value {
  min-width: 0;
  direction: rtl;
  unicode-bidi: isolate;
}

.formula-name {
  margin: 14px 0 5px;
  color: var(--muted);
  font-weight: 700;
}

.formula sub,
.formula sup,
.math sub,
.math sup {
  position: static;
  line-height: 1;
  margin-inline: 0.1em 0.09em;
}

.formula sub,
.math sub {
  vertical-align: -0.3em;
}

.formula sup,
.math sup {
  vertical-align: 0.58em;
}

.indexed-term {
  display: inline-block;
  margin-inline: 0.08em 0.18em;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  direction: ltr;
  unicode-bidi: isolate;
  vertical-align: middle;
  min-width: 1.35em;
  margin-inline: 0.18em;
  text-align: center;
  line-height: 1.08;
}

/* Stacked integral/bracket bounds (``_{a}^{b}`` in the math dialect): the
   upper limit hugs the top edge of the ∫ or ] it follows and the lower limit
   its bottom edge, instead of floating as a centered pair to its side. */
.bounds {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  height: 2.6em;
  direction: ltr;
  unicode-bidi: isolate;
  vertical-align: middle;
  margin-inline-start: 1px;
  text-align: start;
  font-size: 0.72em;
  line-height: 1;
}

/* Structural radical (``\sqrt{x}`` in the math dialect): one continuous
   root sign whose vinculum covers the whole radicand. The &radic; glyph in
   .sqrt-sign stays in the DOM for plain-text copying but is hidden; the
   visible sign is a CSS shape stretched to the radicand's height so the
   ascending stroke meets the vinculum with no seam. */
.sqrt {
  display: inline-flex;
  align-items: stretch;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
  vertical-align: middle;
}

.sqrt-sign {
  position: relative;
  width: 0.62em;
  visibility: hidden;
}

.sqrt-sign::after {
  content: "";
  position: absolute;
  inset: 0;
  visibility: visible;
  background: currentColor;
  clip-path: polygon(
    0% 60%, 12% 52%, 36% 84%, 88% 0%, 100% 0%,
    100% 6%, 93% 6%, 40% 100%, 30% 100%, 6% 62%
  );
}

.sqrt-body {
  display: inline-block;
  border-top: 1.35px solid currentColor;
  padding: 0.06em 0.2em 0 0.12em;
}

.frac-num {
  padding: 0 0.22em 0.1em;
  border-bottom: 1.35px solid currentColor;
}

.frac-den {
  padding: 0.1em 0.22em 0;
}

.frac .frac {
  font-size: 0.9em;
}

.frac sub,
.frac sup {
  position: static;
  line-height: 1;
}

.frac sub {
  vertical-align: sub;
}

.frac sup {
  vertical-align: super;
}

.frac-den sup {
  position: relative;
  top: 0.18em;
}

.sum {
  display: inline-grid;
  grid-template-areas:
    "upper"
    "symbol"
    "lower";
  grid-template-rows: 0.68em 1em 0.68em;
  align-items: center;
  justify-items: center;
  min-width: 1.9em;
  margin-inline: 0.28em;
  vertical-align: middle;
  line-height: 1;
}

.sum-upper,
.sum-lower {
  font-size: 0.68em;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.sum-upper {
  grid-area: upper;
  align-self: end;
}

.sum-symbol {
  grid-area: symbol;
  font-size: 1.55em;
  line-height: 0.72;
}

.sum-lower {
  grid-area: lower;
  align-self: start;
}

.sum + .frac {
  margin-inline-start: 0.32em;
}

.formula-compact {
  width: fit-content;
}

.formula-annotated {
  width: 100%;
  margin: 14px 0 20px;
}

.formula-annotated-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0 0 16px;
}

.formula-annotated-expression {
  order: 2;
  width: fit-content;
  max-width: 100%;
  margin-top: 5px;
  direction: ltr;
  unicode-bidi: isolate;
  padding: 8px 12px;
  border-block: 1px solid var(--formula-line);
  background: var(--formula-bg);
  color: var(--formula-ink);
  font-family: "Times New Roman", "Noto Serif", serif;
  font-size: 1.1rem;
  text-align: left;
  white-space: nowrap;
  overflow-x: auto;
}

.formula-annotated-expression sub,
.formula-annotated-expression sup {
  position: static;
  font-size: 0.82em;
  font-weight: 700;
  line-height: 1;
  margin-inline: 0.1em 0.09em;
}

.formula-annotated-expression sub {
  vertical-align: -0.3em;
}

.formula-annotated-expression sup {
  vertical-align: 0.58em;
}

.formula-annotated-note {
  order: 1;
  padding: 0;
  color: var(--muted);
  font-weight: 600;
}

.formula-example {
  margin: -6px 0 22px;
  padding: 11px 13px;
  border-inline-start: 3px solid var(--blue);
  background: var(--blue-soft);
  display: grid;
  gap: 6px;
  line-height: 1.6;
}

.formula-example-title {
  color: var(--blue);
  font-size: 0.94em;
  line-height: 1.35;
}

.formula-example p {
  margin: 0;
}

.formula-example-label {
  color: var(--ink);
  font-weight: 700;
}

.derivation-steps {
  margin: 18px 0 24px;
  padding-inline-start: 1.4rem;
}

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

.derivation-steps li:first-child {
  border-top: 0;
  padding-top: 0;
}

.derivation-line {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 6px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 1.1rem;
}

.timeline-guide {
  margin: 28px 0 34px;
}

.timeline-guide > h3 {
  color: var(--blue);
}

.timeline-scale-note {
  color: var(--muted);
  font-size: 0.95rem;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 14px 0 18px;
  padding: 10px 12px;
  border-block: 1px solid var(--line);
  background: var(--neutral);
}

.timeline-legend-item {
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 700;
}

.cashflow-positive {
  color: var(--green);
}

.cashflow-negative {
  color: var(--red);
}

.valuation-marker {
  color: var(--blue);
}

.timeline-scenarios {
  display: grid;
  gap: 18px;
}

.timeline-scenario {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.timeline-scenario h4 {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 1.05rem;
}

.cashflow-timeline {
  max-width: 100%;
  margin: 14px 0 10px;
  overflow-x: auto;
  border-block: 1px solid var(--line);
  background: var(--neutral);
  direction: ltr;
  unicode-bidi: isolate;
}

.timeline-grid {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(96px, 1fr);
  min-width: 560px;
  padding: 10px 12px 8px;
}

.timeline-grid::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 49px;
  right: 22px;
  left: 22px;
  height: 2px;
  background: var(--line-strong);
}

.timeline-grid::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 44px;
  right: 18px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--line-strong);
}

.timeline-moment {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 34px 12px 24px;
  justify-items: center;
  align-items: center;
  min-width: 0;
}

.cashflow-marker {
  direction: ltr;
  unicode-bidi: isolate;
  align-self: end;
  min-height: 1.5rem;
  font-family: "Times New Roman", "Noto Serif", serif;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.timeline-dot {
  width: 11px;
  height: 11px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  background: var(--paper);
}

.timeline-moment.is-valuation .timeline-dot {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 3px var(--paper);
}

.timeline-time {
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.timeline-rule {
  margin: 8px 0 0;
  color: var(--muted);
}

.final-answer-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.final-answer-list li {
  margin: 0;
  padding: 9px 0;
  border-top: 1px solid var(--green-line);
}

.final-answer-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.svg-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

svg,
.svg-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

svg {
  direction: ltr;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
}

@media (max-width: 720px) {
  html {
    font-size: 17px;
  }

  main {
    /* width comes from the base rule's clamp() now, which already gives
       narrow screens more than this old flat 12px-per-side override did. */
    padding-top: 26px;
  }

  h1 {
    font-size: 2rem;
  }

  .page-title-solution {
    font-size: 1.85rem;
  }

  .course,
  .topic,
  .exam-question {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .status {
    white-space: normal;
  }

  .solution-roadmap,
  .symbol-list,
  .result-breakdown,
  .formula-sheet-nav {
    grid-template-columns: 1fr;
  }

  .solution-roadmap li {
    padding: 10px 0;
    border-inline-start: 0;
    border-top: 1px solid var(--line);
  }

  .solution-roadmap li:first-child {
    border-top: 0;
  }

  .symbol-list dd,
  .result-breakdown dd {
    padding-bottom: 5px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  table.transportation-table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }
}

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

  main {
    width: 100%;
    padding: 0;
  }

  body,
  a {
    color: #000;
  }

  .course,
  .topic,
  .exam-question,
  .algorithm-walkthrough,
  .exam-progress,
  .related,
  .theory-links,
  .note,
  .question,
  .readiness,
  .final-answer,
  .formula,
  .formula-annotated {
    background: #fff;
    break-inside: avoid;
  }

  .view-tabs {
    display: none;
  }

  .formula-sheet-nav,
  .study-resource-link {
    display: none;
  }

  .formula-sheet-page .method-block {
    break-before: page;
  }

  .formula-sheet-page .method-block:first-of-type {
    break-before: auto;
  }

  .exercise-prompt,
  .try-first {
    break-inside: avoid;
  }

  .try-first {
    min-height: 34mm;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .lesson-view[hidden] {
    display: block !important;
  }
}
