:root {
  /* 🇵🇱 белый · красный · чёрный/серый */
  --pl-red: #c8102e;
  --pl-red-dark: #9b0c24;
  --pl-red-soft: #fde8ec;
  --pl-white: #ffffff;
  --pl-black: #1a1a1a;
  --pl-gray: #6b7280;
  --pl-gray-light: #f3f4f6;
  --pl-gray-mid: #e5e7eb;

  --bg: var(--pl-gray-light);
  --bg2: var(--pl-gray-mid);
  --surface: var(--pl-white);
  --card: var(--pl-white);
  --surface-hover: #f9fafb;
  --text: var(--pl-black);
  --muted: var(--pl-gray);
  --accent: var(--pl-red);
  --accent-soft: var(--pl-red-soft);
  --accent2: var(--pl-red-dark);
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --bad: var(--pl-red);
  --bad-bg: var(--pl-red-soft);
  --warn: #b45309;
  --border: var(--pl-gray-mid);
  --border-strong: #d1d5db;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --container-max: 1360px;
  --container-wide: 1360px;
  --content-max: 720px;
  --container-pad: clamp(16px, 2.5vw, 28px);
  --page-gutter: max(var(--container-pad), calc((100vw - var(--container-max)) / 2));
  --header-h: 64px;
  --site-footer-h: 52px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--site-footer-h);
}

body.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── dev notice (dismissible popup, bottom-right) ── */

.dev-banner {
  position: fixed;
  right: 16px;
  bottom: calc(var(--site-footer-h) + 16px);
  z-index: 110;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(320px, calc(100vw - 32px));
  padding: 12px 36px 12px 14px;
  background: linear-gradient(180deg, #fff9e8 0%, #fff4d6 100%);
  border: 1px solid #ecd27a;
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(26, 26, 26, 0.16);
  color: #5c4810;
  font-size: 13px;
  line-height: 1.45;
  animation: dev-banner-in 0.2s ease-out;
}

@keyframes dev-banner-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dev-banner.hidden {
  display: none;
}

.dev-banner-text {
  margin: 0;
}

.dev-banner-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #7a6220;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.dev-banner-close:hover {
  background: rgba(92, 72, 16, 0.08);
}

.landing-page .dev-banner {
  bottom: 16px;
}

@media (max-width: 880px) {
  body.app-shell.has-tabbar .dev-banner {
    bottom: calc(var(--tabbar-h) + 16px);
  }
}

body.game-active .dev-banner,
body.exercise-active .dev-banner {
  display: none !important;
}

/* ── header ── */

.app-header {
  padding-inline: 0;
  min-height: var(--header-h);
  background: var(--pl-white);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  justify-content: stretch;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
  width: 100%;
  max-width: var(--container-wide);
  margin: 0 auto;
  padding-inline: var(--container-pad);
}

.header-left {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  min-width: 0;
  justify-self: start;
}

.header-right {
  justify-self: end;
}

.brand {
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.main-nav {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-link {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border-color: transparent;
}
.nav-link.active {
  color: var(--text);
  background: var(--pl-white);
  border-color: var(--border);
}

.stats { display: flex; gap: 8px; flex-shrink: 0; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-login.hidden,
.header-user.hidden {
  display: none;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.stat.bump { opacity: 0.85; }
.score { color: var(--accent); }

/* ── layout ── */

.screen {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 0;
  padding-inline: 0;
}
.screen:not(.screen-section):not(.game-screen):not(.exercise-screen) {
  min-height: calc(100vh - var(--header-h));
  padding-inline: var(--page-gutter);
}
.screen:not(.screen-hub):not(.screen-section):not(.game-screen):not(.exercise-screen) {
  padding-top: var(--container-pad);
  padding-bottom: 48px;
}
.screen-hub {
  background: var(--bg);
}

.screen-section.screen-hub,
.screen-section.screen-full {
  padding: 0 !important;
}

.layout-shell,
.page-container,
.hub-shell,
.lesson-shell,
.section-page {
  width: 100%;
  max-width: none;
  margin-inline: auto;
}

.page-container--narrow {
  max-width: var(--content-max);
}
.screen-full.lesson-screen,
#screen-wordlist.screen-full {
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ── section pages (grammar, competitions) ── */

.section-page {
  padding-top: 8px;
}
.section-hero {
  margin-bottom: 32px;
}
.section-hero h1,
.training-hero h1 {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.section-lead {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  max-width: 560px;
}
.placeholder-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
}
.placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.placeholder-panel h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.placeholder-panel p {
  color: var(--muted);
  font-size: 15px;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── competitions leaderboard ── */

.leaderboard-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.leaderboard-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-count {
  font-size: 14px;
  color: var(--muted);
}
.leaderboard-table-wrap {
  overflow-x: auto;
}
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.leaderboard-table th,
.leaderboard-table td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 92%, var(--text) 8%);
}
.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}
.leaderboard-rank {
  width: 56px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.leaderboard-name {
  font-weight: 600;
}
.leaderboard-you {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
}
.leaderboard-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.leaderboard-stat {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.leaderboard-row--me {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.leaderboard-row--top1 .leaderboard-score {
  color: #d4a017;
}
.leaderboard-row--top2 .leaderboard-score {
  color: #8a9199;
}
.leaderboard-row--top3 .leaderboard-score {
  color: #b87333;
}
.leaderboard-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 20px !important;
}

/* ── training hub (main page) ── */

.hub-shell {
  width: 100%;
  padding: 0;
}

.hub-header {
  margin-bottom: clamp(24px, 3vw, 36px);
}

.hub-title {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.hub-lead {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  max-width: 560px;
}

.hub-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(300px, 28vw);
  gap: clamp(20px, 2.5vw, 32px);
  align-items: start;
}

.hub-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 3vw, 40px);
}

.hub-section {
  margin: 0;
}

.hub-section-head {
  margin-bottom: 16px;
}

.hub-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 4px;
}

.hub-section-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
  opacity: 0.9;
}

