/* ============================================================================
   Learn — notes reader view family („Notatki”).

   Scope: everything rendered by renderLearn() and the chapter HTML content —
   .learn-reader, .learn-toolbar (chapter picker + notes search), the article
   sheet, in-chapter table of contents, prose, callouts, tables, charts,
   interactive sandboxes, autotests and the chapter footer. Shell chrome (top
   app bar, drawer, navigation bar/rail, reading progress bar, chart lightbox)
   and shared buttons/chips/fields/cards live in shell.css / components.css and
   are only *used* here.

   Contract: tokens only (colour / shape / type / elevation / state / motion /
   measurement from css/tokens.css; no raw colours, radii, shadows, durations or
   font sizes), no gradients as decoration (only the QA-recognised edge-fade
   scroll affordance, expressed through a mask), no glow/pulse/scale-on-hover.
   M3 geometry used: outlined card 12dp · filter chip 32dp/8dp · outlined text
   field 56dp/4dp/1dp→2dp focus · list item 56dp · divider 1dp outline-variant ·
   focus ring 3dp secondary @2dp offset (base.css) · targets ≥48 via padding or
   ::before without inflating the spec visual size.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   0. Reader frame + local token aliases
   --------------------------------------------------------------------------- */
.learn-reader {
  /* Surface roles used inside the notes sheet. The M3 baseline neutral palette
     is pink/lavender-tinted above tone 95, so large reading surfaces use the
     neutral roles only: pure-white containers separated by 1px outline-variant
     (no pink-grey slabs); tint comes from the semantic callout containers.
     surface-container-high stays reserved for small components (headers/chips). */
  --learn-sheet: var(--md-sys-color-surface-container-lowest);
  --learn-inset: var(--md-sys-color-surface-container-lowest);
  --learn-raised: var(--md-sys-color-surface-container-lowest);
  --learn-line: var(--md-sys-color-outline-variant);
  --learn-quiet: var(--md-sys-color-on-surface-variant);
  --learn-state-layer: color-mix(
    in srgb,
    var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-opacity) * 100%),
    transparent
  );

  /* Icon glyphs — drawn with alpha masks so the colour always comes from the
     surrounding on-role token (never a hard-coded icon colour). */
  --learn-icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  --learn-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z'/%3E%3C/svg%3E");
  --learn-icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
  --learn-icon-bulb: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7z'/%3E%3C/svg%3E");
  --learn-icon-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2 2.4 7.2H22l-6.2 4.5 2.4 7.3L12 16.4 5.8 21l2.4-7.3L2 9.2h7.6z'/%3E%3C/svg%3E");
  --learn-icon-check-circle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
  --learn-icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'/%3E%3C/svg%3E");
  --learn-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  /* Edge-fade affordance for horizontal scrollers (mask, not a colour wash). */
  --learn-fade-right: linear-gradient(
    to right,
    currentColor 0,
    currentColor calc(100% - var(--md-sys-measurement-space400)),
    transparent 100%
  );

  display: flex;
  flex-direction: column;
  gap: var(--md-sys-measurement-space150);
  width: 100%;
  max-width: calc(var(--layout-prose-max) + var(--md-sys-measurement-space800) * 2);
  margin-inline: auto;
  min-width: 0;
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line);
  color: var(--md-sys-color-on-surface);
}

html[data-theme="dark"] .learn-reader {
  --learn-sheet: var(--md-sys-color-surface-container-low);
  --learn-inset: var(--md-sys-color-surface-container-high);
  --learn-raised: var(--md-sys-color-surface-container);
}

/* ---------------------------------------------------------------------------
   1. Chapter toolbar — outlined chapter picker + outlined notes search
   The native <select>/<input> already carry the M3 outlined field geometry from
   components.css (56dp · 4dp corner · 1dp outline → 2dp primary focus); this
   block only sizes them inside the reader and adds the search leading icon.
   --------------------------------------------------------------------------- */
.learn-reader .learn-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: var(--md-sys-measurement-space150);
  width: 100%;
  min-width: 0;
}

.learn-reader .learn-toolbar-left {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--md-sys-measurement-space150);
  min-width: 0;
}

/* Chapter picker: full-width outlined field on phones, sharing the row ≥600. */
.learn-reader .inline-chapter-select {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Notes search — outlined field with a leading magnifier + trailing clear. */
.learn-reader .learn-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
}
.learn-reader .learn-search-wrap::before {
  content: "";
  position: absolute;
  left: var(--md-sys-measurement-space200);
  top: 50%;
  width: var(--md-comp-text-field-leading-icon-size);
  height: var(--md-comp-text-field-leading-icon-size);
  transform: translateY(-50%);
  background-color: var(--md-sys-color-on-surface-variant);
  -webkit-mask: var(--learn-icon-search) center / contain no-repeat;
  mask: var(--learn-icon-search) center / contain no-repeat;
  pointer-events: none;
}
/* app.js renders the search input without a type attribute, so the shared
   input[type="text"] geometry in components.css does not match it — restate the
   spec field here (56dp · 4dp · 1dp outline → 2dp primary focus). */
