/* =============================================
   КАТАЛОГ СУБХАШИТ — Design System & Styles
   ============================================= */

/* Шрифт транслитерации: Charis SIL (OFL), урезан до латиницы/кириллицы/комбинируемых знаков.
   Один файл на всё, чтобы знак не отрывался от буквы (у Google Fonts кириллица и знаки в разных файлах). */
@font-face {
  font-family: 'Translit Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/CharisSIL-Italic.subset.woff2') format('woff2');
}
@font-face {
  font-family: 'Translit Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/CharisSIL-Regular.subset.woff2') format('woff2');
}
@font-face {
  font-family: 'Translit Serif';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/CharisSIL-BoldItalic.subset.woff2') format('woff2');
}

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Color Palette — warm bookish theme */
  --bg-primary: #F9F3EA;
  --bg-secondary: #EBE1D5;
  --bg-card: #F9F3EA;
  --text-primary: #4A3B32;
  --text-secondary: #705D53;
  --text-tertiary: #9B8A80;
  --accent: #B28F6F;
  --accent-hover: #967557;
  --accent-light: rgba(178, 143, 111, 0.1);
  --accent-dark: #7A5B40;
  --border: #E8DCCB;
  --border-light: #F0E6D8;
  --shadow: rgba(74, 59, 50, 0.08);
  --shadow-lg: rgba(74, 59, 50, 0.14);
  --player-bg: #2C1810;
  --player-text: #FAF6F0;
  --player-accent: #B28F6F;
  --nav-bg: #F9F3EA;
  --danger: #C0392B;
  --success: #27AE60;
  --header-bg: rgba(250, 246, 240, 0.92);
  --lv-color: #d1182b;
  --chip-green-bg: #eaf5ed;
  --chip-green-text: #1e5631;
  --chip-green-border: #c3e2cc;
  --chip-amber-bg: #fdf3e3;
  --chip-amber-text: #855319;
  --chip-amber-border: #ebd3b4;

  /* Слайды (режим изучения), дневная тема: бежевый лист, тёмные буквы, гуру красно-коричневые */
  --study-bg: #F9F3EA;
  --study-heading: #3E2F26;
  --study-verse: #2E211A;
  --study-guru: #A3381F;
  --study-sub: #5E4E44;
  --study-sub-strong: #3A2C24;
  --study-gloss: #7A6A5F;
  --study-rule: rgba(74, 59, 50, 0.16);
  --study-corner: rgba(178, 143, 111, 0.16);
  --study-tool-bg: rgba(74, 59, 50, 0.07);
  --study-tool-fg: rgba(74, 59, 50, 0.78);
  --study-tool-hover-bg: rgba(74, 59, 50, 0.14);
  --study-tool-hover-fg: #2E211A;
  --study-on-bg: rgba(163, 56, 31, 0.12);
  --study-on-fg: #A3381F;
  --study-counter: rgba(74, 59, 50, 0.62);
  --study-link-bg: rgba(178, 143, 111, 0.3);
  --study-link-line: #A3381F;
  --study-bar-bg: rgba(255, 253, 249, 0.97);
  --study-bar-shadow: 0 6px 24px rgba(74, 59, 50, 0.16);
  --study-seg-on-bg: #FFFFFF;

  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif', 'Georgia', serif;
  --font-translit: 'Translit Serif', 'Noto Serif', 'Georgia', serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Borders & Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Shadows */
  --card-shadow: 0 2px 12px var(--shadow);
  --card-shadow-hover: 0 8px 30px var(--shadow-lg);
  --header-shadow: 0 2px 20px rgba(44, 24, 16, 0.06);

  /* Layout */
  --header-height: 56px;
  --player-height: 60px;
  --nav-height: 60px;
  --max-width: 1200px;
}

