﻿:root {
  color-scheme: light;
  --bg: #0e1320;
  --panel: #151b2e;
  --panel-2: #1a2238;
  --card: #f7f8fc;
  --card-soft: #eef1f8;
  --text: #e8ecff;
  --text-strong: #0d1730;
  --muted: #98a4c7;
  --accent: #ffb703;
  --accent-2: #7ce0c3;
  --accent-3: #7aa7ff;
  --accent-4: #ff9f1c;
  --accent-5: #90be6d;
  --accent-6: #f28482;
  --accent-7: #b8f2e6;
  --danger: #ff6b6b;
  --success: #38b000;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(122, 167, 255, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(124, 224, 195, 0.14), transparent 24%),
    linear-gradient(160deg, #0b1020 0%, #10172a 42%, #11182d 100%);
  color: var(--text);
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  padding: 24px;
  background: rgba(7, 11, 24, 0.75);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.brand__badge {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--accent), #ff7b00);
  color: #1b1200;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}

.brand h1,
.topbar h2,
.sidebar__card h2 {
  margin: 0;
}

.brand p,
.sidebar__card p,
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.sidebar__card {
  padding: 18px;
  margin-bottom: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 0.82rem;
}

.tag--accent {
  background: rgba(255, 183, 3, 0.18);
  color: #ffd166;
}

.topic-nav {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  padding-right: 4px;
}

.topic-nav-search {
  margin-bottom: 6px;
}

.topic-nav-search__hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.topic-nav-search__active {
  margin: 0 0 6px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 183, 3, 0.12);
  color: #ffe19c;
  font-size: 0.92rem;
}

.topic-nav-empty {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  line-height: 1.5;
}

.lesson-ref {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid rgba(122, 79, 0, 0.18);
  border-radius: 999px;
  background: rgba(122, 79, 0, 0.08);
  color: #6e4300;
  font: inherit;
  line-height: 1.35;
}

.lesson-ref-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.lesson-ref--link {
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.lesson-ref--link:hover,
.lesson-ref--link:focus-visible {
  color: #4f2f00;
  background: rgba(122, 79, 0, 0.16);
  border-color: rgba(122, 79, 0, 0.35);
  outline: none;
}

.lesson-ref-sep {
  color: var(--muted);
}

.topic {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}

.topic__title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
}

.topic__title > span:first-child {
  min-width: 0;
}

.topic__count {
  flex: 0 0 auto;
  white-space: nowrap;
  background: #ffd166 !important;
  color: #241600 !important;
  border: 1px solid rgba(36, 22, 0, 0.18);
  font-weight: 800;
}

.topic__list {
  display: grid;
  gap: 8px;
}

.lesson-link {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.lesson-link:hover,
.lesson-link:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.11);
  outline: none;
}

.lesson-link.is-active {
  background: linear-gradient(145deg, rgba(124, 224, 195, 0.2), rgba(122, 167, 255, 0.16));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.main {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.mode-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-switch__btn {
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.mode-switch__btn.is-active {
  background: linear-gradient(145deg, var(--accent), #ffd166);
  color: #221700;
  font-weight: 700;
}

.workspace {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.workspace__hero,
.workspace__content {
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.workspace__hero {
  padding: 18px 20px;
}

.workspace__content {
  padding: 20px;
  min-height: 520px;
  color: var(--text);
}

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

.hero-card {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
}

.hero-card h3,
.hero-card p {
  margin: 0;
}

.hero-card p {
  margin-top: 6px;
  color: var(--muted);
}

.panel {
  display: grid;
  gap: 16px;
}

.panel h3 {
  margin: 0;
}

.lesson-intro {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255, 183, 3, 0.12), rgba(124, 224, 195, 0.08));
  color: var(--text);
}

.sidebar__note {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  line-height: 1.5;
}

.print-header {
  display: none;
}

.print-header__eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: #5d6786;
}

.lesson-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 6px;
}

.lesson-print-btn {
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--accent-2), #b7f1e0);
  color: #0e1a18;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(124, 224, 195, 0.22);
}

.lesson-print-btn:hover,
.lesson-print-btn:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

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

.info-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--card);
  color: var(--text-strong);
}

.info-card--soft {
  background: var(--card-soft);
}

.info-card h4 {
  margin: 0 0 8px;
}

.info-card ul {
  margin: 0;
  padding-left: 18px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(11, 16, 32, 0.08);
  font-size: 0.9rem;
}