.learn-reader .learn-search-input {
  width: 100%;
  min-width: 0;
  height: var(--md-comp-text-field-container-height);
  padding-block: 0;
  padding-left: calc(
    var(--md-sys-measurement-space200) * 2 + var(--md-comp-text-field-leading-icon-size)
  );
  padding-right: calc(
    var(--md-comp-target-size) + var(--md-sys-measurement-space200)
  );
  border: var(--md-comp-text-field-outline-width) solid var(--md-sys-color-outline);
  border-radius: var(--md-comp-text-field-container-shape);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
  transition: border-color var(--md-sys-motion-duration-short2)
      var(--md-sys-motion-easing-standard),
    box-shadow var(--md-sys-motion-duration-short2)
      var(--md-sys-motion-easing-standard);
}
.learn-reader .learn-search-clear {
  position: absolute;
  right: var(--md-sys-measurement-space75);
  top: 50%;
  display: inline-grid;
  place-items: center;
  width: var(--md-comp-target-size);
  height: var(--md-comp-target-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color var(--md-sys-motion-duration-short2)
    var(--md-sys-motion-easing-standard);
}
.learn-reader .learn-search-clear:hover {
  background: var(--learn-state-layer);
  color: var(--md-sys-color-on-surface);
}

/* Toolbar action row: one filter chip + quiet tonal actions. The chip geometry
   (32dp · 8dp · secondary-container selected) comes from components.css .chip;
   the legacy .btn variant keeps the spec button metrics. */
.learn-reader .learn-toolbar > .pill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--md-sys-measurement-space100);
  min-width: 0;
}
.learn-reader .learn-toolbar .chip,
.learn-reader .learn-toolbar .pill {
  position: relative;
  flex: 0 0 auto;
}
/* 48dp hit area around the 32dp chip without inflating the spec visual size. */
.learn-reader .learn-toolbar .chip::before,
.learn-reader .learn-toolbar .pill::before {
  content: "";
  position: absolute;
  inset: calc((var(--md-comp-target-size) - var(--md-comp-chip-container-height)) / -2) 0;
  border-radius: inherit;
}
/* Keyboard hints inside reader actions should read as quiet keycaps. */
.learn-reader :is(.btn, .chip, .pill, .toc-pill) kbd {
  background: color-mix(in srgb, currentColor 12%, transparent);
  border-color: transparent;
  color: inherit;
}

/* ---------------------------------------------------------------------------
   2. The notes sheet — M3 outlined card (surface · 1dp outline-variant · 12dp)
   --------------------------------------------------------------------------- */
.learn-reader .article {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-comp-card-container-shape);
  background: var(--learn-sheet);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line);
  box-shadow: none;
}

/* Single centred reading column: header, TOC, prose and footer share 72ch. */
.learn-reader .article > .article-header,
.learn-reader .article > .toc-bar,
.learn-reader .article > .article-content,
.learn-reader .article > .article-footer {
  width: 100%;
  max-width: var(--layout-prose-max);
  margin-inline: auto;
  min-width: 0;
}

/* --- chapter header --- */
.learn-reader .article-header {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-measurement-space100);
  margin-bottom: var(--md-sys-measurement-space250);
  padding-bottom: var(--md-sys-measurement-space250);
  border-bottom: 1px solid var(--learn-line);
}
.learn-reader .article-header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space50) var(--md-sys-measurement-space200);
}
.learn-reader .article-header .eyebrow {
  margin: 0;
  color: var(--subject-accent);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* base.css sets h1–h6 at ID level, so the header title needs #app. */
#app .learn-reader .article-header h2 {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-headline-small-size);
  line-height: var(--md-sys-typescale-headline-small-line);
  font-weight: var(--md-sys-typescale-weight-medium);
  letter-spacing: var(--md-sys-typescale-headline-small-tracking);
  overflow-wrap: break-word;
}
.learn-reader .article-header .source {
  flex: 0 1 auto;
  max-width: 62%;
  margin-left: auto;
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line);
  color: var(--learn-quiet);
  text-align: right;
}

/* ---------------------------------------------------------------------------
   3. In-chapter table of contents — visible M3 list card with active pill
   The section index is always readable (no clipped horizontal row): a one-line
   M3 list on phones with a visible scrollbar, two columns from 640px. The
   current section is the secondary-container pill with a check icon
   (aria-current is set by app.js when jumping).
   --------------------------------------------------------------------------- */
