/* POLIQ shell v2: full-viewport app layout, Geist type, zinc neutrals + Polish red accent,
   light/dark themes. Loaded after style.css and design-ui.css and overrides them.
   Shape system: cards 14px, buttons/inputs 10px, chips and pills fully round. */

/* ── tokens ── */

:root {
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: var(--font);
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --pl-red: #c8102e;
  --pl-red-dark: #a00d25;
  --pl-red-soft: #fdecef;
  --pl-black: #18181b;
  --pl-gray: #71717a;
  --pl-gray-light: #f4f4f5;
  --pl-gray-mid: #e4e4e7;

  --page-bg: #fafafa;
  --bg: var(--page-bg);
  --bg2: #f4f4f5;
  --surface: #ffffff;
  --card: var(--surface);
  --surface-2: #f4f4f5;
  --surface-hover: #f4f4f5;
  --text: #18181b;
  --text-secondary: #52525b;
  --muted: #71717a;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --card-border: var(--border);
  --card-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
  --accent: var(--pl-red);
  --accent2: var(--pl-red-dark);
  --accent-soft: var(--pl-red-soft);
  --accent-contrast: #ffffff;
  --pill-red-bg: var(--pl-red-soft);
  --pill-red-border: #f5c2cb;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --bad: var(--pl-red);
  --bad-bg: var(--pl-red-soft);
  --warn: #b45309;
  --ring-track: #e4e4e7;

  --radius: 10px;
  --radius-sm: 8px;
  --radius-card: 14px;
  --radius-pill: 999px;

  --rail: 0px;
  --gutter: clamp(16px, 3vw, 40px);
  --container-max: none;
  --container-wide: none;
  --container-pad: var(--gutter);
  --page-gutter: var(--gutter);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pl-red: #e5484d;
    --pl-red-dark: #c93a40;
    --pl-red-soft: rgba(229, 72, 77, 0.14);
    --pl-black: #f4f4f5;
    --pl-white: #18181b;
    --pl-gray: #a1a1aa;
    --pl-gray-light: #1f1f23;
    --pl-gray-mid: #2e2e33;
    --page-bg: #0e0e10;
    --bg2: #1f1f23;
    --surface: #17171a;
    --surface-2: #1f1f23;
    --surface-hover: #222226;
    --text: #f4f4f5;
    --text-secondary: #c4c4cc;
    --muted: #a1a1aa;
    --text-muted: #a1a1aa;
    --border: #2a2a2f;
    --border-strong: #3a3a40;
    --card-shadow: none;
    --pill-red-border: rgba(229, 72, 77, 0.35);
    --ok: #4ade80;
    --ok-bg: rgba(74, 222, 128, 0.12);
    --warn: #fbbf24;
    --ring-track: #2e2e33;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --pl-red: #e5484d;
  --pl-red-dark: #c93a40;
  --pl-red-soft: rgba(229, 72, 77, 0.14);
  --pl-black: #f4f4f5;
  --pl-white: #18181b;
  --pl-gray: #a1a1aa;
  --pl-gray-light: #1f1f23;
  --pl-gray-mid: #2e2e33;
  --page-bg: #0e0e10;
  --bg2: #1f1f23;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --surface-hover: #222226;
  --text: #f4f4f5;
  --text-secondary: #c4c4cc;
  --muted: #a1a1aa;
  --text-muted: #a1a1aa;
  --border: #2a2a2f;
  --border-strong: #3a3a40;
  --card-shadow: none;
  --pill-red-border: rgba(229, 72, 77, 0.35);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --ring-track: #2e2e33;
  color-scheme: dark;
}

/* ── base ── */

html { background: var(--page-bg); }
body,
body.app-shell {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text);
  font-feature-settings: "ss01", "cv11";
}
h1, h2, h3, .pt-display { letter-spacing: -0.025em; }
.ph { font-size: 1.15em; line-height: 1; vertical-align: -0.15em; }

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

.btn,
button,
input,
select,
textarea { font-family: inherit; }

.btn:active,
.pt-game-card:active,
.game-card:active { transform: translateY(1px); }

/* ── app header: top bar on mobile, sidebar on desktop ── */

