:root {
  /* Свадебная палитра (дресс-код 20 ноября) */
  --cabernet: #681D2F;
  --cabernet-hover: #7E243A;
  --rosewater: #E7C6C2;
  --olive: #566045;
  --ivory: #F6F1E9;
  --beige: #E7DCCB;
  --brown: #6C5142;
  --gray: #635D55;
  --espresso: #271C18;
  --black: #14100F;

  /* Семантические токены — светлый альбом */
  --bg: var(--ivory);
  --surface: #EFE7DA;
  --surface-elevated: #FAF6F0;
  --surface-tab: #E8DEC9;
  --text: var(--espresso);
  --text-muted: var(--gray);
  --text-warm: var(--brown);
  --border: rgba(39, 28, 24, 0.12);
  --border-strong: rgba(39, 28, 24, 0.22);
  --accent: var(--cabernet);
  --accent-hover: var(--cabernet-hover);
  --accent-soft: rgba(104, 29, 47, 0.1);
  --accent-text: var(--ivory);
  --secondary-accent: var(--olive);
  --header-scrolled-bg: rgba(246, 241, 233, 0.92);
  --header-scrolled-text: var(--espresso);
  --envelope-flap: #E4D7C3;
  --envelope-body: #FBF7F1;
  --shadow-soft: 0 20px 50px rgba(39, 28, 24, 0.08);
  --shadow-seal: 0 10px 24px rgba(104, 29, 47, 0.34);

  /* Типографика: ровно 2 шрифта и 3 размера ниже hero */
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --text-heading: clamp(1.75rem, 2.7vw, 2.35rem);
  --text-body: 1rem;
  --text-sm: 0.875rem;

  /* Ритм и скругления */
  --container-max: 1320px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #1E1613;
  --surface: #281E1A;
  --surface-elevated: #312420;
  --surface-tab: #2D211D;
  --text: var(--ivory);
  --text-muted: #C8BCB0;
  --text-warm: var(--rosewater);
  --border: rgba(246, 241, 233, 0.13);
  --border-strong: rgba(246, 241, 233, 0.24);
  --accent: #8C2B42;
  --accent-hover: #A1334E;
  --accent-soft: rgba(231, 198, 194, 0.14);
  --accent-text: var(--ivory);
  --secondary-accent: #8A9674;
  --header-scrolled-bg: rgba(30, 22, 19, 0.92);
  --header-scrolled-text: var(--ivory);
  --envelope-flap: #352722;
  --envelope-body: #2A1F1B;
  --shadow-soft: 0 24px 56px rgba(0, 0, 0, 0.38);
  --shadow-seal: 0 10px 26px rgba(0, 0, 0, 0.45);
}

/* 9 живых атмосфер по оттенкам дресс-кода */
[data-palette="cabernet"] {
  --bg: #F6ECEE;
  --surface: #EDDCDF;
  --surface-elevated: #FBF5F6;
  --surface-tab: #E7D4D8;
  --accent: #681D2F;
  --accent-hover: #7E243A;
  --header-scrolled-bg: rgba(246, 236, 238, 0.93);
  --envelope-flap: #E5CDD2;
  --envelope-body: #FAF3F4;
}

[data-palette="rosewater"] {
  --bg: #FAF1F0;
  --surface: #F2E2E0;
  --surface-elevated: #FFF8F7;
  --surface-tab: #EED9D6;
  --accent: #914452;
  --accent-hover: #A45261;
  --text-warm: #7E414C;
  --header-scrolled-bg: rgba(250, 241, 240, 0.93);
  --envelope-flap: #EED4D0;
  --envelope-body: #FDF7F6;
}

[data-palette="olive"] {
  --bg: #F3F4EE;
  --surface: #E6E8DC;
  --surface-elevated: #F9FAF6;
  --surface-tab: #DFE3D3;
  --accent: #4E593E;
  --accent-hover: #5E6B4C;
  --text-warm: #4E593E;
  --header-scrolled-bg: rgba(243, 244, 238, 0.93);
  --envelope-flap: #DCE1D0;
  --envelope-body: #F8F9F4;
}

[data-palette="ivory"] {
  --bg: #FAF8F3;
  --surface: #F0ECE3;
  --surface-elevated: #FFFFFF;
  --surface-tab: #EAE4D8;
  --accent: #5C493E;
  --accent-hover: #70594C;
  --header-scrolled-bg: rgba(250, 248, 243, 0.94);
  --envelope-flap: #EBE4D8;
  --envelope-body: #FFFFFF;
}