.learn-reader .toc-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--md-sys-measurement-space25);
  margin-bottom: var(--md-sys-measurement-space300);
  padding: var(--md-sys-measurement-space100);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--learn-inset);
}
.learn-reader .toc-label {
  margin: 0;
  padding: var(--md-sys-measurement-space100) var(--md-sys-measurement-space150)
    var(--md-sys-measurement-space50);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line);
  font-weight: var(--md-sys-typescale-weight-semibold);
  letter-spacing: 0;
  text-transform: none;
}
.learn-reader .toc-pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--md-sys-measurement-space100);
  width: 100%;
  min-height: var(--md-comp-target-size);
  padding: var(--md-sys-measurement-space100) var(--md-sys-measurement-space150);
  border: 0;
  border-radius: var(--md-sys-shape-corner-medium);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  font-weight: var(--md-sys-typescale-weight-medium);
  letter-spacing: 0;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background-color var(--md-sys-motion-duration-short2)
      var(--md-sys-motion-easing-standard),
    color var(--md-sys-motion-duration-short2)
      var(--md-sys-motion-easing-standard);
}
.learn-reader .toc-pill:hover {
  background: var(--learn-state-layer);
  color: var(--md-sys-color-on-surface);
}
.learn-reader .toc-pill:active {
  background: color-mix(
    in srgb,
    var(--md-sys-color-on-surface) calc(var(--md-sys-state-pressed-opacity) * 100%),
    transparent
  );
}
.learn-reader .toc-pill[aria-current="true"] {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.learn-reader .toc-pill[aria-current="true"]::after {
  content: "";
  flex: 0 0 auto;
  margin-left: auto;
  width: var(--md-comp-chip-icon-size);
  height: var(--md-comp-chip-icon-size);
  background-color: currentColor;
  -webkit-mask: var(--learn-icon-check) center / contain no-repeat;
  mask: var(--learn-icon-check) center / contain no-repeat;
}
/* Phones: a compact, clearly scrollable list (visible scrollbar). */
@media (max-width: 639px) {
  .learn-reader .toc-bar {
    max-height: 42vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
/* Tablet / desktop: the whole chapter index is visible in two columns. */
@media (min-width: 640px) {
  .learn-reader .toc-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--md-sys-measurement-space100);
  }
  .learn-reader .toc-label {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------------------
   4. Reading typography — 16/1.75 on phones, 17/1.75 from 768px, measure 72ch
   --------------------------------------------------------------------------- */
.learn-reader .article-content {
  max-width: var(--layout-prose-max);
  margin-inline: auto;
  min-width: 0;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-prose-line);
  overflow-wrap: break-word;
}
.learn-reader .article-content > * + * {
  margin-top: var(--md-sys-measurement-space200);
}
.learn-reader .article-content p + p {
  margin-top: var(--md-sys-measurement-space150);
}
.learn-reader .article-content .lead {
  font-size: inherit;
  line-height: inherit;
}
.learn-reader .article-content .small,
.learn-reader .article-content small {
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line);
}
.learn-reader .article-content .muted {
  color: var(--learn-quiet);
}
/* Quiet links inside prose. */
.learn-reader .article-content a {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
  text-decoration-color: color-mix(
    in srgb,
    var(--md-sys-color-primary) 40%,
    transparent
  );
  text-underline-offset: 2px;
}
.learn-reader .article-content a:hover {
  text-decoration-color: var(--md-sys-color-primary);
}
/* Search hit highlight — tonal warning role (legible on every callout tone). */
.learn-reader .article-content mark {
  padding: 0 var(--md-sys-measurement-space25);
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
  animation: none;
}

/* Lists — comfortable rhythm, quiet markers. */
.learn-reader .article-content :is(ul, ol) {
  margin: var(--md-sys-measurement-space150) 0;
  padding-left: 1.4em;
}
.learn-reader .article-content li {
  margin: 0;
  padding-left: var(--md-sys-measurement-space25);
}
.learn-reader .article-content li + li {
  margin-top: var(--md-sys-measurement-space75);
}
.learn-reader .article-content li::marker {
  color: var(--learn-quiet);
}
.learn-reader .article-content li > :is(ul, ol) {
  margin: var(--md-sys-measurement-space75) 0;
}

/* Section headings inside the chapter body. */
#app .learn-reader .article-content :is(h2, h3, h4) {
  color: var(--md-sys-color-on-surface);
  scroll-margin-top: calc(var(--layout-topbar-height) + var(--md-sys-measurement-space200));
  overflow-wrap: break-word;
}
#app .learn-reader .article-content h2 {
  margin: var(--md-sys-measurement-space500) 0 var(--md-sys-measurement-space150);
  font-size: var(--md-sys-typescale-headline-small-size);
  line-height: var(--md-sys-typescale-headline-small-line);
  font-weight: var(--md-sys-typescale-weight-medium);
  letter-spacing: var(--md-sys-typescale-headline-small-tracking);
}
#app .learn-reader .article-content h3 {
  margin: var(--md-sys-measurement-space600) 0 var(--md-sys-measurement-space150);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line);
  font-weight: var(--md-sys-typescale-weight-medium);
  letter-spacing: var(--md-sys-typescale-title-large-tracking);
}
#app .learn-reader .article-content h4 {
  margin: var(--md-sys-measurement-space400) 0 var(--md-sys-measurement-space100);
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line);
  font-weight: var(--md-sys-typescale-weight-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
}
#app .learn-reader .article-content > :is(h2, h3, h4):first-child {
  margin-top: 0;
}
.learn-reader .article-content :is(h3, h4) + p {
  margin-top: 0;
}

/* ---------------------------------------------------------------------------
   5. Math — KaTeX displays scroll inside the prose measure, never widen it
   --------------------------------------------------------------------------- */