.nav-link--accent { color: var(--accent); font-weight: 600; }
.nav-link--accent.active { background: var(--accent-soft); }
.hub-section--tools { margin-bottom: 4px; }

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

.hub-grid--solo {
  grid-template-columns: minmax(0, 1fr);
  max-width: min(100%, 420px);
}

.hub-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

/* legacy aliases (words sub-hub, etc.) */
.training-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}
.training-main { min-width: 0; }
.training-hero { margin-bottom: 24px; }
.training-aside {
  width: 300px;
  max-width: 100%;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.game-group-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 28px 0 14px;
}
.game-group-title:first-of-type { margin-top: 0; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.aside-card {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.aside-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 14px;
}
.training-aside .progress-box,
.hub-aside .progress-box {
  margin-top: 0;
  border: none;
  box-shadow: none;
  padding: 0;
  background: transparent;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  min-height: 188px;
}
.game-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.game-card--tool {
  background: var(--bg);
}
.game-card--accent,
.game-card-accent {
  border-color: var(--accent);
  border-left-width: 3px;
  background: var(--surface);
}
.game-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.game-card-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.game-card-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.game-card-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.game-card-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  flex: 1;
}
.game-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.game-card-pts {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.game-card-go {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.training-aside .tier-current,
.hub-aside .tier-current {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin: -6px 0 14px;
  line-height: 1.4;
}
.training-aside .tier-slider,
.hub-aside .tier-slider {
  width: 100%;
  display: block;
  margin-top: 4px;
}
.training-aside .tier-presets,
.hub-aside .tier-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.training-aside .tier-range-ends,
.hub-aside .tier-range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.training-aside .tier-note,
.hub-aside .tier-note {
  text-align: left;
  margin-bottom: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.page-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 28px;
}
.page-subtitle-tight {
  margin-top: -12px;
  margin-bottom: 20px;
}

/* ── menu cards ── */

.menu-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.card-emoji {
  font-size: 28px;
  margin-bottom: 12px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.card h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.card-pts {
  margin-top: 14px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.progress-box {
  margin-top: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}
.progress-box b { color: var(--text); }
.progress-box .weak-word { color: var(--bad); font-weight: 600; }

/* ── exercise fullscreen ── */

.exercise-screen {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  margin: 0;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exercise-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: var(--container-wide);
  height: 100%;
  margin: 0 auto;
  padding: 12px var(--container-pad) 16px;
  min-height: 0;
  box-sizing: border-box;
}

.exercise-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.exercise-topbar .counter {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.exercise-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--exercise-nav-w, 280px);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.exercise-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--border);
  padding-inline: clamp(16px, 2.5vw, 24px);
}

.exercise-stage-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.exercise-sentence-block {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-block: clamp(20px, 4vh, 40px);
  min-height: 220px;
  overflow-y: auto;
}

.exercise-sentence-block.is-loading .lesson-label,
.exercise-sentence-block.is-loading .ru-sentence,
.exercise-sentence-block.is-loading .slots {
  visibility: hidden;
}

.exercise-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
}

.exercise-loading.hidden {
  display: none;
}

.exercise-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: exercise-spin 0.75s linear infinite;
}

