/* ==========================================================================
   ГДЗ — design system
   Colours sampled directly from the approved mockup.
   ========================================================================== */

/* Allow smooth theme fades: custom props are not interpolable unless registered */
@property --bg { syntax: "<color>"; inherits: true; initial-value: #eeeeee; }
@property --surface { syntax: "<color>"; inherits: true; initial-value: #ffffff; }
@property --card { syntax: "<color>"; inherits: true; initial-value: #f7f7f7; }
@property --line { syntax: "<color>"; inherits: true; initial-value: #e6e6ea; }
@property --ink { syntax: "<color>"; inherits: true; initial-value: #242c40; }
@property --ink-2 { syntax: "<color>"; inherits: true; initial-value: #545b6b; }
@property --ink-3 { syntax: "<color>"; inherits: true; initial-value: #8b91a0; }
@property --purple { syntax: "<color>"; inherits: true; initial-value: #594299; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: #6c4fd0; }
@property --accent-2 { syntax: "<color>"; inherits: true; initial-value: #8e76d5; }
@property --accent-soft { syntax: "<color>"; inherits: true; initial-value: #ece4f8; }
@property --input-bg { syntax: "<color>"; inherits: true; initial-value: #ffffff; }
@property --seo-bg { syntax: "<color>"; inherits: true; initial-value: #f0f0fa; }
@property --hero-plate { syntax: "<color>"; inherits: true; initial-value: #f4efff; }
@property --header-link-bg { syntax: "<color>"; inherits: true; initial-value: #e8e1f6; }
@property --header-link-ink { syntax: "<color>"; inherits: true; initial-value: #3a3358; }
@property --header-link-bg-hover { syntax: "<color>"; inherits: true; initial-value: #ddd4f2; }
@property --header-link-bg-active { syntax: "<color>"; inherits: true; initial-value: #d4c8f0; }
@property --header-link-ink-active { syntax: "<color>"; inherits: true; initial-value: #2f2850; }
@property --chip-bg { syntax: "<color>"; inherits: true; initial-value: #ffffff; }
@property --chip-ink { syntax: "<color>"; inherits: true; initial-value: #545b6b; }
@property --task-ready-bg { syntax: "<color>"; inherits: true; initial-value: #ece4f8; }
@property --task-ready-ink { syntax: "<color>"; inherits: true; initial-value: #594299; }
@property --task-ready-border { syntax: "<color>"; inherits: true; initial-value: #d4c8ef; }
@property --task-visited-bg { syntax: "<color>"; inherits: true; initial-value: #cbb6ef; }
@property --task-visited-ink { syntax: "<color>"; inherits: true; initial-value: #3a246e; }
@property --task-visited-ready-bg { syntax: "<color>"; inherits: true; initial-value: #b79ae6; }
@property --task-visited-ready-ink { syntax: "<color>"; inherits: true; initial-value: #2f1d5c; }

:root {
  --bg: #eeeeee;
  --surface: #ffffff;
  --card: #f7f7f7;
  --line: #e6e6ea;

  --ink: #242c40;
  --ink-2: #545b6b;
  --ink-3: #8b91a0;

  --purple: #594299;
  --accent: #6c4fd0;
  --accent-2: #8e76d5;
  --accent-soft: #ece4f8;

  --seo-bg: #f0f0fa;
  --footer-a: #6b41c2;
  --footer-b: #ac41c2;

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow: 0 1px 2px rgba(36, 44, 64, .04);
  --input-bg: #ffffff;
  --hero-bg: linear-gradient(103deg, #f9f6ff 0%, #f4efff 42%, #ece0fd 100%);
  --hero-plate: #f4efff;
  --header-link-bg: #e8e1f6;
  --header-link-ink: #3a3358;
  --header-link-bg-hover: #ddd4f2;
  --header-link-bg-active: #d4c8f0;
  --header-link-ink-active: #2f2850;
  --scroll-track: #ebe7f3;
  --scroll-thumb: #b5a6d8;
  --scroll-thumb-hover: #8e76d5;
  --msg-user-bg: #e4def4;
  --msg-user-ink: #242c40;
  --msg-error-bg: #fdecec;
  --msg-error-ink: #b03636;
  --task-ready-bg: #ece4f8;
  --task-ready-ink: #594299;
  --task-ready-border: #d4c8ef;
  --task-visited-bg: #cbb6ef;
  --task-visited-ink: #3a246e;
  --task-visited-ready-bg: #b79ae6;
  --task-visited-ready-ink: #2f1d5c;
  --chip-bg: #ffffff;
  --chip-ink: #545b6b;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121018;
  --surface: #1c1a24;
  --card: #322e3f;
  --line: #3d3850;
  --ink: #eceaf3;
  --ink-2: #b8b4c4;
  --ink-3: #8d889c;
  --purple: #cbbfff;
  --accent: #d7c9ff;
  --accent-2: #b9a4f0;
  --accent-soft: #2a2438;
  --seo-bg: #1a1722;
  --footer-a: #4a2d86;
  --footer-b: #6b2d86;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --input-bg: #16141c;
  --hero-bg: linear-gradient(103deg, #221e2c 0%, #2a2438 42%, #322a48 100%);
  --hero-plate: #221e2c;
  --header-link-bg: #2a2438;
  --header-link-ink: #d7c9ff;
  --header-link-bg-hover: #322a48;
  --header-link-bg-active: #3d2e6b;
  --header-link-ink-active: #ffffff;
  --scroll-track: #1a1722;
  --scroll-thumb: #5a4d7a;
  --scroll-thumb-hover: #8e76d5;
  --msg-user-bg: #3d2e6b;
  --msg-user-ink: #ffffff;
  --msg-error-bg: #3a1c1c;
  --msg-error-ink: #ff9c9c;
  --task-ready-bg: #2a2438;
  --task-ready-ink: #d7c9ff;
  --task-ready-border: #4a3d6e;
  --task-visited-bg: #3d2f66;
  --task-visited-ink: #f0e9ff;
  --task-visited-ready-bg: #4a3780;
  --task-visited-ready-ink: #ffffff;
  --chip-bg: #3a3448;
  --chip-ink: #f3f0fa;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    color-scheme: dark;
    --bg: #121018;
    --surface: #1c1a24;
    --card: #322e3f;
    --line: #3d3850;
    --ink: #eceaf3;
    --ink-2: #b8b4c4;
    --ink-3: #8d889c;
    --purple: #cbbfff;
    --accent: #d7c9ff;
    --accent-2: #b9a4f0;
    --accent-soft: #2a2438;
    --seo-bg: #1a1722;
    --footer-a: #4a2d86;
    --footer-b: #6b2d86;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --input-bg: #16141c;
    --hero-bg: linear-gradient(103deg, #221e2c 0%, #2a2438 42%, #322a48 100%);
    --hero-plate: #221e2c;
    --header-link-bg: #2a2438;
    --header-link-ink: #d7c9ff;
    --header-link-bg-hover: #322a48;
    --header-link-bg-active: #3d2e6b;
    --header-link-ink-active: #ffffff;
    --scroll-track: #1a1722;
    --scroll-thumb: #5a4d7a;
    --scroll-thumb-hover: #8e76d5;
    --msg-user-bg: #3d2e6b;
    --msg-user-ink: #ffffff;
    --msg-error-bg: #3a1c1c;
    --msg-error-ink: #ff9c9c;
    --task-ready-bg: #2a2438;
    --task-ready-ink: #d7c9ff;
    --task-ready-border: #4a3d6e;
    --task-visited-bg: #3d2f66;
    --task-visited-ink: #f0e9ff;
    --task-visited-ready-bg: #4a3780;
    --task-visited-ready-ink: #ffffff;
    --chip-bg: #3a3448;
    --chip-ink: #f3f0fa;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  /* Slightly larger UI — feels like browser zoom ~110% on hub and satellites. */
  zoom: 1.1;
  scroll-padding-top: 18px;
}

html.theme-animated {
  /* Single clock for the whole UI: tokens, plate and covers share one beat */
  transition:
    --bg .5s ease,
    --surface .5s ease,
    --card .5s ease,
    --line .5s ease,
    --ink .5s ease,
    --ink-2 .5s ease,
    --ink-3 .5s ease,
    --purple .5s ease,
    --accent .5s ease,
    --accent-2 .5s ease,
    --accent-soft .5s ease,
    --input-bg .5s ease,
    --seo-bg .5s ease,
    --hero-plate .5s ease,
    --header-link-bg .5s ease,
    --header-link-ink .5s ease,
    --header-link-bg-hover .5s ease,
    --header-link-bg-active .5s ease,
    --header-link-ink-active .5s ease,
    --chip-bg .5s ease,
    --chip-ink .5s ease,
    --task-ready-bg .5s ease,
    --task-ready-ink .5s ease,
    --task-ready-border .5s ease,
    --task-visited-bg .5s ease,
    --task-visited-ink .5s ease,
    --task-visited-ready-bg .5s ease,
    --task-visited-ready-ink .5s ease !important;
}
html.theme-animated .hero__cover,
html.theme-animated .hero::before,
html.theme-animated .hero::after,
html.theme-animated .error-page__card::before,
html.theme-animated .error-page__card::after,
html.theme-animated .error-page__btn {
  transition: opacity .5s ease !important;
}
/* Kill local color/bg transitions so they don't lag behind the token clock */
html.theme-animated .chip,
html.theme-animated .search,
html.theme-animated .search__input,
html.theme-animated .tasks__button,
html.theme-animated .tasks__more,
html.theme-animated .book-card,
html.theme-animated .subject-card,
html.theme-animated .subject-tile {
  transition: none !important;
  box-shadow: none !important;
  transform: none !important;
  outline: none !important;
}
html[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] { color-scheme: dark; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 1000;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

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

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 1280px) {
  .page {
    max-width: 1360px;
  }
}

.surface {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 10px 20px 22px;
}

.empty {
  color: var(--ink-3);
  font-size: 14px;
  padding: 24px 0;
}

/* ---------------------------------------------------------------- header */

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  font-size: 13px;
  font-weight: 600;
  color: var(--header-link-ink);
  padding: 0 12px;
  border-radius: 8px;
  background: var(--header-link-bg);
  box-sizing: border-box;
}

.site-header__link:hover { color: var(--purple); background: var(--header-link-bg-hover); }
.site-header__link.is-active { background: var(--header-link-bg-active); color: var(--header-link-ink-active); }
.site-header__link--back { white-space: nowrap; }

.site-header__search {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
}

.site-header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.site-header__menu { position: relative; }

.burger {
  display: flex;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  align-items: center;
  flex: 0 0 36px;
}

.burger span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--purple);
}

.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--purple);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  line-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  display: block;
  position: static;
  transform: none;
  margin: 0;
}

.burger:hover,
.theme-toggle:hover {
  background: var(--accent-soft);
}

.theme-toggle .theme-toggle__sun { visibility: hidden; }
.theme-toggle .theme-toggle__moon { visibility: visible; }

html[data-theme="dark"] .theme-toggle .theme-toggle__sun,
html[data-resolved="dark"] .theme-toggle .theme-toggle__sun { visibility: visible; }
html[data-theme="dark"] .theme-toggle .theme-toggle__moon,
html[data-resolved="dark"] .theme-toggle .theme-toggle__moon { visibility: hidden; }

html[data-theme="light"] .theme-toggle .theme-toggle__sun,
html[data-resolved="light"] .theme-toggle .theme-toggle__sun { visibility: hidden; }
html[data-theme="light"] .theme-toggle .theme-toggle__moon,
html[data-resolved="light"] .theme-toggle .theme-toggle__moon { visibility: visible; }

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .theme-toggle .theme-toggle__sun { visibility: visible; }
  html[data-theme="auto"] .theme-toggle .theme-toggle__moon { visibility: hidden; }
}

.mobile-search { display: none; }

/* ---------------------------------------------------------------- search */

.search {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  width: 100%;
  height: 34px;
  border: 1.5px solid #9074d4;
  border-radius: 9px;
  background: var(--input-bg);
  transition: border-color .15s, box-shadow .15s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 79, 208, .12);
}

.search__icon {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--ink-3);
  pointer-events: none;
  z-index: 1;
}

.search__input {
  width: 100%;
  height: 100%;
  padding: 0 16px 0 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search__input::placeholder {
  color: var(--ink-3);
  text-overflow: ellipsis;
}
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search__suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: 0 10px 30px rgba(36, 44, 64, .12);
  max-height: min(70vh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
}

.search__suggest a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.search__suggest a:last-child { border-bottom: 0; }
.search__suggest a:hover { background: var(--card); }
.search__suggest small { display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px; }

.search__hit-text {
  min-width: 0;
  line-height: 1.35;
  white-space: normal;
}

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  z-index: 4;
  margin-top: 10px;
  border-radius: var(--r-md);
  background-color: var(--hero-plate);
  padding: 26px 30px 24px;
  overflow: visible;
  height: 340px;
  min-height: 340px;
  display: flex;
  align-items: center;
  isolation: isolate;
}

.hero__covers {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
  clip-path: inset(1px round calc(var(--r-md) - 1px));
  -webkit-clip-path: inset(1px round calc(var(--r-md) - 1px));
}

.hero__covers::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--hero-plate);
}

.hero__cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  overflow: hidden;
  border-radius: inherit;
  opacity: 1;
  transition: opacity .5s ease;
}

.hero__cover img {
  position: absolute;
  /* Bleed past edges so subpixel AA never shows the plate */
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  max-width: none;
  object-fit: cover;
  /* Anchors the prop cluster (bottom-right), not the empty fabric center */
  object-position: right center;
  image-rendering: auto;
}

.hero__cover--light {
  z-index: 0;
  opacity: 1;
}

/* Subject satellites only: nudge crop via object-position (no transform gap) */
.page-home--subject .hero__cover--light img {
  object-position: calc(100% + 3px) center;
}

.hero__cover--dark {
  z-index: 1;
  opacity: 0;
}

html[data-resolved="dark"] .hero__cover--light { opacity: 0; }
html[data-resolved="dark"] .hero__cover--dark { opacity: 1; }

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity .5s ease;
}

.hero::before {
  background: linear-gradient(
    100deg,
    rgba(249, 246, 255, .88) 0%,
    rgba(249, 246, 255, .72) 34%,
    rgba(249, 246, 255, .18) 58%,
    rgba(249, 246, 255, 0) 72%
  );
  opacity: 1;
}

.hero::after {
  background: linear-gradient(
    100deg,
    rgba(34, 30, 44, .92) 0%,
    rgba(34, 30, 44, .78) 34%,
    rgba(34, 30, 44, .22) 58%,
    rgba(34, 30, 44, 0) 72%
  );
  opacity: 0;
}

html[data-resolved="dark"] .hero::before { opacity: 0; }
html[data-resolved="dark"] .hero::after { opacity: 1; }

.hero__text {
  position: relative;
  z-index: 2;
  max-width: 470px;
}

.hero__title {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.24;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--purple);
}

.hero__lead {
  margin: 0 0 20px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
}

.hero__search {
  position: relative;
  z-index: 5;
  max-width: 400px;
}

.empty-panel {
  grid-column: 1 / -1;
  padding: 30px 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(103deg, #fbf8ff 0%, #f4efff 100%);
}

.empty-panel__title {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--purple);
}

.empty-panel__text {
  margin: 0;
  max-width: 620px;
  color: var(--ink-2);
}

/* -------------------------------------------------------- subject cards */

.home-grades {
  margin-top: 18px;
  margin-bottom: 4px;
  background: var(--card);
  border-radius: var(--r-md);
  padding: 20px 22px 18px;
}

.home-popular {
  margin-top: 18px;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 18px 20px 16px;
}

.home-grades .chip {
  background: var(--chip-bg);
}

.home-grades__title,
.home-popular__title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--purple);
}

.home-grades + .subject-tiles,
.home-grades + .author-picker {
  margin-top: 14px;
}

.subject-tiles + .home-popular__title,
.subject-tiles + .catalog-books-title,
.author-picker + .home-popular__title,
.author-picker + .catalog-books-title {
  margin-top: 32px;
}

.catalog-books-title {
  margin: 28px 0 14px;
}

.home-grades__list {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 8px;
}

.chip--grade {
  width: 100%;
  min-height: 36px;
  height: auto;
  padding: 8px 6px;
}

@media (max-width: 1100px) {
  .home-grades__list { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.home-popular .book-grid {
  margin-top: 0;
}

@media (min-width: 1001px) {
  .home-popular .book-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.home-popular--error {
  margin-top: 16px;
}

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

.page-home--subject .subjects {
  grid-template-columns: minmax(0, 1fr);
  max-width: none;
}

.subject-card {
  position: relative;
  background: var(--card);
  border-radius: var(--r-md);
  padding: 24px 26px 22px;
  min-height: 136px;
  overflow: hidden;
}

.subject-card__title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 16px;
}

.subject-card__title:hover { color: var(--accent); }
.subject-card__chev { color: var(--ink-3); font-weight: 400; }

.subject-card__grades {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: calc(100% - 96px);
}

.subject-card__icon-link {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 78px;
  height: 78px;
  z-index: 1;
}

.subject-card__icon-link picture {
  display: block;
  width: 100%;
  height: 100%;
}

.subject-card__icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent !important;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.subject-card__icon,
.book-card__cover img,
.site-rail__cover img {
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--chip-bg);
  border: 0;
  font-size: 13px;
  color: var(--chip-ink);
  white-space: nowrap;
  transition: color .15s, background .15s;
}

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

/* ---------------------------------------------------------------- layout */

.layout {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-top: 10px;
}

.layout__main { flex: 1; min-width: 0; }

.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px;
}

.sidebar__list,
.sidebar__sub { list-style: none; margin: 0; padding: 0; }

.sidebar__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 0;
  background: none;
  border-radius: 7px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}

.sidebar__toggle:hover { background: var(--card); }
.sidebar__chevron { color: var(--ink-3); transition: transform .28s ease; flex: none; }
.sidebar__item.is-open > .sidebar__toggle { color: var(--ink); font-weight: 500; }
.sidebar__item.is-open > .sidebar__toggle .sidebar__chevron { transform: rotate(180deg); }

.sidebar__sub {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .32s ease;
}

.sidebar__item.is-open > .sidebar__sub { grid-template-rows: 1fr; }

.sidebar__sub-inner {
  overflow: hidden;
  min-height: 0;
  list-style: none;
  margin: 0;
  padding: 0 0 6px 12px;
}

.sidebar__sub a {
  display: block;
  padding: 5px 9px;
  font-size: 11.5px;
  color: var(--ink-2);
  border-radius: 6px;
}

.sidebar__sub a:hover { color: var(--accent); background: var(--card); }
.sidebar__sub a.is-active { color: var(--accent); font-weight: 500; }

.sidebar__empty {
  padding: 10px 8px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.5;
}

/* ----------------------------------------------------------- breadcrumbs */

.crumbs { margin: 18px 0 4px; }

.crumbs__list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  font-size: 11px;
  color: var(--ink-3);
}

.crumbs__item + .crumbs__item::before {
  content: "・";
  margin-right: 6px;
  color: var(--ink-3);
}

.crumbs__item a:hover { color: var(--accent); }
.crumbs__current { color: var(--ink); font-weight: 500; }

.page-title {
  margin: 10px 0 18px;
  font-size: 21px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
}

.page-title--task { font-size: 19px; }

.error-page {
  padding: 12px 0 4px;
}

.error-page__card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 320px;
  border-radius: var(--r-lg);
  background-color: var(--hero-plate);
  padding: 34px 36px;
}

.error-page__card::before,
.error-page__card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity .45s ease;
}

.error-page__card::before {
  background: linear-gradient(
    100deg,
    rgba(249, 246, 255, .88) 0%,
    rgba(249, 246, 255, .72) 34%,
    rgba(249, 246, 255, .18) 58%,
    rgba(249, 246, 255, 0) 72%
  );
  opacity: 1;
}

.error-page__card::after {
  background: linear-gradient(
    100deg,
    rgba(34, 30, 44, .92) 0%,
    rgba(34, 30, 44, .78) 34%,
    rgba(34, 30, 44, .22) 58%,
    rgba(34, 30, 44, 0) 72%
  );
  opacity: 0;
}

html[data-resolved="dark"] .error-page__card::before { opacity: 0; }
html[data-resolved="dark"] .error-page__card::after { opacity: 1; }

.page-error--subject .hero__cover--light img {
  object-position: calc(100% + 3px) center;
}

.error-page__content {
  position: relative;
  z-index: 2;
  max-width: 520px;
}

.error-page__eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}

.error-page__title {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 1.15;
  color: var(--purple);
}

.error-page__text {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.error-page__search {
  margin-top: 16px;
  max-width: 420px;
}

.error-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.error-page__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--purple);
  font-weight: 600;
}

.error-page__btn--primary {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

.error-page__art {
  display: none;
}

/* ------------------------------------------------------------ book cards */

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

.book-card {
  display: flex;
  gap: 14px;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 14px;
  transition: box-shadow .16s, transform .16s;
}

.book-card--compact {
  align-items: flex-start;
  min-height: 0;
  padding: 16px 18px;
  gap: 16px;
}

.book-card--compact .book-card__body {
  gap: 6px;
  justify-content: center;
}

.book-card:hover {
  box-shadow: 0 6px 20px rgba(36, 44, 64, .08);
  transform: translateY(-1px);
}

.book-card--wide { margin-bottom: 18px; }
.book-card--wide:hover { box-shadow: none; transform: none; }

.book-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.book-card__go {
  align-self: flex-end;
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 9px;
  background: #594299;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.book-card:hover .book-card__go {
  background: #6c4fd0;
}

html[data-theme="dark"] .book-card__go,
html[data-resolved="dark"] .book-card__go {
  background: #6c4fd0;
  color: #fff;
}

html[data-theme="dark"] .book-card:hover .book-card__go,
html[data-resolved="dark"] .book-card:hover .book-card__go {
  background: #7b5fe0;
}

.book-card__cover {
  flex: 0 0 78px;
  width: 78px;
  height: 104px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px var(--card);
}

.book-card__cover img {
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  max-width: none;
  margin: -1px;
  object-fit: cover;
}

.book-card__placeholder {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}

.book-card__meta {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-2);
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 3px;
  align-items: start;
}

.book-card__meta > div { display: contents; }
.book-card[id^="author-"] { scroll-margin-top: 28px; }
.book-card__meta dt {
  color: var(--ink-3);
  text-align: left;
  font-weight: 400;
}
.book-card__meta dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ----------------------------------------------------------------- tasks */

.sitemap-group { margin-bottom: 22px; }
.sitemap-group .tasks__title a:hover { color: var(--accent); }

.tasks { margin-top: 22px; }

.tasks__title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.tasks__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px;
}

.tasks__button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 38px;
  padding: 6px 4px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid transparent;
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color .14s, color .14s, background-color .14s;
}

.tasks__button--wide {
  grid-column: span 2;
  padding: 6px 8px;
}

.tasks__button--xl {
  grid-column: span 4;
  min-height: 44px;
  justify-content: flex-start;
  text-align: left;
  padding: 8px 12px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

.tasks__button[hidden],
.tasks__button.is-folded,
.tasks[hidden],
.tasks.is-folded {
  display: none !important;
}

.tasks__more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: var(--card);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tasks__more:hover {
  color: var(--accent);
}

.tasks__button.has-scan {
  background: var(--task-ready-bg);
  border-color: transparent;
  color: var(--task-ready-ink);
  font-weight: 600;
}

.tasks__button:hover {
  border-color: var(--accent-2);
  color: var(--accent);
  background: var(--input-bg);
}

.tasks__button.has-scan:hover {
  background: var(--task-ready-bg);
  border-color: transparent;
  color: var(--accent);
}

.tasks__button.is-visited {
  background: var(--task-visited-bg);
  border-color: transparent;
  color: var(--task-visited-ink);
  font-weight: 700;
}

.tasks__button.has-scan.is-visited,
.tasks__button.has-scan.is-visited:hover {
  background: var(--task-visited-ready-bg);
  border-color: transparent;
  color: var(--task-visited-ready-ink);
}

.dev-ingest {
  margin: 16px 0 4px;
  padding: 12px 14px;
  border: 1px dashed #cfc4ea;
  border-radius: 10px;
  background: #f7f4fc;
}

.dev-ingest__note {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}

.dev-ingest__note code {
  font-size: 11px;
  background: #fff;
  padding: 1px 5px;
  border-radius: 4px;
}

.dev-ingest__btn {
  border: 0;
  border-radius: 8px;
  background: var(--purple);
  color: #fff;
  padding: 7px 12px;
  cursor: pointer;
}

.dev-ingest__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.dev-ingest__btn--stop { background: #8a4a4a; }

.dev-ingest__btn:disabled { opacity: .55; cursor: default; }

.dev-ingest__bar {
  margin-top: 10px;
  height: 8px;
  border-radius: 99px;
  background: #e7e0f4;
  overflow: hidden;
}

.dev-ingest__bar-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--purple);
  transition: width .25s ease;
}

.dev-ingest__status {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-2);
}

/* ------------------------------------------------------------- condition */

.condition {
  background: var(--card);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.condition__title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.condition--in-tab {
  background: none;
  padding: 4px 0 12px;
  margin: 0;
}

.condition__text { margin: 0; font-size: 13px; color: var(--ink); white-space: pre-wrap; }

.condition--about .condition__text {
  line-height: 1.55;
  color: var(--ink-2);
}

/* -------------------------------------------------------------- solution */

.solution {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

.solution__tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.solution__tab {
  position: relative;
  padding: 12px 10px 10px;
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}

.solution__tab::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
}

.solution__tab.is-active { color: var(--ink); font-weight: 500; }
.solution__tab.is-active::after { background: var(--accent-2); }

.solution__panel { padding: 18px 20px 4px; }
.solution__panel[hidden] { display: none; }

.step {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.step__badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  margin-bottom: 10px;
}

.step__body {
  margin: 0;
  max-width: 62ch;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
}

.step__note {
  margin: 0 0 8px;
  color: var(--ink-3);
  font-size: 13px;
  font-style: italic;
}

.step__text {
  margin: 0 0 8px;
}

.step__text:last-child,
.step__formula:last-child,
.step__note:last-child {
  margin-bottom: 0;
}

.step__formula {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.solution__answer {
  margin: 4px 0 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

.teacher-cta {
  padding: 8px 0 18px;
}

.teacher-cta__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #7b41c2;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(123, 65, 194, .28);
}

.teacher-cta__btn:hover { background: #6935ad; }
.teacher-cta__btn:disabled { opacity: .5; cursor: default; box-shadow: none; }

.teacher-cta__status.is-error { color: #b03636; }

html[data-theme="dark"] .teacher-cta__btn,
html[data-resolved="dark"] .teacher-cta__btn {
  background: #9b6dff;
}

.step__body .katex-display {
  margin: 0.45em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.scan { margin: 0 0 18px; }

.scan__open {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.scan img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

.scan--missing .scan__open {
  display: flex;
  min-height: 120px;
  align-items: center;
  justify-content: center;
  cursor: default;
  background: var(--card);
  border-radius: var(--r-sm);
}

.scan--missing .scan__open::after {
  content: "Скан временно недоступен";
  color: var(--ink-3);
  font-size: 14px;
}

.scan figcaption {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-3);
}

.pager {
  display: flex;
  gap: 10px;
  padding: 6px 20px 18px;
}

.pager__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-2);
  transition: background .14s, color .14s, border-color .14s;
}

.pager__btn:hover:not(.is-disabled) { background: var(--accent-soft); color: var(--accent); }
.pager__btn.is-disabled { display: none; }
.pager__btn span { color: var(--ink-3); }
.pager__btn--next { padding-left: 16px; }

/* ------------------------------------------------------------- assistant */

.assistant {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px 14px;
}

.assistant__head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 14px;
}

.assistant__spark { color: var(--accent); flex: none; }

.assistant__log-wrap {
  position: relative;
  margin-bottom: 12px;
}

.assistant__log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 0;
  scroll-behavior: auto;
}

.assistant__jump {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #7b41c2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(123, 65, 194, .35);
  z-index: 2;
}

.assistant__jump[hidden] { display: none; }

.msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg--bot {
  align-self: flex-start;
  background: var(--accent-soft);
  color: var(--ink);
}

.msg--bot .katex {
  font-size: 1.05em;
}

.msg--bot .katex-display {
  margin: 0.55em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.msg--user {
  align-self: flex-end;
  background: var(--msg-user-bg);
  color: var(--msg-user-ink);
}

.msg--streaming .msg__caret {
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin-left: 1px;
  vertical-align: -0.1em;
  background: var(--accent);
  animation: caret 0.85s step-end infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

.msg--error { align-self: flex-start; background: var(--msg-error-bg); color: var(--msg-error-ink); }

.msg.msg--status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  align-self: flex-start;
  background: transparent;
  color: var(--ink-3);
  font-style: normal;
  padding: 4px 2px;
}

.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  flex-shrink: 0;
  animation: gdz-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spin {
    animation: none;
    border-right-color: currentColor;
    opacity: 0.45;
  }
}

.teacher-cta__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.msg--typing { display: flex; gap: 4px; align-items: center; align-self: flex-start; }

.msg--typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: dot 1.1s infinite ease-in-out;
}

.msg--typing i:nth-child(2) { animation-delay: .18s; }
.msg--typing i:nth-child(3) { animation-delay: .36s; }

@keyframes dot {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.assistant__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
  overflow: hidden;
  max-height: 88px;
  opacity: 1;
  transform: translateY(0);
  transition: max-height .4s ease, opacity .32s ease, margin .4s ease, transform .4s ease;
}

.assistant__chips.is-gone {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  transform: translateY(14px);
  pointer-events: none;
}

.assistant__chip {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .14s, color .14s, background .14s;
}

.assistant__chip:hover { border-color: var(--accent-2); color: var(--accent); }

.assistant__form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 16px;
}

.assistant__input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  height: 34px;
  font-size: 12px;
  color: var(--ink);
  min-width: 0;
}

.assistant__input::placeholder { color: var(--ink-3); }

.assistant__send {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #7b41c2;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .14s, transform .14s;
  box-shadow: 0 2px 8px rgba(123, 65, 194, .35);
}

.assistant__send:hover { background: #6935ad; }
.assistant__send:disabled { opacity: .45; cursor: default; box-shadow: none; }

.assistant__note {
  margin: 9px 0 0;
  font-size: 10.5px;
  color: var(--ink-3);
}

/* --------------------------------------------------------------- tiles */

.subject-tiles {
  display: grid;
  /* auto-fit: empty tracks collapse — no orphan gap when few authors */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.subject-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--card);
  font-size: 13px;
  transition: background .14s, color .14s;
  min-width: 0;
}

button.subject-tile {
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.subject-tile.is-open,
.subject-tile[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .subject-tile:hover { background: var(--accent-soft); color: var(--accent); }
  .subject-tile--more:hover { color: var(--accent); }
}
.subject-tile__name { min-width: 0; }
.subject-tile__count { font-size: 11px; color: var(--ink-3); flex: 0 0 auto; }
.subject-tile.is-open .subject-tile__count,
.subject-tile[aria-pressed="true"] .subject-tile__count { color: inherit; }

.subject-tile[hidden],
.subject-tile.is-folded {
  display: none !important;
}

.subject-tile--more {
  justify-content: center;
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--ink-3);
  cursor: pointer;
  border: 0;
  width: 100%;
}

.author-picker { margin: 0 0 18px; }

.author-picker .author-picker__all {
  margin-top: 12px;
}

.author-picker .book-card {
  overflow: hidden;
  max-height: 420px;
  transition: opacity .32s ease, transform .32s ease, box-shadow .16s ease, max-height .36s ease, padding .36s ease, gap .36s ease;
}

.author-picker .book-card.is-away {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
  box-shadow: none;
  max-height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  gap: 0;
}

.author-picker .book-card.is-away:hover {
  transform: scale(0.97);
  box-shadow: none;
}

.author-picker .book-card[hidden] {
  display: none !important;
}

.author-block { margin: 0 0 22px; }
.author-block__title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.authors { list-style: none; margin: 0; padding: 0; }

.authors__item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.authors__name { font-weight: 600; min-width: 200px; }
.authors__books { color: var(--ink-2); }
.authors__books a:hover { color: var(--accent); }

.prose { font-size: 13.5px; line-height: 1.7; color: var(--ink-2); max-width: 760px; }
.prose p { margin: 0 0 14px; }
.prose a { color: var(--accent); }

/* ------------------------------------------------------------------- seo */

.seo {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 16px;
}

.seo__inner {
  background: var(--seo-bg);
  border-radius: var(--r-md);
  padding: 22px 26px;
}

.seo__title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--purple);
}

.seo__subtitle {
  margin: 18px 0 8px;
  font-size: 16px;
  font-weight: 650;
  color: var(--ink);
}

.seo__text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}

.seo__text:last-child { margin-bottom: 0; }

.seo__faq {
  margin: 4px 0 8px;
  display: grid;
  gap: 12px;
}

.seo__faq-q {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.45;
}

.seo__math {
  overflow-x: auto;
}

.seo__math .katex {
  font-size: 1.08em;
}

.seo__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 14px;
}