.learn-reader .article-content .math {
  display: inline;
  font-weight: inherit;
  color: inherit;
  font-variant-numeric: tabular-nums;
}
.learn-reader .article-content .math-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 100%;
  margin: 0 var(--md-sys-measurement-space25);
  padding: 1px var(--md-sys-measurement-space50);
  vertical-align: middle;
  font-size: 0.94em;
  line-height: 1.3;
  text-align: center;
}
.learn-reader .article-content .math-num {
  max-width: 100%;
  padding: 0 var(--md-sys-measurement-space50) var(--md-sys-measurement-space25);
  border-bottom: 1px solid var(--md-sys-color-outline);
  color: inherit;
  font-weight: var(--md-sys-typescale-weight-medium);
  overflow-wrap: break-word;
}
.learn-reader .article-content .math-den {
  max-width: 100%;
  padding: var(--md-sys-measurement-space25) var(--md-sys-measurement-space50) 0;
  color: inherit;
  overflow-wrap: break-word;
}
.learn-reader .article-content .katex {
  font-size: 1.05em;
}
.learn-reader .article-content .katex-display {
  max-width: 100%;
  margin: var(--md-sys-measurement-space150) 0;
  padding-block: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-mask-image: var(--learn-fade-right);
  mask-image: var(--learn-fade-right);
}
.learn-reader .article-content .katex-display > .katex {
  max-width: 100%;
}

/* ---------------------------------------------------------------------------
   6. Callouts — tonal M3 containers with an icon + a bold label (never
   colour-only). Tone pairs: primary / tertiary / warning / secondary + neutral
   inset for informational notes.
   --------------------------------------------------------------------------- */
.learn-reader .article-content :is(
    .lead,
    .summary-box,
    .memory,
    .warning,
    .example,
    .callout,
    .note
  ) {
  position: relative;
  padding: var(--md-sys-measurement-space200);
  border: 0;
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: none;
  color: var(--md-sys-color-on-surface);
  font-size: inherit;
  line-height: inherit;
}
/* Bold segments inside a tonal block inherit its on-role colour. */
.learn-reader .article-content :is(
    .lead,
    .summary-box,
    .memory,
    .warning,
    .example,
    .callout,
    .note
  ) :is(b, strong) {
  color: inherit;
}
/* Tonal callouts reserve a leading icon gutter. */
.learn-reader .article-content :is(
    .summary-box,
    .memory,
    .warning,
    .example,
    .callout,
    .note
  ) {
  padding-left: calc(
    var(--md-sys-measurement-space200) + var(--md-sys-measurement-space400)
  );
}
.learn-reader .article-content :is(
    .summary-box,
    .memory,
    .warning,
    .example,
    .callout,
    .note
  )::before {
  content: "";
  position: absolute;
  left: var(--md-sys-measurement-space200);
  top: var(--md-sys-measurement-space200);
  width: var(--md-sys-measurement-space250);
  height: var(--md-sys-measurement-space250);
  background-color: currentColor;
  -webkit-mask: var(--learn-icon-info) center / contain no-repeat;
  mask: var(--learn-icon-info) center / contain no-repeat;
}
/* Intro strip of a chapter — quiet inset, no icon. */
.learn-reader .article-content .lead {
  border: 1px solid var(--learn-line);
  background: var(--learn-inset);
}
/* „W pigułce” — key takeaways. */
.learn-reader .article-content .summary-box {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.learn-reader .article-content .summary-box::before {
  -webkit-mask-image: var(--learn-icon-star);
  mask-image: var(--learn-icon-star);
}
/* Mnemonic device. */
.learn-reader .article-content .memory {
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}
.learn-reader .article-content .memory::before {
  -webkit-mask-image: var(--learn-icon-bulb);
  mask-image: var(--learn-icon-bulb);
}
/* Exam trap. */
.learn-reader .article-content .warning {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
}
.learn-reader .article-content .warning::before {
  -webkit-mask-image: var(--learn-icon-warning);
  mask-image: var(--learn-icon-warning);
}
/* Conclusions / worked example. */
.learn-reader .article-content .example {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.learn-reader .article-content .example::before {
  -webkit-mask-image: var(--learn-icon-check-circle);
  mask-image: var(--learn-icon-check-circle);
}
/* Neutral informational blocks: outlined white cards (no pink-grey fill). */
.learn-reader .article-content :is(.callout, .note) {
  border: 1px solid var(--learn-line);
  background: var(--learn-inset);
}
/* Bold opener of a callout is its label. */
.learn-reader .article-content :is(
    .summary-box,
    .memory,
    .warning,
    .example,
    .callout,
    .note
  ) > b:first-child {
  display: block;
  margin-bottom: var(--md-sys-measurement-space100);
  color: inherit;
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line);
  font-weight: var(--md-sys-typescale-weight-semibold);
}
/* Lists inside tonal blocks sit flush with their text. */
.learn-reader .article-content :is(
    .summary-box,
    .memory,
    .warning,
    .example,
    .callout,
    .note
  ) :is(ul, ol) {
  margin: var(--md-sys-measurement-space100) 0 0;
  padding-left: 1.25em;
}
/* Task statement card — outlined, clearly delimited. */
.learn-reader .article-content .example-box {
  padding: var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
}
/* Formula panels — calm inset blocks that scroll instead of widening the page. */
.learn-reader .article-content .formula {
  padding: var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
  font-size: inherit;
  line-height: var(--md-sys-typescale-prose-line);
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.learn-reader .article-content .formula-box {
  padding: var(--md-sys-measurement-space150) var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
  text-align: center;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.learn-reader .article-content .formula-box .katex-display {
  margin: var(--md-sys-measurement-space50) 0;
}
.learn-reader .article-content .formula-note {
  margin-top: var(--md-sys-measurement-space75);
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line);
}
.learn-reader .article-content :is(h3, h4) + :is(.formula, .formula-box, .summary-box, .memory, .warning, .example) {
  margin-top: var(--md-sys-measurement-space150);
}

/* ---------------------------------------------------------------------------
   7. Autotest / quick check — M3 expandable card (<details class="quick-check">)
   --------------------------------------------------------------------------- */
.learn-reader .article-content details.quick-check {
  margin: var(--md-sys-measurement-space400) 0 var(--md-sys-measurement-space150);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
  overflow: hidden;
}
.learn-reader .article-content details.quick-check > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--md-sys-measurement-space75) var(--md-sys-measurement-space150);
  min-height: var(--md-comp-list-item-height);
  padding: var(--md-sys-measurement-space150) var(--md-sys-measurement-space200);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line);
  font-weight: var(--md-sys-typescale-weight-medium);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color var(--md-sys-motion-duration-short2)
    var(--md-sys-motion-easing-standard);
}
.learn-reader .article-content details.quick-check > summary::-webkit-details-marker {
  display: none;
}
.learn-reader .article-content details.quick-check > summary::before {
  content: "";
  flex: 0 0 auto;
  width: var(--md-comp-list-icon-size);
  height: var(--md-comp-list-icon-size);
  background-color: var(--md-sys-color-primary);
  -webkit-mask: var(--learn-icon-chevron) center / contain no-repeat;
  mask: var(--learn-icon-chevron) center / contain no-repeat;
  transition: transform var(--md-sys-motion-duration-short3)
    var(--md-sys-motion-easing-standard);
}
.learn-reader .article-content details.quick-check[open] > summary::before {
  transform: rotate(180deg);
}
.learn-reader .article-content details.quick-check > summary::after {
  content: "Pokaż odpowiedzi";
  margin-left: auto;
  color: var(--md-sys-color-primary);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
  white-space: nowrap;
}
.learn-reader .article-content details.quick-check[open] > summary::after {
  content: "Ukryj odpowiedzi";
}
.learn-reader .article-content details.quick-check > summary:hover {
  background: var(--learn-state-layer);
}
.learn-reader .article-content details.quick-check[open] > summary {
  border-bottom: 1px solid var(--learn-line);
}
.learn-reader .article-content details.quick-check .quick-check-body {
  padding: var(--md-sys-measurement-space200);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font-size: inherit;
  line-height: inherit;
  animation: none;
}
.learn-reader .article-content .quick-check-body > * + * {
  margin-top: var(--md-sys-measurement-space200);
}
.learn-reader .article-content .quick-check-body p + p {
  margin-top: var(--md-sys-measurement-space200);
  padding-top: var(--md-sys-measurement-space200);
  border-top: 1px solid var(--learn-line);
}
.learn-reader .article-content .quick-check-body b {
  font-weight: var(--md-sys-typescale-weight-semibold);
}