[data-palette="beige"] {
  --bg: #F1E8DA;
  --surface: #E5D8C3;
  --surface-elevated: #F8F2E7;
  --surface-tab: #E0D1B9;
  --accent: #6C5142;
  --accent-hover: #7F604F;
  --header-scrolled-bg: rgba(241, 232, 218, 0.93);
  --envelope-flap: #DFCFAF;
  --envelope-body: #F7F0E5;
}

[data-palette="brown"] {
  --bg: #F3EAE2;
  --surface: #E6D6C8;
  --surface-elevated: #FAF4EE;
  --surface-tab: #E1CEBD;
  --accent: #6A4837;
  --accent-hover: #7E5643;
  --header-scrolled-bg: rgba(243, 234, 226, 0.93);
  --envelope-flap: #DFCBB9;
  --envelope-body: #F9F2EB;
}

[data-palette="gray"] {
  --bg: #F1F0EE;
  --surface: #E4E2DE;
  --surface-elevated: #FAF9F7;
  --surface-tab: #DDDAD5;
  --text: #22201E;
  --text-muted: #5C5853;
  --text-warm: #4D4945;
  --accent: #4C4844;
  --accent-hover: #605B56;
  --header-scrolled-bg: rgba(241, 240, 238, 0.93);
  --envelope-flap: #DCD9D4;
  --envelope-body: #F9F8F6;
}

[data-palette="espresso"] {
  --bg: #221814;
  --surface: #2E211C;
  --surface-elevated: #382822;
  --surface-tab: #31231D;
  --text: var(--ivory);
  --text-muted: #CBBFB3;
  --text-warm: var(--rosewater);
  --border: rgba(246, 241, 233, 0.14);
  --border-strong: rgba(246, 241, 233, 0.25);
  --accent: #8C2B42;
  --accent-hover: #A1334E;
  --header-scrolled-bg: rgba(34, 24, 20, 0.93);
  --header-scrolled-text: var(--ivory);
  --envelope-flap: #3A2A24;
  --envelope-body: #2C1F1A;
  --shadow-soft: 0 24px 56px rgba(0, 0, 0, 0.42);
}

[data-palette="black"] {
  --bg: #131110;
  --surface: #1E1B1A;
  --surface-elevated: #282422;
  --surface-tab: #221E1D;
  --text: var(--ivory);
  --text-muted: #C2BAB2;
  --text-warm: var(--rosewater);
  --border: rgba(246, 241, 233, 0.14);
  --border-strong: rgba(246, 241, 233, 0.26);
  --accent: #7A2338;
  --accent-hover: #922B44;
  --header-scrolled-bg: rgba(19, 17, 16, 0.94);
  --header-scrolled-text: var(--ivory);
  --envelope-flap: #2A2523;
  --envelope-body: #1E1A19;
  --shadow-soft: 0 24px 56px rgba(0, 0, 0, 0.5);
}

/* Тёмная тема поверх выбранного светлого акцента сохраняет тёмный фон */
[data-theme="dark"][data-palette="cabernet"] {
  --bg: #221418;
  --surface: #2F1C21;
  --surface-elevated: #3B232A;
  --surface-tab: #331F25;
  --accent: #9A3049;
  --accent-hover: #B03A56;
  --header-scrolled-bg: rgba(34, 20, 24, 0.93);
  --envelope-flap: #3E252C;
  --envelope-body: #2D1B20;
}

[data-theme="dark"][data-palette="olive"] {
  --bg: #1A1D16;
  --surface: #24281F;
  --surface-elevated: #2E3327;
  --surface-tab: #272B21;
  --accent: #6A7855;
  --accent-hover: #7B8B63;
  --header-scrolled-bg: rgba(26, 29, 22, 0.93);
  --envelope-flap: #31372A;
  --envelope-body: #23271E;
}

[data-theme="dark"][data-palette="rosewater"] {
  --bg: #24191A;
  --surface: #312324;
  --surface-elevated: #3C2B2D;
  --surface-tab: #342527;
  --accent: #A95A68;
  --accent-hover: #BE6B7A;
  --header-scrolled-bg: rgba(36, 25, 26, 0.93);
  --envelope-flap: #3F2E30;
  --envelope-body: #2F2123;
}

[data-theme="dark"][data-palette="gray"] {
  --bg: #1B1A19;
  --surface: #262523;
  --surface-elevated: #312F2C;
  --surface-tab: #292725;
  --text: var(--ivory);
  --text-muted: #C2BDB7;
  --text-warm: #E0DBD4;
  --accent: #6E6963;
  --accent-hover: #817B74;
  --header-scrolled-bg: rgba(27, 26, 25, 0.93);
  --envelope-flap: #33312E;
  --envelope-body: #252422;
}