.flashcard,
.drill-card,
.glossary-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--card);
  color: var(--text-strong);
}

.flashcard-deck {
  display: grid;
  grid-template-columns: 56px minmax(280px, 640px) 56px;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.deck-arrow {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #ffd166);
  color: #241600;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.flashcard {
  min-height: 300px;
  width: min(100%, 640px);
  max-width: 640px;
  justify-self: center;
  position: relative;
  cursor: pointer;
  perspective: 1200px;
  overflow: hidden;
  margin: 0 auto;
}

.flashcard__face {
  position: absolute;
  inset: 0;
  padding: 18px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  backface-visibility: hidden;
  transition: transform 0.45s ease;
  overflow-y: auto;
  text-align: center;
}

.flashcard__face--front {
  transform: rotateY(0deg);
}

.flashcard__face--back {
  transform: rotateY(180deg);
}

.flashcard.is-flipped .flashcard__face--front {
  transform: rotateY(-180deg);
}

.flashcard.is-flipped .flashcard__face--back {
  transform: rotateY(0deg);
}

.flashcard__label {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(122, 167, 255, 0.12);
  color: #3958b7;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.flashcard__face p {
  margin: 0;
  line-height: 1.45;
}

.flashcard__question {
  font-size: 1.18rem;
  font-weight: 700;
  max-width: 28rem;
}

.flashcard__answer {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.6;
  color: #22304f;
  max-width: 28rem;
}

.flashcard .lesson-figure {
  margin: 4px auto;
  max-width: 320px;
}

.flashcard .lesson-svg--compact {
  max-height: 130px;
}

.flashcard .lesson-figure figcaption {
  font-size: 0.82rem;
}

.flashcard-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  color: var(--text);
}

.visual-card {
  overflow: hidden;
  border-radius: 18px;
  background: var(--card);
  color: var(--text-strong);
  max-width: 100%;
}

.visual-card__header {
  padding: 16px 16px 0;
}

.visual-card__header h4,
.visual-card__header p {
  margin: 0;
}

.visual-card__header p {
  margin-top: 6px;
  color: #5d6786;
}

.visual-card__body {
  padding: 12px 16px 16px;
  display: flex;
  justify-content: center;
}

.lesson-photo-figure {
  margin: 0;
  width: 100%;
  max-width: 760px;
}

.lesson-photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 14px;
  background: #f8fafc;
  box-shadow: 0 14px 28px rgba(13, 23, 48, 0.14);
}

.lesson-photo-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.glossary-search {
  display: grid;
  gap: 8px;
}

.glossary-search__row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.glossary-search__label {
  font-weight: 700;
  color: var(--text);
}