.seo__link {
  display: inline-flex;
  align-items: center;
  padding: 12px 20px;
  min-height: 44px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  text-decoration: none;
  white-space: normal;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
}

.seo__link:hover {
  filter: brightness(1.08);
}

/* ---------------------------------------------------------- site rail */

.site-rail {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px 22px 18px;
}

.site-rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.site-rail__title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--purple);
}

.site-rail__nav {
  display: flex;
  gap: 6px;
}

.site-rail__btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-rail__btn:hover {
  color: var(--ink);
  background: var(--accent-soft);
}

.site-rail__btn:disabled {
  opacity: .35;
  cursor: default;
}

.site-rail__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.site-rail__track::-webkit-scrollbar { display: none; }

.site-rail__card {
  flex: 0 0 108px;
  width: 108px;
  scroll-snap-align: start;
  text-align: center;
  color: var(--ink);
}

.site-rail__card:hover .site-rail__name { color: var(--accent); }

.site-rail__cover {
  display: block;
  width: 108px;
  height: 144px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(140deg, #cfa6e6, #8f6fd6);
  box-shadow: 0 4px 12px rgba(36, 44, 64, .1);
}

.site-rail__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-rail__cover--hub {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  padding: 10px;
}

.site-rail__name {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.site-rail__dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.site-rail__dots[hidden] { display: none; }

.site-rail__dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  cursor: pointer;
}

.site-rail__dot.is-active {
  background: var(--purple);
}

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

/* ---------------------------------------------------------------- footer */

.footer {
  position: relative;
  border-radius: var(--r-lg);
  background: #8b3fc4;
  padding: 22px 28px 20px;
  overflow: hidden;
  min-height: 196px;
  color: #fff;
}

.footer__body { position: relative; z-index: 2; max-width: 42%; }

.footer__title {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
}

.footer__links { list-style: none; margin: 0; padding: 0; }

.footer__links li { margin-bottom: 8px; }

.footer__links a {
  font-size: 12.5px;
  color: rgba(255, 255, 255, .94);
  transition: color .14s;
}

.footer__links a:hover { color: #fff; text-decoration: underline; }

.footer__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 82% center;
  z-index: 1;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, transparent 28%, #000 58%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, transparent 28%, #000 58%, #000 100%);
}

html[data-theme="dark"] .footer,
html[data-resolved="dark"] .footer {
  background: #5c2d86;
}

/* ---------------------------------------------------------- mobile menu */

/* ---------------------------------------------------------- header menu */

.mobile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 92;
  width: 300px;
  max-height: min(72vh, 560px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 36px rgba(36, 44, 64, .14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transform-origin: top right;
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
}

.mobile-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.mobile-menu[hidden] { display: block; }

.mobile-menu__inner {
  width: 100%;
  padding: 6px 10px 10px;
}

.mobile-menu__head { display: none; }

.mobile-menu__home {
  font-size: 13px;
  color: var(--ink-2);
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--card);
}

.mobile-menu__close {
  border: 0;
  background: none;
  padding: 4px;
  color: var(--ink-2);
  cursor: pointer;
}

.mobile-menu__list { list-style: none; margin: 0; padding: 0; }

.mobile-menu__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}