[data-theme="dark"][data-palette="ivory"],
[data-theme="dark"][data-palette="beige"],
[data-theme="dark"][data-palette="brown"] {
  --bg: #1E1613;
  --surface: #281E1A;
  --surface-elevated: #312420;
  --surface-tab: #2D211D;
  --text: var(--ivory);
  --text-muted: #C8BCB0;
  --text-warm: var(--rosewater);
  --header-scrolled-bg: rgba(30, 22, 19, 0.92);
  --envelope-flap: #352722;
  --envelope-body: #2A1F1B;
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 220ms var(--ease-out), color 220ms var(--ease-out);
}

body.lightbox-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button,
a {
  color: inherit;
  font-family: inherit;
}

button {
  cursor: pointer;
}

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

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: clamp(1rem, 3.2vw, 2.5rem);
}

/* ==========================================================================
   Навигация — одна компактная строка, прозрачная поверх hero
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  color: var(--ivory);
  border-bottom: 1px solid transparent;
  transition: background-color 200ms var(--ease-out),
    color 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    backdrop-filter 200ms var(--ease-out);
}

.site-header.is-scrolled {
  background-color: var(--header-scrolled-bg);
  color: var(--header-scrolled-text);
  border-bottom-color: var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0.95rem clamp(1rem, 3.2vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand-wordmark {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 1.9vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.75rem);
}

.nav-link {
  background: none;
  border: none;
  padding: 0.25rem 0;
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 160ms var(--ease-out), color 160ms var(--ease-out);
}

.nav-link:hover {
  opacity: 1;
}

.fav-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--rosewater);
}

.site-header.is-scrolled .fav-count {
  color: var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
}

.theme-switch {
  background: none;
  border: none;
  padding: 0.25rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}

.theme-switch-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid currentColor;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  opacity: 0.85;
  transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.theme-switch-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: currentColor;
  transition: transform 200ms var(--ease-out);
}

[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(16px);
}

/* ==========================================================================
   Полноэкранная обложка (Hero bleeding to y = 0)
   ========================================================================== */
.hero {
  position: relative;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background-color: var(--espresso);
}

.hero-media {
  position: absolute;
  inset: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 56% 24%;
  opacity: 0;
  transition: opacity 420ms var(--ease-out);
}

.hero-media img.is-loaded {
  opacity: 1;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to bottom,
      rgba(20, 16, 15, 0.42) 0%,
      rgba(20, 16, 15, 0.08) 28%,
      rgba(20, 16, 15, 0.24) 58%,
      rgba(20, 16, 15, 0.82) 100%
    );
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--container-max);
  padding: 0 clamp(1.25rem, 3.2vw, 2.5rem) clamp(3rem, 7vh, 5.25rem);
  text-align: center;
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.1rem, 7.6vw, 6.4rem);
  font-weight: 500;
  line-height: 0.94;
  letter-spacing: -0.025em;
  color: var(--ivory);
  text-shadow: 0 8px 32px rgba(20, 16, 15, 0.35);
}

.hero-subtitle {
  margin: 1.15rem 0 2rem;
  font-size: var(--text-body);
  font-weight: 400;
  max-width: 44ch;
  color: rgba(246, 241, 233, 0.92);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.85rem;
  border: none;
  border-radius: 999px;
  background-color: var(--accent);
  color: var(--accent-text);
  font-size: var(--text-body);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.text-action {
  background: none;
  border: none;
  padding: 0.4rem 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--border-strong);
  transition: color 160ms var(--ease-out), text-decoration-color 160ms var(--ease-out);
}

.text-action:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* ==========================================================================
   Интерактивный конверт и памятный триптих
   ========================================================================== */
.letter-section {
  padding: clamp(4rem, 8vw, 6.75rem) 0 clamp(3rem, 6vw, 5rem);
  border-bottom: 1px solid var(--border);
}

.letter-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(2rem, 4.5vw, 4.25rem);
  align-items: center;
}

.envelope-card {
  position: relative;
  border-radius: var(--radius-lg);
  background-color: var(--envelope-body);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: background-color 220ms var(--ease-out), border-color 220ms var(--ease-out);
}