/* Ночная тема (переключатель «день / ночь», theme.js ставит data-theme на <html>) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #1F2023;
  --bg-secondary: #2A2B2F;
  --bg-card: #26272B;
  --text-primary: #ECE6DD;
  --text-secondary: #C2B8AD;
  --text-tertiary: #978D84;
  --accent: #B28F6F;
  --accent-hover: #C5A27F;
  --accent-light: rgba(178, 143, 111, 0.16);
  --accent-dark: #D9BC9A;
  --border: #3A3B40;
  --border-light: #313236;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-lg: rgba(0, 0, 0, 0.5);
  --player-bg: #141517;
  --player-text: #F1ECE4;
  --nav-bg: #1F2023;
  --header-bg: rgba(31, 32, 35, 0.92);
  --lv-color: #ff6b6b;
  --chip-green-bg: rgba(107, 170, 120, 0.16);
  --chip-green-text: #A9D8B4;
  --chip-green-border: rgba(107, 170, 120, 0.4);
  --chip-amber-bg: rgba(214, 160, 90, 0.16);
  --chip-amber-text: #E8C291;
  --chip-amber-border: rgba(214, 160, 90, 0.4);

  --study-bg: #1F2023;
  --study-heading: #FEFEFE;
  --study-verse: #EFC869;
  --study-guru: #FCEECD;
  --study-sub: #A9AAAD;
  --study-sub-strong: #D4D5D8;
  --study-gloss: #A9AAAD;
  --study-rule: rgba(254, 254, 254, 0.12);
  --study-corner: rgba(239, 200, 105, 0.07);
  --study-tool-bg: rgba(254, 254, 254, 0.06);
  --study-tool-fg: rgba(254, 254, 254, 0.7);
  --study-tool-hover-bg: rgba(254, 254, 254, 0.14);
  --study-tool-hover-fg: #FEFEFE;
  --study-on-bg: rgba(239, 200, 105, 0.2);
  --study-on-fg: #EFC869;
  --study-counter: rgba(254, 254, 254, 0.55);
  --study-link-bg: rgba(239, 200, 105, 0.18);
  --study-link-line: #EFC869;
  --study-bar-bg: rgba(44, 45, 49, 0.97);
  --study-bar-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --study-seg-on-bg: rgba(239, 200, 105, 0.2);
}


/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}


/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--header-shadow);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--space-md);
  gap: var(--space-sm);
}

.header-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.header-back-btn:hover {
  background: var(--accent-light);
}

.header-title {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
}

.header-logo-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.header-logo-text {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(178, 143, 111, 0.35);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.header-search-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

@media (max-width: 520px) {
  .header-search-btn { padding: 10px 12px; }
  .header-search-btn span { display: none; }
}


/* --- Search Overlay --- */
.search-overlay {
  display: none;
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.search-overlay.active {
  display: block;
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-md);
  transition: border-color var(--transition);
}

.search-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.search-icon {
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-primary);
  min-width: 0;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.search-close-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}


/* --- App Container --- */
.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  min-height: calc(100vh - var(--header-height));
  transition: padding-bottom var(--transition);
}

body.player-visible .app-container {
  padding-bottom: calc(var(--player-height) + var(--space-xl));
}


