:root {
  color-scheme: light;
  --ink: #17221d;
  --muted: #6d776f;
  --paper: #f4f1e8;
  --panel: #fffdf8;
  --panel-soft: rgba(255, 253, 248, 0.72);
  --panel-soft-2: rgba(255, 253, 248, 0.6);
  --line: #dcd8cc;
  --border-soft: rgba(23, 34, 29, 0.1);
  --surface-soft: rgba(23, 34, 29, 0.07);
  --topbar-bg: rgba(244, 241, 232, 0.86);
  --green: #225c46;
  --green-text: #225c46;
  --green-soft: #dfeae2;
  --green-focus-ring: rgba(34, 92, 70, 0.12);
  --green-focus-ring-soft: rgba(34, 92, 70, 0.11);
  --orange: #df713e;
  --orange-soft: #f8e4d8;
  --wrong-text: #b3362e;
  --wrong-soft: #f8dcd8;
  --shadow: 0 18px 50px rgba(31, 45, 37, 0.08);
  --input-bg: #fff;
  --input-bg-dashed: #fbfaf5;
  --block-start-bg: #eceee9;
  --block-start-border: rgba(34, 92, 70, 0.22);
  --rule-body-text: #3f4943;
  --role-toolbar-border: #cdddcf;
  --role-toolbar-text: #52665b;
  --error-bg: #fff8ef;
  --error-border: rgba(197, 102, 53, 0.25);
  --question-hint: #929a94;
  --toast-error-bg: #9d3d2f;
  --star-meter-bg: #fbf3e2;
  --star-meter-bg-strong: #f9ead0;
  --star-meter-border: rgba(190, 146, 62, 0.28);
  --star-meter-border-strong: rgba(190, 146, 62, 0.6);
  --star-meter-glyph: #c99a34;
  --star-meter-strong: #8a6516;
  --star-meter-text: #7a6330;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8e9e8;
  --muted: #9a9f9c;
  --paper: #121313;
  --panel: #1c1e1d;
  --panel-soft: rgba(28, 30, 29, 0.75);
  --panel-soft-2: rgba(28, 30, 29, 0.6);
  --line: #303332;
  --border-soft: rgba(255, 255, 255, 0.09);
  --surface-soft: rgba(255, 255, 255, 0.06);
  --topbar-bg: rgba(18, 19, 19, 0.86);
  --green: #2f7d5c;
  --green-text: #6fd8ab;
  --green-soft: rgba(47, 125, 92, 0.22);
  --green-focus-ring: rgba(111, 216, 171, 0.18);
  --green-focus-ring-soft: rgba(111, 216, 171, 0.16);
  --orange: #e88354;
  --orange-soft: rgba(232, 131, 84, 0.16);
  --wrong-text: #f08a80;
  --wrong-soft: rgba(240, 100, 90, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --input-bg: #1a1b1a;
  --input-bg-dashed: #171817;
  --block-start-bg: #24322b;
  --block-start-border: rgba(111, 216, 171, 0.32);
  --rule-body-text: #cbcecb;
  --role-toolbar-border: rgba(111, 216, 171, 0.25);
  --role-toolbar-text: #a9c2b3;
  --error-bg: rgba(232, 131, 84, 0.1);
  --error-border: rgba(232, 131, 84, 0.3);
  --question-hint: #838785;
  --toast-error-bg: #7a2c22;
  --star-meter-bg: rgba(201, 154, 52, 0.12);
  --star-meter-bg-strong: rgba(201, 154, 52, 0.22);
  --star-meter-border: rgba(201, 154, 52, 0.3);
  --star-meter-border-strong: rgba(201, 154, 52, 0.65);
  --star-meter-glyph: #e0b45c;
  --star-meter-strong: #f0cf8a;
  --star-meter-text: #c4ac7c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(223, 113, 62, 0.1), transparent 28rem),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--border-soft);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: white;
  background: var(--green);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.lesson-badge {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--green-text);
  font-size: 13px;
  font-weight: 750;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-button,
.role-toolbar button {
  padding: 10px 15px;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--green);
  cursor: pointer;
  font-weight: 750;
}

.topbar-button:disabled,
.role-toolbar button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.workspace {
  display: grid;
  /* Заголовок урока — отдельная строка во всю ширину, под ним материалы и
     практика встают на одном уровне. */
  grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.25fr);
  align-items: start;
  gap: clamp(24px, 4vw, 64px);
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 64px);
}