.envelope-closed-view {
  position: relative;
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(2.25rem, 4vw, 3.5rem);
  text-align: center;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 46%;
  background-color: var(--envelope-flap);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-bottom: 1px solid var(--border);
  opacity: 0.85;
  transition: transform 360ms var(--ease-out), opacity 280ms var(--ease-out);
  transform-origin: top center;
}

.envelope-front {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.envelope-address {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 500;
  line-height: 1.15;
  color: var(--text);
}

.envelope-date {
  margin: 0 0 1.65rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.wax-seal-btn {
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  color: var(--accent);
  transition: color 220ms var(--ease-out);
}

.wax-seal {
  position: relative;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 10px 18px rgba(104, 29, 47, 0.32));
  transition: transform 220ms var(--ease-out), filter 220ms var(--ease-out);
}

.wax-seal-btn:hover .wax-seal {
  transform: scale(1.05) rotate(-3deg);
  filter: drop-shadow(0 14px 22px rgba(104, 29, 47, 0.42));
}

.wax-seal-monogram {
  position: absolute;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ivory);
  user-select: none;
}

.wax-seal-hint {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-warm);
}

/* Раскрытое письмо */
.letter-paper {
  display: none;
  padding: clamp(2.25rem, 4.5vw, 3.75rem);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}

.envelope-card[data-open="true"] .envelope-closed-view {
  display: none;
}

.envelope-card[data-open="true"] .letter-paper {
  display: block;
}

.envelope-card[data-open="true"].is-revealed .letter-paper {
  opacity: 1;
  transform: translateY(0);
}

.section-heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--text);
}

.letter-heading {
  margin-bottom: 1.5rem;
}

.letter-body {
  max-width: 56ch;
}

.letter-body p {
  margin: 0 0 1.15rem;
  font-size: var(--text-body);
  color: var(--text);
}

.letter-body p:last-child {
  margin-bottom: 0;
}

.letter-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.letter-signature {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--text-warm);
}

/* Триптих знаковых кадров */
.triptych-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: stretch;
}

.triptych-item {
  margin: 0;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--surface);
  cursor: pointer;
}

.triptych-item:first-child {
  grid-row: span 2;
  aspect-ratio: 2 / 3;
}

.triptych-item:not(:first-child) {
  aspect-ratio: 4 / 3;
}

.triptych-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  transition: transform 280ms var(--ease-out);
}

.triptych-item:first-child img {
  object-position: center 6%;
}

.triptych-item:hover img {
  transform: scale(1.035);
}

.triptych-caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 2rem 0.95rem 0.75rem;
  font-size: var(--text-sm);
  color: var(--ivory);
  background: linear-gradient(to top, rgba(20, 16, 15, 0.78), rgba(20, 16, 15, 0));
}

/* ==========================================================================
   Галерея и вкладки глав
   ========================================================================== */
.gallery-section {
  padding: clamp(3.5rem, 6vw, 5.5rem) 0 clamp(4rem, 7vw, 6rem);
}

.gallery-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.gallery-header-copy {
  max-width: 60ch;
}

.section-description {
  margin: 0.55rem 0 0;
  font-size: var(--text-body);
  color: var(--text-muted);
}

.gallery-counter {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Связанный сегментированный контрол выбора глав + интерактивная палитра */
.chapter-bar-wrap {
  position: sticky;
  top: 60px;
  z-index: 25;
  margin-bottom: 1.75rem;
  padding: 0.65rem 0;
  background-color: var(--bg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  transition: background-color 220ms var(--ease-out);
}

.palette-filter-bar {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.palette-filter-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.palette-swatches {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.palette-swatch-btn {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background-color: var(--swatch-hex);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transition: transform 160ms var(--ease-out), box-shadow 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.palette-swatch-btn:hover {
  transform: scale(1.16);
}

.palette-swatch-btn[aria-checked="true"] {
  transform: scale(1.18);
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}

.palette-reset-btn {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease-out), color 160ms var(--ease-out);
}

.palette-reset-btn.is-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.chapter-tabs {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  padding: 4px;
  border-radius: var(--radius-md);
  background-color: var(--surface-tab);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chapter-tabs::-webkit-scrollbar {
  display: none;
}

.chapter-tab {
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 3px);
  padding: 0.55rem 1rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: background-color 170ms var(--ease-out), color 170ms var(--ease-out);
}

.chapter-tab:hover {
  color: var(--text);
}

.chapter-tab[aria-selected="true"] {
  background-color: var(--surface-elevated);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(39, 28, 24, 0.08);
}

.chapter-tab-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.72;
}

.chapter-tab[data-chapter="favorites"][aria-selected="true"] {
  background-color: var(--accent);
  color: var(--accent-text);
}

.chapter-tab[data-chapter="favorites"][aria-selected="true"] .chapter-tab-count {
  opacity: 0.9;
}

/* Панель "Мой конверт" */
.favorites-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding: 1.15rem 1.4rem;
  margin-bottom: 1.75rem;
  border-radius: var(--radius-md);
  background-color: var(--surface);
  border: 1px solid var(--border);
}

.favorites-toolbar[hidden] {
  display: none;
}

.favorites-toolbar-text {
  margin: 0;
  font-size: var(--text-body);
  color: var(--text);
}

.favorites-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.4rem;
}

.empty-favorites {
  padding: 4rem 1.5rem;
  text-align: center;
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  border: 1px solid var(--border);
}

.empty-favorites[hidden] {
  display: none;
}

.empty-favorites-title {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 500;
}

.empty-favorites-text {
  margin: 0 auto 1.6rem;
  max-width: 48ch;
  color: var(--text-muted);
}

/* Портретно-ориентированная журнальная сетка */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
}