/* --- Page Transitions --- */
.page-enter {
  animation: pageEnter 0.35s ease forwards;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* --- Category Gradient Palette --- */
.gradient-1 { background: linear-gradient(135deg, #C4943A, #D4A54A); }
.gradient-2 { background: linear-gradient(135deg, #8B6B4A, #A0845C); }
.gradient-3 { background: linear-gradient(135deg, #6B8E6B, #8AAD8A); }
.gradient-4 { background: linear-gradient(135deg, #7B6B8E, #9B8DAE); }
.gradient-5 { background: linear-gradient(135deg, #8E7B6B, #AD9B8D); }
.gradient-6 { background: linear-gradient(135deg, #6B7B8E, #8D9BAD); }
.gradient-7 { background: linear-gradient(135deg, #8E6B6B, #AD8D8D); }
.gradient-8 { background: linear-gradient(135deg, #6B8E7B, #8DAD9B); }


/* --- Library Page --- */
.library-page {
  padding-top: var(--space-sm);
}

.library-heading {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
  line-height: 1.3;
}

.library-heading-sub {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-full);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  text-align: center;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 4px var(--shadow);
  font-weight: 600;
}

.tab-btn:not(.active):hover {
  color: var(--text-primary);
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.category-card {
  position: relative;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: #FFFFFF;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: all var(--transition);
  overflow: hidden;
  aspect-ratio: 3 / 5;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  box-shadow: var(--card-shadow);
  background-color: #A6907C; /* Sepia placeholder */
  background-size: cover;
  background-position: center;
}

.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(30,20,15,0.85) 0%, rgba(30,20,15,0.4) 40%, rgba(30,20,15,0.1) 100%);
  border-radius: inherit;
  z-index: 1;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.category-card:active {
  transform: translateY(-1px);
}

.category-card-content {
  position: relative;
  z-index: 2;
}

.category-card-name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.category-card-count {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.9;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.category-card-icon {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-size: 1.6rem;
  opacity: 0.5;
  z-index: 2;
}


/* --- Playlist / Category Page --- */
.playlist-page {
  padding-top: var(--space-sm);
}

.playlist-header {
  margin-bottom: var(--space-lg);
}

.playlist-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: var(--space-xs);
}

.playlist-meta {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.listen-all-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--accent);
  color: #FFFFFF;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: var(--space-md);
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(196, 148, 58, 0.3);
}

.listen-all-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(196, 148, 58, 0.4);
}

.listen-all-btn svg {
  flex-shrink: 0;
}

/* Verse list */
.verse-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 900px;
  margin: 0 auto;
}

.verse-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border-light);
}

.verse-list-item:hover {
  border-color: var(--border);
  box-shadow: var(--card-shadow);
  transform: translateX(2px);
}

.verse-list-item.now-playing {
  border-color: var(--accent);
  background: var(--accent-light);
}

.verse-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition);
}

.verse-list-item:hover .verse-number {
  background: var(--accent);
  color: #FFFFFF;
}

.verse-list-item.now-playing .verse-number {
  background: var(--accent);
  color: #FFFFFF;
}

.verse-item-info {
  flex: 1;
  min-width: 0;
}

.verse-item-title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.verse-item-desc {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.verse-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  transition: all var(--transition);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(196, 148, 58, 0.15);
}

.verse-play-btn svg {
  margin-left: 2px; /* Optical alignment for play triangle */
}

.verse-play-btn:hover {
  background: var(--accent);
  color: #FFFFFF;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(196, 148, 58, 0.3);
}

.verse-recitation-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(196, 148, 58, 0.1);
  border: 1px solid rgba(196, 148, 58, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.verse-recitation-btn:hover {
  background: var(--accent);
  color: #FFFFFF;
}

.verse-recitation-btn svg {
  width: 14px;
  height: 14px;
}


/* --- Verse Detail Page --- */
.verse-page {
  padding-top: var(--space-sm);
}

.verse-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.verse-card-header {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.verse-source-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.verse-detail-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: var(--space-xs);
}

.verse-detail-number {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

/* Inline player controls on verse page */
.verse-player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}

.verse-play-main-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #FFFFFF;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(196, 148, 58, 0.3);
}

.verse-play-main-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.verse-player-info {
  flex: 1;
  min-width: 0;
}

.verse-player-label {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.verse-player-track {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Author in player controls */
.verse-player-author {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.verse-player-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.verse-player-author-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.verse-player-author-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.1;
}

.verse-player-author-role {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

@media (max-width: 480px) {
  .verse-player-author-info {
    display: none;
  }
}

/* Verse body content sections */
.verse-body {
  padding: var(--space-lg);
}

.verse-section {
  margin-bottom: var(--space-lg);
}

.verse-section:last-child {
  margin-bottom: 0;
}

.verse-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.verse-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* Transliteration block */
.verse-transliteration {
  font-family: var(--font-translit);
  font-style: italic;
  font-size: clamp(1.15rem, 1rem + 0.4vw, 1.35rem);
  line-height: 1.65;
  color: var(--text-primary);
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(196, 148, 58, 0.05), rgba(196, 148, 58, 0.02));
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: pre-line;
}

/* Word-by-word — shown by default, small hide/show link */
.verse-word-by-word-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-xs, 4px);
}

.verse-word-by-word-toggle {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color var(--transition), text-decoration-color var(--transition);
}

.verse-word-by-word-toggle:hover,
.verse-word-by-word-toggle:focus-visible {
  color: var(--text-secondary);
  text-decoration-color: currentColor;
}

.verse-word-by-word-content.is-hidden {
  display: none;
}

.word-by-word-text {
  font-family: var(--font-translit);
  font-size: clamp(1rem, 0.85rem + 0.35vw, 1.15rem);
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-line;
}

/* Literary translation */
.verse-translation {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
}

/* Commentary */
.verse-commentary {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.verse-commentary p {
  margin-bottom: var(--space-md);
}

.verse-commentary p:last-child {
  margin-bottom: 0;
}

.verse-commentary em, .verse-commentary i {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-primary);
}

.verse-commentary b, .verse-commentary strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* Divider */
.verse-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-md) 0;
}

/* Author signature */
.verse-author {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.verse-author-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
  background: var(--border);
}

.verse-author-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.verse-author-role {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Acharya comment */
.acharya-comment {
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(107, 142, 107, 0.08), rgba(107, 142, 107, 0.03));
  border-left: 3px solid #6B8E6B;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.acharya-comment-label {
  font-weight: 700;
  color: #6B8E6B;
  margin-bottom: var(--space-xs);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Share buttons */
.share-buttons {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--border-light);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.share-btn svg {
  width: 16px;
  height: 16px;
}

.share-btn-tg:hover {
  border-color: #0088CC;
  color: #0088CC;
  background: rgba(0, 136, 204, 0.08);
}

.share-btn-wa:hover {
  border-color: #25D366;
  color: #25D366;
  background: rgba(37, 211, 102, 0.08);
}

.share-btn-copy.copied {
  border-color: var(--success);
  color: var(--success);
  background: rgba(39, 174, 96, 0.08);
}


/* --- Search Results --- */
.search-results-page {
  padding-top: var(--space-sm);
}

.search-results-heading {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

.search-results-heading strong {
  color: var(--text-primary);
}

.search-result-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}

.search-result-card:hover {
  border-color: var(--border);
  box-shadow: var(--card-shadow);
}

.search-result-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.search-result-source {
  font-size: 0.75rem;
  color: var(--accent-dark);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.search-result-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-snippet mark {
  background: rgba(196, 148, 58, 0.2);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 2px;
}

.no-results {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-tertiary);
}

.no-results-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.no-results-text {
  font-size: 1rem;
  margin-bottom: var(--space-xs);
  color: var(--text-secondary);
}

.no-results-sub {
  font-size: 0.85rem;
}


/* --- Loading / Skeleton States --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-light) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-md);
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
}

.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-100 { width: 100%; }

.skeleton-verse-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--border-light);
}

.skeleton-circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.skeleton-text-group {
  flex: 1;
}


/* --- Audio Player Bar --- */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--player-bg);
  color: var(--player-text);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition);
}

.player-bar.hidden {
  transform: translateY(100%);
}

.player-progress-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(250, 246, 240, 0.15);
  cursor: pointer;
  z-index: 2;
}

.player-progress-container:hover {
  height: 5px;
}

.player-progress-bar {
  height: 100%;
  background: var(--player-accent);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
  position: relative;
}

.player-progress-container:hover .player-progress-bar::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--player-accent);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.player-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  max-width: var(--max-width);
  margin: 0 auto;
  height: var(--player-height);
}

.player-track-info {
  flex: 0 1 auto;
  min-width: 0;
  padding-right: var(--space-sm);
}

.player-track-title {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--player-text);
  line-height: 1.3;
}

.player-track-source {
  font-size: 0.7rem;
  color: rgba(250, 246, 240, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--player-text);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.player-btn:hover {
  background: rgba(250, 246, 240, 0.1);
}

.player-btn-prev,
.player-btn-next {
  width: 36px;
  height: 36px;
}

.player-btn-play {
  width: 44px;
  height: 44px;
  background: var(--player-accent);
  margin: 0 var(--space-xs);
}

.player-btn-play:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.player-time {
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: rgba(250, 246, 240, 0.7);
  white-space: nowrap;
  min-width: 75px;
  text-align: center;
}

.player-speed-btn {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--player-accent);
  padding: 2px 8px;
  border: 1px solid rgba(196, 148, 58, 0.4);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.player-speed-btn:hover {
  border-color: var(--player-accent);
  background: rgba(196, 148, 58, 0.15);
}


/* --- Admin Panel --- */
.admin-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.admin-login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--card-shadow);
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--border-light);
}

