:root {
  --ink: #20211d;
  --muted: #6d6a61;
  --paper: #f7f3e9;
  --paper-deep: #eee6d5;
  --white: #fffdf8;
  --wine: #7e3428;
  --wine-dark: #5b251e;
  --gold: #b7863f;
  --green: #277052;
  --green-pale: #e5f2e9;
  --red: #a83b32;
  --red-pale: #fae8e4;
  --line: #d9cfbc;
  --shadow: 0 18px 50px rgba(55, 42, 23, 0.12);
  --exercise-scale: 1;
  --exercise-relative-width: 100%;
}

* { box-sizing: border-box; }

html { max-width: 100%; overflow-x: clip; scroll-behavior: smooth; }

body {
  max-width: 100%;
  overflow-x: clip;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", Arial, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(183, 134, 63, 0.55);
  outline-offset: 3px;
}

.hero {
  width: 100%;
  max-width: 100vw;
  min-height: 720px;
  color: white;
  background:
    linear-gradient(90deg, rgba(27, 20, 14, 0.84) 0%, rgba(27, 20, 14, 0.63) 38%, rgba(27, 20, 14, 0.14) 74%),
    url("img/title.jpg") 57% 18% / max(100%, 1100px) auto;
  background-repeat: no-repeat;
  background-color: #4b3928;
  position: relative;
}

main { min-width: 0; overflow-x: clip; }

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 5px;
  background: linear-gradient(90deg, var(--wine), var(--gold), var(--wine));
}

.topbar {
  width: min(1200px, calc(100% - 48px));
  margin: auto;
  padding: 24px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "brand";
  align-items: center;
  gap: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,.24);
}

.brand {
  grid-area: brand;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: "Marcellus", Georgia, serif;
  font-size: 1.1rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.65);
  transform: rotate(45deg);
}

.brand-mark::first-letter { transform: rotate(-45deg); }

.hero-scale-control {
  width: min(620px, 100%);
  margin-top: 22px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.scale-slider-track {
  --scale-position: 100%;
  width: 100%;
  min-width: 0;
  height: 44px;
  position: relative;
  display: flex;
  align-items: center;
}

.hero-scale-control input[type="range"] {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  accent-color: #e6c27c;
  cursor: pointer;
}

.hero-scale-control input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px;
  background: rgba(255,255,255,.22);
}

.hero-scale-control input[type="range"]::-webkit-slider-thumb {
  width: 48px;
  height: 30px;
  margin-top: -10px;
  appearance: none;
  -webkit-appearance: none;
  opacity: 0;
}

.hero-scale-control input[type="range"]::-moz-range-track {
  height: 10px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px;
  background: rgba(255,255,255,.22);
}

.hero-scale-control input[type="range"]::-moz-range-thumb {
  width: 48px;
  height: 30px;
  border: 0;
  opacity: 0;
}

.view-scale-value {
  width: 48px;
  height: 30px;
  position: absolute;
  z-index: 2;
  top: 50%;
  left: clamp(24px, var(--scale-position), calc(100% - 24px));
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  border-radius: 999px;
  color: var(--wine-dark);
  background: #e6c27c;
  box-shadow: 0 2px 7px rgba(0,0,0,.35);
  font-size: .68rem;
  font-weight: 800;
  pointer-events: none;
}

.scale-preset-button {
  min-width: 58px;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 999px;
  color: white;
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(7px);
  font-size: .78rem;
  font-weight: 700;
}