.photo-card {
  position: relative;
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--surface);
  aspect-ratio: 2 / 3;
}

.photo-card.is-landscape {
  grid-column: span 2;
  aspect-ratio: 3 / 2;
}

.photo-trigger {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  opacity: 0;
  transform: scale(1.01);
  transition: opacity 280ms var(--ease-out), transform 240ms var(--ease-out);
}

.photo-card img.is-loaded {
  opacity: 1;
  transform: scale(1);
}

.photo-card:hover img.is-loaded {
  transform: scale(1.028);
}

.photo-fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background-color: rgba(20, 16, 15, 0.46);
  color: var(--ivory);
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 160ms var(--ease-out),
    transform 160ms var(--ease-out),
    background-color 160ms var(--ease-out);
}

.photo-card:hover .photo-fav-btn,
.photo-card:focus-within .photo-fav-btn,
.photo-fav-btn[aria-pressed="true"] {
  opacity: 1;
  transform: scale(1);
}

.photo-fav-btn[aria-pressed="true"] {
  background-color: var(--accent);
  color: var(--accent-text);
}

.photo-fav-btn[aria-pressed="true"] svg {
  fill: currentColor;
}

.photo-fav-btn:hover {
  background-color: var(--accent-hover);
}

.load-more-wrap {
  margin-top: 2.5rem;
  text-align: center;
}

.load-more-wrap[hidden] {
  display: none;
}

.load-sentinel {
  height: 1px;
}

/* ==========================================================================
   Секция оригиналов Google Фото и Футер
   ========================================================================== */
.originals-section {
  padding: clamp(4rem, 7vw, 6rem) 0;
  background-color: var(--espresso);
  color: var(--ivory);
}

[data-theme="dark"] .originals-section {
  background-color: #16100E;
  border-top: 1px solid var(--border);
}

.originals-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.originals-heading {
  color: var(--ivory);
}

.originals-text {
  margin: 0.9rem 0 2rem;
  max-width: 54ch;
  color: rgba(246, 241, 233, 0.84);
}

.btn-originals {
  background-color: var(--accent);
  color: var(--accent-text);
}

.btn-originals:hover {
  background-color: var(--accent-hover);
}

.site-footer {
  padding: 2.5rem 0 3rem;
  background-color: var(--black);
  color: rgba(246, 241, 233, 0.85);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 2.5rem;
}

.footer-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ivory);
}

.footer-meta {
  margin: 0.25rem 0 0;
  font-size: var(--text-sm);
  color: rgba(246, 241, 233, 0.65);
}

.footer-top-link {
  font-size: var(--text-sm);
  font-weight: 500;
  color: rgba(246, 241, 233, 0.78);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(246, 241, 233, 0.28);
  transition: color 160ms var(--ease-out), text-decoration-color 160ms var(--ease-out);
}

.footer-top-link:hover {
  color: var(--ivory);
  text-decoration-color: currentColor;
}