.exercise-loading-text {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

@keyframes exercise-spin {
  to { transform: rotate(360deg); }
}

.exercise-sentence-block .lesson-label {
  margin-bottom: 0;
}

.exercise-sentence-block .ru-sentence {
  max-width: 36ch;
}

.exercise-sentence-block .slots {
  margin-bottom: 0;
  max-width: 100%;
}

.exercise-action-bar {
  flex-shrink: 0;
  min-height: 88px;
  padding: 14px 0 18px;
  margin-inline: calc(-1 * clamp(16px, 2.5vw, 24px));
  padding-inline: clamp(16px, 2.5vw, 24px);
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.exercise-action-bar .feedback {
  margin-bottom: 0;
  min-height: 24px;
}

.exercise-action-bar .lesson-actions {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exercise-progress-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: clamp(16px, 2.5vh, 20px) clamp(18px, 2.5vw, 26px);
  gap: 0;
}

.exercise-settings {
  flex-shrink: 0;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.exercise-progress-panel:has(.sent-progress.hidden) .exercise-settings {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.exercise-settings-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.exercise-settings-desc {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.exercise-feedback-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exercise-feedback-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.exercise-feedback-option:hover {
  border-color: #cbd5e1;
  background: #fafafa;
}

.exercise-feedback-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(200, 16, 46, 0.08);
}

.exercise-feedback-option input {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.exercise-feedback-option-body {
  min-width: 0;
}

.exercise-feedback-option-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.exercise-feedback-option-desc {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.exercise-feedback-option:has(input:checked) .exercise-feedback-option-title {
  color: var(--accent);
}

.exercise-feedback-option--toggle input {
  margin-top: 3px;
}

.exercise-feedback-option--toggle + .exercise-feedback-option--toggle {
  margin-top: 8px;
}

/* answer popup */

.exercise-answer-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(960px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
  margin: 0;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: fit-content;
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--surface);
  box-shadow:
    0 24px 64px rgba(26, 26, 26, 0.22),
    0 0 0 1px rgba(26, 26, 26, 0.06);
  animation: exercise-dialog-in 0.18s ease-out;
}

@keyframes exercise-dialog-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 10px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.exercise-answer-dialog:not([open]) {
  display: none;
}

.exercise-answer-dialog::backdrop {
  background: rgba(26, 26, 26, 0.52);
  backdrop-filter: blur(4px);
}

.exercise-answer-dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 40px);
}

.exercise-answer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
  flex-shrink: 0;
}

.exercise-answer-intro {
  min-width: 0;
}

.exercise-answer-context {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
}

.exercise-answer-context.hidden {
  display: none;
}

.exercise-answer-context-ru {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.exercise-answer-context-pl {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.exercise-answer-context-pl .ctx-gap {
  display: inline;
}

.exercise-answer-context-pl .ctx-gap--active {
  padding: 1px 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.exercise-answer-context-pl .ctx-gap--blank {
  opacity: 0.42;
  font-weight: 500;
}

.exercise-answer-context-pl .ctx-gap-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 2px;
}

.exercise-answer-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.exercise-answer-word {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.exercise-answer-hint {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}

.exercise-answer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.exercise-answer-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--pl-white);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.exercise-answer-close:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.exercise-answer-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
}

.exercise-answer-meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.exercise-hard-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.exercise-hard-toggle input {
  accent-color: var(--accent);
}

.picker-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.picker-step {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
}

.picker-step.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.picker-step.done {
  border-color: rgba(22, 163, 74, 0.35);
  color: #15803d;
  background: rgba(22, 163, 74, 0.08);
}

.picker-trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  font-size: 12px;
}

.picker-trail-chip {
  padding: 4px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}

.picker-trail-sep {
  color: var(--muted);
}

.picker-footer {
  display: flex;
  justify-content: flex-start;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.picker-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.picker-panel--compact {
  gap: 10px;
}

.picker-empty {
  margin: 0;
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

/* compact case table */
.picker-case-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.picker-case-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
}

.picker-case-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.picker-case-q {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.picker-case-rows {
  display: flex;
  flex-direction: column;
}

.picker-case-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 5px 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.picker-case-row:first-child {
  border-top: none;
}

.picker-case-row-label {
  flex: 0 0 auto;
  min-width: 68px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--muted);
}

.picker-case-row-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1 1 0;
  justify-content: flex-start;
}

/* paradigm table: singular | plural columns per case */
.picker-paradigm-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker-paradigm-case {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.picker-paradigm-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.picker-paradigm-columns--single {
  grid-template-columns: 1fr;
}

.picker-paradigm-col {
  min-width: 0;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker-paradigm-col + .picker-paradigm-col {
  border-left: 1px solid var(--border);
}

.picker-paradigm-col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.picker-paradigm-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker-paradigm-subgroup {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.picker-paradigm-gender {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.picker-paradigm-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.picker-paradigm-chips .picker-form-chip {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
}

.picker-paradigm-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 2px 0;
}

.picker-comparative-section .picker-paradigm-table {
  padding: 0 0 8px;
}

.picker-comparative-section .picker-paradigm-case {
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
}

.picker-comparative-section .picker-paradigm-case:first-child {
  border-top: none;
}

.picker-form-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s, transform 0.08s;
}

.picker-form-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.picker-form-chip:active {
  transform: scale(0.98);
}

.picker-form-chip.right {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

.picker-form-chip.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
}

.picker-form-chip--labeled {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 6px 12px;
}

.picker-form-chip--inline {
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 4px 10px;
}

.picker-form-chip-sep {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
  user-select: none;
}

.picker-form-chip-pl {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

.picker-form-chip--inline .picker-form-chip-pl {
  font-size: 14px;
}

.picker-form-chip-ru {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--muted);
  text-align: center;
  max-width: 140px;
  white-space: normal;
}

.picker-form-chip--inline .picker-form-chip-ru {
  font-weight: 600;
  text-align: left;
  max-width: none;
  white-space: nowrap;
}

.picker-form-chip--labeled.wrong .picker-form-chip-pl,
.picker-form-chip--labeled.wrong .picker-form-chip-ru {
  color: var(--bad);
}

.picker-form-chip--labeled.right .picker-form-chip-pl,
.picker-form-chip--labeled.right .picker-form-chip-ru {
  color: var(--ok);
}

/* ── lemma gate popover («выбери слово» у слота) ── */

.lemma-popover {
  position: absolute;
  z-index: 300;
  max-width: 340px;
  padding: 10px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.lemma-popover-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lemma-popover-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.picker-chip-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 12px;
  background: #fff;
}

.picker-chip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.picker-chip-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.picker-chip-sub {
  font-size: 11px;
  color: var(--muted);
}

.picker-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.picker-group-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker-group-head-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.picker-group-head-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.picker-subgroup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 4px;
  border-left: 2px solid var(--border);
  margin-left: 2px;
}

.picker-subgroup-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.picker-subgroup-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.picker-subgroup-sub {
  font-size: 11px;
  color: var(--muted);
}

.picker-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  align-items: stretch;
}

.picker-panel--lemma {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px;
}

.picker-panel--group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 12px;
}

.picker-lemma-card,
.picker-group-card,
.picker-form-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  min-width: max-content;
  min-height: 72px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  box-sizing: border-box;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s, transform 0.1s;
}

.picker-lemma-card:hover,
.picker-group-card:hover,
.picker-form-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 2px 10px rgba(200, 16, 46, 0.08);
}