.panel-heading {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.study-panel {
  min-width: 0;
}

.panel-heading h1 {
  max-width: none;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3.3vw, 51px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.eyebrow,
.instruction {
  margin: 0 0 8px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-heading h1 {
  max-width: none;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3.3vw, 51px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.035em;
  /* Длинный заголовок переносится, а не обрезается: он занимает всю ширину
     страницы, поэтому искусственное ограничение по символам больше не нужно. */
  overflow-wrap: break-word;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.source-links a {
  color: var(--green-text);
  font-weight: 750;
  text-decoration: none;
}

.tabs {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin-bottom: 14px;
  padding: 5px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.tab {
  min-width: 100px;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.tab.is-active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 3px 12px rgba(23, 34, 29, 0.08);
}

.tab-content {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 285px);
  overflow: auto;
  padding: 2px 8px 28px 2px;
  scrollbar-color: rgba(34, 92, 70, 0.3) transparent;
}

.is-hidden {
  display: none !important;
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  overflow: clip;
}

.rule-card[open] {
  background: var(--panel);
  box-shadow: 0 8px 26px rgba(23, 34, 29, 0.05);
}

.rule-card summary {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 760;
}

.rule-card summary::-webkit-details-marker {
  display: none;
}

.rule-number {
  color: var(--orange);
  font-size: 12px;
}

.chevron {
  color: var(--muted);
  transition: transform 160ms ease;
}

.rule-card[open] .chevron {
  transform: rotate(180deg);
}

.rule-body {
  padding: 0 22px 20px 60px;
  color: var(--rule-body-text);
  font-size: 14px;
  line-height: 1.65;
}

.rule-body p,
.rule-body ul {
  margin: 0 0 10px;
}

.rule-body code {
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--green-text);
  background: var(--green-soft);
}

.rule-body code.wrong,
.error-review code.wrong {
  color: var(--wrong-text);
  background: var(--wrong-soft);
  text-decoration: line-through;
  text-decoration-color: var(--wrong-text);
}

.rule-body blockquote {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--orange);
  border-radius: 0 8px 8px 0;
  background: var(--orange-soft);
}

.rule-body table {
  width: 100%;
  margin: 0 0 14px;
  border-collapse: collapse;
  font-size: 13px;
}

.rule-body th,
.rule-body td {
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  text-align: left;
}

.rule-body th {
  background: var(--surface-soft);
  font-weight: 700;
}

.word-search {
  display: grid;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.word-search input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--panel);
}

.word-search input:focus {
  border-color: var(--green-text);
  box-shadow: 0 0 0 3px var(--green-focus-ring);
}

.word-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.word-card {
  display: grid;
  gap: 3px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.word-card strong {
  color: var(--green-text);
  font-size: 16px;
}

.word-card span {
  color: var(--muted);
  font-size: 13px;
}

.chat-empty {
  padding: 16px 4px;
  color: var(--muted);
  font-size: 13px;
}

.chat-messages {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.chat-message {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-message.is-user {
  justify-self: end;
  color: white;
  background: var(--green);
}

.chat-message.is-assistant {
  justify-self: start;
  border: 1px solid var(--line);
  background: var(--panel);
}

.chat-message.is-pending {
  color: var(--muted);
  font-style: italic;
}

.chat-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.chat-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  resize: vertical;
  color: var(--ink);
  background: var(--panel);
  font-size: 14px;
  line-height: 1.5;
}

.chat-form textarea:focus {
  border-color: var(--green-text);
  box-shadow: 0 0 0 3px var(--green-focus-ring);
}

.chat-form .primary-button {
  margin-top: 10px;
}

.practice-panel {
  min-width: 0;
}

.progress-block {
  margin-bottom: 18px;
}

.role-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--role-toolbar-border);
  border-radius: 15px;
  background: var(--green-soft);
}

.role-toolbar strong,
.role-toolbar span {
  display: block;
}

.role-toolbar strong {
  margin-bottom: 3px;
  color: var(--green-text);
  font-family: Georgia, "Times New Roman", serif;
}

.role-toolbar span {
  color: var(--role-toolbar-text);
  font-size: 12px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 13px;
}

.progress-copy strong {
  color: var(--green-text);
}

.progress-track {
  height: 6px;
  border-radius: 99px;
  background: var(--border-soft);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  transition: width 260ms ease;
}

/* Счётчик звёзд: намеренно маленький и тихий — одна строка под прогрессом.
   Никаких модальных окон: награда должна радовать, а не требовать действия. */
.star-meter {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 11px 4px 9px;
  border: 1px solid var(--star-meter-border);
  border-radius: 99px;
  background: var(--star-meter-bg);
  color: var(--star-meter-text);
  font-size: 13px;
  line-height: 1.4;
  transition: background 220ms ease, border-color 220ms ease;
}

.star-meter-glyph {
  color: var(--star-meter-glyph);
  font-size: 13px;
  transition: transform 220ms ease;
}

.star-meter strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--star-meter-strong);
}

