:root {
  color-scheme: light;
  --color-page-bg: #f5f2ed;
  --color-text-primary: #292524;
  --color-text-body: #44403c;
  --color-text-muted: #78716c;
  --color-header-bg: #ffffff;
  --color-header-border: rgba(231, 229, 228, 0.85);
  --color-card: #ffffff;
  --color-panel-warm: #ebe6df;
  --color-media-placeholder: #f5f5f4;
  --color-media-placeholder-2: #e7e5e4;
  --color-nav-muted: #57534e;
  --color-nav-hover: #f5f5f4;
  --color-heading: #705a3e;
  --color-brand: #8b6d4d;
  --color-footer-bg: #8b6d4d;
  --color-footer-text: #ffffff;
  --color-footer-link-subtle: rgba(255, 255, 255, 0.88);
  --shadow-card: 0 10px 15px -3px rgba(28, 25, 23, 0.06);
  --hero-gradient-bottom: #f5f2ed;
  --color-radio-player-bg: rgba(255, 255, 255, 0.92);
  --color-radio-border: #eeeeee;
  --color-radio-heading: #2c3e50;
  --color-radio-text: #444444;
  --color-radio-muted: #555555;
  --theme-toggle-bg: #f5f5f4;
  --theme-toggle-bg-hover: #e7e5e4;
  --theme-toggle-icon: #57534e;
}

/* Уютная тёмная тема: тёплый графит / тёмный коричневый */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-page-bg: #2a2622;
  --color-text-primary: #e8e4dc;
  --color-text-body: #d6d1c7;
  --color-text-muted: #a89f94;
  --color-header-bg: #332e29;
  --color-header-border: rgba(90, 83, 76, 0.45);
  --color-card: #3a342f;
  --color-panel-warm: #35302b;
  --color-media-placeholder: #2f2a26;
  --color-media-placeholder-2: #4a423a;
  --color-nav-muted: #c9c2b8;
  --color-nav-hover: #443d36;
  --color-heading: #d4b896;
  --color-brand: #c4a574;
  --color-footer-bg: #524636;
  --color-footer-text: #faf8f4;
  --color-footer-link-subtle: rgba(250, 248, 244, 0.88);
  --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.35);
  --hero-gradient-bottom: #2a2622;
  --color-radio-player-bg: rgba(58, 52, 47, 0.96);
  --color-radio-border: #4a423a;
  --color-radio-heading: #e8e4dc;
  --color-radio-text: #d6d1c7;
  --color-radio-muted: #a89f94;
  --theme-toggle-bg: #443d36;
  --theme-toggle-bg-hover: #4f4740;
  --theme-toggle-icon: #e8e4dc;
}