.picker-lemma-form,
.picker-form-word {
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

.picker-lemma-ru {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.35;
}

.picker-lemma-pos,
.picker-group-count {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.picker-group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.picker-group-sub {
  font-size: 12px;
  color: var(--muted);
}

.picker-form-desc {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
}

.picker-lemma-card.wrong,
.picker-group-card.wrong,
.picker-form-card.wrong,
.exercise-answer-dialog .opt-tile.wrong {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

.picker-lemma-card.right,
.picker-group-card.right,
.picker-form-card.right,
.exercise-answer-dialog .opt-tile.right {
  border-color: #16a34a;
  background: rgba(22, 163, 74, 0.1);
}

.picker-lemma-card:disabled,
.picker-group-card:disabled,
.picker-form-card:disabled {
  opacity: 0.72;
  cursor: default;
}

.exercise-answer-dialog .exercise-options-grid,
.exercise-answer-dialog .picker-panel {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 18px;
  width: 100%;
}

.exercise-answer-dialog .opt-group-block {
  margin: 0;
  width: 100%;
}

.exercise-answer-dialog .opt-group {
  margin: 0 0 10px;
  padding: 0;
  border: none;
  width: auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.exercise-answer-dialog .opt-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  width: 100%;
}

.exercise-answer-dialog .opt-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--pl-white);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  box-sizing: border-box;
  transition: border-color 0.12s, background 0.12s, transform 0.1s, box-shadow 0.12s;
}

.exercise-answer-dialog .opt-tile:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.08);
}

.exercise-answer-dialog .opt-tile:active {
  transform: scale(0.98);
}

.exercise-answer-dialog .opt-form {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.exercise-answer-dialog .opt-label {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
}

.exercise-answer-dialog .opt-tile.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.exercise-answer-dialog .opt-tile.wrong .opt-form {
  color: var(--bad);
}

.exercise-answer-dialog .opt-tile.right {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.exercise-answer-dialog .opt-tile.right .opt-form {
  color: var(--ok);
}

@media (max-width: 640px) {
  .exercise-answer-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 14px;
  }

  .exercise-answer-header {
    padding: 16px 16px 14px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .exercise-answer-toolbar {
    width: 100%;
    justify-content: flex-end;
  }

  .exercise-answer-body {
    padding: 14px 16px 18px;
  }

  .exercise-answer-dialog .opt-group-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 6px;
  }

  .exercise-answer-dialog .opt-tile {
    min-height: 58px;
    padding: 8px 10px;
  }

  .exercise-answer-dialog .opt-form {
    font-size: 15px;
  }

  .picker-form-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .picker-form-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .picker-lemma-form,
  .picker-form-word {
    font-size: 20px;
  }

  .exercise-hard-toggle span {
    font-size: 11px;
  }

  .picker-case-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .picker-case-row-chips {
    justify-content: flex-start;
  }

  .picker-paradigm-columns {
    grid-template-columns: 1fr;
  }

  .picker-paradigm-col + .picker-paradigm-col {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

/* ── lesson shell (unified lesson layout) ── */

.lesson-screen {
  padding-top: 0;
}

.lesson-shell {
  width: 100%;
}
.lesson-shell-wide {
  width: 100%;
}

.lesson-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lesson-header .counter {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.lesson-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px 28px;
}

.lesson-label {
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}
.lesson-label-center { margin-bottom: 16px; }
.step-badge-wrap { text-align: center; margin-bottom: 12px; }

.lesson-prompt {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.lesson-workspace {
  margin-bottom: 8px;
}

.lesson-footer {
  margin-top: 20px;
  padding-top: 8px;
}

.sent-progress {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 12px;
}

.sent-progress.hidden {
  display: none;
}

.sent-progress-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.sent-progress-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sent-progress-reset {
  font-size: 12px;
  padding: 4px 10px;
  min-height: 0;
  flex-shrink: 0;
}

.sent-progress-label {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.sent-progress-meta {
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.sent-progress-meta.hidden {
  display: none;
}

.sent-progress-track {
  height: 6px;
  border-radius: 999px;
  background: #eceef2;
  overflow: hidden;
  flex-shrink: 0;
}

.sent-progress-track-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ok), #34d399);
  transition: width 0.25s ease;
}

.sent-progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
  flex-shrink: 0;
}

.sent-progress-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sent-progress-legend .sent-progress-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.sent-progress-legend .sent-progress-dot.ok {
  background: var(--ok);
}

.sent-progress-legend .sent-progress-dot.err {
  background: var(--bad);
}

.sent-progress-legend .sent-progress-dot.blocked {
  background: #1a1a1a;
}

.sent-progress-dots {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  flex: 1;
  min-height: 48px;
  max-height: none;
  overflow-y: auto;
  overflow-x: visible;
  padding: 8px 6px;
}

.sent-progress-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: #d8dce3;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
}

.sent-progress-dot::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.sent-progress-dot:hover {
  transform: scale(1.2);
}

.sent-progress-dot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sent-progress-dot.ok {
  background: var(--ok);
}

.sent-progress-dot.err {
  background: var(--bad);
}

.sent-progress-dot.blocked {
  background: #1a1a1a;
}

.sent-progress-dot.current {
  box-shadow: 0 0 0 2px var(--accent);
  background: #fff;
}

/* ── topbar (legacy + lesson) ── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.lesson-header.topbar {
  margin-bottom: 16px;
  border-bottom: none;
  padding-bottom: 0;
}
.counter { color: var(--muted); font-size: 13px; font-weight: 500; }

.ru-sentence {
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  line-height: 1.45;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── slots ── */

.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
  font-size: 20px;
  align-items: flex-end;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.slot {
  min-width: 88px;
  max-width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  border: 2px dashed #cbd5e1;
  background: var(--bg);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.2s, color 0.15s;
  font-size: 18px;
  font-family: inherit;
  white-space: nowrap;
}
.slot:hover:not(.done) {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.slot.active {
  border-color: var(--accent);
  border-style: solid;
  color: var(--text);
  background: var(--accent-soft);
  outline: 2px solid rgba(200, 16, 46, 0.15);
  outline-offset: 0;
}
.slot.done {
  border: 2px solid var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
  cursor: default;
  font-weight: 700;
}
.slot.picked {
  border: 2px solid var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.slot.picked:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.slot.wrong {
  border: 2px solid var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
  cursor: default;
  font-weight: 700;
}
.slot--new-tier {
  border-color: #6366f1;
  background: #eef2ff;
  color: #312e81;
}
.slot--new-tier:hover:not(.done) {
  border-color: #4338ca;
  background: #e0e7ff;
}
.slot-tier-label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4338ca;
  line-height: 1.1;
}
.sent-new-tier-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
}
.sent-new-tier-banner.hidden {
  display: none;
}
.tier-word-chip-label {
  font-size: 12px;
  font-weight: 700;
  color: #4338ca;
}
.tier-word-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #c7d2fe;
  font-size: 13px;
  color: #1e1b4b;
}
.tier-word-chip em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
}
.slot.fixed-word {
  border: none;
  background: none;
  color: var(--text);
  cursor: default;
  padding: 12px 4px;
  min-width: 0;
  font-weight: 500;
}
.slot .slot-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
  white-space: nowrap;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.shake { animation: shake 0.25s ease-in-out 2; }

