.theory-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  border-radius: var(--shape-panel);
  padding: clamp(1.35rem, 4vw, 3.15rem);
  border: 1px solid var(--border);
  background: var(--tint);
}

.theory-intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.theory-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.25rem;
  margin-block-end: 1rem;
}

.theory-toolbar h2 { font: 650 clamp(1.35rem, 3.5vw, 1.85rem)/1.2 var(--type); }

.theory-toolbar input, .theory-filter select {
  color: var(--text);
  border-radius: var(--shape-control);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  min-block-size: 2.65rem;
  padding: 0.4rem 0.7rem;
}
.theory-toolbar input { inline-size: min(100%, 24rem); }

.theory-grid, .theory-level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
.theory-level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.theory-level-grid.theory-single { grid-template-columns: minmax(0, 48rem); }

.theory-group {
  min-block-size: 8rem;
  justify-items: start;
  gap: 0.3rem;
  transition: border-color 150ms, background-color 150ms;
}
.theory-group:hover, .theory-group:focus-visible { border-color: var(--accent); background: var(--tint); }
.theory-group h2 { overflow-wrap: anywhere; }
.theory-group-mark {
  border-radius: 0.4rem;
  padding-inline: 0.6rem;
  margin-block-end: 0.42rem;
  background: var(--tint);
  color: var(--accent);
  font-family: var(--type);
  font-weight: 700;
  min-inline-size: 2.2rem;
  text-align: center;
}

.theory-russian { display: block; color: var(--text-muted); }
.theory-article-intro { background: var(--tint); }
.theory-article-intro h1 { overflow-wrap: anywhere; }
.theory-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.55rem;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.theory-breadcrumb a, .theory-article-intro .lesson-meta a, .theory-table a {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.theory-breadcrumb a:hover, .theory-table a:hover { color: var(--accent-hover); }
.theory-topic-list {
  display: grid;
  gap: 0.2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.theory-topic-list li + li { border-block-start: 1px solid var(--border); }
.theory-topic-list a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.4rem;
  padding: 0.62rem 0.5rem;
}
.theory-topic-list a:hover { background: var(--tint); }
.theory-topic-list strong { overflow-wrap: anywhere; }
.theory-topic-list .level-pill { flex: 0 0 auto; }

.theory-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0;
}
.theory-forms > div {
  border-radius: var(--shape-control);
  border: 1px solid var(--border);
  padding: 0.65rem 0.8rem;
  background: var(--tint);
}
.theory-forms dt { font-size: 0.82rem; font-weight: 750; color: var(--text-muted); }
.theory-forms dd { margin-inline-start: 0; overflow-wrap: anywhere; }

.theory-note { background: var(--note); border-color: var(--border); }
.theory-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.theory-example {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  min-inline-size: 0;
  margin: 0;
  border-radius: 0.4rem;
  padding: 0.78rem 0.9rem;
  border-inline-start: 3px solid var(--accent);
  background: var(--tint);
}
.theory-example blockquote { font-weight: 720; }
.theory-example figcaption { color: var(--text-muted); }
.theory-example audio {
  margin-block-start: auto;
  inline-size: min(100%, 13.5rem);
  block-size: 2.45rem;
}

.theory-table-block, .theory-table-region { min-inline-size: 0; }
.theory-table-region { overflow-x: auto; border-radius: var(--shape-control); border: 1px solid var(--border); }
.theory-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.91rem;
  text-align: start;
}
.theory-table th, .theory-table td {
  text-align: start;
  padding: 0.55rem 0.65rem;
  border-block-end: 1px solid var(--border);
  vertical-align: top;
}
.theory-table thead { background: var(--tint); }
.theory-table tbody tr:last-child > * { border-block-end: none; }
.theory-table tbody tr:nth-child(even) { background: var(--tint); }
.theory-table-note { color: var(--text-muted); font-size: 0.84rem; margin-block-start: 0.55rem; }
.theory-letter-audio { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; }
.theory-letter-audio audio { inline-size: 10.5rem; block-size: 2rem; }
.theory-alphabet th:first-child { white-space: nowrap; }
.theory-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
  margin-block-end: 0.65rem;
  font-weight: 700;
}
.theory-table[data-declension="1"] [data-declension-column]:not([data-declension-column="1"]),
.theory-table[data-declension="2"] [data-declension-column]:not([data-declension-column="2"]),
.theory-table[data-declension="3"] [data-declension-column]:not([data-declension-column="3"]) { display: none; }
.theory-score { font-weight: 750; margin-block-end: 0.7rem; }
#theory-quiz .progress-line { margin-block-end: 0.8rem; }
.theory-module-links { background: var(--tint); }

@media (max-width: 59rem) {
  .theory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 37rem) {
  .theory-grid, .theory-level-grid, .theory-forms, .theory-examples { grid-template-columns: minmax(0, 1fr); }
  .theory-group { min-block-size: 0; }
  .theory-toolbar input { inline-size: 100%; }
  .theory-toolbar input, .theory-filter select { min-block-size: 2.75rem; max-inline-size: 100%; font-size: 1rem; }
  .theory-table th, .theory-table td { padding: 0.5rem 0.42rem; }
  .theory-letter-audio { align-items: flex-start; flex-direction: column; gap: 0.25rem; }
  .theory-letter-audio audio, .theory-example audio { max-inline-size: 100%; block-size: 2.75rem; }
}

@media print {
  body:has(.theory-sheet) :is(#site-header, #site-footer, .theory-breadcrumb, .theory-sheet-actions, .theory-sheet-topics, .theory-filter, audio) { display: none; }
  .theory-sheet { inline-size: 100%; padding-block: 0; gap: 0.65rem; }
  .theory-sheet .section-heading h1 { font-size: 1.8rem; }
  .theory-sheet .study-card { padding: 0.5rem; }
  .theory-sheet .theory-table { font-size: 0.72rem; }
  .theory-sheet .theory-table-region { overflow: visible; break-inside: avoid; }
  .theory-sheet .theory-table :is(th, td)[data-declension-column] { display: table-cell; }
}