.app-header {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-family: var(--font);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--text);
}
.main-nav { background: var(--surface-2); border-radius: 12px; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
}
.nav-link .ph { font-size: 18px; }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.header-stat-pill {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 6px 12px;
}
.header-stat-pill--streak { background: var(--accent-soft); color: var(--accent); border-color: var(--pill-red-border); }
.header-stat-pill--score { background: var(--surface-2); color: var(--text); border-color: var(--border); }

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}
.header-icon-btn:hover { color: var(--text); background: var(--surface-hover); }
.header-icon-btn .ph { font-size: 18px; }
.header-icon-btn .sidebar-label { display: none; }

.header-avatar {
  background: var(--accent);
  border-color: transparent;
  font-family: var(--font);
  font-weight: 600;
}
.header-user-name { color: var(--text-secondary); }

/* группа «Тренировки», карточка пользователя — только в сайдбаре (≥1024px) */
.nav-group,
.header-user-avatar,
.header-user-sub,
.header-user-logout { display: none; }
.header-user { display: flex; align-items: center; gap: 6px; }
.header-user.hidden { display: none; }
.header-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

@media (min-width: 1024px) {
  :root { --rail: 232px; --header-h: 0px; }

  .app-header {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail);
    min-height: 0;
    height: 100dvh;
    z-index: 60;
    border-bottom: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .app-header-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 28px;
    height: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 22px 14px 18px;
  }
  .header-left { padding: 0 10px; justify-self: auto; }
  .brand { font-size: 20px; }

  .main-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 0;
    background: none;
    border-radius: 0;
    justify-self: auto;
    overflow: visible;
  }
  .nav-link {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    font-size: 14px;
    border: 0;
  }
  .nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    border: 0;
  }

  .header-right {
    margin-top: auto;
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 14px;
    justify-self: auto;
  }
  .header-right .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .header-right .header-stat-pill { justify-content: center; }
  .header-auth { order: -1; }
  .header-auth,
  .header-user { min-width: 0; }
  .header-user-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }
  .header-avatar { display: none !important; }

  .main-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .nav-link--compact-only { display: none; }
  .nav-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 10px 0 8px;
  }
  .nav-group-label {
    padding: 6px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .nav-sublink {
    padding: 8px 12px 8px 14px;
    font-size: 13.5px;
    text-decoration: none;
  }
  .nav-sublink .ph { font-size: 16px; }

  .header-user {
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .header-user-card {
    flex: 1 1 auto;
    padding: 4px;
    border-radius: var(--radius-sm);
  }
  .header-user-card:hover,
  .header-user-card.active { background: var(--surface-hover); }
  .header-user-card.active .header-user-sub { color: var(--accent); }
  .header-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
  }
  .header-user-text { display: flex; flex-direction: column; min-width: 0; }
  .header-user-card .header-user-name { color: var(--text); font-weight: 600; }
  .header-user-sub { display: block; font-size: 11.5px; color: var(--muted); }
  .header-user-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    cursor: pointer;
  }
  .header-user-logout:hover { background: var(--surface-hover); color: var(--bad, #dc2626); }
  .header-user-logout .ph { font-size: 18px; }
  .header-icon-btn {
    width: 100%;
    height: auto;
    justify-content: flex-start;
    padding: 9px 12px;
    font-size: 13px;
  }
  .header-icon-btn .sidebar-label { display: inline; }

  body.app-shell { padding-left: var(--rail); }
  .screen-section,
  .game-screen,
  .exercise-screen { left: var(--rail); }
  .app-site-footer { left: var(--rail); }

  .pt-tabbar { display: none !important; }
}

/* games and exercises take the whole viewport: no sidebar, no top bar */
body.game-active,
body.exercise-active { --header-h: 0px; padding-left: 0 !important; }
body.game-active .app-header,
body.exercise-active .app-header { display: none !important; }
body.game-active .game-screen,
body.game-active .screen-full,
body.exercise-active .exercise-screen { left: 0; top: 0; }

/* ── page width: use the full viewport ── */

.pt-page,
.game-shell,
.exercise-layout {
  max-width: none;
  padding-inline: var(--gutter);
}
.pt-page { padding-top: clamp(20px, 3vh, 36px); padding-bottom: 48px; }
.game-shell,
.exercise-layout { padding-top: 14px; padding-bottom: 16px; }

/* ── game top bars ── */

.game-topbar,
.exercise-topbar,
.screen > .topbar {
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.game-topbar-title { font-family: var(--font); font-weight: 600; font-size: 16px; }
.game-topbar-meta,
.counter { font-family: var(--font); font-weight: 500; color: var(--muted); }
.fs-toggle {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fs-toggle .ph { font-size: 18px; }
.game-topbar .fs-toggle { order: 99; }

/* ── buttons & chips ── */

.btn {
  border-radius: var(--radius);
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
.btn:hover { background: var(--surface-hover); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.toggle {
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn.toggle.active {
  background: var(--accent-soft);
  border-color: var(--pill-red-border);
  color: var(--accent);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
select,
textarea {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--radius);
}
input::placeholder,
textarea::placeholder { color: var(--muted); }

/* ── hub ── */

.pt-hero {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: none;
  padding: clamp(24px, 3vw, 40px);
  align-items: center;
}
.pt-hero::before,
.pt-hero::after { display: none; }
.pt-hero-kicker {
  color: var(--accent);
  opacity: 1;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.pt-hero-title {
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.pt-hero-lead { color: var(--text-secondary); opacity: 1; max-width: 52ch; }
.pt-hero-cta {
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius);
  box-shadow: none;
  font-weight: 600;
  padding: 13px 22px;
  transition: background-color 0.2s, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.pt-hero-cta:hover { background: var(--accent2); transform: translateY(-1px); }
.pt-goal-ring-inner { background: var(--surface); color: var(--text); }
.pt-goal-value { font-family: var(--font); font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-goal-label,
.pt-hero-goal-caption { color: var(--muted); opacity: 1; }

.pt-stats-grid { gap: 12px; }
.pt-stat-card,
.pt-game-card,
.pt-panel,
.pt-profile-card,
.pt-podium-panel,
.game-card,
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: none;
}
/* Список мест с 4-го — просто стопка карточек: своя рамка у списка складывалась с рамками строк */
.pt-leaderboard-list { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
.pt-leaderboard-row--me .pt-leaderboard-avatar { background: var(--surface); }
.pt-stat-head { color: var(--muted); font-weight: 500; }
.pt-stat-head .ph { color: var(--accent); }
.pt-stat-value { font-family: var(--font); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.pt-stat-value small { color: var(--muted); font-weight: 500; }

.pt-section-head { align-items: baseline; }
.pt-section-title { font-family: var(--font); font-weight: 600; font-size: 20px; letter-spacing: -0.02em; }
.pt-section-desc { color: var(--muted); }

.pt-card-grid,
.words-hub {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.pt-game-card,
.game-card {
  transition: border-color 0.2s, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.pt-game-card:hover,
.game-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: none;
}
.pt-game-card-icon,
.game-card-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  border: 0;
  font-size: 20px;
}
.pt-game-card-icon .ph,
.game-card-icon .ph { font-size: 22px; vertical-align: 0; }
.pt-game-card-tag,
.game-card-tag {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}
.pt-game-card-title,
.game-card-title { font-family: var(--font); font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.pt-game-card-desc,
.game-card-desc { color: var(--text-secondary); }
.pt-game-card-foot,
.game-card-foot { border-top-color: var(--border); }
.pt-game-card-meta,
.game-card-pts { color: var(--muted); }
.pt-game-card-go,
.game-card-go { color: var(--accent); font-weight: 600; }

/* words hub page */
#screen-words .page-container { padding-inline: var(--gutter); }
.section-hero h1 { font-family: var(--font); font-weight: 700; letter-spacing: -0.035em; }
.section-lead { color: var(--text-secondary); }
.words-cats { justify-content: flex-start; }
#screen-words .section-hero { text-align: left; }

/* ── game surfaces ── */

.game-card-panel,
.game-screen .swipe-card,
.game-screen .flash-card,
.game-sidebar,
.game-list-pane,
.exercise-stage,
.wordlist-table-wrap {
  background: var(--surface);
  border-color: var(--border);
  border-radius: var(--radius-card);
  box-shadow: none;
}
.game-screen .swipe-word,
.game-card-prompt { font-family: var(--font); letter-spacing: -0.035em; }
.game-screen .swipe-example { background: var(--surface-2); border-color: var(--border); }
.game-action-btn { border-radius: var(--radius); font-weight: 600; }
.game-action-btn--learn { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.game-action-btn--skip { background: var(--accent-soft); color: var(--accent); border-color: var(--pill-red-border); }

.grammar-heading,
.game-kicker { letter-spacing: 0.04em; color: var(--accent); }

/* ── mobile ── */

.pt-tabbar {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--border);
}
.pt-tabbar-btn { color: var(--muted); }
.pt-tabbar-btn.active { color: var(--accent); }

@media (max-width: 767px) {
  .pt-hero { flex-direction: column; align-items: flex-start; }
  .pt-hero-goal { flex-direction: row; gap: 14px; }
  .pt-goal-ring { width: 84px; height: 84px; }
  .pt-goal-ring-inner { width: 66px; height: 66px; }
  .pt-goal-value { font-size: 18px; }
  .pt-card-grid,
  .words-hub { grid-template-columns: 1fr; }
}

/* ── footer & dev notice ── */

.app-site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .pt-game-card:hover,
  .game-card:hover,
  .pt-hero-cta:hover { transform: none; }
}

/* ── fixes ── */

.main-nav { border: 0; box-shadow: none; }
.pt-game-card-go,
.game-card-go { white-space: nowrap; flex-shrink: 0; }
.pt-game-card-foot,
.game-card-foot { gap: 12px; }
.app-site-footer-inner { max-width: none; padding-inline: var(--gutter); }

/* heatmap: levels from the backend palette, rendered with theme tokens */
.pt-heatmap-cell[data-level="0"] { background: var(--surface-2); }
.pt-heatmap-cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); }
.pt-heatmap-cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.pt-heatmap-cell[data-level="3"] { background: color-mix(in srgb, var(--accent) 70%, var(--surface-2)); }
.pt-heatmap-cell[data-level="4"],
.pt-heatmap-cell[data-level="5"] { background: var(--accent); }

/* account & leaderboard */
.pt-profile-avatar,
.pt-podium-avatar { box-shadow: none; }
.pt-profile-avatar { background: var(--accent); font-family: var(--font); font-weight: 600; }
.pt-profile-name,
.pt-comp-title,
.pt-settings-title { font-family: var(--font); font-weight: 700; letter-spacing: -0.035em; }
.pt-podium-place .pt-podium-pedestal {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: 0;
  font-family: var(--font);
  font-weight: 700;
}
.pt-podium-place--first .pt-podium-pedestal { color: #c99a1f; }
.pt-podium-place--second .pt-podium-pedestal { color: var(--muted); }
.pt-podium-place--third .pt-podium-pedestal { color: #b87333; }
.pt-progress-bar { background: var(--surface-2); }
.pt-progress-fill { background: var(--accent); }


/* mobile: compact game bars, one-row scrollable category chips */
@media (max-width: 767px) {
  .game-topbar { flex-wrap: nowrap; gap: 8px; }
  .game-topbar > .btn.ghost[data-go] {
    font-size: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
  }
  .game-topbar > .btn.ghost[data-go]::before { content: "←"; font-size: 18px; }
  .game-topbar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .game-topbar-meta { white-space: nowrap; font-size: 11px; }
  .words-cats {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--gutter);
  }
  .words-cats::-webkit-scrollbar { display: none; }
  .words-cats .btn.toggle { flex-shrink: 0; scroll-snap-align: start; white-space: nowrap; }
}

@media (max-width: 960px) {
  #screen-dict .game-split--list,
  #screen-wordlist .game-split--list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .game-topbar .game-topbar-meta { width: auto; order: 0; margin-left: auto; text-align: right; }
  .select-cats { margin: 4px calc(var(--gutter) * -1) 14px; }
}
@media (max-width: 480px) {
  /* «где я» важнее служебного: заголовок экрана остаётся, уходят полноэкранная кнопка и значок уровня */
  .game-topbar .fs-toggle,
  .game-topbar .tier-badge { display: none !important; }
  .game-topbar-title { flex: 1 1 auto; }
}

/* review bar is a grid: give the fullscreen button and «Автозвук» their own columns */
#screen-review .game-topbar {
  grid-template-columns: auto 1fr auto auto auto auto;
  grid-template-areas:
    "back title autosay set meta fs"
    "modes modes modes modes modes modes";
}
#screen-review .game-topbar .btn.ghost.fs-toggle { grid-area: fs; }
#screen-review .game-autosay { grid-area: autosay; }
#screen-review .game-topbar [data-game-settings] { grid-area: set; } /* что спрашивать: слово / формы */

/* select: breathing room between category filter and the card */
@media (min-width: 768px) { .select-cats { margin: 4px 0 18px; } }

/* ── Тексты: библиотека и читалка (метод Франка) ── */
.texts-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 20px; }
.texts-cat {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.texts-cat:hover { background: var(--surface-hover); color: var(--text); }
.texts-cat.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.texts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.texts-card { text-decoration: none; color: inherit; }
.texts-card-ru { margin: -4px 0 6px; color: var(--muted); font-size: 13.5px; }
.texts-empty { color: var(--muted); }

.texts-reader { max-width: 760px; margin: 0 auto; }
.texts-back { margin-bottom: 18px; }
.texts-reader-cat {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.texts-reader-title { margin: 6px 0 4px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -0.02em; }
.texts-reader-sub { margin: 0 0 18px; color: var(--muted); }
.texts-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 22px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.texts-toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); cursor: pointer; }
.texts-toggle.is-disabled { opacity: 0.45; cursor: default; }
.texts-toggle .switch:disabled { cursor: default; }
.texts-para { margin-bottom: 26px; }
.texts-adapted,
.texts-plain { margin: 0; font-size: 18px; line-height: 1.75; }
.texts-plain { margin-top: 10px; padding-left: 14px; border-left: 3px solid var(--accent-soft); }
.texts-adapted + .texts-plain { color: var(--text); }
.texts-plain:only-child { margin-top: 0; padding-left: 0; border-left: 0; } /* режим «без перевода»: это сам текст, а не повтор */
.texts-gloss { color: var(--muted); font-style: italic; font-size: 0.86em; }
.tw { cursor: pointer; border-radius: 4px; transition: background 0.12s; }
.tw:hover { background: var(--accent-soft); }
.tw.active { background: var(--accent-soft); color: var(--accent); }

.tw-popover { width: min(320px, calc(100vw - 16px)); }
.tw-entry { padding: 8px 0; border-top: 1px solid var(--border); }
.tw-entry:first-of-type { border-top: 0; padding-top: 2px; }
.tw-lemma { font-size: 15px; }
.tw-pos { color: var(--muted); font-size: 12px; }
.tw-tr { margin-top: 2px; font-size: 14px; }
.tw-alt { margin-top: 2px; color: var(--text-secondary); font-size: 12.5px; }
.tw-ex { margin-top: 4px; color: var(--muted); font-size: 12.5px; font-style: italic; }
.tw-learn { margin-top: 8px; padding: 6px 12px; font-size: 13px; }
.tw-empty { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* невысокий экран: сайдбар компактнее, чтобы все пункты были видны без прокрутки */
@media (min-width: 1024px) and (max-height: 860px) {
  .app-header-inner { gap: 14px; padding: 16px 12px 12px; }
  .nav-link { padding: 7px 12px; }
  .nav-group { margin: 6px 0 4px; }
  .nav-group-label { padding: 4px 12px 2px; }
  .header-right { gap: 8px; }
}

/* ── телефон: меню «Учиться» из нижней панели — то же меню, что сайдбар (игр на главной нет) ── */
.nav-backdrop { display: none; }
@media (max-width: 880px) {
  body.nav-open .app-header { backdrop-filter: none; -webkit-backdrop-filter: none; } /* иначе fixed-меню прилипает к шапке */
  body.nav-open .main-nav {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    max-height: min(72dvh, 620px);
    overflow-y: auto;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(17, 24, 39, 0.22);
    animation: nav-sheet-in 0.18s ease-out;
  }
  body.nav-open .main-nav .nav-link { display: flex; width: 100%; padding: 11px 12px; font-size: 15px; text-decoration: none; }
  body.nav-open .main-nav .nav-link--compact-only { display: none; }
  body.nav-open .main-nav .nav-group { display: flex; flex-direction: column; gap: 1px; margin: 6px 0 4px; }
  body.nav-open .main-nav .nav-group-label {
    display: block;
    padding: 8px 12px 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  body.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(17, 24, 39, 0.28);
  }
}
@keyframes nav-sheet-in { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { body.nav-open .main-nav { animation: none; } }