/* ── options panel ── */

.options-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 20px;
  margin-bottom: 16px;
}
.options-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  font-weight: 500;
}
.options-title b { color: var(--accent); font-weight: 700; }
.options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.opt-group {
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 10px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.opt-group:first-child { margin-top: 0; }

.opt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.opt:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.opt .opt-label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.opt-phrase {
  width: 100%;
  text-align: left;
  font-size: 16px;
  padding: 12px 16px;
}

/* ── feedback & buttons ── */

.feedback {
  text-align: center;
  min-height: 28px;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 16px;
}
.feedback.good { color: var(--ok); }
.feedback.bad { color: var(--bad); }

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.btn.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  font-weight: 600;
  display: block;
  margin: 0 auto;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
}
.btn.primary:hover {
  background: var(--pl-red-dark);
  border-color: var(--pl-red-dark);
}
.btn.ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px;
}
.btn.ghost:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--border);
}

.btn.danger {
  background: transparent;
  border: 1px solid var(--pl-red, #c0392b);
  color: var(--pl-red, #c0392b);
  font-weight: 500;
  box-shadow: none;
}
.btn.danger:hover {
  background: rgba(192, 57, 43, 0.08);
  filter: none;
}

.lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn.toggle {
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.btn.toggle.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

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

/* ── pairs ── */

.pair-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 14px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.pair-mode-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  flex: 0 0 auto;
}

.pair-mode-toggle {
  flex: 1 1 240px;
}

.pair-mode-toggle .btn.toggle {
  font-size: 13px;
  padding: 8px 12px;
}

.pair-topbar { flex-wrap: wrap; gap: 10px; }
.pair-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
@media (max-width: 700px) {
  .pair-controls { align-items: stretch; }
}

.pair-task { text-align: center; margin-bottom: 8px; }
.pair-type-badge {
  margin: 0 0 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.pair-context-sentence {
  text-align: center;
  line-height: 1.65;
}

.pair-highlight {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.pair-context {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}
.pair-error {
  color: var(--bad);
  text-align: center;
  padding: 16px;
}
.pair-prompt { color: var(--muted); font-size: 14px; margin-top: 12px; }
.pair-case {
  display: inline-block;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  margin-bottom: 16px;
}
.pair-line {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: flex-end;
  font-size: 22px;
  font-weight: 600;
  flex-wrap: wrap;
}
.pair-word { padding: 10px 4px; }
.pair-word .slot-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}
.explain { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ── word quiz ── */

.words-topbar { flex-wrap: wrap; gap: 10px; }
.words-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}
.words-cats .btn.toggle { font-size: 12px; padding: 7px 12px; }

.words-prompt { text-align: center; margin-bottom: 24px; }
.words-pos {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
}
.words-ru {
  font-size: 32px;
  font-weight: 700;
  margin: 14px 0 8px;
  line-height: 1.25;
  letter-spacing: -0.03em;
}
.words-sub { color: var(--muted); font-size: 14px; }

.words-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto 20px;
}
.study-main .words-choices { max-width: none; }
.study-main.lesson-card .words-choices { max-width: 560px; }
.words-choice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.words-choice:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.words-choice:disabled { cursor: default; opacity: 0.9; }
.words-choice.right { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.words-choice.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

@media (max-width: 480px) {
  .words-choices { grid-template-columns: 1fr; }
  .words-ru { font-size: 26px; }
  .lesson-card { padding: 22px 18px 26px; }
}

/* words hub */
.words-hub,
.theme-grid,
.game-grid {
  width: 100%;
}

#screen-wordlist .page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

#screen-wordlist .wordlist-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.study-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(440px, 34vw);
  gap: clamp(16px, 2vw, 28px);
  align-items: start;
  flex: 1;
  width: 100%;
}

.study-top {
  margin-bottom: 12px;
  width: 100%;
}

.training-hero,
.section-hero {
  width: 100%;
}
.study-main {
  min-width: 0;
}
.study-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  position: sticky;
  top: calc(var(--header-h) + 16px);
}
.grammar-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 12px;
}
.grammar-panel { font-size: 13px; line-height: 1.45; }
.grammar-empty { color: var(--muted); font-size: 13px; }
.grammar-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
  font-weight: 500;
}
.grammar-section { margin-bottom: 14px; }