.scale-preset-button:hover,
.scale-preset-button.active { color: var(--wine-dark); border-color: #e6c27c; background: #e6c27c; }

.hero-content {
  width: min(1200px, calc(100% - 48px));
  margin: auto;
  padding: 220px 0 86px;
}

.eyebrow, .panel-kicker, .lesson-label, .breadcrumb {
  color: var(--gold);
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 700px;
  margin: 12px 0 18px;
  font-family: "Marcellus", Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  line-height: .98;
  font-weight: 400;
  text-wrap: balance;
}

.hero h1 em { color: #e6c27c; font-style: normal; }
.hero-copy { max-width: 590px; font-size: 1.08rem; line-height: 1.65; color: rgba(255,255,255,.86); }

.learning-scale-frame {
  width: min(1260px, calc(100% - 48px));
  margin: -34px auto 70px;
  position: relative;
  z-index: 2;
  overflow-x: clip;
}

.learning-shell {
  width: var(--exercise-relative-width);
  margin: 0;
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  transform: scale(var(--exercise-scale));
  transform-origin: top left;
  position: relative;
  background: var(--white);
  box-shadow: var(--shadow);
}

.topic-panel { padding: 34px 22px; background: #eee7d9; border-right: 1px solid var(--line); }
.topic-panel h2 { margin: 5px 0 28px; font-family: "Marcellus", Georgia, serif; font-size: 1.45rem; font-weight: 400; }
.panel-kicker { color: var(--wine); margin: 0; }

.topic {
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  padding: 12px;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: left;
}

.topic.active { background: var(--white); border-left-color: var(--wine); color: var(--ink); box-shadow: 0 5px 20px rgba(55,42,23,.07); }
.topic:disabled { cursor: default; opacity: .55; }
.topic-icon { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-family: "Marcellus", serif; }
.topic strong, .topic small { display: block; }
.topic strong { font-size: .9rem; }
.topic small { margin-top: 2px; font-size: .72rem; }

.exercise-area { min-width: 0; padding: 38px 46px 28px; }
.exercise-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; }
.breadcrumb { margin: 0; color: var(--wine); }
.breadcrumb span { color: var(--gold); margin: 0 6px; }
.exercise-heading h2 { margin: 7px 0 6px; font: 400 clamp(1.7rem, 3vw, 2.4rem) "Marcellus", Georgia, serif; }
.exercise-heading > div > p:last-child { margin: 0; color: var(--muted); }
.exercise-actions { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; }

.secondary-button, .celebration-card button {
  border: 1px solid var(--wine);
  background: transparent;
  color: var(--wine);
  padding: 11px 16px;
  font-weight: 700;
  white-space: nowrap;
}
.secondary-button:hover { color: white; background: var(--wine); }
.secondary-button.active { color: white; background: var(--wine); }

.toolbar { margin: 28px 0 14px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.toolbar[hidden] { display: none; }
.declension-tabs { display: flex; gap: 5px; overflow-x: auto; padding: 2px; }
.declension-tabs[hidden] { display: none; }
.declension-tabs button, .mode-switch button, .number-layout-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  white-space: nowrap;
  font-size: .82rem;
  font-weight: 600;
}
.declension-tabs button[aria-selected="true"] { color: var(--wine); border-bottom: 2px solid var(--wine); }
.declension-tabs button:disabled { cursor: not-allowed; opacity: .48; }
.mode-switch, .number-layout-switch { display: flex; background: var(--paper-deep); padding: 3px; border-radius: 4px; }
.mode-switch button, .number-layout-switch button { padding: 8px 10px; }
.mode-switch button.active, .number-layout-switch button.active { background: var(--white); color: var(--wine); box-shadow: 0 2px 7px rgba(55,42,23,.1); }

.noun-search { position: relative; margin: 0 0 14px; padding: 14px 16px; border: 1px solid var(--line); background: #f6f0e4; }
.noun-search[hidden] { display: none; }
.noun-search > label { display: block; margin-bottom: 7px; color: var(--wine); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.noun-search-control { display: flex; gap: 8px; }
.noun-search-control input { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #cfc3af; background: white; color: var(--ink); }
.noun-search-control button { flex: 0 0 auto; padding: 10px 16px; border: 1px solid var(--wine); color: white; background: var(--wine); font-weight: 700; }
.noun-search-results { position: absolute; z-index: 8; top: calc(100% - 8px); right: 16px; left: 16px; max-height: 280px; overflow-y: auto; border: 1px solid #c9bca5; background: var(--white); box-shadow: 0 12px 30px rgba(55,42,23,.2); }
.noun-result { width: 100%; padding: 10px 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 15px; border: 0; border-bottom: 1px solid #e3dac9; color: var(--ink); background: transparent; text-align: left; }
.noun-result:last-child { border-bottom: 0; }
.noun-result:hover, .noun-result:focus { background: #f1e7d5; }
.noun-result strong { color: var(--wine); font: 400 1rem "Marcellus", Georgia, serif; }
.noun-result small { color: var(--muted); font-size: .68rem; text-align: right; }
.noun-search-empty { margin: 0; padding: 13px; color: var(--muted); font-size: .8rem; }

.pronoun-selection { padding: 14px 16px; border: 1px solid var(--line); background: #f6f0e4; }
.pronoun-selection > label { display: block; margin-bottom: 7px; color: var(--wine); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pronoun-selection-control { display: flex; gap: 8px; }
.pronoun-selection-control input { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #cfc3af; background: white; color: var(--ink); }
.pronoun-selection-control button { flex: 0 0 auto; padding: 10px 16px; border: 1px solid var(--wine); color: white; background: var(--wine); font-weight: 700; }

.exercise-card { border: 1px solid var(--line); background: #fffefa; }
.exercise-card.drag-active { display: block; }
.card-title-row { padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: #f2ecdf; }
.card-title-row > div { display: flex; align-items: center; gap: 13px; }
.card-title-row .card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.lesson-number { width: 43px; height: 43px; display: grid; place-items: center; background: var(--wine); color: white; font: 400 1.1rem "Marcellus", serif; }
.lesson-label { margin: 0; color: var(--gold); font-size: .62rem; }
.card-title-row h3 { margin: 2px 0 0; font: 400 1.25rem "Marcellus", serif; }
.instruction { margin: 0; color: var(--muted); font-size: .78rem; }
.table-solution-button { flex: 0 0 auto; padding: 8px 11px; border: 1px solid #c98980; color: var(--red); background: var(--red-pale); font-size: .74rem; font-weight: 700; }
.table-solution-button:hover { color: white; border-color: var(--wine); background: var(--wine); }
.table-solution-button[aria-pressed="true"] { color: #876300; border-color: #d1a43a; background: #fff1bd; }

.declension-table { padding: 22px; display: grid; gap: 28px; }
.exercise-card.quiz-active .declension-table { padding: 0; }
.grammar-quiz { padding: 22px; }
.quiz-filter-panel { margin-bottom: 20px; padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 12px 24px; border: 1px solid var(--line); background: #f6f0e4; }
.quiz-filter-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.quiz-filter-group legend { margin-bottom: 7px; color: var(--wine); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.quiz-filter-options { display: flex; flex-wrap: wrap; gap: 7px; }
.quiz-filter-option { padding: 7px 10px; display: flex; align-items: center; gap: 6px; border: 1px solid #cbbda5; background: var(--white); color: var(--ink); cursor: pointer; font-size: .76rem; font-weight: 700; }
.quiz-filter-option:has(input:checked) { color: var(--wine); border-color: var(--gold); background: #fff2c9; }
.quiz-filter-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--wine); }
.quiz-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.quiz-column { min-width: 0; display: grid; align-content: start; gap: 9px; }
.quiz-column h4 { margin: 0 0 3px; color: var(--wine); font: 400 1.05rem "Marcellus", Georgia, serif; text-align: center; }
.quiz-card {
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid #cbbda5;
  border-radius: 3px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 2px 5px rgba(55,42,23,.07);
  font-weight: 600;
  line-height: 1.25;
  transition: color .18s, background .18s, border-color .18s, transform .18s;
}
.quiz-card:hover:not(:disabled), .quiz-card:focus-visible:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); }
.quiz-card.selected { color: #6b4b00; border-color: var(--gold); background: #fff2c9; box-shadow: 0 0 0 2px rgba(183,134,63,.2); }
.quiz-card.wrong { color: var(--red); border-color: #c97d74; background: var(--red-pale); animation: shake .27s ease; }
.quiz-card.matched { cursor: default; color: var(--green); border-color: #72a78c; background: var(--green-pale); box-shadow: none; }
.quiz-completion { margin-top: 20px; padding: 15px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-left: 3px solid var(--green); background: var(--green-pale); color: var(--green); }
.quiz-completion button { flex: 0 0 auto; padding: 9px 13px; border: 1px solid var(--green); color: white; background: var(--green); font-weight: 700; }
.number-layout-control { margin-bottom: -14px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.number-layout-label { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.number-layout-switch button { font-size: .76rem; }
.declension-table-section { min-width: 0; overflow-x: auto; }
.declension-table-title { margin: 0 0 11px; color: var(--wine); font: 400 1.08rem "Marcellus", Georgia, serif; }
.verb-table-title { margin-bottom: 3px; }
.verb-table-title.group-complete { color: var(--green); }
.verb-form-label { margin: 0 0 10px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.declension-note { margin: -8px 0 0; padding: 13px 15px; border-left: 3px solid var(--gold); color: var(--muted); background: #f6f0e4; font-size: .8rem; line-height: 1.5; }
.lesson-reference { padding: 30px; border-left: 4px solid var(--gold); background: #f6f0e4; }
.lesson-reference p { max-width: 680px; margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.lesson-reference-link { display: inline-block; padding: 10px 15px; border: 1px solid var(--wine); color: white; background: var(--wine); font-weight: 700; text-decoration: none; }
.lesson-reference-link:hover, .lesson-reference-link:focus-visible { background: #5f1420; }
.grammar-grid { min-width: 520px; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.verb-grid { min-width: 430px; }
.pronoun-case-grid { min-width: 760px; }
.combined-pronoun-grid { min-width: var(--combined-grid-min-width, 760px); }
.pronoun-overview-grid { min-width: 580px; }
.pronoun-overview-grid.combined-pronoun-grid { min-width: var(--combined-grid-min-width, 760px); }
.pronoun-vocabulary-grid { min-width: 360px; }
.grid-cell { min-height: 50px; padding: 6px; display: flex; align-items: center; background: var(--white); }
.grid-header { min-height: auto; padding: 9px 7px; justify-content: center; color: var(--muted); background: #eee7d9; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; text-align: center; }
.grid-group { color: var(--wine); background: #e7ddcb; font-family: "Marcellus", serif; font-size: .86rem; letter-spacing: .04em; text-transform: none; }
.grid-group.group-complete { color: var(--green); background: var(--green-pale); }
.combined-grid-group { gap: 6px; }
.combined-group-label.group-complete { color: var(--green); }
.case-label { justify-content: flex-start; color: var(--wine); background: #f2ecdf; font-family: "Marcellus", serif; font-size: .79rem; font-weight: 700; }
.given-word { width: 100%; text-align: center; font: 400 1rem "Marcellus", serif; }
.unavailable-form { width: 100%; color: var(--muted); text-align: center; font: 400 1rem "Marcellus", serif; }
.combined-form-cell { min-width: 0; }
.number-form-pair { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; }
.number-form-part { min-width: 0; display: flex; align-items: center; }
.number-pair-separator { flex: 0 0 auto; color: var(--gold); font: 700 .9rem "Marcellus", serif; }

.answer-input, .drop-slot {
  width: 100%;
  min-height: 37px;
  border: 1px solid #cfc3af;
  border-radius: 2px;
  color: var(--ink);
  background: white;
  text-align: center;
  transition: background .18s, border .18s, transform .18s;
}
.answer-cell { position: relative; }
.answer-input { padding: 7px 31px 7px 5px; }
.answer-input::placeholder { color: #b3aa9b; }
.answer-input.exception-form, .drop-slot.exception-form { border-color: #a7b5bf; background: #eff4f6; box-shadow: inset 3px 0 0 #879ba8; }
.answer-input.correct, .drop-slot.correct { color: var(--green); border-color: #72a78c; background: var(--green-pale); font-weight: 700; }
.answer-input.incorrect { color: var(--red); border-color: #c97d74; background: var(--red-pale); }
.answer-input.assisted, .drop-slot.assisted { color: #876300; border-color: #d1a43a; background: #fff1bd; font-weight: 700; }
.answer-input.compact-answer, .drop-slot.compact-answer { font-size: var(--answer-font-size); }
.answer-input.shake, .drop-slot.shake { animation: shake .27s ease; }
.drop-slot { padding: 6px 31px 6px 6px; display: grid; place-items: center; border-style: dashed; cursor: pointer; }
.drop-slot.drag-over { border-color: var(--gold); background: #fff6db; transform: scale(1.02); }
.drop-slot.selected-target { border-color: var(--gold); background: #fff6db; box-shadow: 0 0 0 2px rgba(183,134,63,.22); }
.drop-slot.correct { cursor: default; }
.field-solution-button {
  width: 23px;
  height: 23px;
  padding: 0;
  position: absolute;
  z-index: 1;
  top: 50%;
  right: 11px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid #c98980;
  border-radius: 50%;
  color: var(--red);
  background: var(--red-pale);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1;
}
.field-solution-button:hover:not(:disabled) { color: white; border-color: var(--wine); background: var(--wine); }
.field-solution-button[aria-pressed="true"] { color: #876300; border-color: #d1a43a; background: #fff1bd; }
.field-solution-button:disabled { cursor: default; opacity: .35; }

.word-bank { margin: 0; padding: 15px; border: 1px dashed #b8a98d; background: #f7f0e3; }
.table-word-bank { margin-top: -18px; }
.word-bank-heading { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: .74rem; }
.word-bank-heading strong { color: var(--wine); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.word-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 13px; }
.word-group { padding: 11px; border: 1px solid #d8ccb8; background: rgba(255, 253, 248, .65); }
.word-group-title { display: block; margin-bottom: 8px; color: var(--wine); font: 400 .9rem "Marcellus", Georgia, serif; }
.word-group-title::before { content: "Nominativ: "; color: var(--muted); font: 600 .62rem "DM Sans", Arial, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
.word-group-title.vocabulary-title::before { content: ""; }
.word-group-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.word-chip { border: 1px solid #cbbda5; background: var(--white); padding: 7px 11px; color: var(--ink); font-family: "Marcellus", serif; box-shadow: 0 2px 4px rgba(55,42,23,.06); }
.word-chip:hover, .word-chip:focus-visible { border-color: var(--gold); color: var(--wine); transform: translateY(-1px); }
.word-chip.dragging { opacity: .35; }

.status-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 14px; color: var(--muted); font-size: .82rem; }
.status-row p { margin: 0; }
.status-row strong { color: var(--wine); }
.text-button { border: 0; background: transparent; color: var(--wine); text-decoration: underline; text-underline-offset: 4px; }

.quote-section { padding: 42px 24px 70px; text-align: center; }
.quote-section > span { display: block; height: 30px; color: var(--gold); font: 4rem Georgia, serif; }
.quote-section blockquote { margin: 10px 0; color: var(--wine); font: 400 clamp(1.6rem, 4vw, 2.6rem) "Marcellus", serif; }
.quote-section p { color: var(--muted); font-size: .85rem; }

footer { padding: 18px max(24px, calc((100% - 1200px) / 2)); display: flex; justify-content: space-between; background: #27241f; color: #d4cbb9; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.celebration { position: fixed; inset: 0; z-index: 10; display: none; place-items: center; padding: 24px; background: rgba(31,24,18,.72); }
.celebration.visible { display: grid; }
.celebration-card { width: min(420px, 100%); padding: 38px; position: relative; z-index: 2; background: var(--white); border: 4px double var(--gold); text-align: center; }
.celebration-card .laurel { color: var(--gold); font-size: 1.65rem; letter-spacing: .2em; }
.celebration-card h2 { margin: 6px 0; color: var(--wine); font: 400 2.3rem "Marcellus", serif; }
.celebration-card p:not(.eyebrow) { color: var(--muted); }
.celebration-card button { margin-top: 12px; background: var(--wine); color: white; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

@media (max-width: 900px) {
  .learning-shell { grid-template-columns: 1fr; }
  .topic-panel { padding: 18px 22px; border-right: 0; border-bottom: 1px solid var(--line); }
  .topic-panel h2, .panel-kicker { display: none; }
  .topic-panel { display: flex; gap: 6px; overflow-x: auto; }
  .topic { width: auto; min-width: 145px; margin: 0; }
  .exercise-area { padding: 32px 26px 24px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .mode-switch { align-self: flex-start; }
  .exercise-card.drag-active { display: block; }
}

@media (max-width: 620px) {
  .hero { min-height: 680px; background-position: 57% center; }
  .topbar, .hero-content { width: calc(100% - 28px); }
  .learning-scale-frame { width: calc(100% - 28px); }
  .topbar { padding: 18px 0; gap: 12px; }
  .hero-content { padding-top: 180px; padding-bottom: 62px; }
  .learning-scale-frame { margin-top: -22px; }
  .exercise-area { padding: 25px 15px 20px; }
  .exercise-heading { align-items: flex-start; flex-direction: column; }
  .exercise-actions { width: 100%; flex-wrap: wrap; justify-content: stretch; }
  .exercise-actions .secondary-button { flex: 1; }
  .declension-tabs { margin-right: -15px; }
  .card-title-row { align-items: flex-start; flex-direction: column; padding: 15px; }
  .card-title-row .card-tools { width: 100%; align-items: stretch; flex-direction: column; gap: 9px; }
  .instruction { padding-left: 56px; }
  .table-solution-button { width: 100%; }
  .noun-search-control { align-items: stretch; flex-direction: column; }
  .pronoun-selection-control { align-items: stretch; flex-direction: column; }
  .declension-table { padding: 14px; }
  .grammar-quiz { padding: 14px; }
  .quiz-filter-panel { padding: 10px; gap: 10px 16px; }
  .quiz-filter-option { padding: 7px 8px; }
  .quiz-columns { gap: 8px; }
  .quiz-column { gap: 7px; }
  .quiz-card { min-height: 50px; padding: 8px 6px; font-size: .8rem; }
  .quiz-completion { align-items: stretch; flex-direction: column; }
  .declension-table { gap: 24px; }
  .number-layout-control { margin-bottom: -10px; align-items: stretch; flex-direction: column; gap: 6px; }
  .number-layout-switch { align-self: flex-start; }
  .declension-table-section { overflow-x: visible; }
  .declension-table-title { margin-bottom: 8px; }
  .declension-note { margin-top: -4px; }
  .grammar-grid { min-width: 0; display: block !important; border: 0; background: transparent; }
  .grid-header { display: none; }
  .grid-cell.case-label { margin-top: 14px; padding: 7px 10px; min-height: auto; background: var(--wine); color: white; }
  .grid-cell:not(.case-label):not(.grid-header) { min-height: 48px; border: 1px solid var(--line); border-top: 0; padding: 6px 7px; }
  .grid-cell:not(.case-label):not(.grid-header)::before { content: attr(data-mobile-label); flex: 0 0 44%; padding-right: 8px; color: var(--muted); font-size: .66rem; font-weight: 700; line-height: 1.25; text-transform: uppercase; }
  .grid-cell.combined-form-cell { align-items: stretch; flex-direction: column; gap: 6px; }
  .grid-cell.combined-form-cell::before { width: 100%; flex: 0 0 auto; padding-right: 0; }
  .combined-form-cell .number-form-pair { width: 100%; }
  .given-word, .answer-input, .drop-slot { flex: 1; }
  .table-word-bank { margin-top: -14px; }
  .word-bank-heading { flex-direction: column; gap: 4px; }
  .status-row { align-items: flex-start; }
  footer { align-items: center; flex-direction: column; gap: 7px; }
}

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