.admin-login-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.admin-form-group {
  margin-bottom: var(--space-md);
}

.admin-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.admin-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
  outline: none;
}

.admin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.admin-submit-btn {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition);
  margin-top: var(--space-sm);
}

.admin-submit-btn:hover {
  background: var(--accent-hover);
}

.admin-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: var(--space-sm);
  text-align: center;
}

/* Admin Dashboard */
.admin-dashboard {
  padding-top: var(--space-sm);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.admin-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
}

.admin-logout-btn {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: all var(--transition);
}

.admin-logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.admin-stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--card-shadow);
}

.admin-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.admin-stat-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-section {
  margin-bottom: var(--space-xl);
}

.admin-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-light);
}

.admin-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-light);
  white-space: nowrap;
}

.admin-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: var(--accent-light);
}

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
}

.admin-badge-active {
  background: rgba(39, 174, 96, 0.1);
  color: var(--success);
}

.admin-badge-draft {
  background: rgba(107, 76, 59, 0.1);
  color: var(--text-secondary);
}


/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: calc(var(--player-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: all var(--transition);
  z-index: 300;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body:not(.player-visible) .toast {
  bottom: var(--space-lg);
}


/* --- Responsive Breakpoints --- */

/* Tablet — 768px */
@media (min-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .header-logo-text {
    font-size: 1.25rem;
  }

  .library-heading {
    font-size: 1.8rem;
  }

  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
  }

  .category-card {
    aspect-ratio: 3 / 4;
    padding: var(--space-md);
  }

  .category-card-name {
    font-size: 1.05rem;
  }

  .verse-card {
    max-width: 720px;
    margin: 0 auto;
  }

  .verse-detail-title {
    font-size: 1.5rem;
  }

  .verse-transliteration {
    font-size: 1.2rem;
    padding: var(--space-lg);
  }

  .admin-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .player-content {
    padding: var(--space-sm) var(--space-lg);
  }

  .player-track-title {
    font-size: 0.9rem;
  }
}

/* Desktop — 1024px */
@media (min-width: 1024px) {
  .app-container {
    padding: var(--space-xl) var(--space-lg);
  }

  .category-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .category-card {
    aspect-ratio: 4 / 5;
  }

  .category-card-name {
    font-size: 1.1rem;
  }

  .verse-list-item {
    padding: var(--space-md) var(--space-lg);
  }

  .library-heading {
    font-size: 2rem;
  }

  .player-time {
    font-size: 0.8rem;
    min-width: 90px;
  }
}


/* --- Utility Classes --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-tertiary); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* --- Bottom Navigation --- */
/* --- Home Sections --- */
.section-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  padding: 0 var(--space-md);
}