.star-meter-total {
  color: var(--muted);
  font-size: 12px;
}

/* Всплывающая искра при получении звезды: чистая CSS-анимация, элемент живёт
   только на время проигрывания и не блокирует интерфейс. */
.star-meter-spark {
  position: absolute;
  left: 10px;
  top: 0;
  color: var(--star-meter-glyph);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
}

.star-meter.is-gaining {
  border-color: var(--star-meter-border-strong);
  background: var(--star-meter-bg-strong);
}

.star-meter.is-gaining .star-meter-glyph {
  animation: star-pop 420ms ease;
}

.star-meter.is-gaining .star-meter-spark {
  animation: star-float 720ms ease-out;
}

.star-meter.is-sending {
  border-color: var(--star-meter-border-strong);
}

.star-meter.is-sent .star-meter-glyph {
  animation: star-settle 520ms ease;
}

@keyframes star-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.5) rotate(-8deg); }
  100% { transform: scale(1); }
}

@keyframes star-float {
  0% { opacity: 0; transform: translateY(2px) scale(0.8); }
  30% { opacity: 1; transform: translateY(-4px) scale(1); }
  100% { opacity: 0; transform: translateY(-16px) scale(0.9); }
}

@keyframes star-settle {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.exercise-stage {
  position: relative;
  padding: clamp(28px, 4vw, 52px);
  border: 1px solid var(--border-soft);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.exercise-stage.is-block-start {
  background: var(--block-start-bg);
  border-color: var(--block-start-border);
}

.exercise-stage.is-block-start #answerInput:not(:focus),
.exercise-stage.is-block-start #questionInput:not(:focus) {
  border-color: var(--block-start-border);
}

.exercise-stage::after {
  content: "";
  position: absolute;
  top: -90px;
  right: -75px;
  width: 210px;
  height: 210px;
  border: 38px solid rgba(34, 92, 70, 0.05);
  border-radius: 50%;
  pointer-events: none;
}

.exercise-meta {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 42px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.instruction {
  position: relative;
  z-index: 1;
}

.exercise-stage h2 {
  position: relative;
  z-index: 1;
  min-height: 2.4em;
  margin: 0 0 42px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3vw, 46px);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.025em;
}

#answerForm label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

#answerForm .question-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

#answerForm .question-label span {
  color: var(--question-hint);
  font-size: 11px;
  font-weight: 500;
}

#answerInput,
#questionInput {
  width: 100%;
  padding: 17px 18px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--ink);
  background: var(--input-bg);
  font-size: 18px;
  line-height: 1.5;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#answerInput {
  min-height: 106px;
}

#questionInput {
  min-height: 76px;
  border-style: dashed;
  background: var(--input-bg-dashed);
  font-size: 15px;
}

#answerInput:focus,
#questionInput:focus {
  border-color: var(--green-text);
  border-style: solid;
  box-shadow: 0 0 0 4px var(--green-focus-ring-soft);
}

.answer-actions,
.navigation,
.map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.answer-actions {
  margin-top: 14px;
}