/* ---------------------------------------------------------------------------
   8. Tables — scroll inside the wrapper (edge-fade affordance), 1dp dividers,
   tonal sticky header, tabular numbers. The page never widens.
   --------------------------------------------------------------------------- */
.learn-reader .article-content .table-wrap {
  width: 100%;
  max-width: 100%;
  margin: var(--md-sys-measurement-space200) 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-lowest);
  -webkit-mask-image: var(--learn-fade-right);
  mask-image: var(--learn-fade-right);
}
.learn-reader .article-content .table-scroll {
  width: 100%;
  max-width: 100%;
  margin: var(--md-sys-measurement-space150) 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-mask-image: var(--learn-fade-right);
  mask-image: var(--learn-fade-right);
}
.learn-reader .article-content .table-wrap table,
.learn-reader .article-content .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  color: var(--md-sys-color-on-surface);
}
.learn-reader .article-content .table-wrap :is(th, td),
.learn-reader .article-content .table-scroll :is(th, td),
.learn-reader .article-content .data-table :is(th, td) {
  padding: var(--md-sys-measurement-space125) var(--md-sys-measurement-space175);
  border: 0;
  border-bottom: 1px solid var(--learn-line);
  border-right: 0;
  vertical-align: top;
  overflow-wrap: break-word;
}
.learn-reader .article-content .table-wrap th,
.learn-reader .article-content .table-scroll th,
.learn-reader .article-content .data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  text-align: left;
  white-space: normal;
}
.learn-reader .article-content .table-wrap tbody tr:last-child td,
.learn-reader .article-content .table-scroll tbody tr:last-child td,
.learn-reader .article-content .data-table tbody tr:last-child td {
  border-bottom: 0;
}
.learn-reader .article-content :is(.table-wrap, .table-scroll, .data-table) td {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   9. Content grids + feature cards (outlined cards on the notes sheet)
   --------------------------------------------------------------------------- */
.learn-reader .article-content :is(.grid-2, .grid-3, .card-grid) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--md-sys-measurement-space150);
  margin: var(--md-sys-measurement-space250) 0;
}
.learn-reader .article-content :is(.grid-2, .grid-3, .card-grid) > * {
  min-width: 0;
  margin: 0;
}
/* Grid cells that wrap a table scroll their table instead of the page. */
.learn-reader .article-content .grid-2 > div:has(table) {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-mask-image: var(--learn-fade-right);
  mask-image: var(--learn-fade-right);
}
.learn-reader .article-content .feature-card {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-measurement-space75);
  padding: var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
}
#app .learn-reader .article-content .feature-card h4 {
  margin: 0;
}
.learn-reader .article-content .feature-card p {
  margin: 0;
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
}
.learn-reader .article-content :is(.sandbox-header h4, .feature-card h4) {
  margin-top: 0;
}