.horizontal-scroll {
  display: flex;
  overflow-x: auto;
  padding: 0 var(--space-md) var(--space-md);
  gap: var(--space-md);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.horizontal-scroll::-webkit-scrollbar {
  display: none;
}

.horizontal-scroll .category-card {
  flex: 0 0 calc(45% - 8px);
  min-width: 140px;
  scroll-snap-align: start;
}

.home-search {
  margin: 0 var(--space-md) var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--text-tertiary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  height: 44px;
}

.home-search input {
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  padding-left: var(--space-sm);
  outline: none;
  font-family: var(--font-ui);
  color: var(--text-primary);
}

.home-search svg {
  color: var(--text-secondary);
}


/* The top header is hidden only on the home page (router sets body.is-home):
   the home screen has its own search and tabs. On every other page the
   header gives the Back button and the logo link to the home page. */
body.is-home .app-header {
  display: none;
}

.app-container {
  padding-top: var(--space-md) !important;
}

/* ========================================
   FILTER CHIPS (Book/Source filters)
   ======================================== */
.filter-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: 14px;
  min-width: 140px;
  cursor: pointer;
  flex-shrink: 0;
  color: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  user-select: none;
}
.filter-chip:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}
.filter-chip:active {
  transform: scale(0.97);
}
.filter-chip-name {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}
.filter-chip-count {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-top: 4px;
}