.mobile-menu__toggle:hover {
  background: var(--card);
  color: var(--ink);
}

.mobile-menu__chevron { color: var(--ink-3); transition: transform .28s ease; flex: none; }
.mobile-menu__item.is-open > .mobile-menu__toggle { color: var(--ink); background: var(--card); }
.mobile-menu__item.is-open > .mobile-menu__toggle .mobile-menu__chevron { transform: rotate(180deg); }

.mobile-menu__sub {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .32s ease;
}

.mobile-menu__item.is-open > .mobile-menu__sub { grid-template-rows: 1fr; }

.mobile-menu__sub-inner {
  overflow: hidden;
  min-height: 0;
  list-style: none;
  margin: 0;
  padding: 0 0 8px 8px;
}

.mobile-menu__sub a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.mobile-menu__sub a:hover {
  background: var(--card);
  color: var(--purple);
}

.mobile-menu__backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 91;
  background: transparent;
}

.mobile-menu__backdrop[hidden] { display: none; }

.mobile-menu__empty {
  margin: 16px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

body.menu-open { overflow: visible; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1000px) {
  .sidebar { display: none; }
}

/* Burger replaces sidebar on tablet/phone; hide on wide catalog pages */
@media (min-width: 1001px) {
  .site-header:not(.site-header--home) .site-header__menu {
    display: none;
  }
}

@media (max-width: 860px) {
  .subjects { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: 1fr; }
  .home-popular .book-grid > :nth-child(n + 6) {
    display: none;
  }
  .footer__body { max-width: 100%; }
  .footer {
    min-height: 480px;
    padding: 28px 22px 210px;
    background: #8b3fc4;
  }
  .footer__title { margin-bottom: 22px; font-size: 20px; }
  .footer__links li { margin-bottom: 15px; }
  .footer__art {
    position: absolute;
    inset: auto 0 0 0;
    width: 100%;
    height: 48%;
    max-width: none;
    margin: 0;
    object-fit: cover;
    object-position: center bottom;
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 32%, #000 100%);
    mask-image: linear-gradient(180deg, transparent 0%, #000 32%, #000 100%);
  }
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .footer {
    background: linear-gradient(180deg, #5a2a86 0%, #7a34a0 52%, #8d4aad 100%);
  }
}

@media (max-width: 700px) {
  .page { padding: 10px 10px 24px; gap: 10px; overflow-x: clip; overflow-y: visible; }
  .surface { padding: 12px 14px 18px; border-radius: 16px; overflow-x: clip; overflow-y: visible; }

  .site-header { min-height: 24px; gap: 6px; }
  .site-header__link {
    height: 24px;
    min-height: 24px;
    font-size: 11px;
    padding: 0 8px;
    border-radius: 7px;
  }
  .site-header__link--desk { display: none; }
  .site-header__link--back {
    white-space: nowrap;
    height: 24px;
    min-height: 24px;
    padding: 0 8px;
    line-height: 1;
    max-width: none;
  }
  .burger,
  .theme-toggle {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    flex-basis: 24px;
    border-radius: 7px;
  }
  .burger { gap: 2px; }
  .burger span { width: 11px; }
  .theme-toggle svg { width: 13px; height: 13px; }
  .site-header__search { display: none; }
  .mobile-search { display: block; position: relative; z-index: 6; margin: 10px 0 8px; }

  .mobile-menu {
    position: fixed;
    inset: 0;
    width: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }
  .mobile-menu[hidden] { display: flex; }
  .mobile-menu__inner {
    max-width: 420px;
    margin: 0 auto;
    padding: 16px 20px 40px;
  }
  .mobile-menu__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  .mobile-menu__backdrop { display: none; }
  body.menu-open { overflow: hidden; }

  .hero {
    z-index: 4;
    margin-top: 8px;
    padding: 18px 16px 20px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 1023 / 1537;
    border-radius: var(--r-md);
    text-align: left;
    overflow: visible;
    clip-path: none;
    -webkit-clip-path: none;
  }
  .hero__text {
    max-width: 100%;
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .hero__title {
    font-size: 21px;
    text-align: left;
  }
  .hero__lead {
    font-size: 11.5px;
    margin-bottom: 14px;
    text-align: left;
  }
  .hero__search {
    max-width: 100%;
    width: 100%;
    margin-bottom: 0;
  }
  .hero__cover img {
    display: block;
    inset: -4px;
    width: calc(100% + 8px);
    height: calc(100% + 8px);
    max-width: none;
    object-fit: cover;
    object-position: center bottom;
  }
  .page-home--subject .hero__cover--light img {
    object-position: center bottom;
  }
  .hero__covers {
    position: absolute;
    inset: 0;
    height: auto;
    margin: 0;
    overflow: hidden;
    border-radius: inherit;
    clip-path: inset(1px round calc(var(--r-md) - 1px));
    -webkit-clip-path: inset(1px round calc(var(--r-md) - 1px));
  }
  .hero::before {
    background: linear-gradient(
      180deg,
      rgba(249, 246, 255, .88) 0%,
      rgba(249, 246, 255, .42) 38%,
      rgba(249, 246, 255, 0) 62%
    );
  }
  .hero::after {
    background: linear-gradient(
      180deg,
      rgba(34, 30, 44, .88) 0%,
      rgba(34, 30, 44, .4) 38%,
      rgba(34, 30, 44, 0) 62%
    );
  }

  .home-grades,
  .home-popular { padding: 14px 14px 12px; }
  .home-grades__title,
  .home-popular__title { font-size: 16px; }
  .home-grades__list { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .subjects { padding: 0; gap: 10px; }
  .empty-panel { padding: 22px 18px; }
  .empty-panel__title { font-size: 18px; }
  .subject-card {
    min-height: 0;
    padding: 16px 14px 14px;
  }
  .subject-card__title { font-size: 14px; margin-bottom: 12px; color: var(--ink); }
  .subject-card__icon-link { width: 44px; height: 44px; top: 14px; right: 14px; }
  .subject-card__grades {
    max-width: calc(100% - 56px);
    gap: 6px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .chip { height: 26px; font-size: 11px; }
  .chip--grade {
    min-height: 26px;
    height: 26px;
    padding: 0 6px;
  }
  .tasks__grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
  .tasks__button--wide { grid-column: span 2; }
  .tasks__button--xl { grid-column: span 3; }

  .page-title, .page-title--task { font-size: 17px; margin: 10px 0 14px; }
  .crumbs { margin-top: 16px; }
  .crumbs__list { font-size: 10.5px; }
  .error-page__card { padding: 24px 18px; min-height: 280px; flex-direction: column; align-items: stretch; }
  .error-page__title { font-size: 24px; }
  .error-page__search { margin: 14px 0 0; }

  .page-title--task + .book-card--wide { display: none; }

  .book-grid,
  .home-popular .book-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .book-card {
    align-items: flex-start;
    padding: 14px 14px 16px;
    gap: 12px;
    overflow: visible;
  }
  .book-card--compact {
    min-height: 0;
    height: auto;
    align-items: flex-start;
    padding: 14px 14px 16px;
  }
  .book-card__cover { flex-basis: 56px; width: 56px; height: 76px; }
  .book-card__meta { font-size: 12px; column-gap: 8px; }
  .book-card__meta > .book-card__extra { display: none; }

  .seo__link {
    padding: 16px 22px;
    min-height: 48px;
    width: fit-content;
    max-width: 100%;
    justify-content: flex-start;
  }

  .solution__panel { padding: 14px 14px 4px; }
  .solution__tabs { padding: 0 10px; }
  .pager { padding: 4px 14px 14px; flex-direction: row; }
  .pager__btn { font-size: 11px; padding: 0 16px; }

  .assistant { padding: 14px; }
  .assistant__form { padding: 3px 3px 3px 12px; }
  .assistant__input,
  .search__input,
  .comments__name,
  .comments__body,
  input,
  textarea,
  select { font-size: 16px; }
  .assistant__input::placeholder { font-size: 13px; }
  .msg { max-width: 90%; }

  .seo { padding: 0; background: none; }
  .seo__inner { padding: 18px 16px; }
  .seo__title { font-size: 16px; }
  .seo__text { font-size: 13.5px; }

  .footer { padding: 28px 20px 220px; }
  .footer__title { font-size: 18px; }
}

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

html[data-theme="dark"] .assistant__send,
html[data-resolved="dark"] .assistant__send,
html[data-theme="dark"] .assistant__jump,
html[data-resolved="dark"] .assistant__jump {
  background: #9b6dff;
  box-shadow: 0 2px 10px rgba(155, 109, 255, .4);
}

html[data-theme="dark"] .assistant__send:hover,
html[data-resolved="dark"] .assistant__send:hover {
  background: #b18bff;
}

html[data-theme="dark"] .comments__send,
html[data-resolved="dark"] .comments__send {
  background: #9b6dff;
}

html[data-theme="dark"] .comments__send:hover,
html[data-resolved="dark"] .comments__send:hover {
  background: #b18bff;
}

html[data-theme="dark"] .cookie-banner__btn:not(.cookie-banner__btn--ghost),
html[data-resolved="dark"] .cookie-banner__btn:not(.cookie-banner__btn--ghost) {
  background: #9b6dff;
}

html[data-theme="dark"] .cookie-banner__btn:not(.cookie-banner__btn--ghost):hover,
html[data-resolved="dark"] .cookie-banner__btn:not(.cookie-banner__btn--ghost):hover {
  background: #b18bff;
}

html[data-theme="dark"] .cookie-banner__btn--ghost,
html[data-resolved="dark"] .cookie-banner__btn--ghost {
  background: var(--card);
  color: var(--purple);
  border-color: var(--line);
  box-shadow: none;
}

html[data-theme="dark"] .cookie-banner__btn--ghost:hover,
html[data-resolved="dark"] .cookie-banner__btn--ghost:hover {
  background: var(--card);
  color: var(--ink);
}

html[data-theme="dark"] .search__suggest,
html[data-theme="dark"] .empty-panel,
html[data-theme="dark"] .solution__panel,
html[data-theme="dark"] .assistant,
html[data-theme="dark"] .assistant__form,
html[data-theme="dark"] .mobile-menu,
html[data-theme="dark"] .sidebar {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

html[data-theme="dark"] .book-card,
html[data-resolved="dark"] .book-card {
  background: var(--card);
  color: var(--ink);
}

html[data-theme="dark"] .subject-card,
html[data-theme="dark"] .assistant__chip,
html[data-theme="dark"] .pager__btn,
html[data-theme="dark"] .seo__link {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink-2);
}

html[data-theme="dark"] .subject-card__title,
html[data-theme="dark"] .seo__link,
html[data-theme="dark"] .assistant__head {
  color: var(--purple);
}

html[data-theme="dark"] .empty-panel {
  background-color: var(--hero-plate);
}

html[data-theme="dark"] .error-page__card {
  background-color: var(--hero-plate);
  color: var(--ink);
}

html[data-theme="dark"] .error-page__eyebrow,
html[data-resolved="dark"] .error-page__eyebrow {
  color: var(--accent-2);
}

html[data-theme="dark"] .error-page__text,
html[data-resolved="dark"] .error-page__text {
  color: var(--ink-2);
}

html[data-theme="dark"] .error-page__btn,
html[data-resolved="dark"] .error-page__btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
}

html[data-theme="dark"] .error-page__btn:hover,
html[data-resolved="dark"] .error-page__btn:hover {
  background: var(--header-link-bg-hover);
  border-color: var(--line);
  color: #fff;
}

html[data-theme="dark"] .error-page__btn--primary,
html[data-resolved="dark"] .error-page__btn--primary {
  background: #9b6dff;
  border-color: #9b6dff;
  color: #fff;
}

html[data-theme="dark"] .error-page__btn--primary:hover,
html[data-resolved="dark"] .error-page__btn--primary:hover {
  background: #b18bff;
  border-color: #b18bff;
  color: #fff;
}

html[data-theme="dark"] .error-page__art {
  display: none;
}

html[data-theme="dark"] .search__suggest a:hover,
html[data-theme="dark"] .chip:hover,
html[data-theme="dark"] .assistant__chip:hover,
html[data-theme="dark"] .msg--bot,
html[data-theme="dark"] .seo__link:hover {
  background: var(--task-ready-bg);
  border-color: var(--task-ready-border);
  color: var(--task-ready-ink);
}

html[data-theme="dark"] .tasks__button.has-scan,
html[data-resolved="dark"] .tasks__button.has-scan {
  background: var(--task-ready-bg);
  border-color: transparent;
  color: var(--task-ready-ink);
}

html[data-theme="dark"] .tasks__button.is-visited,
html[data-resolved="dark"] .tasks__button.is-visited {
  background: var(--task-visited-bg);
  border-color: transparent;
  color: var(--task-visited-ink);
}

html[data-theme="dark"] .tasks__button.has-scan.is-visited,
html[data-resolved="dark"] .tasks__button.has-scan.is-visited,
html[data-theme="dark"] .tasks__button.has-scan.is-visited:hover,
html[data-resolved="dark"] .tasks__button.has-scan.is-visited:hover {
  background: var(--task-visited-ready-bg);
  border-color: transparent;
  color: var(--task-visited-ready-ink);
}

html[data-theme="dark"] .msg--user,
html[data-resolved="dark"] .msg--user {
  background: var(--msg-user-bg);
  color: var(--msg-user-ink);
}

html[data-theme="dark"] .msg--error,
html[data-resolved="dark"] .msg--error {
  background: var(--msg-error-bg);
  color: var(--msg-error-ink);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .search__suggest,
  html[data-theme="auto"] .empty-panel,
  html[data-theme="auto"] .solution__panel,
  html[data-theme="auto"] .assistant,
  html[data-theme="auto"] .assistant__form,
  html[data-theme="auto"] .mobile-menu,
  html[data-theme="auto"] .sidebar {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
  }

  html[data-theme="auto"] .book-card {
    background: var(--card);
    color: var(--ink);
  }

  html[data-theme="auto"] .tasks__button.has-scan {
    background: var(--task-ready-bg);
    border-color: transparent;
    color: var(--task-ready-ink);
  }

  html[data-theme="auto"] .tasks__button.is-visited {
    background: var(--task-visited-bg);
    border-color: transparent;
    color: var(--task-visited-ink);
  }

  html[data-theme="auto"] .tasks__button.has-scan.is-visited,
  html[data-theme="auto"] .tasks__button.has-scan.is-visited:hover {
    background: var(--task-visited-ready-bg);
    border-color: transparent;
    color: var(--task-visited-ready-ink);
  }

  html[data-theme="auto"] .subject-card,
  html[data-theme="auto"] .assistant__chip,
  html[data-theme="auto"] .pager__btn,
  html[data-theme="auto"] .seo__link {
    background: var(--card);
    border-color: var(--line);
    color: var(--ink-2);
  }

  html[data-theme="auto"] .subject-card__title,
  html[data-theme="auto"] .seo__link,
  html[data-theme="auto"] .assistant__head {
    color: var(--purple);
  }

  html[data-theme="auto"] .hero,
  html[data-theme="auto"] .empty-panel {
    background-color: #221e2c;
  }

  html[data-theme="auto"] .error-page__card {
    background-color: var(--hero-plate);
    color: var(--ink);
  }

  html[data-theme="auto"] .error-page__eyebrow {
    color: var(--accent-2);
  }

  html[data-theme="auto"] .error-page__text {
    color: var(--ink-2);
  }

  html[data-theme="auto"] .error-page__btn {
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--ink);
  }

  html[data-theme="auto"] .error-page__btn:hover {
    background: var(--header-link-bg-hover);
    border-color: var(--line);
    color: #fff;
  }

  html[data-theme="auto"] .error-page__btn--primary {
    background: #9b6dff;
    border-color: #9b6dff;
    color: #fff;
  }

  html[data-theme="auto"] .error-page__btn--primary:hover {
    background: #b18bff;
    border-color: #b18bff;
    color: #fff;
  }

  html[data-theme="auto"] .error-page__art {
    display: none;
  }

  html[data-theme="auto"] .footer__art {
    mix-blend-mode: normal;
    opacity: .95;
  }
}

/* ----------------------------------------------------------- scrollbars */
/* Chromium ignores ::-webkit-scrollbar if scrollbar-width/color are set. */

html {
  scrollbar-gutter: stable;
}

::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid var(--scroll-track);
}

::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  }
}

/* ------------------------------------------------------------- lightbox */

.zoom-open { overflow: hidden; }

.zoom {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: rgba(12, 10, 18, .88);
}

.zoom[hidden] { display: none !important; }

.zoom__stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.zoom__stage.is-dragging { cursor: grabbing; }

.zoom__img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}