/* ---------------------------------------------------------------------------
   10. Chart figures — tonal card, rounded media, caption body-small
   --------------------------------------------------------------------------- */
.learn-reader .article-content .chart-card {
  display: flex;
  flex-direction: column;
  margin: var(--md-sys-measurement-space250) 0;
  padding: var(--md-sys-measurement-space150);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
  box-shadow: none;
  overflow: hidden;
}
/* No lift, shadow or scale-on-hover (legacy layered rules are neutralised). */
.learn-reader .article-content .chart-card:hover {
  border-color: var(--learn-line);
  box-shadow: none;
  transform: none;
}
.learn-reader .article-content .chart-img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-lowest);
  overflow: hidden;
  cursor: zoom-in;
}
.learn-reader .article-content .chart-img-wrap img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 40vh;
  border-radius: var(--md-sys-shape-corner-small);
  user-select: none;
  transition: none;
}
.learn-reader .article-content .chart-img-wrap:hover img {
  transform: none;
}
.learn-reader .article-content .chart-zoom-badge {
  position: absolute;
  top: var(--md-sys-measurement-space100);
  right: var(--md-sys-measurement-space100);
  display: inline-flex;
  align-items: center;
  gap: var(--md-sys-measurement-space50);
  height: var(--md-sys-measurement-space300);
  padding: 0 var(--md-sys-measurement-space100);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  font-size: var(--md-sys-typescale-label-small-size);
  line-height: var(--md-sys-typescale-label-small-line);
  font-weight: var(--md-sys-typescale-label-small-weight);
  white-space: nowrap;
  pointer-events: none;
  transform: none;
}
.learn-reader .article-content .chart-card:hover .chart-zoom-badge {
  background: var(--md-sys-color-inverse-surface);
  transform: none;
}
.learn-reader .article-content .chart-caption {
  padding: var(--md-sys-measurement-space150) var(--md-sys-measurement-space50)
    var(--md-sys-measurement-space50);
}
.learn-reader .article-content .chart-caption-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space50) var(--md-sys-measurement-space150);
  margin: 0 0 var(--md-sys-measurement-space50);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line);
  font-weight: var(--md-sys-typescale-weight-medium);
}
.learn-reader .article-content .chart-source-tag {
  flex: 0 0 auto;
  padding: 0 var(--md-sys-measurement-space100);
  min-height: var(--md-sys-measurement-space300);
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-label-small-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.learn-reader .article-content .chart-caption-desc {
  margin: 0;
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line);
}
.learn-reader .article-content .chart-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--md-sys-measurement-space200);
  margin: var(--md-sys-measurement-space250) 0;
}
.learn-reader .article-content .chart-grid-2 .chart-card {
  margin: 0;
}

/* ---------------------------------------------------------------------------
   11. Interactive sandboxes — live lecture calculators
   --------------------------------------------------------------------------- */
.learn-reader .article-content .interactive-sandbox {
  margin: var(--md-sys-measurement-space400) 0;
  padding: var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--learn-raised);
  box-shadow: none;
}
.learn-reader .article-content .sandbox-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--md-sys-measurement-space75);
  margin-bottom: var(--md-sys-measurement-space100);
}
.learn-reader .article-content .sandbox-badge {
  display: inline-flex;
  align-items: center;
  min-height: var(--md-sys-measurement-space300);
  padding: 0 var(--md-sys-measurement-space100);
  border: 0;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  text-transform: none;
}
#app .learn-reader .article-content .sandbox-header h4 {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line);
  font-weight: var(--md-sys-typescale-weight-medium);
}
.learn-reader .article-content .sandbox-desc {
  margin: 0 0 var(--md-sys-measurement-space200);
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
}
.learn-reader .article-content .sandbox-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--md-sys-measurement-space200);
  margin-bottom: var(--md-sys-measurement-space200);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.learn-reader .article-content .sandbox-control {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-measurement-space50);
  min-width: 0;
}
.learn-reader .article-content .sandbox-control :is(label, .control-label) {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space50) var(--md-sys-measurement-space100);
  margin: 0;
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
}
.learn-reader .article-content .sandbox-control :is(label, .control-label) b {
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-label-large-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--md-sys-typescale-weight-semibold);
  white-space: nowrap;
}
.learn-reader .article-content .sandbox-control .katex,
.learn-reader .article-content .sandbox-control .math {
  font-size: 1em;
}
.learn-reader .article-content .sandbox-range-labels {
  display: flex;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space100);
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-label-small-size);
  line-height: var(--md-sys-typescale-label-small-line);
}
/* Live result cards. */
.learn-reader .article-content .sandbox-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--md-sys-measurement-space150);
  margin-top: var(--md-sys-measurement-space200);
}
.learn-reader .article-content .sandbox-stat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--md-sys-measurement-space150);
}
.learn-reader .article-content :is(.sandbox-stat, .sandbox-card) {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-measurement-space25);
  min-width: 0;
  padding: var(--md-sys-measurement-space150) var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-lowest);
}
.learn-reader .article-content :is(.sandbox-stat, .sandbox-card).highlight {
  border-color: transparent;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.learn-reader .article-content :is(.sandbox-stat, .sandbox-card):hover {
  box-shadow: none;
  transform: none;
}
.learn-reader .article-content .sandbox-stat small,
.learn-reader .article-content .sandbox-card .card-label {
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  letter-spacing: 0;
  text-transform: none;
}
.learn-reader .article-content :is(.sandbox-stat.highlight small, .sandbox-card.highlight .card-label) {
  color: var(--md-sys-color-on-primary-container);
}
.learn-reader .article-content .sandbox-stat strong,
.learn-reader .article-content .sandbox-card .card-value {
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line);
  font-weight: var(--md-sys-typescale-weight-semibold);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}