/* управление глагола: PL vs RU */
.grammar-differs .grammar-section-title { color: #b45309; }
.grammar-differs {
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
}
.gov-lang {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.gov-row-pl .gov-lang { color: #dc2626; }
.gov-row-ru .gov-lang { color: #2563eb; }
.grammar-section:last-child { margin-bottom: 0; }
.grammar-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.grammar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.grammar-table th,
.grammar-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.grammar-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
}
.grammar-table td:first-child {
  color: var(--muted);
  white-space: nowrap;
  width: 1%;
}
.grammar-table tr:last-child td { border-bottom: none; }

.match-full {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px 28px;
  width: 100%;
}
.match-full .match-grid {
  max-width: min(900px, 100%);
}

@media (max-width: 960px) {
  .study-layout {
    grid-template-columns: 1fr;
  }
  .study-side {
    position: static;
    max-height: none;
    order: 2;
  }
}

/* ── swipe selection ── */

.swipe-zone {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 360px;
  margin-bottom: 24px;
}
.swipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: min(420px, 92vw);
  text-align: center;
  cursor: grab;
  user-select: none;
  position: relative;
  touch-action: pan-y;
}
.swipe-card:active { cursor: grabbing; }
.swipe-word {
  font-size: 36px;
  font-weight: 700;
  margin: 14px 0 6px;
  letter-spacing: -0.03em;
}
.swipe-ru { font-size: 20px; color: var(--muted); margin-bottom: 18px; }
.swipe-example {
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: left;
}
.swipe-example .ex-pl { display: block; font-weight: 500; }
.swipe-example .ex-ru { display: block; color: var(--muted); margin-top: 4px; }

.swipe-stamp {
  position: absolute;
  top: 18px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 5px 14px;
  border-radius: 8px;
  border: 2.5px solid;
  opacity: 0;
  transform: rotate(-12deg);
  transition: opacity 0.12s;
  pointer-events: none;
}
.stamp-learn { left: 16px; color: var(--ok); border-color: var(--ok); }
.stamp-skip { right: 16px; color: var(--bad); border-color: var(--bad); transform: rotate(12deg); }
.swipe-card.show-learn .stamp-learn { opacity: 1; }
.swipe-card.show-skip .stamp-skip { opacity: 1; }

.swipe-actions { display: flex; gap: 16px; justify-content: center; }
.swipe-btn {
  font-size: 15px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
}
.swipe-btn.learn { color: var(--ok); border-color: var(--ok); }
.swipe-btn.learn:hover { background: var(--ok-bg); }
.swipe-btn.skip { color: var(--bad); border-color: var(--bad); }
.swipe-btn.skip:hover { background: var(--bad-bg); }
.swipe-empty { text-align: center; font-size: 18px; color: var(--muted); }
.swipe-empty .btn { margin-top: 18px; }

/* ── dictionary ── */

.dict-tabs { justify-content: center; margin-bottom: 20px; }
.dict-list { display: flex; flex-direction: column; gap: 8px; }
.dict-entry {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.dict-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.dict-grammar summary {
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  border-top: 1px solid var(--border);
  list-style: none;
}
.dict-grammar summary::-webkit-details-marker { display: none; }
.dict-grammar summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}
.dict-grammar[open] summary::before { transform: rotate(90deg); }
.dict-grammar .grammar-panel { padding: 0 18px 14px; }
.dict-word { flex: 1; min-width: 180px; font-size: 15px; }
.dict-word b { font-size: 16px; }
.dict-pos { color: var(--accent); font-size: 11px; font-weight: 600; margin: 0 6px; }
.dict-ru { color: var(--muted); }
.dict-meta { font-size: 12px; color: var(--muted); }
.dict-meta.due { color: var(--warn); font-weight: 600; }
.dict-del { color: var(--bad); border-color: transparent; box-shadow: none; }
.dict-add { color: var(--ok); border-color: transparent; box-shadow: none; }
.dict-actions { display: flex; gap: 8px; }
.dict-empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ── phrase bank ── */

.phrases-list-pane {
  background: #fff;
  border: 1px solid var(--card-border, var(--border));
  border-radius: 20px;
  box-shadow: var(--card-shadow, 0 2px 12px rgba(0, 0, 0, 0.06));
  padding: 12px;
  min-height: 200px;
}

.phrases-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.phrases-search {
  flex: 1 1 220px;
  min-width: 180px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.phrases-filter {
  flex: 0 1 auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  max-width: 200px;
}
.phrases-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phrases-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--card-border, #ececef);
  border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.phrases-card:hover {
  border-color: rgba(200, 16, 46, 0.22);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.phrases-card-body {
  flex: 1;
  min-width: 0;
}

.phrases-pl {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}

.phrases-ru {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.phrases-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.phrase-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  line-height: 1.2;
}

.phrase-tag.muted { background: #f3f4f6; color: var(--muted); }
.phrase-tag.curated { background: #e8f5e9; color: #2e7d32; }
.phrase-tag-tier { background: #eef2ff; color: #4338ca; }

.phrases-card .phrase-id {
  flex-shrink: 0;
  align-self: flex-start;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  color: var(--muted);
  background: #f8f9fb;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #eef0f3;
}

/* ── review ── */

.review-empty { text-align: center; font-size: 18px; padding: 40px 0; color: var(--muted); }
.review-empty .words-sub { margin-top: 10px; }
.review-empty .btn { margin-top: 18px; }
.review-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}
.review-empty-actions .btn { margin-top: 0; }

/* ── word catalog (flat table) ── */

.wordlist-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wordlist-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.wordlist-search {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
}

.wordlist-select {
  flex: 0 1 200px;
  min-width: 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}

.wordlist-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wordlist-stats {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.wordlist-table-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.wordlist-table-head,
.wordlist-table-row {
  display: grid;
  grid-template-columns: 56px minmax(100px, 1.1fr) minmax(120px, 1.4fr) 76px minmax(90px, 0.9fr) 32px;
  align-items: center;
  gap: 8px 10px;
  padding: 0 12px;
}

.wordlist-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  min-height: 40px;
  background: #f8f8fa;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.wordlist-th {
  border: none;
  background: transparent;
  padding: 10px 4px;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
}

.wordlist-th:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.wordlist-th.active {
  color: var(--accent);
}

.wordlist-th-flag {
  cursor: default;
}

.wordlist-table-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0 12px;
}

.wordlist-table-row {
  min-height: 44px;
  padding-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f0f2;
  background: #fff;
  cursor: pointer;
  transition: background 0.12s;
}

.wordlist-table-row:hover {
  background: #fafafa;
}

.wordlist-table-row.is-selected {
  background: var(--pill-red-bg, rgba(220, 38, 38, 0.06));
  box-shadow: inset 3px 0 0 var(--pl-red, #dc2626);
}

.wordlist-col-rank {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
  padding-right: 4px;
}

.wordlist-col-lemma b {
  font-size: 15px;
  font-weight: 700;
}

.wordlist-col-ru {
  font-size: 14px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wordlist-col-pos {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, var(--muted));
}

.wordlist-col-status {
  min-width: 0;
}

.wordlist-col-status .wordlist-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wordlist-table-row .wordlist-flag {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.wordlist-table-row .wordlist-flag:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.wordlist-table-row .wordlist-flag.flagged {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.wordlist-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.wordlist-badge.status-new {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.wordlist-badge.status-skipped {
  background: rgba(239, 68, 68, 0.12);
  color: var(--bad);
}

.wordlist-badge.status-due {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
}

.wordlist-badge.status-learn {
  background: rgba(34, 197, 94, 0.12);
  color: var(--ok);
}

.wordlist-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .wordlist-table-head {
    display: none;
  }

  .wordlist-table-row {
    grid-template-columns: 44px minmax(0, 1fr) 32px;
    grid-template-areas:
      "rank lemma flag"
      "rank ru flag"
      "rank pos status";
    gap: 2px 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .wordlist-col-rank { grid-area: rank; align-self: start; padding-top: 2px; }
  .wordlist-col-lemma { grid-area: lemma; }
  .wordlist-col-ru { grid-area: ru; white-space: normal; }
  .wordlist-col-pos { grid-area: pos; font-size: 11px; }
  .wordlist-col-status { grid-area: status; }
  .wordlist-table-row .wordlist-flag { grid-area: flag; align-self: start; }
}

.review-example {
  max-width: 520px;
  margin: 0 auto 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.55;
}
.review-example .ex-pl { font-weight: 500; }
.review-example .ex-ru { color: var(--muted); margin-bottom: 6px; }

.match-sub { text-align: center; margin-bottom: 20px; }
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto 24px;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, opacity 0.2s;
}
.match-item:hover:not(.done) { border-color: var(--accent); background: var(--accent-soft); }
.match-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: 2px solid rgba(200, 16, 46, 0.12);
  outline-offset: 0;
}
.match-item.done {
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-bg);
  opacity: 0.5;
  cursor: default;
}
.match-item.wrong { border-color: var(--bad); background: var(--bad-bg); }

/* flashcards */
.flash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  width: min(460px, 92vw);
  margin: 0 auto 22px;
  text-align: center;
  cursor: pointer;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
.flash-front { font-size: 38px; font-weight: 700; letter-spacing: -0.03em; }
.flash-ru { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.flash-back { font-size: 14px; line-height: 1.55; }
.flash-back .ex-pl { margin-top: 8px; font-weight: 500; }
.flash-back .ex-ru { color: var(--muted); }
.flash-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 18px;
}

/* ── tier slider ── */

.tier-panel {
  margin: 0 auto 28px;
  max-width: 520px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pl-red);
  border-radius: var(--radius);
}
.tier-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.tier-title { font-weight: 700; font-size: 14px; }
.tier-current { font-size: 13px; color: var(--accent); font-weight: 600; text-align: right; }
.tier-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}
.tier-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.tier-preset {
  flex: 1 1 auto;
  min-width: 44px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.tier-preset:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tier-preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tier-range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.tier-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.level-checks {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.topbar .level-checks { margin-left: 8px; }
.level-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}
.level-check input { margin: 0; cursor: pointer; }
.level-check:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tier-badge {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  background: var(--bg);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.topbar .tier-badge {
  margin-left: 0;
}
.topbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.pair-topbar .tier-badge { margin-left: 0; }

.btn-report {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn-report:hover {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.22);
}
.btn-report:focus-visible {
  outline: 2px solid rgba(200, 16, 46, 0.25);
  outline-offset: 2px;
}

.btn-report-icon {
  flex-shrink: 0;
}
.btn-report-compact {
  font-size: 11px;
  padding: 6px 10px;
}

.options-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.options-head .options-title {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.report-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  margin: auto;
  position: fixed;
  inset: 0;
  height: fit-content;
  max-height: calc(100vh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  animation: report-dialog-in 0.15s ease-out;
}
.report-dialog:not([open]) {
  display: none;
}
@keyframes report-dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.report-dialog::backdrop {
  background: rgba(26, 26, 26, 0.4);
}
.report-form {
  padding: 22px 22px 20px;
}
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.report-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  flex: 1;
}
.report-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.report-close:hover {
  background: var(--bg);
  color: var(--text);
}
.report-context {
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.report-context.hidden {
  display: none;
}
.report-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.report-message {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  min-height: 96px;
}
.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.report-actions .btn.primary {
  display: inline-flex;
  margin: 0;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
}

.report-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 16px 32px;
  text-align: center;
}

.report-loading.hidden {
  display: none;
}

.report-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: exercise-spin 0.75s linear infinite;
}

.report-loading-text {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.report-success {
  margin: 0;
  padding: 28px 16px 32px;
  text-align: center;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.report-success.hidden {
  display: none;
}

/* ── scenarios ── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.theme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.theme-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.theme-emoji { font-size: 36px; margin-bottom: 10px; }
.theme-emoji-inline { font-size: 22px; }
.theme-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.theme-pl { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.theme-cefr {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.theme-section-head {
  grid-column: 1 / -1;
  margin: 8px 0 0;
}
.theme-section-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.theme-progress-bar {
  height: 6px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.theme-progress-fill {
  height: 100%;
  background: var(--pl-red);
  border-radius: var(--radius-pill);
}
.theme-steps { font-size: 12px; color: var(--muted); font-weight: 500; }

.step-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.scenario-head {
  text-align: center;
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 600;
}

/* scenario progress stepper */
.lesson-stepper {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
}
.lesson-step {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--bg2);
  transition: background 0.2s, width 0.2s;
}
.lesson-step.done { background: var(--ok); }
.lesson-step.current {
  background: var(--accent);
  width: 24px;
}

/* ── responsive: nav + training ── */

@media (max-width: 900px) {
  .hub-body,
  .training-layout {
    grid-template-columns: 1fr;
  }
  .hub-aside,
  .training-aside {
    width: 100%;
    position: static;
    order: -1;
  }
  .hub-grid {
    grid-template-columns: 1fr;
  }
  .hub-grid--solo {
    max-width: none;
  }
}

@media (max-width: 720px) {
  .app-header {
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px;
  }
  .header-left {
    flex-wrap: wrap;
    width: 100%;
  }
  .main-nav {
    width: 100%;
    order: 3;
    padding-bottom: 2px;
  }
  .nav-link {
    font-size: 13px;
    padding: 7px 12px;
  }
  .stats {
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  .topbar-end {
    width: 100%;
    justify-content: space-between;
  }
  .btn-report span {
    display: none;
  }
  .btn-report {
    padding: 8px 10px;
  }
  .btn-report-compact span {
    display: inline;
  }
  .options-head {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-report-compact {
    align-self: flex-end;
  }
}

@media (max-width: 480px) {
  .hub-grid,
  .game-grid {
    grid-template-columns: 1fr;
  }
  .game-card {
    min-height: 0;
  }
  .brand {
    font-size: 15px;
  }
}

/* ── site footer / account feedback ── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: var(--pl-white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04);
}

.app-site-footer-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--site-footer-h);
  padding: 8px var(--page-gutter);
  max-width: var(--container-wide);
  margin-inline: auto;
}

.app-site-footer-copy {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
}

.account-feedback {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-feedback-guest {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.account-feedback-login {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.account-feedback-login:hover {
  text-decoration: underline;
}

.account-feedback-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.account-feedback-input {
  flex: 1;
  min-width: 0;
  resize: none;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  max-height: 72px;
}

.account-feedback-input:focus {
  outline: 2px solid rgba(200, 16, 46, 0.2);
  border-color: var(--accent);
}

.account-feedback-submit {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.account-feedback-submit:hover {
  background: var(--pl-red-dark);
  border-color: var(--pl-red-dark);
}

.account-feedback-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.account-feedback-status {
  font-size: 11px;
  color: var(--ok);
  margin: 0;
}

.account-feedback-status.is-error {
  color: var(--bad);
}

@media (max-width: 900px) {
  .exercise-layout {
    padding: 8px var(--container-pad) 10px;
  }

  .exercise-topbar {
    margin-bottom: 8px;
    padding-bottom: 8px;
    gap: 8px;
  }

  .exercise-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .exercise-progress-panel {
    order: -1;
    flex-shrink: 0;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .exercise-stage {
    border-right: none;
    border-bottom: none;
    min-height: 0;
  }

  .exercise-stage-inner {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sent-progress {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
  }

  .sent-progress-head {
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
  }

  .sent-progress-label {
    font-size: 14px;
  }

  .sent-progress-meta {
    font-size: 10px;
  }

  .sent-progress-track {
    flex: 1 1 100%;
    order: 3;
    height: 4px;
  }

  .sent-progress-dots,
  .sent-progress-legend {
    display: none !important;
  }

  .sent-progress-reset {
    font-size: 11px;
    padding: 3px 8px;
  }

  .exercise-sentence-block {
    flex: 1 1 auto;
    min-height: 0;
    justify-content: flex-start;
    padding-block: 12px 16px;
    gap: 14px;
  }

  .exercise-sentence-block .ru-sentence {
    max-width: none;
    font-size: clamp(18px, 4.8vw, 22px);
  }

  .exercise-action-bar {
    min-height: auto;
    padding-block: 10px 12px;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--surface);
  }
}

@media (max-width: 640px) {
  .exercise-topbar .counter {
    flex: 1 1 100%;
    order: 3;
    text-align: left;
    font-size: 11px;
    line-height: 1.35;
  }

  .exercise-topbar .topbar-end {
    margin-left: auto;
  }

  .exercise-layout {
    padding-inline: 12px;
  }

  .exercise-sentence-block .slots {
    font-size: 17px;
    gap: 8px;
  }

  .exercise-sentence-block .slot {
    min-width: 72px;
    padding: 10px 14px;
    font-size: 16px;
  }

  .exercise-sentence-block .slot.fixed-word {
    padding: 10px 3px;
  }
}

@media (max-width: 640px) {
  .app-site-footer-inner {
    flex-wrap: wrap;
    min-height: auto;
    padding-block: 10px;
  }

  .app-site-footer-copy {
    width: 100%;
  }

  .account-feedback-form {
    flex-direction: column;
    align-items: stretch;
  }

  .account-feedback-submit {
    width: 100%;
  }
}