.theme-body {
  background-color: var(--color-page-bg);
  color: var(--color-text-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-body main {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.theme-body #main-content,
.theme-body #htmx-page-swap {
  min-width: 0;
  max-width: 100%;
}

.theme-header {
  background-color: var(--color-header-bg);
  border-bottom: 1px solid var(--color-header-border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Логотип + подписи: не сжимать блок в flex-ряду шапки; две строки без переноса по словам */
.theme-header .spa-brand-link {
  flex-shrink: 0;
}

.theme-header .site-brand-title,
.theme-header .site-brand-tagline {
  white-space: nowrap;
}

/* Основное меню: компактнее, один ряд без переноса подписей */
.theme-header-nav-link {
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

@media (max-width: 1023px) {
  .theme-header-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: 9999px;
    font-weight: 500;
  }
}

@media (min-width: 1024px) {
  /* Одна строка: бренд | flex-1 меню по центру | плеер + тема */
  .theme-header .site-header-row {
    flex-wrap: nowrap;
    align-items: center;
  }

  .theme-header .site-header-nav {
    flex-wrap: nowrap;
    justify-content: center;
    position: relative;
    z-index: 10;
  }

  .theme-header .site-header-brand,
  .theme-header .header-player-cluster {
    flex-shrink: 0;
  }

  .theme-header .header-player-cluster {
    position: relative;
    z-index: 1;
  }

  .theme-header-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: 9999px;
    font-weight: 500;
  }
}

@media (min-width: 1280px) {
  .theme-header-nav-link {
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
  }
}

.theme-nav-link {
  color: var(--color-nav-muted);
}

.theme-nav-link:hover {
  background-color: var(--color-nav-hover);
}

.theme-footer {
  background-color: var(--color-footer-bg);
  color: var(--color-footer-text);
}

/* На всю ширину экрана: цветная полоса; контент центрируется только внутри .footer-site-inner */
.theme-footer.footer-site-root {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.theme-footer .footer-site-inner {
  box-sizing: border-box;
  margin-inline: auto;
  width: 100%;
  max-width: 72rem; /* синхрон с Tailwind max-w-6xl, даже если CDN не подхватит класс */
}

.theme-footer-muted {
  color: var(--color-footer-link-subtle);
}

.theme-footer-link {
  color: var(--color-footer-text);
  text-decoration-color: color-mix(in srgb, var(--color-footer-text) 42%, transparent);
}

.theme-footer-link:hover {
  color: var(--color-footer-text);
  text-decoration-color: var(--color-footer-text);
}

.theme-footer-border {
  border-color: color-mix(in srgb, var(--color-footer-text) 28%, transparent);
}

.theme-shadow-card {
  box-shadow: var(--shadow-card);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  flex-shrink: 0;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  background-color: var(--theme-toggle-bg);
  color: var(--theme-toggle-icon);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-toggle-btn:hover {
  background-color: var(--theme-toggle-bg-hover);
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.theme-toggle-btn .theme-icon-moon {
  display: block;
}

.theme-toggle-btn .theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .theme-icon-sun {
  display: block;
}

/* Контент с сайта (HTML из CKEditor 5): адаптивные картинки и типографика */
.site-richtext.ck-content {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.site-richtext.ck-content > * + * {
  margin-top: 0.75rem;
}

.site-richtext.ck-content h2 {
  font-family: Lora, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.35rem;
  color: var(--color-heading);
}

.site-richtext.ck-content h3 {
  font-family: Lora, Georgia, serif;
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  color: var(--color-heading);
}

.site-richtext.ck-content ul,
.site-richtext.ck-content ol {
  margin: 0.5rem 0 0.5rem 1.25rem;
  padding-left: 0.25rem;
}

.site-richtext.ck-content a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-richtext.ck-content img {
  max-width: 100%;
  height: auto;
  display: block;
}

.site-richtext.ck-content figure {
  margin: 0.75rem auto;
  max-width: 100%;
}

.site-richtext.ck-content figure.image {
  display: table;
}

.site-richtext.ck-content figure.image img {
  margin-left: auto;
  margin-right: auto;
}

.site-richtext.ck-content figcaption {
  display: table-caption;
  caption-side: bottom;
  font-size: 0.875rem;
  line-height: 1.4;
  margin-top: 0.4rem;
  color: var(--color-text-muted);
  text-align: center;
}

.theme-footer .site-richtext.ck-content figcaption {
  color: inherit;
  opacity: 0.88;
}

.site-richtext.ck-content table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}

.site-richtext.ck-content table tbody {
  display: table;
  width: 100%;
}

.site-richtext.ck-content th,
.site-richtext.ck-content td {
  border: 1px solid var(--color-header-border);
  padding: 0.35rem 0.5rem;
}

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

.grp-shell {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  border-top: 1px solid var(--color-radio-border);
  background: var(--color-radio-player-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] .grp-shell {
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}

.grp-play-btn {
  flex-shrink: 0;
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-brand);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-brand) 40%, transparent);
}

.grp-play-btn:hover {
  filter: brightness(1.06);
  transform: scale(1.04);
}

.grp-play-btn:active {
  transform: scale(0.98);
}

.grp-vol {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--color-text-muted) 32%, transparent);
  width: 5.5rem;
  max-width: 22vw;
}

.grp-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-brand);
  cursor: pointer;
}

.grp-vol::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 0;
  cursor: pointer;
}

.grp-viz-canvas {
  display: block;
  width: 104px;
  height: 36px;
  border-radius: 0.5rem;
  background: linear-gradient(
    160deg,
    color-mix(in srgb, #c9a24a 11%, transparent),
    color-mix(in srgb, var(--color-media-placeholder) 58%, transparent)
  );
}

.global-play-btn {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-brand);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-brand) 38%, transparent);
}

.global-play-btn:hover {
  filter: brightness(1.06);
  transform: scale(1.04);
}

.global-play-btn:active {
  transform: scale(0.96);
}

.header-radio-meta {
  flex-shrink: 1;
  min-width: 0;
  max-width: min(11rem, 36vw);
}

@media (min-width: 640px) {
  .header-radio-meta {
    max-width: 14rem;
  }
}

@media (min-width: 1024px) {
  .theme-header .header-radio-meta {
    max-width: 9.5rem;
  }
}

.header-radio-title,
.header-radio-artist {
  max-width: 100%;
}

@media (max-width: 380px) {
  #header-radio-artist {
    display: none;
  }
}

/* --- Фотогалерея: альбом + оверлей PhotoSwipe --- */
.gallery-album-intro {
  margin-bottom: 1.75rem;
}
.gallery-album-grid a {
  cursor: zoom-in;
}
.gallery-album-thumb {
  transition: opacity 0.2s ease;
}

/* --- История: блок «Документы и материалы» (PhotoSwipe) --- */
.history-gallery-grid a {
  cursor: zoom-in;
}
.history-gallery-thumb {
  transition: opacity 0.2s ease;
}

.gallery-pswp-ui {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.78),
    rgba(0, 0, 0, 0.15),
    transparent
  );
}

.gallery-pswp-caption-wrap {
  max-width: min(920px, 92vw);
  text-align: center;
  pointer-events: none;
}

.gallery-pswp-caption-text {
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.gallery-pswp-caption-meta {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 2px;
}

.gallery-pswp-thumbs {
  display: flex;
  gap: 6px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 8px 4px;
  pointer-events: auto;
  scrollbar-width: thin;
}

.gallery-pswp-thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 52px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  padding: 0;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  opacity: 0.55;
}

.gallery-pswp-thumb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.gallery-pswp-thumb.active {
  border-color: #fff;
  opacity: 1;
}

.gallery-pswp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (min-width: 768px) {
  .gallery-pswp-caption-text {
    font-size: 1rem;
  }
  .gallery-pswp-thumb {
    width: 88px;
    height: 60px;
  }
}