/* ==========================================================================
   Кинозал (Полноэкранный просмотрщик Lightbox)
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: var(--black);
  color: var(--ivory);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.lightbox[hidden] {
  display: none;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox-topbar,
.lightbox-bottombar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 3vw, 2rem);
}

.lightbox-meta {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  min-width: 0;
}

.lightbox-counter {
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lightbox-chapter {
  font-size: var(--text-sm);
  color: rgba(246, 241, 233, 0.68);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.lb-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(246, 241, 233, 0.16);
  background-color: rgba(246, 241, 233, 0.06);
  color: var(--ivory);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.lb-icon-btn:hover {
  background-color: rgba(246, 241, 233, 0.14);
}

.lb-icon-btn[aria-pressed="true"] {
  background-color: var(--cabernet);
  border-color: var(--cabernet);
}

.lb-icon-btn[aria-pressed="true"] svg {
  fill: currentColor;
}

.lb-close-btn {
  padding: 0.5rem;
}

.lightbox-progress {
  height: 2px;
  width: 100%;
  background-color: rgba(246, 241, 233, 0.12);
  overflow: hidden;
}

.lightbox-progress[hidden] {
  display: none;
}

.lightbox-progress-bar {
  height: 100%;
  width: 0%;
  background-color: var(--rosewater);
}

.lightbox-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem clamp(3.5rem, 6vw, 5.5rem);
  user-select: none;
}

.lightbox-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-figure img {
  max-width: 100%;
  max-height: calc(100dvh - 132px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(246, 241, 233, 0.18);
  background-color: rgba(20, 16, 15, 0.55);
  color: var(--ivory);
  display: grid;
  place-items: center;
  transition: background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.lb-nav:hover {
  background-color: rgba(104, 29, 47, 0.85);
}

.lb-prev {
  left: clamp(0.75rem, 2vw, 1.5rem);
}

.lb-next {
  right: clamp(0.75rem, 2vw, 1.5rem);
}

.lightbox-bottombar {
  font-size: var(--text-sm);
  color: rgba(246, 241, 233, 0.65);
}

.lightbox-filename {
  font-variant-numeric: tabular-nums;
}

.lightbox-gphotos {
  color: var(--rosewater);
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 160ms var(--ease-out);
}

.lightbox-gphotos:hover {
  color: var(--ivory);
}

/* Уведомление */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 120;
  transform: translateX(-50%) translateY(12px);
  padding: 0.75rem 1.35rem;
  border-radius: 999px;
  background-color: var(--espresso);
  color: var(--ivory);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: 0 14px 36px rgba(20, 16, 15, 0.35);
  border: 1px solid rgba(246, 241, 233, 0.16);
  opacity: 0;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}