/* Verse list page (source filter results) */
.verse-list-meta {
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 2px;
}
.verse-list-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-style: italic;
}

.verse-list-info { flex: 1; min-width: 0; }

/* ========================================
   GAUDIABOOKS STYLE BOOK CARDS GRID
   ======================================== */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.book-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.book-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
  border-color: var(--accent-light);
}

.book-cover-wrap {
  position: relative;
  width: 100%;
  padding-top: 133.33%; /* 3:4 Book Ratio */
  overflow: hidden;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.book-cover-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.book-card:hover .book-cover-img {
  transform: scale(1.04);
}

.book-cover-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: #ffffff;
}

.book-fallback-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Placeholder for authors whose photo we don't have yet - same gradient tile
   as a missing book cover, but stacked so the silhouette reads as "person". */
.author-cover-fallback {
  flex-direction: column;
  gap: 8px;
}

.author-fallback-icon {
  font-size: 2rem;
  line-height: 1;
  opacity: 0.9;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* Spiritual names run longer than book titles ("Радха-према деви даси"), so the
   two-line box the book cards use clipped six of them. Give authors a third line.
   Both classes are named in the selector so this wins over .book-card-title,
   which is defined further down the file at equal specificity. */
.book-card-title.author-card-title {
  min-height: 4.2em;
  max-height: 4.2em;
}

.book-count-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

.book-card-title {
  padding: 10px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2em;
  max-height: 3.2em;
  overflow: hidden;
  word-break: break-word;
}

/* --- Режим изучения (слайды): тёмный экран, только текст и колонка кнопок справа --- */
.study-mode-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  background: var(--study-bg);
  color: var(--study-heading);
  overflow: hidden;
  box-sizing: border-box;
}

.study-mode-overlay [hidden] {
  display: none !important;
}

/* Орнамент в углах: еле заметные пятна, как у образца */
.study-corner {
  position: absolute;
  width: 180px;
  height: 180px;
  pointer-events: none;
}

.study-corner-top {
  top: 0;
  left: 0;
  background: radial-gradient(circle at 0 0, var(--study-corner), transparent 70%);
}

.study-corner-bottom {
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 100% 100%, var(--study-corner), transparent 70%);
}