.zoom__bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px 18px;
}

.zoom__btn {
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #2a2438;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.zoom__btn:hover { background: #3d2e6b; }

.zoom__btn--close {
  min-width: 40px;
  padding: 0;
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}

.book-card__cover-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prose h2 {
  margin: 22px 0 8px;
  font-size: 16px;
  color: var(--ink);
}

.prose ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

@media (max-width: 700px) {
  .site-rail {
    padding: 16px 14px 14px;
    border-radius: 16px;
  }
  .site-rail__card,
  .site-rail__cover {
    flex-basis: 90px;
    width: 90px;
  }
  .site-rail__cover { height: 120px; }
  .site-rail__name { font-size: 12px; }
}

/* --------------------------------------------------------- cookie banner */

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 12000;
  max-width: 560px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}

.cookie-banner[hidden] {
  display: none !important;
}

.cookie-banner.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.cookie-banner__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "ico title actions"
    "ico text actions";
  align-items: center;
  column-gap: 14px;
  row-gap: 4px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(36, 44, 64, .2);
}

.cookie-banner__title {
  grid-area: title;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.cookie-banner__ico {
  grid-area: ico;
  flex: none;
  width: 42px;
  height: 42px;
  align-self: center;
}

.cookie-banner__text {
  grid-area: text;
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
}

.cookie-banner__more {
  color: var(--ink-2);
}

.cookie-banner__link {
  display: inline-block;
  width: fit-content;
  color: var(--purple);
  text-decoration: underline;
  font-size: 13px;
}

.cookie-banner__actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  flex: none;
  gap: 8px;
  min-width: 132px;
  align-self: center;
}