.toast[hidden] {
  display: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Адаптивность (планшеты и телефоны 390px)
   ========================================================================== */
@media (max-width: 1099px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .letter-stage {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .header-inner {
    gap: 0.75rem;
    padding-block: 0.8rem;
  }

  .header-nav {
    gap: 0.8rem;
  }

  .nav-originals,
  .theme-switch-label {
    display: none;
  }

  .hero-media img {
    object-position: 62% 22%;
  }

  .envelope-closed-view {
    min-height: 360px;
  }

  .triptych-column {
    grid-template-columns: 1fr 1fr;
  }

  .triptych-item:first-child {
    grid-row: auto;
    grid-column: span 2;
    aspect-ratio: 4 / 5;
  }

  .triptych-item:not(:first-child) {
    aspect-ratio: 2 / 3;
  }

  .gallery-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .chapter-bar-wrap {
    top: 52px;
    gap: 0.6rem;
  }

  .palette-filter-bar {
    width: 100%;
    justify-content: flex-start;
  }

  .palette-swatch-btn {
    width: 26px;
    height: 26px;
  }

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

  /* На сенсорных экранах сердечко всегда аккуратно видно */
  .photo-fav-btn {
    opacity: 0.92;
    transform: scale(1);
    width: 34px;
    height: 34px;
  }

  .lb-btn-label {
    display: none;
  }

  .lightbox-stage {
    padding: 0.5rem 0.75rem;
  }

  .lb-nav {
    width: 40px;
    height: 40px;
    background-color: rgba(20, 16, 15, 0.72);
  }

  .palette-tribute {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .header-inner {
    gap: 0.6rem;
  }

  .brand-wordmark {
    font-size: 1.2rem;
  }

  .header-nav a[href="#letter-section"],
  .header-nav a[href="#gallery-section"],
  .header-nav a[href="quiz.html"],
  .header-nav a[href="#leaderboard-section"] {
    display: none;
  }
}

/* ==========================================================================
   Блок-анонс конкурса на главной странице
   ========================================================================== */
.quiz-teaser-section {
  padding: clamp(3rem, 6vw, 4.75rem) 0;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background-color 220ms var(--ease-out);
}

.quiz-teaser-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
}

.quiz-teaser-copy {
  max-width: 58ch;
}

.quiz-teaser-cta {
  margin-top: 1.65rem;
}

.quiz-teaser-fan {
  position: relative;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.fan-sheet {
  position: absolute;
  width: 170px;
  aspect-ratio: 960 / 1360;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
  transition: transform 240ms var(--ease-out);
}

.fan-sheet-1 {
  transform: translateX(-82px) rotate(-8deg);
  z-index: 1;
}

.fan-sheet-2 {
  transform: translateY(-6px) rotate(1deg);
  z-index: 3;
}

.fan-sheet-3 {
  transform: translateX(82px) rotate(8deg);
  z-index: 2;
}

.quiz-teaser-fan:hover .fan-sheet-1 {
  transform: translateX(-96px) rotate(-11deg) translateY(-4px);
}

.quiz-teaser-fan:hover .fan-sheet-2 {
  transform: translateY(-14px) scale(1.03);
}

.quiz-teaser-fan:hover .fan-sheet-3 {
  transform: translateX(96px) rotate(11deg) translateY(-4px);
}

/* ==========================================================================
   Страница итогов конкурса (quiz.html)
   ========================================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.quiz-main {
  padding-top: 76px;
}

.quiz-hero {
  padding: clamp(2.75rem, 6vw, 5rem) 0 clamp(3rem, 6vw, 4.5rem);
  border-bottom: 1px solid var(--border);
}

.quiz-hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.quiz-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 6.2vw, 5rem);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.025em;
  color: var(--text);
}

.quiz-lead {
  margin: 1rem 0 2.5rem;
  max-width: 56ch;
  color: var(--text-muted);
}

.winner-stage {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  background-color: var(--envelope-body);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: clamp(2.25rem, 5vw, 3.75rem) clamp(1.25rem, 4vw, 3rem);
  overflow: hidden;
  transition: background-color 220ms var(--ease-out), border-color 220ms var(--ease-out);
}

.petal-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.winner-sealed {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.winner-sealed[hidden],
.winner-revealed[hidden] {
  display: none;
}

.winner-sealed-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 500;
  color: var(--text);
}

.winner-sealed-sub {
  margin: 0.5rem 0 2rem;
  color: var(--text-muted);
}

.winner-reveal-btn {
  gap: 1.4rem;
}

.winner-revealed {
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 280ms var(--ease-out), transform 280ms var(--ease-out);
}

.winner-stage.is-revealed .winner-revealed {
  opacity: 1;
  transform: translateY(0);
}

.winner-heading {
  margin-bottom: 0.5rem;
}

.winner-sub {
  margin: 0 0 2.25rem;
  color: var(--text-muted);
}

.winners-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  text-align: left;
}

.winner-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  padding: 1.15rem;
  border-radius: var(--radius-md);
  background-color: var(--surface);
  border: 1px solid var(--border);
}

.winner-card-thumb {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
}

.winner-card-thumb img {
  width: 100%;
  aspect-ratio: 960 / 1360;
  object-fit: cover;
  transition: transform 220ms var(--ease-out);
}

.winner-card-thumb:hover img {
  transform: scale(1.03);
}

.winner-card-place {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
}

.winner-card-name {
  margin: 0.2rem 0 0.3rem;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 500;
  line-height: 1.1;
}

.winner-card-score {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.winner-card-blocks {
  margin: 0.45rem 0 0.8rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.runners-up {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}

.runners-up-text {
  margin: 0;
  color: var(--text-muted);
}

.runner-link {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color 160ms var(--ease-out);
}

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

/* Почётная открытка от бабушки Тани */
.special-note-section {
  padding: clamp(3rem, 6vw, 4.75rem) 0;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
}

.special-note-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(2rem, 4.5vw, 4.25rem);
  align-items: center;
}

.special-note-quote {
  margin: 1.25rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  line-height: 1.35;
  color: var(--text);
}

.special-note-sheet-btn {
  display: block;
  margin-inline: auto;
  max-width: 300px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: none;
  box-shadow: var(--shadow-soft);
  transition: transform 220ms var(--ease-out);
}

.special-note-sheet-btn:hover {
  transform: translateY(-3px);
}

.special-note-sheet-btn img {
  width: 100%;
  aspect-ratio: 960 / 1360;
  object-fit: cover;
}

/* Полный рейтинг и все 25 анкет */
.leaderboard-section {
  padding: clamp(3.5rem, 6vw, 5.5rem) 0;
  border-bottom: 1px solid var(--border);
}

.leaderboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2.25rem;
}

.leaderboard-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.search-input {
  width: 220px;
  padding: 0.58rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: var(--surface-elevated);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  transition: border-color 160ms var(--ease-out);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.guest-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface-elevated);
  overflow: hidden;
  transition: transform 200ms var(--ease-out), border-color 200ms var(--ease-out);
}