.study-heading {
  position: absolute;
  top: 18px;
  left: 68px;
  right: 68px;
  margin: 0;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 24px;
  line-height: 36px;
  font-weight: 500;
  color: var(--study-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.study-stage {
  position: absolute;
  top: 66px;
  bottom: 66px;
  left: 68px;
  right: 68px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.study-stage.study-scroll {
  align-items: flex-start;
  overflow-y: auto;
}

.study-bare .study-heading,
.study-bare .study-counter,
.study-bare .study-navigation {
  display: none;
}

.study-bare .study-stage {
  top: 24px;
  bottom: 24px;
}

.study-content {
  width: 100%;
  font-size: var(--study-fs, 28px);
}

.study-block {
  display: block;
  margin: 0;
  text-align: left;
}

.study-block:not([hidden]) ~ .study-block:not([hidden]) {
  border-top: 1px solid var(--study-rule);
  margin-top: 0.4em;
  padding-top: 0.4em;
}

.study-sanskrit {
  font-family: var(--font-translit);
  font-style: italic;
  font-weight: 400;
  font-size: 1em;
  line-height: 1.55;
  color: var(--study-verse);
}

/* Каждая строка стиха отдельным блоком: если не влезает в экран, вторая половина
   идёт с висячим отступом, как продолжение той же строки */
.study-sanskrit > br {
  display: none;
}

.study-line {
  display: block;
  padding-left: 1.6em;
  text-indent: -1.6em;
  /* не text-wrap: сокращение сбросило бы nowrap родителя */
  text-wrap-style: balance;
}

.study-line .study-iword {
  text-indent: 0;
}

.study-sanskrit.study-nowrap {
  white-space: nowrap;
}

/* Гуру-гласные: днём красно-коричневые, ночью чуть светлее золота */
.study-sanskrit .lv {
  color: var(--study-guru);
}

.study-wbw,
.study-literary {
  font-size: max(15.2px, 0.8em);
  line-height: 1.5;
  color: var(--study-sub);
}

.study-wbw {
  font-family: var(--font-translit);
}

.study-wbw i {
  color: var(--study-sub-strong);
}

.study-literary {
  font-family: var(--font-serif);
}

.study-empty {
  font-style: italic;
  opacity: 0.6;
}

/* Пара «слово стиха - запись пословника» под мышью или после касания: мягкая плашка */
.study-word,
.study-wentry {
  border-radius: 0.25em;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.study-word.is-linked,
.study-wentry.is-linked {
  background: var(--study-link-bg);
  box-shadow: 0 0 0 0.12em var(--study-link-bg), inset 0 -0.08em 0 var(--study-link-line);
}

@media (hover: none) {
  .study-linking .study-word[data-links],
  .study-linking .study-wentry {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Надстрочный перевод: у каждого слова стиха значение сверху, мелким серым */
.study-interlinear {
  line-height: 1.2;
}

.study-iword {
  display: inline-block;
  vertical-align: baseline;
  min-width: 2.4em;
  margin: 0 0.3em 0.35em 0;
  line-height: 1.45;
}

.study-iword::before {
  content: attr(data-gloss);
  display: block;
  /* Колонка не уже самого длинного слова подписи: подпись переносится только между словами */
  width: min-content;
  min-width: 100%;
  margin-bottom: 0.1em;
  font-family: var(--font-serif);
  font-style: normal;
  font-size: 0.55em;
  line-height: 1.25;
  color: var(--study-gloss);
  white-space: normal;
}

.study-tool {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--study-tool-bg);
  color: var(--study-tool-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.study-tool:hover {
  background: var(--study-tool-hover-bg);
  color: var(--study-tool-hover-fg);
}

.study-tool:focus-visible {
  outline: 2px solid var(--study-on-fg);
  outline-offset: 2px;
}

.study-tool[aria-pressed="true"] {
  background: var(--study-on-bg);
  color: var(--study-on-fg);
}

.study-tool:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Меню слайдов: панель сверху (заход 9, вариант А). В покое видна только «ручка» у верхнего
   края; панель выезжает, когда мышь у верхнего края, по касанию названия или ручки, и при фокусе
   с клавиатуры. Режимы словами в одном переключателе-«таблетке». */
.study-bar-handle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

.study-bar-handle::before {
  content: "";
  display: block;
  width: 64px;
  height: 6px;
  margin: 0 auto;
  border-radius: 0 0 6px 6px;
  background: var(--study-tool-hover-bg);
}

.study-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--study-bar-bg);
  box-shadow: var(--study-bar-shadow);
  border-radius: 0 0 16px 16px;
  transform: translateY(calc(-100% - 12px));
  transition: transform 0.25s ease;
}

.study-bar-open .study-bar,
.study-bar:focus-within {
  transform: none;
}

.study-bar-gap {
  flex: 1;
}

.study-seg {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-full);
  background: var(--study-tool-bg);
}

.study-mode-btn {
  border: 0;
  background: transparent;
  color: var(--study-tool-fg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.study-mode-btn:hover {
  color: var(--study-tool-hover-fg);
}

.study-mode-btn[aria-pressed="true"] {
  background: var(--study-seg-on-bg);
  color: var(--study-on-fg);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(74, 59, 50, 0.2);
}

.study-mode-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.study-mode-btn:focus-visible,
.study-pill:focus-visible,
.study-bar-handle:focus-visible {
  outline: 2px solid var(--study-on-fg);
  outline-offset: 2px;
}

.study-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--study-tool-bg);
  color: var(--study-tool-fg);
  font-family: var(--font-ui);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.study-pill:hover {
  background: var(--study-tool-hover-bg);
  color: var(--study-tool-hover-fg);
}

.study-pill[aria-pressed="true"] {
  background: var(--study-on-bg);
  color: var(--study-on-fg);
}

.study-word-sm {
  display: none;
}

/* Стрелки и счётчик внизу по центру */
.study-navigation {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
}

.study-counter {
  min-width: 4.5em;
  text-align: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--study-counter);
}

@media (max-width: 768px) {
  .study-heading {
    left: 16px;
    right: 16px;
    top: 14px;
    font-size: 18px;
    line-height: 36px;
  }

  .study-stage {
    top: 58px;
    bottom: 64px;
    left: 16px;
    right: 16px;
  }

  .study-bar {
    gap: 6px;
    padding: 8px 10px;
  }

  .study-seg {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .study-mode-btn {
    flex: 1;
    font-size: 13px;
    padding: 8px 6px;
  }

  .study-pill {
    padding: 0 10px;
    font-size: 13px;
  }

  .study-word-lg {
    display: none;
  }

  .study-word-sm {
    display: inline;
  }
}

/* Player: file missing or failed to load */
.player-bar.player-unavailable .player-time { color: #e07a5f; font-weight: 600; }
.player-bar.player-unavailable .player-progress-bar { width: 0 !important; }

/* Долгие гласные (заход 6): красим только гласную, остальной текст как был */
.lv {
  color: var(--lv-color);
}

.lv-toggle {
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary, var(--text-tertiary));
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.lv-toggle.active {
  background: rgba(209, 24, 43, 0.1);
  border-color: rgba(209, 24, 43, 0.45);
  color: #d1182b;
}

.verse-section-label .lv-toggle {
  font-size: 0.72rem;
  padding: 3px 10px;
  order: 1;
  margin-left: 4px;
}


/* Переключатель «день / ночь»: в шапке, на главной и в слайдах (theme.js) */
.theme-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.main-search-bar .theme-toggle {
  width: 44px;
  height: 44px;
  align-self: center;
}

.home-topbar {
  display: flex;
  justify-content: flex-end;
  padding: 0 var(--space-md);
  margin-bottom: calc(-1 * var(--space-sm));
}

.study-mode-overlay .theme-toggle {
  width: 36px;
  height: 36px;
  border: 0;
  background: var(--study-tool-bg);
  color: var(--study-tool-fg);
}

.study-mode-overlay .theme-toggle:hover {
  background: var(--study-tool-hover-bg);
  color: var(--study-tool-hover-fg);
}

/* «Скопировать ссылку» на странице шлоки и темы (заход 10) */
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.copy-link-btn:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}
.copy-link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Подвал на всех страницах: куда писать об ошибках (заход 10) */
.site-footer {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.site-footer a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}
body.player-visible .site-footer {
  padding-bottom: calc(var(--player-height) + var(--space-xl));
}
body.player-visible .app-container {
  padding-bottom: var(--space-lg);
}