.cookie-banner__btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: #7b41c2;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(123, 65, 194, .28);
  white-space: nowrap;
}

.cookie-banner__btn:hover {
  background: #6935ad;
}

.cookie-banner__btn--ghost {
  background: var(--card);
  color: var(--purple);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 600;
}

.cookie-banner__btn--ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.search__suggest a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.search__thumb {
  flex: none;
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: linear-gradient(140deg, #cfa6e6, #8f6fd6);
}

.search__hit-text {
  min-width: 0;
  line-height: 1.35;
  white-space: normal;
}

.comments {
  --comments-accent: #7b41c2;
  --comments-accent-ink: #ffffff;
  margin: 28px 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.comments__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 28px 40px;
  align-items: start;
}

.comments__title {
  margin: 0 0 22px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.comments__form {
  display: grid;
  justify-items: start;
  gap: 10px;
}

.comments__hp {
  position: absolute;
  left: -9999px;
  height: 0;
  overflow: hidden;
}

.comments__box {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg, var(--card));
}

.comments__name,
.comments__body {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 12px 14px;
}

.comments__name {
  border-bottom: 1px solid var(--line);
}

.comments__name:focus,
.comments__body:focus {
  outline: none;
  background: color-mix(in srgb, var(--comments-accent) 7%, transparent);
}

.comments__body {
  resize: vertical;
  min-height: 92px;
}

.comments__replying,
.comments__status {
  margin: 0;
  font-size: 13px;
}

.comments__replying { color: var(--ink-2); }

.comments__status { color: #b42318; }

.comments__send {
  border: 0;
  border-radius: 999px;
  padding: 10px 26px;
  background: #7b41c2;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.comments__send:hover {
  filter: brightness(1.06);
}

.comments__list,
.comments__replies {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comments__item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 0 0 20px;
  border: 0;
}

.comments__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--comments-accent);
  color: var(--comments-accent-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.comments__main { min-width: 0; }

.comments__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.comments__author {
  font-size: 14px;
  font-weight: 700;
}

.comments__time {
  color: var(--ink-3);
  font-size: 12px;
}

.comments__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.comments__reply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.comments__reply:hover { color: var(--comments-accent); }

.comments__replies {
  grid-column: 1 / -1;
  margin: 10px 0 0 28px;
}

.comments__item--reply { padding-bottom: 12px; }

.comments__empty {
  padding: 4px 0 12px;
  color: var(--ink-3);
  font-size: 14px;
}

@media (max-width: 860px) {
  .comments__grid { grid-template-columns: 1fr; }
  .comments__title { font-size: 24px; margin-bottom: 16px; }
}

.gdz-dialog {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.gdz-dialog[hidden] { display: none !important; }

.gdz-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 20, 36, .46);
}

.gdz-dialog__card {
  position: relative;
  width: min(420px, 100%);
  padding: 20px 20px 16px;
  border-radius: 16px;
  background: var(--gdz-surface, var(--surface, #fff));
  color: var(--gdz-ink, var(--ink, #242c40));
  border: 1px solid var(--gdz-line, var(--line, #e6e6ea));
  box-shadow: 0 18px 40px rgba(20, 16, 32, .18);
}

.gdz-dialog__title {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.3;
}

.gdz-dialog__text {
  margin: 0 0 18px;
  color: var(--gdz-ink-2, var(--ink-2, #545b6b));
  line-height: 1.5;
}

.gdz-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.gdz-dialog__btn {
  border: 1px solid var(--gdz-line, var(--line, #e6e6ea));
  background: transparent;
  color: inherit;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.gdz-dialog__btn--primary {
  border-color: #594299;
  background: #594299;
  color: #fff;
}

.gdz-dialog__btn--danger {
  border-color: #8a4a4a;
  background: #8a4a4a;
  color: #fff;
}

body.gdz-dialog-open { overflow: hidden; }

@media (max-width: 700px) {
  .cookie-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: 420px;
  }
  .cookie-banner__inner {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "title title"
      "ico text"
      "actions actions";
    column-gap: 12px;
    row-gap: 10px;
    padding: 14px 14px 12px;
    border-radius: 18px;
  }
  .cookie-banner__title {
    font-size: 15px;
  }
  .cookie-banner__ico {
    width: 34px;
    height: 34px;
    align-self: start;
    margin-top: 2px;
  }
  .cookie-banner__text {
    font-size: 12.5px;
    gap: 3px;
  }
  .cookie-banner__actions {
    flex-direction: row;
    min-width: 0;
    width: 100%;
    gap: 8px;
  }
  .cookie-banner__btn {
    flex: 1;
    padding: 10px 8px;
    font-size: 12px;
    white-space: normal;
    line-height: 1.25;
  }
}