.save-status {
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.secondary-button {
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.primary-button {
  padding: 12px 18px;
  border: 0;
  color: white;
  background: var(--green);
}

.secondary-button {
  padding: 10px 2px;
  border: 0;
  color: var(--green-text);
  background: transparent;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.secondary-button:disabled {
  cursor: default;
  opacity: 0.3;
  transform: none;
}

.navigation {
  margin-top: 32px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.exercise-map-wrap {
  margin-top: 24px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft-2);
}

.map-heading {
  margin-bottom: 14px;
}

.map-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
}

.map-heading span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.answered {
  background: var(--green);
}

.exercise-map {
  display: grid;
  grid-template-columns: repeat(11, minmax(28px, 1fr));
  gap: 7px;
}

.exercise-chip {
  aspect-ratio: 1;
  min-width: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.exercise-chip.is-answered {
  border-color: var(--green-soft);
  color: var(--green-text);
  background: var(--green-soft);
}

.exercise-chip.is-current {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.empty-state {
  color: var(--muted);
}

.error-review {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--error-border);
  border-radius: 16px;
  background: var(--error-bg);
}

.error-review h2,
.error-review h3 {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.error-review p,
.error-review li {
  line-height: 1.55;
}

.dictionary-toggle,
.hotkeys-toggle {
  position: fixed;
  z-index: 20;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 12px 32px rgba(23, 34, 29, 0.24);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 180ms ease;
}

.dictionary-toggle {
  right: 24px;
  bottom: 24px;
  padding: 12px 18px;
  font-weight: 750;
}

.hotkeys-toggle {
  right: 24px;
  bottom: 80px;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
}

.dictionary-toggle:hover,
.hotkeys-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(23, 34, 29, 0.28);
}

.dictionary-toggle:active,
.hotkeys-toggle:active {
  transform: translateY(0);
  box-shadow: 0 8px 24px rgba(23, 34, 29, 0.2);
}

.dictionary-panel,
.hotkeys-panel {
  position: fixed;
  z-index: 21;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(23, 34, 29, 0.22);
}

.dictionary-panel {
  right: 24px;
  bottom: 82px;
  width: min(380px, calc(100vw - 32px));
  padding: 20px;
}

.hotkeys-panel {
  right: 24px;
  bottom: 138px;
  width: min(560px, calc(100vw - 32px));
  max-height: 75vh;
  overflow-y: auto;
  padding: 0;
}

.dictionary-panel[hidden],
.hotkeys-panel[hidden] {
  display: none;
}

.dictionary-heading,
.hotkeys-heading,
.dictionary-heading > div,
.hotkeys-heading > div {
  display: flex;
}

.dictionary-heading,
.hotkeys-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dictionary-heading {
  margin-bottom: 18px;
}

.hotkeys-heading {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.dictionary-heading > div,
.hotkeys-heading > div {
  flex-direction: column;
  gap: 4px;
}

.dictionary-heading span,
.hotkeys-heading span,
.dictionary-status {
  color: var(--muted);
  font-size: 12px;
}

.dictionary-heading strong,
.hotkeys-heading strong {
  display: block;
  margin-bottom: 3px;
  font-size: 16px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.dictionary-heading button,
.hotkeys-heading button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

#dictionaryClose,
#hotkeysClose {
  width: 32px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 26px;
  font-weight: 400;
  line-height: 0;
  cursor: pointer;
  transition: color 120ms, background 120ms;
}

#dictionaryClose:hover,
#hotkeysClose:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.dictionary-panel label {
  display: block;
  margin: 12px 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.dictionary-panel input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: var(--input-bg);
  font: inherit;
}

.dictionary-panel input:focus {
  border-color: var(--green-text);
  box-shadow: 0 0 0 4px var(--green-focus-ring-soft);
}

.dictionary-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  line-height: 1.4;
}

.dictionary-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--input-bg);
}

.dictionary-result[hidden] {
  display: none;
}

.dictionary-source {
  color: var(--muted);
  font-size: 12px;
}

.dictionary-translation {
  font-size: 17px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 84px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 48px));
  padding: 13px 17px;
  border-radius: 12px;
  color: white;
  background: var(--green);
  box-shadow: 0 12px 32px rgba(23, 34, 29, 0.2);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast[data-type="error"] {
  background: var(--toast-error-bg);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  /* В одну колонку заголовок остаётся первым блоком, а под ним — материалы и
     практика друг за другом. */
  .panel-heading {
    margin-bottom: 4px;
  }

  .tab-content {
    max-height: 520px;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 68px;
    padding: 0 16px;
  }

  .brand small,
  .source-links span {
    display: none;
  }

  .lesson-badge {
    display: none;
  }

  .topbar-button {
    padding: 9px 11px;
    font-size: 12px;
  }

  .workspace {
    padding: 24px 14px 40px;
  }

  .panel-heading h1 {
    font-size: 34px;
  }

  .exercise-stage {
    padding: 26px 20px;
    border-radius: 20px;
  }

  .exercise-meta {
    margin-bottom: 34px;
  }

  .exercise-stage h2 {
    margin-bottom: 32px;
    font-size: 32px;
  }

  .answer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .role-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .role-toolbar button {
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .exercise-map {
    grid-template-columns: repeat(7, minmax(28px, 1fr));
  }

  .word-list {
    grid-template-columns: 1fr;
  }

  .dictionary-toggle {
    right: 16px;
    bottom: 16px;
  }

  .hotkeys-toggle {
    right: 16px;
    bottom: 70px;
  }

  .dictionary-panel {
    right: 16px;
    bottom: 70px;
  }

  .hotkeys-panel {
    right: 16px;
    bottom: 126px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  /* Счётчик звёзд остаётся читаемым, но без движения. */
  .star-meter.is-gaining .star-meter-glyph,
  .star-meter.is-gaining .star-meter-spark,
  .star-meter.is-sent .star-meter-glyph {
    animation: none !important;
  }

  .star-meter.is-gaining .star-meter-spark {
    opacity: 1;
    transform: translateY(-6px);
  }
}