.glossary-search__input {
  width: 100%;
  max-width: 540px;
  flex: 1 1 320px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.glossary-search__button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(145deg, var(--accent), #ffd166);
  color: #241600;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(255, 183, 3, 0.22);
}

.glossary-search__button.secondary-btn {
  background: linear-gradient(145deg, var(--accent), #ffd166) !important;
  color: #241600 !important;
  border: 1px solid rgba(36, 22, 0, 0.18);
}

.glossary-card {
  overflow-x: auto;
}

.responsive-table {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 14px 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 18px;
  border: 1px solid rgba(13, 23, 48, 0.10);
  background: rgba(255, 255, 255, 0.55);
  -webkit-overflow-scrolling: touch;
}

.responsive-table .glossary-table {
  min-width: max-content;
}

.responsive-table .lesson-section-table--wrapped {
  min-width: 100%;
  table-layout: auto;
}

.lesson-section-table--wrapped th,
.lesson-section-table--wrapped td {
  max-width: 24ch;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.lesson-section-table--wrapped .table-cell--nowrap {
  width: 1%;
  max-width: none;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.responsive-table:focus {
  outline: 3px solid rgba(180, 83, 9, 0.32);
  outline-offset: 2px;
}

.glossary-search__input::placeholder {
  color: var(--muted);
}

.lesson-svg {
  width: 100%;
  max-width: 540px;
  max-height: 300px;
  height: auto;
  display: block;
}

.lesson-figure {
  margin: 16px auto 0;
  max-width: 560px;
}

.lesson-figure--compact {
  max-width: 520px;
}

.lesson-svg--compact {
  max-height: 240px;
}
.lesson-figure:has(.lesson-svg--trigo-x4) {
  max-width: 2240px;
  overflow-x: auto;
}

.lesson-svg--trigo-x4 {
  max-width: 2160px;
  max-height: 1200px;
}

.lesson-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.code-block {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: #0e1320;
  color: #dfe8ff;
  font-family: Consolas, "Courier New", monospace;
  overflow-x: auto;
}

.code-block__title {
  margin-bottom: 10px;
  color: #7ce0c3;
  font-weight: 700;
}

@media print {
  .sidebar,
  .topbar,
  .mode-switch,
  .lesson-actions,
  .workspace__hero,
  .app-nav,
  .lesson-print-btn,
  .lesson-link,
  .lesson-svg {
    display: none !important;
  }

  .shell,
  .main,
  .workspace,
  .panel {
    display: block !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .panel,
  .lesson-intro,
  .info-card,
  .flashcard,
  .drill-card,
  .glossary-card {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    border: 1px solid #ccc;
  }

  .function-visual,
  .plane-visual,
  .stats-visual {
    break-inside: avoid;
  }

  .print-header {
    display: block !important;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid #000;
  }

  .print-header h2,
  .print-header h3,
  .print-header p {
    margin: 0 0 6px;
    color: #000;
  }

  .code-block {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #bbb;
  }

  .visual-card__header p {
    color: #000;
  }
}

.code-line {
  padding: 2px 0;
  white-space: pre;
}

.code-line::before {
  content: " ";
}

.noscript-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  padding: 12px 16px;
  border-radius: 14px;
  background: #fff3cd;
  color: #463200;
  border: 1px solid #f0d27a;
  box-shadow: var(--shadow);
}

.primary-btn,
.secondary-btn,
a.primary-btn {
  display: inline-block;
  text-decoration: none;
}

.flashcard__question {
  font-size: 1.15rem;
  font-weight: 700;
}

.flashcard__answer,
.solution-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(13, 23, 48, 0.12);
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.primary-btn,
.secondary-btn {
  border: 0;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(145deg, var(--accent), #ffd166);
  color: #241600;
  font-weight: 700;
}

.secondary-btn {
  background: rgba(11, 16, 32, 0.08);
  color: var(--text-strong);
}

.drill-batch-actions {
  justify-content: center;
  margin: 18px 0;
}

.drill-random-btn {
  background: linear-gradient(145deg, #f59e0b, #ffd166) !important;
  color: #241600 !important;
  border: 1px solid rgba(36, 22, 0, 0.20);
  box-shadow: 0 10px 24px rgba(180, 83, 9, 0.20);
  font-weight: 800;
}

.drill-options {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.option-btn {
  text-align: left;
  border: 1px solid rgba(13, 23, 48, 0.12);
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  white-space: pre-line;
}

.option-btn.is-correct {
  border-color: rgba(56, 176, 0, 0.45);
  background: rgba(56, 176, 0, 0.08);
}

.option-btn.is-wrong {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.option-btn.is-selected {
  border-color: rgba(85, 127, 224, 0.55);
  background: rgba(122, 167, 255, 0.12);
}

.option-btn.is-selected.is-correct {
  border-color: rgba(56, 176, 0, 0.45);
  background: rgba(56, 176, 0, 0.08);
}

.option-btn.is-selected.is-wrong {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.test-panel {
  display: grid;
  gap: 14px;
}

.test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.test-header h3 {
  margin: 0;
}

.test-filter-card {
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid rgba(13, 23, 48, 0.10);
  border-radius: 20px;
  background: #fffaf0;
  color: #1f1300;
}

.test-filter-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.test-filter-card__header h4 {
  margin: 0 0 4px;
  color: #1f1300;
  font-weight: 900;
}

.test-filter-card .muted {
  color: #4b2f05;
}

.test-filter-card__actions {
  margin-top: 0;
  justify-content: flex-end;
}

.test-filter-btn {
  white-space: nowrap;
}

.test-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

.test-topic-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(13, 23, 48, 0.12);
  border-radius: 18px;
  background: #ffffff;
}

.test-topic-card.has-selection {
  border-color: rgba(180, 83, 9, 0.35);
  box-shadow: 0 10px 22px rgba(180, 83, 9, 0.10);
}

.test-topic-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(13, 23, 48, 0.12);
  border-radius: 16px;
  background: #fff7ed;
  color: #1f1300;
  cursor: pointer;
}

.test-topic-chip--theme {
  border-color: rgba(180, 83, 9, 0.28);
}

.test-topic-chip strong {
  color: #1f1300;
}

.test-topic-chip input,
.test-lesson-chip input {
  width: 18px;
  height: 18px;
  accent-color: #b45309;
  flex: 0 0 auto;
}

.test-topic-chip span,
.test-lesson-chip span {
  display: grid;
  gap: 2px;
}

.test-topic-chip small,
.test-lesson-chip small {
  color: #5b3a08;
}

.test-lesson-list {
  display: grid;
  gap: 6px;
  padding-left: 4px;
}

.test-lesson-chip {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 12px;
  color: #1f1300;
  cursor: pointer;
}

.test-lesson-chip:hover {
  background: #fffaf0;
}

.test-score {
  padding: 14px 18px;
  border: 2px solid rgba(145, 87, 0, 0.38);
  border-radius: 16px;
  background: linear-gradient(145deg, #ffd166, #ffb703);
  color: var(--text-strong);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 16px 34px rgba(13, 23, 48, 0.2);
}

.test-score--muted {
  background: rgba(11, 16, 32, 0.06);
  border-color: rgba(13, 23, 48, 0.12);
  font-weight: 600;
  font-size: 1rem;
  box-shadow: none;
}

.test-drill-card {
  margin-top: 0;
}

.test-drill-card__meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.test-actions {
  position: sticky;
  bottom: 12px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.feedback {
  margin-top: 12px;
  font-weight: 700;
}

.feedback--good {
  color: var(--success);
}

.feedback--bad {
  color: var(--danger);
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.glossary-table th,
.glossary-table td {
  text-align: left;
  vertical-align: top;
  padding: 12px;
  border-bottom: 1px solid rgba(13, 23, 48, 0.12);
  overflow-wrap: anywhere;
}

.lesson-definition-table {
  table-layout: auto;
}

.lesson-definition-table th:first-child,
.lesson-definition-table td:first-child {
  width: 1%;
  min-width: max-content;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.lesson-definition-table th:nth-child(2),
.lesson-definition-table td:nth-child(2) {
  width: auto;
  white-space: normal;
  overflow-wrap: anywhere;
}

.glossary-table code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(13, 23, 48, 0.06);
}

.history-table th:nth-child(2),
.history-table__period {
  min-width: 9.5rem;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.math-preview {
  display: inline-flex;
  align-items: center;
  gap: 0.08em;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1;
}

.math-preview sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}

.math-fraction {
  flex-direction: column;
  align-items: stretch;
  min-width: 1.8em;
  text-align: center;
}

.math-fraction__num,
.math-fraction__den {
  display: block;
  padding: 0 0.25em;
}

.math-fraction__bar {
  height: 1px;
  margin: 2px 0;
  background: currentColor;
}

.math-sqrt {
  gap: 0.15em;
}

.glossary-table th {
  position: sticky;
  top: 0;
  background: #f0f3fb;
}

.muted {
  color: #5d6786;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .topic-nav {
    max-height: 38vh;
  }

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

  .hero-grid,
  .section-grid {
    grid-template-columns: 1fr;
  }

  .flashcard-deck {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
  }

  .deck-arrow {
    width: 48px;
    height: 48px;
  }

  .visual-card svg {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .sidebar {
    padding: 16px;
  }

  .topic-nav {
    max-height: 34vh;
  }

  .workspace__content,
  .workspace__hero,
  .topbar {
    border-radius: 18px;
  }

  .workspace__content {
    padding: 14px;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-switch__btn {
    flex: 1 1 42%;
    text-align: center;
  }

  .responsive-table {
    margin: 14px -2px;
    padding-bottom: 6px;
  }

  .responsive-table::after {
    content: "faire défiler →";
    position: sticky;
    right: 8px;
    bottom: 6px;
    display: inline-block;
    margin: 0 8px 4px auto;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(120, 53, 15, 0.92);
    color: #fff7ed;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    pointer-events: none;
  }

  .responsive-table .glossary-table th,
  .responsive-table .glossary-table td {
    min-width: 96px;
    padding: 10px;
    font-size: 0.92rem;
  }

  .responsive-table .glossary-table th:first-child,
  .responsive-table .glossary-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fffaf0;
    box-shadow: 8px 0 14px rgba(13, 23, 48, 0.08);
  }

  .flashcard-deck {
    grid-template-columns: 1fr;
  }

  .flashcard {
    min-height: 340px;
    width: 100%;
    max-width: 520px;
  }

  .deck-arrow {
    width: 100%;
    border-radius: 14px;
  }

  .flashcard-meta {
    flex-direction: column;
    align-items: start;
  }
}