.learn-reader .article-content .sandbox-stat :is(span, .katex),
.learn-reader .article-content .sandbox-card .card-hint {
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line);
}
/* „Wzory i podstawione dane” live panel. */
.learn-reader .article-content .sandbox-formula-box {
  margin-top: var(--md-sys-measurement-space200);
  padding: var(--md-sys-measurement-space200);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-lowest);
  box-shadow: none;
}
.learn-reader .article-content .sandbox-formula-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space75) var(--md-sys-measurement-space150);
  margin-bottom: var(--md-sys-measurement-space150);
  padding-bottom: var(--md-sys-measurement-space100);
  border-bottom: 1px solid var(--learn-line);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line);
  font-weight: var(--md-sys-typescale-weight-semibold);
  letter-spacing: 0;
  text-transform: none;
}
.learn-reader .article-content .formula-badge {
  display: inline-flex;
  align-items: center;
  min-height: var(--md-sys-measurement-space300);
  padding: 0 var(--md-sys-measurement-space100);
  border: 0;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-label-small-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
.learn-reader .article-content .formula-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--md-sys-measurement-space150);
}
.learn-reader .article-content .formula-item {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-measurement-space50);
  min-width: 0;
  padding: 0;
  padding-bottom: var(--md-sys-measurement-space150);
  border: 0;
  border-bottom: 1px solid var(--learn-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.learn-reader .article-content .formula-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.learn-reader .article-content .formula-item:hover {
  border-color: var(--learn-line);
  box-shadow: none;
  transform: none;
}
.learn-reader .article-content .formula-item-name {
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line);
  font-weight: var(--md-sys-typescale-label-large-weight);
}
.learn-reader .article-content .formula-item-raw {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: var(--md-sys-measurement-space50) var(--md-sys-measurement-space100);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line);
  font-variant-numeric: tabular-nums;
}
.learn-reader .article-content .formula-item-raw .katex-display {
  margin: var(--md-sys-measurement-space25) 0;
  text-align: left;
}
.learn-reader .article-content .formula-item-raw .katex {
  font-size: 1em;
}
.learn-reader .article-content .formula-item-calc {
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line);
  overflow-wrap: break-word;
}
/* Bold segments of a live calculation stay inline (legacy made them blocks). */
.learn-reader .article-content .formula-item b {
  display: inline;
  margin: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
  font-weight: var(--md-sys-typescale-weight-semibold);
}
.learn-reader .article-content .formula-item-calc b {
  color: var(--md-sys-color-primary);
  font-weight: var(--md-sys-typescale-weight-semibold);
}

/* ---------------------------------------------------------------------------
   12. Chapter footer — completion action + chapter pager
   --------------------------------------------------------------------------- */
.learn-reader .article-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-sys-measurement-space200);
  margin-top: var(--md-sys-measurement-space500);
  padding-top: var(--md-sys-measurement-space250);
  border-top: 1px solid var(--learn-line);
}
.learn-reader .article-footer .pill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--md-sys-measurement-space100);
  min-width: 0;
}
.learn-reader .article-footer .pill-row:last-child {
  margin-left: auto;
}
.learn-reader .article-footer kbd {
  margin-left: var(--md-sys-measurement-space25);
}

/* ---------------------------------------------------------------------------
   13. Search empty state
   --------------------------------------------------------------------------- */
.learn-reader .article.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--md-sys-measurement-space200);
  padding: var(--md-sys-measurement-space600) var(--md-sys-measurement-space300);
  border: 1px solid var(--learn-line);
  border-radius: var(--md-comp-card-container-shape);
  background: var(--learn-sheet);
  color: var(--learn-quiet);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line);
  text-align: center;
}
.learn-reader .article.empty::before {
  content: "";
  width: var(--md-sys-measurement-space600);
  height: var(--md-sys-measurement-space600);
  background-color: var(--learn-quiet);
  -webkit-mask: var(--learn-icon-search) center / contain no-repeat;
  mask: var(--learn-icon-search) center / contain no-repeat;
  opacity: var(--md-sys-state-disabled-opacity);
}

/* ---------------------------------------------------------------------------
   14. Recall mode („Przypominanie”) — bold terms are blurred until revealed.
   Re-implemented with tokens (legacy.css used raw colours).
   --------------------------------------------------------------------------- */