.guest-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}

.guest-card.is-winner {
  border-color: var(--accent);
}

.guest-card-scan {
  width: 100%;
  aspect-ratio: 960 / 1360;
  background-color: var(--surface);
  overflow: hidden;
}

.guest-card-scan img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms var(--ease-out);
}

.guest-card:hover .guest-card-scan img {
  transform: scale(1.025);
}

.guest-card-meta {
  padding: 0.85rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.guest-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.guest-card-rank {
  color: var(--text-muted);
}

.guest-card.is-winner .guest-card-rank {
  color: var(--accent);
  font-weight: 600;
}

.guest-card-score {
  font-weight: 600;
  color: var(--text);
}

.guest-card-name {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.guest-score-bar {
  margin-top: 0.35rem;
  height: 4px;
  border-radius: 999px;
  background-color: var(--surface-tab);
  overflow: hidden;
}

.guest-score-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background-color: var(--secondary-accent);
}

.guest-card.is-winner .guest-score-fill {
  background-color: var(--accent);
}

.quiz-empty-search {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
}

.quiz-empty-search[hidden] {
  display: none;
}

/* Блок правильных ответов */
.answers-section {
  padding: clamp(3.5rem, 6vw, 5.5rem) 0;
}

.answers-header {
  max-width: 64ch;
  margin-bottom: 2.25rem;
}

.answers-blocks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
}

.answers-block-title {
  margin: 0 0 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-strong);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
}

.answer-key-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.answer-key-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.answer-key-q {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.answer-key-a {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--text);
}

/* Модальный инспектор анкеты (Скан + 16 вопросов) */
.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2.5vw, 1.75rem);
  opacity: 0;
  transition: opacity 190ms var(--ease-out);
}

.sheet-modal[hidden] {
  display: none;
}

.sheet-modal.is-open {
  opacity: 1;
}

.sheet-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(20, 16, 15, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sheet-modal-panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1160px;
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background-color: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.sheet-modal-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
}

.sheet-modal-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 500;
  line-height: 1.1;
}

.sheet-modal-meta {
  margin: 0.2rem 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sheet-modal-nav {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.modal-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background-color: var(--surface-elevated);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.modal-btn:hover {
  border-color: var(--accent);
}

.modal-btn[hidden] {
  display: none;
}

.sheet-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  overflow: hidden;
}

.sheet-scan-pane {
  background-color: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
}

.sheet-scan-pane img {
  max-width: 100%;
  max-height: calc(100dvh - 130px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

.sheet-breakdown-pane {
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.75rem;
}

.breakdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.breakdown-item {
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  border-left: 3px solid var(--border-strong);
}

.breakdown-item.is-correct {
  border-left-color: var(--secondary-accent);
}

.breakdown-item.is-partial {
  border-left-color: var(--brown);
}

.breakdown-item.is-wrong {
  border-left-color: var(--accent);
}

.breakdown-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.breakdown-q {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breakdown-pts {
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.breakdown-item.is-correct .breakdown-pts {
  color: var(--secondary-accent);
}

.breakdown-item.is-wrong .breakdown-pts {
  color: var(--accent);
}

.breakdown-answers {
  margin-top: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
  font-size: var(--text-body);
}

.breakdown-correct {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breakdown-special-text {
  padding: 1.5rem 0.5rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.65rem;
  line-height: 1.4;
  color: var(--text);
}

@media (max-width: 1120px) {
  .quiz-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .quiz-teaser-inner,
  .special-note-inner,
  .winners-grid,
  .answers-blocks {
    grid-template-columns: 1fr;
  }

  .quiz-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sheet-modal-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .sheet-scan-pane {
    overflow: visible;
  }

  .sheet-scan-pane img {
    max-height: 62dvh;
  }

  .sheet-breakdown-pane {
    overflow: visible;
  }
}

@media (max-width: 600px) {
  .quiz-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .quiz-teaser-fan {
    height: 220px;
  }

  .fan-sheet {
    width: 126px;
  }

  .fan-sheet-1 {
    transform: translateX(-62px) rotate(-8deg);
  }

  .fan-sheet-3 {
    transform: translateX(62px) rotate(8deg);
  }

  .winner-card {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 0.9rem;
  }

  .search-input {
    width: 100%;
  }

  .leaderboard-controls {
    width: 100%;
  }

  .search-field {
    flex: 1 1 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