.learn-reader .recall-mode .summary-box li b,
.learn-reader .recall-mode .memory b,
.learn-reader .recall-mode .callout b:not(:first-child),
.learn-reader .recall-mode .article-content td b,
.learn-reader .recall-mode .quick-check-body b + * b {
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: color-mix(
    in srgb,
    var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-opacity) * 100%),
    transparent
  );
  filter: blur(6px);
  cursor: pointer;
  user-select: none;
  transition: filter var(--md-sys-motion-duration-short3)
      var(--md-sys-motion-easing-standard),
    background-color var(--md-sys-motion-duration-short3)
      var(--md-sys-motion-easing-standard);
}
.learn-reader .recall-mode .summary-box li b:first-child,
.learn-reader .recall-mode .summary-box li > b:first-child {
  background: none;
  filter: none;
  cursor: default;
  user-select: auto;
}
.learn-reader .recall-mode b.shown {
  background: color-mix(
    in srgb,
    var(--md-sys-color-warning-container) 60%,
    transparent
  );
  filter: none;
  user-select: auto;
}
.learn-reader .recall-mode b.shown:hover {
  filter: none;
}

/* ---------------------------------------------------------------------------
   15. ≥600px — two-up toolbar, wider cards and grids
   --------------------------------------------------------------------------- */
@media (min-width: 600px) {
  .learn-reader .learn-toolbar-left {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    flex: 1 1 auto;
  }
  .learn-reader .inline-chapter-select {
    flex: 1 1 300px;
    width: auto;
  }
  .learn-reader .learn-search-wrap {
    flex: 1 1 240px;
    width: auto;
  }
  .learn-reader .article {
    padding: var(--md-sys-measurement-space300);
  }
  .learn-reader .article-content :is(.grid-2, .card-grid) {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
  .learn-reader .article-content .grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  .learn-reader .article-content .sandbox-controls {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  .learn-reader .article-content .sandbox-results,
  .learn-reader .article-content .sandbox-stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .learn-reader .article-content .chart-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .learn-reader .article-content details.quick-check > summary::after {
    margin-left: auto;
  }
}

/* ---------------------------------------------------------------------------
   16. ≥768px — reading typography (17 / 1.75), roomier headings
   --------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .learn-reader .article-content {
    font-size: var(--md-sys-typescale-prose-size);
    line-height: var(--md-sys-typescale-prose-line);
  }
  .learn-reader .article {
    padding: var(--md-sys-measurement-space400);
  }
  #app .learn-reader .article-header h2 {
    font-size: var(--md-sys-typescale-headline-medium-size);
    line-height: var(--md-sys-typescale-headline-medium-line);
    letter-spacing: var(--md-sys-typescale-headline-medium-tracking);
  }
  .learn-reader .article-content > * + * {
    margin-top: var(--md-sys-measurement-space250);
  }
  .learn-reader .article-content :is(.grid-2, .grid-3, .card-grid) {
    gap: var(--md-sys-measurement-space200);
  }
  #app .learn-reader .article-content h2 {
    font-size: var(--md-sys-typescale-headline-small-size);
  }
}

/* ---------------------------------------------------------------------------
   17. ≥1024px — desktop breathing room
   --------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .learn-reader .article {
    padding: var(--md-sys-measurement-space500);
  }
  .learn-reader .learn-toolbar {
    gap: var(--md-sys-measurement-space200);
    margin-bottom: var(--md-sys-measurement-space300);
  }
  .learn-reader .article-header {
    margin-bottom: var(--md-sys-measurement-space300);
    padding-bottom: var(--md-sys-measurement-space300);
  }
  .learn-reader .article-content .chart-img-wrap img {
    max-height: 62vh;
  }
}

/* ---------------------------------------------------------------------------
   18. Phones — stacked toolbar, full-width footer actions, safe bottom space
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .learn-reader .article-footer .pill-row {
    flex: 1 1 100%;
  }
  .learn-reader .article-footer .pill-row:last-child {
    margin-left: 0;
  }
  .learn-reader .article-footer .btn {
    flex: 1 1 auto;
  }
  #app .learn-reader .article-header h2 {
    overflow-wrap: anywhere;
  }
  .learn-reader .article-content details.quick-check > summary::after {
    flex-basis: 100%;
    margin-left: calc(var(--md-comp-list-icon-size) + var(--md-sys-measurement-space150));
  }
}

/* Very narrow phones: keep the autotest header stacked and labels wrapping. */
@media (max-width: 399px) {
  .learn-reader .article-content .sandbox-control :is(label, .control-label) {
    flex-wrap: wrap;
  }
  .learn-reader .article-content details.quick-check > summary {
    align-items: flex-start;
  }
  .learn-reader .article-content details.quick-check > summary::before {
    margin-top: var(--md-sys-measurement-space25);
  }
}

/* ---------------------------------------------------------------------------
   19. Print — the sheet becomes paper (print.css resets the rest)
   --------------------------------------------------------------------------- */
@media print {
  .learn-reader {
    max-width: none;
  }
  .learn-reader .article,
  .learn-reader .article.empty {
    padding: 0;
    border-radius: 0;
    background: transparent;
  }
  .learn-reader .article-content,
  .learn-reader .article > .article-header,
  .learn-reader .article > .article-footer {
    max-width: none;
  }
  .learn-reader .toc-bar,
  .learn-reader .article-content .chart-zoom-badge {
    display: none;
  }
  .learn-reader .article-content .table-wrap,
  .learn-reader .article-content .table-scroll {
    -webkit-mask-image: none;
    mask-image: none;
  }
}
