/* === MOBILE FIRST: Начинаем с мобильных стилей === */

/* 0. CSS ПЕРЕМЕННЫЕ ДИЗАЙН-СИСТЕМЫ */
:root {
  /* Цветовая палитра */
  --color-primary: #4a6fa5;
  --color-primary-hover: #3a5f8f;
  --color-primary-light: #e8f0fe;
  --color-accent: #4caf50;
  --color-accent-hover: #43a047;
  --color-accent-light: #e8f5e9;
  --color-danger: #e74c3c;
  --color-danger-hover: #c0392b;
  --color-warning: #e67e22;
  --color-warning-light: #fff3e0;
  --color-info: #3498db;
  --color-info-light: #e3f2fd;

  /* Фоны */
  --bg-body: #fafafa;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f5f7fa;
  --bg-sidebar: rgba(240, 247, 255, 0.98);
  --bg-header: #f8f9fa;
  --bg-muted: #f8f9fa;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  /* Текст */
  --text-primary: #2c3e50;
  --text-secondary: #5a6a7a;
  --text-muted: #7f8c8d;
  --text-inverse: #ffffff;

  /* Границы */
  --border-color: #e0e0e0;
  --border-color-light: #ecf0f1;
  --border-focus: #4a6fa5;

  /* Размеры */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  /* Типографика */
  --font-ui: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-reading: 'IBM Plex Serif', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Roboto Mono', 'Courier New', monospace;

  /* Транзишены */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* Тёмная тема */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #121212;
    --bg-surface: #1e1e1e;
    --bg-surface-hover: #2d2d2d;
    --bg-sidebar: #1e1e1e;
    --bg-header: #1e1e1e;
    --bg-muted: #2d2d2d;
    --bg-overlay: rgba(0, 0, 0, 0.7);

    --text-primary: #e0e0e0;
    --text-secondary: #b0bec5;
    --text-muted: #7f8c8d;
    --text-inverse: #ffffff;

    --border-color: #444;
    --border-color-light: #333;
    --border-focus: #5a9fd4;
  }
}

/* 1. БАЗОВЫЕ СТИЛИ для всех устройств */
* {
  box-sizing: border-box;
}

/* Запрет горизонтального скролла - контент должен помещаться */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}

/* Все элементы не должны вылезать за границы */
* {
  max-width: 100%;
}

/* Изображения и медиа адаптивные */
img, video, svg {
  max-width: 100%;
  height: auto;
}

/* iOS полноэкранный режим */
@supports (-webkit-touch-callout: none) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

body {
  margin: 0;
  padding: 15px;
  font-family: var(--font-ui);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 16px;
}

/* SKIP-LINK (для клавиатурной навигации) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 10000;
  padding: 12px 24px;
  background: var(--color-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: 8px;
}

/* СКЕЛЕТОН-ЗАГРУЗЧИКИ */
.skeleton {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line {
  height: 16px;
  margin-bottom: 10px;
  width: 100%;
}
.skeleton-line:last-child {
  width: 60%;
}
.skeleton-block {
  height: 60px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
}
.skeleton-badge {
  display: inline-block;
  width: 60px;
  height: 24px;
  border-radius: 12px;
}

@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
  }
}

/* ПУСТЫЕ СОСТОЯНИЯ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.5;
}

/* ФОКУС */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[contenteditable]:focus-visible {
  outline: none;
}

h1 {
  margin: 0 0 20px 0;
  font-size: 24px;
  color: var(--text-primary);
}

h2 {
  margin: 0 0 15px 0;
  font-size: 18px;
  color: var(--text-primary);
}

h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: var(--text-primary);
}

/* 3. ШАПКА */
.page-header {
  padding: 4px 15px;
  margin-bottom: 15px;
  border-bottom: 2px solid var(--color-accent);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  background: var(--bg-header);
  color: var(--text-primary);
  flex-wrap: nowrap;
  position: relative;
  z-index: 100;
  min-height: 50px;
}

.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-shrink: 1;
  min-width: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.3s;
}

.logo-icon:hover {
  transform: scale(1.1);
}

.page-header h1 {
  margin: 0;
  padding: 0;
  display: inline;
  font-size: 14px;
  line-height: 1.2;
}

.page-header p {
  margin: 1px 0 0 0;
  padding: 0;
  font-size: 10px;
  line-height: 1.2;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.user-greeting {
  font-size: 12px;
  color: var(--text-primary);
  display: none;
}

.user-name {
  font-weight: bold;
  color: var(--color-info);
  font-size: 13px;
}

.user-role-badge {
  padding: 2px 6px;
  background: var(--color-info);
  color: var(--text-inverse);
  border-radius: 10px;
  font-size: 10px;
}

.user-role-badge.admin {
  background: var(--color-danger);
}

.login-btn {
  background: var(--text-muted);
  color: var(--text-inverse);
  padding: 3px 6px;
  border-radius: 3px;
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  transition: background var(--transition-base);
  white-space: nowrap;
}

.login-btn:hover {
  background: #7f8c8d;
}

.logout-btn {
  background: var(--text-muted);
  color: var(--text-inverse);
  padding: 3px 6px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  transition: background var(--transition-base);
  white-space: nowrap;
}

.logout-btn:hover {
  background: #7f8c8d;
}

.header-btn {
  background: #757575;
  color: var(--text-inverse);
  padding: 4px 8px;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 400;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0.8;
}

/* 4. КНОПКИ МОБИЛЬНОГО МЕНЮ */
.mobile-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--color-primary);
  color: var(--text-inverse);
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 15px;
  transition: background-color var(--transition-base);
}

.mobile-menu-toggle:hover {
  background: var(--color-primary-hover);
}

.mobile-menu-toggle span {
  margin-right: 10px;
  font-size: 18px;
}

/* Кнопка выбора тем (для десктопа) */
.desktop-topic-btn {
  display: none;
}

/* Панель управления (десктоп) */
.desktop-control-panel {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  padding: 6px 15px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
}

.desktop-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--color-accent);
  color: var(--text-inverse);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.desktop-control-btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

.desktop-control-btn .btn-icon {
  font-size: 16px;
}

.desktop-sort-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.desktop-sort-controls .sort-select {
  padding: 6px 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
  font-family: inherit;
  min-width: 140px;
}

.desktop-sort-controls .sort-select:hover {
  border-color: #4a90e2;
}

.desktop-sort-controls .sort-select:focus {
  border-color: var(--border-focus);
}

.desktop-sort-controls .sort-order-toggle {
  padding: 6px 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
}

.desktop-sort-controls .sort-order-toggle:hover {
  border-color: #4a90e2;
  background: #e3f2fd;
}

.desktop-sort-controls .sort-order-toggle:active {
  transform: scale(0.95);
}

.desktop-sort-controls .sort-order-icon {
  font-size: 16px;
  font-weight: bold;
  color: #4a90e2;
  transition: transform 0.3s;
}

/* Поиск в десктопной панели */
.desktop-search-placeholder {
  margin-left: auto;
  display: flex;
  align-items: center;
}

#desktopSearchInput {
  padding: 10px 14px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  width: 200px;
  transition: all 0.2s;
}

#desktopSearchInput:focus {
  border-color: var(--border-focus);
  width: 250px;
}

/* 4.1 СТИЛИ ДЛЯ СЕМАНТИЧЕСКОГО ПОИСКА */
.search-type-selector {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 15px;
  border: 2px solid #ecf0f1;
  border-radius: 8px;
  transition: all 0.2s;
  flex: 1;
  min-width: 140px;
}

.radio-label:hover {
  border-color: var(--color-info);
  background: var(--bg-muted);
}

.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.radio-label input[type="radio"]:checked + .radio-text {
  font-weight: 600;
  color: #3498db;
}

.radio-label:has(input[type="radio"]:checked) {
  border-color: #3498db;
  background: #e8f4fc;
}

.radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-text strong {
  font-size: 14px;
}

.radio-text small {
  font-size: 11px;
  color: #7f8c8d;
  font-weight: normal;
}

.search-query-container {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

#semanticSearchInput {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #ecf0f1;
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.3s;
}

#semanticSearchInput:focus {
  border-color: var(--border-focus);
}

#startSemanticSearch {
  padding: 12px 25px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

#startSemanticSearch:hover {
  transform: translateY(-2px);
}

#startSemanticSearch:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
  transform: none;
}

.search-results {
  max-height: 500px;
  overflow-y: auto;
}

.search-results-info {
  font-size: 13px;
  color: #7f8c8d;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ecf0f1;
}

.search-result-item {
  background: #fff;
  border: 1px solid #ecf0f1;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.search-result-item:hover {
  border-color: #3498db;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.search-result-audio {
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
}

.search-result-time {
  background: #3498db;
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.search-result-text {
  color: #34495e;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
}

.search-result-text.highlighted b {
  background: #f1c40f;
  padding: 1px 4px;
  border-radius: 2px;
  color: #2c3e50;
}

.search-result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #ecf0f1;
}

.search-result-context {
  font-size: 12px;
  color: #7f8c8d;
}

.search-result-play {
  background: linear-gradient(135deg, #27ae60, #229954);
  color: white;
  border: none;
  padding: 6px 15px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.search-result-play:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(39, 174, 96, 0.3);
}

.search-placeholder {
  text-align: center;
  color: #999;
  font-size: 14px;
  font-style: italic;
  padding: 40px 20px;
}

.search-result-item {
  background: white;
  border: 1px solid #ecf0f1;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  transition: box-shadow 0.2s;
}

.search-result-item:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.search-result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.search-result-title {
  font-weight: 600;
  color: #2c3e50;
  font-size: 15px;
}

.search-result-timestamp {
  font-size: 12px;
  color: #7f8c8d;
  background: #f8f9fa;
  padding: 3px 8px;
  border-radius: 4px;
}

.search-result-context {
  font-size: 13px;
  color: #34495e;
  line-height: 1.6;
  margin-bottom: 8px;
}

.search-result-meta {
  font-size: 12px;
  color: #95a5a6;
  font-style: italic;
}

.search-loading {
  text-align: center;
  padding: 30px;
  color: #3498db;
  font-size: 15px;
}

.search-error {
  background: #fee;
  color: #c33;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #c33;
  margin: 20px 0;
}

/* Группировка результатов поиска */
.search-result-group {
  margin-bottom: 20px;
  border: 1px solid #ecf0f1;
  border-radius: 8px;
  overflow: hidden;
}

.search-result-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background: linear-gradient(135deg, #f8f9fa, #ecf0f1);
  cursor: pointer;
  transition: background 0.2s;
}

.search-result-group-header:hover {
  background: #e9ecef;
}

.search-result-group-header .search-result-title {
  flex: 1;
  font-weight: 600;
  color: #2c3e50;
}

.search-result-count {
  background: #3498db;
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.search-toggle-icon {
  font-size: 12px;
  color: #7f8c8d;
  transition: transform 0.3s;
}

.search-result-group-content {
  padding: 0;
  max-height: 500px;
  overflow-y: auto;
  transition: all 0.3s;
}

.search-result-group-content.collapsed {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}

.search-segment-divider {
  height: 1px;
  background: #ecf0f1;
  margin: 10px 15px;
}

/* 5. ОСНОВНОЙ КОНТЕЙНЕР */
.container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 6. БОКОВАЯ ПАНЕЛЬ */
.sidebar {
  width: 100%;
  background: var(--bg-sidebar);
  padding: 20px;
  border-radius: 0;
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99;
  overflow-y: auto;
  padding-top: 80px;
  backdrop-filter: blur(5px);
}

.sidebar.visible {
  display: block;
}

/* Затемнение фона */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
}

.sidebar-overlay.visible {
  display: block;
}

/* Контролы сортировки */
.sort-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  align-items: center;
}

.sort-select {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s;
  font-family: inherit;
}

.sort-select:hover {
  border-color: #4a90e2;
}

.sort-select:focus {
  border-color: var(--border-focus);
}

.sort-order-toggle {
  padding: 10px 14px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.sort-order-toggle:hover {
  border-color: #4a90e2;
  background: #e3f2fd;
}

.sort-order-toggle:active {
  transform: scale(0.95);
}

.sort-order-icon {
  font-size: 18px;
  font-weight: bold;
  color: #4a90e2;
  transition: transform 0.3s;
}

/* 7. ЭЛЕМЕНТЫ АУДИО */
.audio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin: 8px 0;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  border: 1px solid transparent;
  font-size: 16px;
  min-height: 52px;
  box-shadow: var(--shadow-sm);
}

.audio-item:hover {
  background: var(--color-info-light);
  border-color: #bbdefb;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.audio-item.active {
  background: #fff8e1;
  border-color: #ffc107;
  font-weight: 600;
  border-left: 4px solid #ffc107;
}

.audio-item-hidden {
  background: #f5f5f5;
  opacity: 0.7;
}

.audio-item-hidden:hover {
  background: #e8e8e8;
  opacity: 1;
}

.audio-item-verified {
  background: linear-gradient(90deg, rgba(39, 174, 96, 0.08) 0%, rgba(39, 174, 96, 0.02) 100%);
  border-left: 4px solid #27ae60;
}

.audio-item-verified:hover {
  background: linear-gradient(90deg, rgba(39, 174, 96, 0.15) 0%, rgba(39, 174, 96, 0.05) 100%);
  border-left-color: #219a52;
}

.audio-hidden-badge {
  background: #ff9800;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.audio-polished-badge {
  background: #27ae60;
  color: white;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 8px;
  display: inline-block;
  min-width: 18px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

/* Бейджи прогресса проверки */
.audio-verified-badge {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(39, 174, 96, 0.3);
}

.audio-progress-badge {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.audio-item-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.audio-name {
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 10px;
  max-width: 100%;
}

.audio-author-label {
  font-size: 0.75em;
  opacity: 0.7;
  white-space: nowrap;
  display: inline;
}

.audio-author {
  color: #7f8c8d;
}

.audio-duration {
  font-size: 0.85em;
  color: #555;
  background: #e8f0f8;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: "Courier New", monospace;
  font-weight: 600;
  min-width: 70px;
  text-align: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  border: 1px solid #d0d8e0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.audio-duration.unknown {
  opacity: 0.5;
}

.audio-item:hover .audio-duration {
  background: #d0e0f0;
  color: #2c3e50;
  border-color: #b0c8d8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.audio-item.active .audio-duration {
  background: #e8c840;
  color: #3d3200;
  border-color: #d4a017;
  box-shadow: 0 2px 4px rgba(212, 160, 23, 0.3);
}

/* Кнопка редактирования аудио */
.audio-edit-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  margin-left: auto;
}

.audio-edit-btn:hover {
  background: #e0e0e0;
  transform: scale(1.1);
}

.audio-edit-btn:active {
  transform: scale(1);
}

/* Кнопка экспорта транскрипта в списке аудио */
.audio-export-btn {
  background: transparent;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
}

.audio-export-btn:hover {
  background: #e0e0e0;
  transform: scale(1.15);
}

.audio-export-btn:active {
  transform: scale(1);
}

/* Кнопка экспорта в статус-баре и панели */
.btn-export {
  background: transparent;
  border: 1px solid #ccc;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-export:hover {
  background: #e8e8e8;
  border-color: #999;
}

.offline-btn {
  background: transparent;
  border: 1px solid #4caf50;
  color: #4caf50;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1.4;
  white-space: nowrap;
  margin-left: 4px;
}

.offline-btn:hover {
  background: #4caf50;
  color: #fff;
}

.offline-btn.cached {
  background: #4caf50;
  color: #fff;
}

.offline-btn.cached:hover {
  background: #f44336;
  border-color: #f44336;
}

/* Кнопка загрузки */
.download-btn {
  display: none;
}

.download-btn:focus {
  outline: none;
}

/* 8. АУДИОПЛЕЕР */
#player {
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fafafa;
  padding: 10px 0;
  margin-top: -10px;
  padding-top: 10px;
}

#player audio {
  width: 100%;
  border-radius: 8px;
}

/* Закрепленная панель для десктопа: плеер + переключатель режимов */
.desktop-sticky-panel {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fafafa;
  padding: 6px 0;
  margin-top: -6px;
  padding-top: 6px;
  margin-bottom: 15px;
  border-bottom: 2px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Стили для переключателя режимов в закрепленной панели */
.desktop-sticky-panel .view-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 4px 0;
  justify-content: center;
  flex-wrap: wrap;
}

.current-audio-name {
  font-size: 12px;
  font-weight: 600;
  color: #2c3e50;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
  flex-shrink: 0;
}

.desktop-sticky-panel .view-mode-btn {
  padding: 5px 12px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  font-weight: 500;
}

.desktop-sticky-panel .view-mode-btn:hover {
  border-color: #4a90e2;
  background: #f0f7ff;
}

.desktop-sticky-panel .view-mode-btn.active {
  border-color: #4a90e2;
  background: #4a90e2;
  color: white;
}

/* Контейнер для транскрипта со скроллом */
.transcript-scroll-container {
  overflow-y: auto;
  max-height: calc(100vh - 180px);
  padding-right: 5px;
}

/* Кастомизация скроллбара для транскрипта */
.transcript-scroll-container::-webkit-scrollbar {
  width: 8px;
}

.transcript-scroll-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.transcript-scroll-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.transcript-scroll-container::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* Плеер в закрепленной панели (десктоп) */
.desktop-sticky-panel #desktop-player {
  padding: 6px 0;
}

.desktop-sticky-panel #desktop-player audio {
  width: 100%;
  border-radius: 6px;
  height: 40px;
}

.success {
  background: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid #4caf50;
}

.warn {
  background: #fff8e1;
  color: #5d4037;
  border-left: 4px solid #ff9800;
}

.error {
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid #f44336;
}

/* 10. СЕГМЕНТЫ ТРАНСКРИПТА */
.segment {
  padding: 16px;
  margin: 12px 0;
  background: var(--bg-surface);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  min-height: 60px;
  box-shadow: var(--shadow-sm);
  /* iOS fix: обеспечиваем кликабельность */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.segment:hover {
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.segment.active {
  background: #fff8e1;
  border-left-color: #d4a017;
}

.timestamp {
  font-family: "Roboto Mono", monospace;
  font-weight: 600;
  color: #2c3e50;
  margin-right: 10px;
  font-size: 14px;
  display: inline-block;
  margin-bottom: 5px;
}

/* Непроверенный сегмент */
.segment.unreviewed {
  background: white;
  border-left: 4px solid #ffc107;
}

/* Проверенный сегмент */
.segment.reviewed {
  background: #e8f5e9;
  border-left: 4px solid #28a745;
}

/* Сегмент для редакторов */
.segment.editable {
  background: white;
  border: 2px dashed #3498db;
}

.segment.editable:hover {
  border: 2px dashed #2980b9;
}

.segment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.segment-timestamp {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.segment-text {
  display: inline;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.segment-text[contenteditable="true"] {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 2px;
  cursor: text;
  display: inline;
  transition: all 0.2s;
}

.segment-text[contenteditable="true"]:hover {
  background: rgba(52, 152, 219, 0.1);
}

.segment-text[contenteditable="true"]:focus {
  background: var(--bg-surface);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

.segment-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.review-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  /* Увеличиваем область клика */
  padding: 8px;
  margin: -8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.review-checkbox:hover {
  background: rgba(40, 167, 69, 0.1);
}

.review-checkbox input {
  cursor: pointer;
  /* iOS fix: увеличиваем размер чекбокса для удобного нажатия */
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  accent-color: #28a745;
  /* Убираем стандартные отступы */
  margin: 0;
}

/* Анимация при изменении состояния */
.review-checkbox input {
  transition: transform 0.15s ease;
}

.review-checkbox input:active {
  transform: scale(0.9);
}

.edit-segment-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
}

.edit-segment-btn:hover {
  background: #2980b9;
}

/* Кнопка удаления сегмента */
.segment-delete-btn {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
  opacity: 0.7;
}

.segment-delete-btn:hover {
  background: #c0392b;
  opacity: 1;
}

.save-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  display: none;
}

.save-indicator.saving {
  display: block;
  background: #ffc107;
  color: #000;
}

.save-indicator.saved {
  display: block;
  background: #28a745;
  color: white;
}

.save-indicator.error {
  display: block;
  background: #dc3545;
  color: white;
}

/* 11. СТАТУС ТРАНСКРИПТА */
.transcript-status-bar {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid #e9ecef;
}

.transcript-status-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 12px;
  flex-wrap: wrap;
}

.version-badge {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

.version-badge.polished {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.status-text {
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
}

.unreviewed-count {
  font-size: 14px;
  color: #e67e22;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(230, 126, 34, 0.1);
  border-radius: 6px;
  margin-left: 8px;
}

.btn-find-unreviewed {
  background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.3);
  margin-left: 8px;
}

.btn-find-unreviewed:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(230, 126, 34, 0.4);
}

.btn-find-unreviewed:active {
  transform: translateY(-1px);
}

/* Подсветка найденного сегмента */
.segment.highlighted {
  background: linear-gradient(135deg, rgba(230, 126, 34, 0.3) 0%, rgba(211, 84, 0, 0.3) 100%);
  border-left: 5px solid #e67e22;
  animation: pulse-highlight 1s ease-in-out;
}

@keyframes pulse-highlight {
  0%, 100% {
    background: linear-gradient(135deg, rgba(230, 126, 34, 0.3) 0%, rgba(211, 84, 0, 0.3) 100%);
  }
  50% {
    background: linear-gradient(135deg, rgba(230, 126, 34, 0.5) 0%, rgba(211, 84, 0, 0.5) 100%);
  }
}

.btn-create-polished {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-create-polished:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.status-progress-bar {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.status-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* 12. ПОДСВЕТКА ПОИСКА */
mark {
  background-color: #ffeb3b;
  padding: 0 2px;
  border-radius: 2px;
}

/* 13. ИНДИКАТОР ЗАГРУЗКИ */
.loading-indicator {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(74, 144, 226, 0.2);
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

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

/* 14. КНОПКИ УПРАВЛЕНИЯ КЭШЕМ */
.cache-controls {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.cache-controls button {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: #f0f0f0;
  color: #555;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.cache-controls button:hover {
  background: #e0e0e0;
}

/* 15. КОММЕНТАРИИ */
.comments-section {
  margin-top: 30px;
}

.comment-form {
  background: var(--bg-muted);
  padding: 20px;
  border-radius: var(--radius-md);
  margin: 20px 0;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 10px;
  margin: 5px 0;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

.comment-form textarea {
  min-height: 100px;
  resize: vertical;
}

.comment-form button {
  background: #4a90e2;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: background-color 0.3s;
  width: 100%;
}

.comment-form button:hover {
  background: #357abd;
}

.comment {
  border: 1px solid #eee;
  padding: 15px;
  margin: 10px 0;
  border-radius: 5px;
  background: white;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.comment-author {
  font-weight: bold;
  color: #333;
}

.comment-date {
  color: #666;
  font-size: 0.9em;
}

.comment-text {
  line-height: 1.5;
}

.success-message {
  background: #d4edda;
  color: #155724;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  display: none;
}

.error-message {
  background: #f8d7da;
  color: #721c24;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  display: none;
}

.comments-desktop {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
}

.comments-desktop h3 {
  margin-top: 0;
}

.comments-mobile {
  margin-top: 20px;
}

.comments-accordion-content {
  max-height: none;
  overflow: visible;
  background: transparent;
}

.comments-accordion-content.expanded {
  max-height: none;
  padding: 0;
  border: none;
}

.comments-accordion-toggle {
  display: none;
}

.comments-list {
  max-height: 400px;
  overflow-y: auto;
}

.no-comments {
  text-align: center;
  color: #666;
  font-style: italic;
  padding: 20px;
}

/* 16. НИЖНЯЯ ПАНЕЛЬ ДЛЯ МОБИЛЬНЫХ */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 5px 10px;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 101;
  min-height: 60px;
  padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  padding: 5px 8px;
  cursor: pointer;
  color: #2c3e50;
  border-radius: 6px;
  transition: all 0.2s ease;
  min-width: 50px;
}

.mobile-nav-btn:active {
  background: #f0f0f0;
  transform: scale(0.95);
}

.mobile-nav-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.mobile-nav-btn[disabled]:active {
  background: transparent;
  transform: none;
}

.btn-icon {
  font-size: 20px;
  line-height: 1;
}

.btn-label {
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
}

/* 16.1 ВЫПАДАЮЩЕЕ МЕНЮ "ЕЩЁ" */
.more-menu {
  position: fixed;
  bottom: 75px;
  right: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 9999;
  min-width: 170px;
  backdrop-filter: blur(12px);
}

.more-menu.show {
  display: flex;
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-color);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
  width: 100%;
  text-align: left;
}

.more-menu-item:hover {
  background: var(--bg-hover, #f0f0f0);
}

.more-menu-item:active {
  background: var(--bg-active, #e0e0e0);
}

.more-menu-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.more-menu-label {
  font-weight: 500;
}

.more-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 8px;
}

/* 17. МОБИЛЬНЫЙ ПЛЕЕР */
#mobile-player {
  display: none !important;
  position: fixed;
  bottom: 70px;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 12px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  z-index: 1000 !important;
}

#mobile-player audio {
  width: 100%;
  height: 44px;
  border-radius: 8px;
}

/* 18. МОДАЛЬНЫЕ ОКНА */
.modal {
  display: none !important;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-overlay);
  overflow-y: auto;
}

.modal.show {
  display: flex !important;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
  margin: 0 auto;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-content-wide {
  max-width: 600px;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Опции фильтра по темам */
.topic-filter-options,
.sort-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-option,
.sort-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.topic-option:hover,
.sort-option:hover {
  background: #e9ecef;
}

.topic-option input,
.sort-option input {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.topic-option span,
.sort-option span {
  font-size: 16px;
  color: #2c3e50;
}

/* Кнопка порядка сортировки */
.sort-order-toggle {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.sort-order-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: #2c3e50;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.sort-order-btn:hover {
  background: #1a252f;
}

/* Статистика редакторов */
.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}

.stats-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #2c3e50;
}

.stats-table tr:hover {
  background: #f8f9fa;
}

.stats-editor-name {
  font-weight: 500;
}

.stats-count {
  font-weight: 600;
  color: #2c3e50;
}

.loading {
  text-align: center;
  color: #666;
  padding: 20px;
}

/* 19. ФОРМА РЕДАКТИРОВАНИЯ АУДИО */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  color: #2c3e50;
  font-size: 14px;
}

.form-group input[type="text"],
.form-group select {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 15px;
  background: white;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
  border-color: var(--color-accent);
}

.form-readonly {
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  color: #666;
  font-size: 14px;
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #4caf50;
  color: white;
}

.btn-primary:hover {
  background: #45a049;
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.form-message {
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
  display: none;
}

.form-message.success {
  background: #e8f5e9;
  color: #2e7d32;
  display: block;
}

.form-message.error {
  background: #ffebee;
  color: #c62828;
  display: block;
}

/* 20. ССЫЛКА НА ФОРУМ */
.footer-links {
  text-align: center;
  padding: 20px;
  margin-top: 30px;
  border-top: 1px solid #e0e0e0;
}

.footer-link {
  color: #999;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.footer-link:hover {
  color: #666;
  text-decoration: underline;
}

/* 20.1 ИНДИКАТОР ОНЛАЙНА */
.online-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f8f9fa;
  border-radius: 20px;
  margin: 10px 15px 10px 0;
  font-size: 13px;
  color: #555;
}

.online-dot {
  width: 8px;
  height: 8px;
  background: #27ae60;
  border-radius: 50%;
  animation: online-pulse 2s infinite;
}

@keyframes online-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.online-text {
  font-weight: 500;
}

.online-link {
  color: #3498db;
  text-decoration: none;
  font-weight: 500;
  margin-left: 5px;
  transition: color 0.2s;
}

.online-link:hover {
  color: #2980b9;
  text-decoration: none;
}

.online-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: white;
  border-radius: 12px;
  font-size: 12px;
  margin-right: 4px;
}

.online-user-badge .role-icon {
  font-size: 11px;
}

/* 20.1 КНОПКИ НАВИГАЦИИ ВВЕРХ/ВНИЗ */
.scroll-nav-btn {
  position: fixed;
  right: 20px;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  transform: translateY(20px);
}

.scroll-nav-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-up-btn {
  bottom: 180px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.scroll-down-btn {
  bottom: 120px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.scroll-nav-btn:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.scroll-nav-btn:active {
  transform: translateY(-1px) scale(1.05);
}

/* Мобильная версия */
@media (max-width: 768px) {
  .scroll-nav-btn {
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 20px;
  }
  
  .scroll-up-btn {
    bottom: 160px;
  }
  
  .scroll-down-btn {
    bottom: 105px;
  }
}

/* На мобильных скрываем плавающие кнопки — они в меню "Ещё" */
@media (max-width: 768px) {
  .scroll-nav-btn {
    display: none;
  }
}

/* 21. АНИМАЦИИ */
.audio-item,
.segment,
button {
  -webkit-tap-highlight-color: transparent;
}

.audio-item:active,
.segment:active {
  transform: scale(0.98);
}

/* === МОБИЛЬНЫЕ СТИЛИ (<768px) === */
@media (max-width: 767px) {
  /* Запрет горизонтального скролла на мобильных */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  /* Адаптация основных контейнеров */
  .main-content-wrapper,
  .transcript-container,
  .sidebar {
    max-width: 100%;
    overflow-x: hidden;
  }

  .comments-desktop {
    display: none;
  }

  #mobile-player:not(.hidden) {
    display: block !important;
  }

  .mobile-bottom-bar {
    display: flex;
  }

  body {
    padding-bottom: 140px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 14px;
  }

  .cache-controls {
    margin-bottom: 140px;
  }

  .mobile-menu-toggle {
    display: none;
  }

  .sidebar .sort-controls {
    display: none;
  }

  /* Скрываем закрепленную панель на мобильных */
  .desktop-sticky-panel {
    display: none !important;
  }

  /* Показываем переключатель режимов в транскрипте на мобильных */
  #transcript .view-mode-toggle {
    display: flex !important;
  }

  .modal.show {
    align-items: flex-end;
    justify-content: center;
  }

  .modal-content {
    border-radius: 12px 12px 0 0;
    width: 100%;
    max-height: 80vh;
  }

  .page-header {
    flex-wrap: wrap;
    padding-right: 70px;
  }

  .header-user {
    position: absolute;
    right: 8px;
    top: 8px;
    gap: 4px;
  }

  .user-greeting {
    display: none;
  }

  .login-btn,
  .logout-btn {
    padding: 3px 6px;
    font-size: 10px;
  }

  .user-role-badge {
    padding: 2px 4px;
    font-size: 9px;
  }
  
  .header-title h1 {
    font-size: 14px;
  }
  
  .header-title p {
    font-size: 10px;
  }

  .audio-duration {
    font-size: 0.8em;
    padding: 1px 6px;
    min-width: 65px;
  }

  .audio-name {
    margin-right: 5px;
  }

  .download-btn {
    display: inline-block;
    padding: 12px 15px;
    font-size: 1.3em;
  }

  .mobile-nav-btn#mobileAuthorsBtn {
    display: none;
  }
  
  .audio-item-content {
    padding: 8px 4px;
  }
}

/* === ДЕСКТОПНАЯ ВЕРСИЯ (от 768px) === */
@media (min-width: 768px) {
  body {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 30px;
    padding-bottom: 20px;
  }

  h1 {
    font-size: 32px;
    margin-bottom: 30px;
  }

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 18px;
  }

  .mobile-menu-toggle {
    display: none;
  }

  .desktop-topic-btn {
    display: none;
  }

  .desktop-control-panel {
    display: flex;
  }

  .container {
    flex-direction: row;
    gap: 30px;
  }

  .sidebar {
    display: block;
    width: 350px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: var(--bg-sidebar);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color-light);
  }

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

  .main-content-wrapper {
    display: flex;
    gap: 30px;
    flex: 1;
    min-width: 0;
  }

  .transcript-container {
    flex: 1;
    min-width: 0;
  }

  .audio-item {
    font-size: 15px;
    min-height: 46px;
    padding: 12px 16px;
  }

  .segment {
    min-height: auto;
    padding: 12px 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .segment-text {
    font-size: 14px;
    line-height: 1.4;
  }

  .segment-timestamp {
    flex-wrap: wrap;
    gap: 4px;
  }

  .timestamp {
    font-size: 12px;
    white-space: nowrap;
  }

  .comments-desktop {
    display: block;
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-muted);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }

  .comments-mobile {
    display: none;
  }

  .comment-form button {
    width: auto;
  }

  .mobile-bottom-bar {
    display: none !important;
  }

  #mobile-player {
    display: none !important;
  }

  /* Скрываем переключатель режимов в транскрипте на десктопе (он в sticky панели) */
  #transcript .view-mode-toggle {
    display: none;
  }

  .cache-controls {
    margin-top: 30px;
    margin-bottom: 20px;
    justify-content: flex-start;
  }

  .footer-links {
    margin-top: 40px;
    margin-bottom: 20px;
    text-align: left;
    padding-left: 0;
  }

  .logo-icon {
    width: 40px;
    height: 40px;
    max-width: none;
  }

  .modal.show {
    align-items: center;
    justify-content: center;
  }

  .modal-content {
    max-width: 500px;
    width: 90%;
    border-radius: 12px;
    margin: 20px auto;
  }
}

/* === ПЛАНШЕТЫ (768-1023px) === */
@media (min-width: 768px) and (max-width: 1023px) {
  .comments-desktop {
    display: none;
  }

  .comments-mobile {
    display: block;
  }

  .main-content-wrapper {
    flex-direction: column;
  }
  
  .sidebar {
    width: 300px;
  }
}

/* === ПЛАНШЕТЫ (от 1024px) === */
@media (min-width: 1024px) {
  .sidebar {
    width: 400px;
  }

  .comments-desktop {
    width: 350px;
  }
}

/* === ТЁМНАЯ ТЕМА (prefers-color-scheme) === */
@media (prefers-color-scheme: dark) {
  body {
    background: #121212;
    color: #e0e0e0;
  }

  .page-header {
    background: #1e1e1e;
    color: #e0e0e0;
    border-bottom-color: #4caf50;
  }

  .header-btn {
    background: #555;
    color: #ccc;
    opacity: 0.7;
  }

  .sidebar {
    background: #1e1e1e;
  }

  .audio-item {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .audio-item:hover {
    background: #3d3d3d;
  }

  .audio-item.active {
    background: #3d3200;
    border-left: 4px solid #d4a017;
    color: white;
  }

  .audio-duration {
    background: #2d3d4d;
    color: #b0c4de;
    border-color: #3d4d5d;
  }

  .audio-item:hover .audio-duration {
    background: #3d4d5d;
    color: #c0d4ee;
    border-color: #4d5d6d;
  }

  .audio-item.active .audio-duration {
    background: #5a4a00;
    color: #ffd700;
    border-color: #d4a017;
  }

  .segment {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .segment:hover {
    background: #3d3d3d;
  }
  
  /* Контрастный текст для редактирования в тёмной схеме */
  .segment-text {
    color: #ffffff;
  }
  
  .segment-text[contenteditable="true"] {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
  }
  
  .segment-text[contenteditable="true"]:hover {
    background: rgba(52, 152, 219, 0.2);
  }
  
  .segment-text[contenteditable="true"]:focus {
    background: #2d3d4d;
    border-color: #4a90e2;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3);
  }
  
  /* Timestamp в сегментах */
  .segment-timestamp {
    color: #b0c4de;
  }
  
  .segment-timestamp .timestamp {
    color: #4caf50;
  }

  /* Режим чтения - тёмная схема */
  .reading-text-container {
    background: #2d2d2d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .reading-text {
    color: #e0e0e0;
  }
  
  .reading-segment {
    color: #e0e0e0;
    border-bottom-color: rgba(224, 224, 224, 0.3);
  }
  
  .reading-segment:hover {
    border-bottom-color: #4a90e2;
    background: rgba(74, 144, 226, 0.15);
  }
  
  .reading-segment.active {
    background: rgba(255, 193, 7, 0.2);
    border-bottom-color: #ffc107;
    color: #ffffff;
  }
  
  .reading-segment.active:hover {
    background: rgba(255, 193, 7, 0.3);
  }

  /* Транскрипт - тёмная схема */
  #transcript,
  .transcript-container {
    background: #1e1e1e !important;
    color: #e0e0e0 !important;
  }
  
  .segment {
    background: #2d2d2d !important;
    color: #e0e0e0 !important;
    border-left-color: #4a90e2;
  }
  
  .segment.reviewed {
    background: #1e3a2e !important;
    border-left-color: #28a745;
  }

  .segment.active {
    background: #3d3200 !important;
    border-left-color: #d4a017;
  }
  
  .segment.unreviewed {
    background: #2d2d2d !important;
    border-left-color: #ffc107;
  }
  
  .segment:hover {
    background: #3d3d3d !important;
  }
  
  /* Текст внутри сегментов */
  .segment-text {
    color: #ffffff !important;
  }
  
  /* Временные метки */
  .timestamp {
    color: #4caf50 !important;
  }
  
  /* Строка статуса транскрипта */
  .transcript-status-bar {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
  }
  
  .status-text {
    color: #e0e0e0;
  }
  
  .unreviewed-count {
    color: #ffc107;
  }
  
  .btn-find-unreviewed {
    background: #4a90e2;
    color: white;
  }
  
  /* Режим чтения - тёмная схема */
  .reading-text-container {
    background: #2d2d2d !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .reading-text {
    color: #e0e0e0 !important;
  }
  
  .reading-segment {
    color: #e0e0e0 !important;
    border-bottom-color: rgba(224, 224, 224, 0.3);
  }
  
  .reading-segment:hover {
    border-bottom-color: #4a90e2;
    background: rgba(74, 144, 226, 0.15);
  }
  
  .reading-segment.active {
    background: rgba(255, 193, 7, 0.2) !important;
    border-bottom-color: #ffc107;
    color: #ffffff !important;
  }
  
  .reading-segment.active:hover {
    background: rgba(255, 193, 7, 0.3) !important;
  }

  /* Поиск - тёмная схема */
  .search-query-container {
    background: #1e1e1e;
  }
  
  #semanticSearchInput {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
  }
  
  #semanticSearchInput:focus {
    border-color: #4a90e2;
  }
  
  .search-results {
    background: #1e1e1e;
  }
  
  .search-placeholder {
    color: #888;
  }
  
  .search-result-item {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
  }
  
  .search-result-item:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  }
  
  .search-result-title {
    color: #e0e0e0;
  }
  
  .search-result-context {
    color: #e0e0e0;
  }
  
  .search-result-group {
    border-color: #444;
  }
  
  .search-result-group-header {
    background: linear-gradient(135deg, #2d2d2d, #1e1e1e);
  }
  
  .search-result-group-header:hover {
    background: #3d3d3d;
  }
  
  .search-segment-divider {
    background: #444;
  }

  #player {
    background: #121212;
  }

  .cache-controls button {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .cache-controls button:hover {
    background: #3d3d3d;
  }

  .sort-select {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
  }

  .sort-select:hover,
  .sort-select:focus {
    border-color: #4a90e2;
  }

  .sort-order-toggle {
    background: #2d2d2d;
    color: #e0e0e0;
    border-color: #444;
  }

  .sort-order-toggle:hover {
    background: #3d3d3d;
    border-color: #4a90e2;
  }

  .sort-order-icon {
    color: #4a90e2;
  }

  .comment-form {
    background: #2d2d2d;
  }

  .comment {
    background: #2d2d2d;
    border-color: #444;
  }

  .comments-desktop {
    background: #1e1e1e;
    border-color: #333;
  }

  .comments-accordion-toggle {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .comments-accordion-toggle:hover {
    background: #3d3d3d;
  }

  .mobile-bottom-bar {
    background: #1e1e1e;
    border-top-color: #333;
  }

  .mobile-nav-btn {
    color: #e0e0e0;
  }
  
  .mobile-nav-btn:active {
    background: #2d2d2d;
  }

  .more-menu {
    background: #1e1e1e;
    border-color: #333;
  }

  .more-menu-item {
    color: #e0e0e0;
  }

  .more-menu-item:hover {
    background: #2d2d2d;
  }

  .more-menu-item:active {
    background: #333;
  }

  #mobile-player {
    background: #1e1e1e;
    border-top-color: #333;
    border-bottom-color: #333;
  }

  #mobile-player audio {
    filter: invert(1) hue-rotate(180deg);
  }

  .modal-content {
    background: #1e1e1e;
  }

  .modal-header {
    border-bottom-color: #333;
  }

  .modal-header h3 {
    color: #e0e0e0;
  }

  .modal-close {
    color: #999;
  }

  .modal-close:hover {
    background: #2d2d2d;
    color: #fff;
  }

  .topic-option,
  .sort-option {
    background: #2d2d2d;
  }

  .topic-option:hover,
  .sort-option:hover {
    background: #3d3d3d;
  }

  .topic-option span,
  .sort-option span {
    color: #e0e0e0;
  }

  .sort-order-btn {
    background: #4caf50;
  }

  .stats-table th {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .stats-table td {
    border-bottom-color: #333;
    color: #e0e0e0;
  }

  .stats-table tr:hover {
    background: #2d2d2d;
  }

  .stats-count {
    color: #4caf50;
  }

  .form-group label {
    color: #e0e0e0;
  }

  .form-group input[type="text"],
  .form-group select {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
  }

  .form-group input[type="text"]:focus,
  .form-group select:focus {
    border-color: #4caf50;
  }

  .form-readonly {
    background: #2d2d2d;
    color: #999;
  }

  .btn-secondary {
    background: #3d3d3d;
    color: #e0e0e0;
  }

  .btn-secondary:hover {
    background: #4d4d4d;
  }

  .form-message.success {
    background: #1b5e20;
    color: #a5d6a7;
  }

  .form-message.error {
    background: #b71c1c;
    color: #ffcdd2;
  }

  .footer-links {
    border-top-color: #444;
  }

  .footer-link {
    color: #666;
  }

  .footer-link:hover {
    color: #999;
  }

  .logo-icon {
    box-shadow: 0 2px 8px rgba(255,255,255,0.1);
  }

  .download-btn {
    color: #fff;
  }
  
  .download-btn:hover,
  .download-btn:active {
    background-color: rgba(255, 255, 255, 0.1);
  }

  .audio-edit-btn:hover {
    background: #3d3d3d;
  }

  .segment-delete-btn {
    background: #c62828;
    color: #ffcdd2;
  }

  .segment-delete-btn:hover {
    background: #b71c1c;
  }
}

/* === 20. ЗАМЕТКИ РЕДАКТОРА === */

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 15px;
  flex-wrap: wrap;
}

.btn-add-note {
  background: #28a745;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-add-note:hover {
  background: #218838;
}

.notes-stats {
  font-size: 14px;
  color: #666;
  background: #f8f9fa;
  padding: 8px 15px;
  border-radius: 8px;
}

.btn-all-notes {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-all-notes:hover {
  background: #2980b9;
}

.note-form {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.note-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

.note-form textarea:focus {
  border-color: var(--border-focus);
}

.note-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* Мобильная версия: кнопки вверху формы */
@media (max-width: 767px) {
  .note-form {
    padding: 12px;
  }
  
  .note-form-actions {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    padding: 8px 0;
    margin-top: 0;
    margin-bottom: 12px;
    z-index: 10;
    border-bottom: 1px solid #e0e0e0;
  }
  
  .note-form-actions button {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .note-form textarea {
    min-height: 80px;
    font-size: 14px;
  }
  
  .notes-header {
    flex-direction: column;
    gap: 8px;
  }
  
  .notes-header button {
    width: 100%;
    justify-content: center;
  }
  
  .btn-all-notes {
    display: flex;
  }
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note-item {
  background: white;
  border-left: 4px solid #3498db;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.2s;
}

.note-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.note-item.has-segment {
  border-left-color: #ffc107;
  cursor: pointer;
}

.note-item.has-segment:hover {
  border-left-color: #ff9800;
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.note-audio-link {
  font-size: 13px;
  color: #3498db;
  text-decoration: none;
  font-weight: 600;
}

.note-audio-link:hover {
  text-decoration: underline;
}

.note-audio-text {
  font-size: 13px;
  color: #3498db;
  font-weight: 600;
}

.note-segment-badge {
  background: #ffc107;
  color: #000;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.note-segment-badge-inactive {
  background: #95a5a6;
  color: #fff;
}

.note-segment-badge-active {
  background: #27ae60;
  color: #fff;
  cursor: pointer;
}

.note-segment-badge-active:hover {
  background: #219a52;
  transform: scale(1.05);
}

.notes-list-header {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border-left: 4px solid #3498db;
}

.notes-list-header h3 {
  margin: 0 0 5px 0;
  font-size: 16px;
  color: #2c3e50;
}

.notes-subtitle {
  margin: 0;
  font-size: 13px;
  color: #7f8c8d;
  font-style: italic;
}

.note-item-global {
  background: #fafafa;
  border-left: 3px solid #95a5a6;
}

.note-item-local {
  background: #fff;
  border-left: 3px solid #27ae60;
}

.note-item-local.has-segment {
  cursor: pointer;
  transition: background 0.2s;
}

.note-item-local.has-segment:hover {
  background: #e8f6e8;
}

.note-segment-info {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.note-segment-info #currentSegmentName {
  font-weight: 600;
  color: #856404;
}

.btn-unlink-segment {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 16px;
  margin-left: auto;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-unlink-segment:hover {
  background: #dc3545;
  color: white;
}

.note-text {
  color: #333;
  line-height: 1.5;
  white-space: pre-wrap;
  margin-bottom: 10px;
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #999;
}

.note-actions {
  display: flex;
  gap: 8px;
}

.note-edit-btn,
.note-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.note-edit-btn:hover {
  background: #e3f2fd;
}

.note-delete-btn:hover {
  background: #ffebee;
}

.empty-notes {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.empty-notes-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

/* === РЕЖИМ ЧТЕНИЯ: сплошной текст === */
.reading-text-container {
  margin-top: 20px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.reading-text {
  font-size: 1.1em;
  line-height: 1.8;
  color: #2c3e50;
  text-align: justify;
}

.reading-segment {
  cursor: pointer;
  border-bottom: 1px dotted transparent;
  transition: all 0.2s;
  padding: 2px 0;
  display: inline;
}

.reading-segment:hover {
  border-bottom-color: #4a90e2;
  background: rgba(74, 144, 226, 0.1);
}

/* Подсветка текущего воспроизводимого сегмента */
.reading-segment.active {
  background: #fff3cd;
  border-bottom-color: #ffc107;
  font-weight: 600;
}

.reading-segment.active:hover {
  background: #ffe69c;
}

/* Переключатель режимов: Редактор / Чтение */
.view-mode-toggle {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  padding: 8px 0;
}

.view-mode-btn {
  padding: 8px 16px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  font-weight: 500;
}

.view-mode-btn:hover {
  border-color: #4a90e2;
  background: #f0f7ff;
}

.view-mode-btn.active {
  border-color: #4a90e2;
  background: #4a90e2;
  color: white;
}

/* ========== СТИЛИ ДЛЯ УПРАВЛЕНИЯ АВТОРАМИ ========== */
.authors-header {
  margin-bottom: 16px;
}

.authors-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.authors-add-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.authors-list {
  max-height: 400px;
  overflow-y: auto;
}

.author-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 6px;
  transition: background 0.2s;
}

.author-item:hover {
  background: #f8f9fa;
}

.author-item-info {
  flex: 1;
}

.author-item-name {
  font-weight: 500;
  font-size: 15px;
}

.author-item-count {
  font-size: 12px;
  color: #7f8c8d;
  margin-top: 2px;
}

.author-item-actions {
  display: flex;
  gap: 6px;
}

.author-edit-btn,
.author-delete-btn {
  background: none;
  border: 1px solid #ddd;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  transition: all 0.2s;
}

.author-edit-btn:hover {
  background: #e8f4fd;
  border-color: #4a90e2;
}

.author-delete-btn:hover {
  background: #fde8e8;
  border-color: #e74c3c;
}

.author-edit-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #4a90e2;
  border-radius: 4px;
  font-size: 14px;
  margin-right: 8px;
}

.author-edit-actions {
  display: flex;
  gap: 4px;
}

.author-save-btn,
.author-cancel-btn {
  background: none;
  border: 1px solid #ddd;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.author-save-btn {
  background: #4a90e2;
  color: white;
  border-color: #4a90e2;
}

.author-cancel-btn:hover {
  background: #f0f0f0;
}

/* === СТИЛИ ДЛЯ ШЕРИНГА === */
.reading-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  margin-bottom: 12px;
  flex-wrap: wrap;
}


.share-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* === ПОИСК В ТРАНСКРИПТЕ === */
.transcript-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin: 8px 0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.transcript-search-bar input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  background: var(--bg-color);
  color: var(--text-color);
  outline: none;
  min-width: 0;
}

.transcript-search-bar input:focus {
  border-color: #4a90e2;
}

.transcript-search-bar button {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-color);
  transition: background 0.15s;
  line-height: 1;
}

.transcript-search-bar button:hover {
  background: var(--bg-hover, #f0f0f0);
}

.transcript-search-bar .search-count {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: center;
  white-space: nowrap;
}

.transcript-search-bar .search-close-btn {
  border: none;
  font-size: 18px;
  padding: 4px 8px;
  opacity: 0.6;
}

.transcript-search-bar .search-close-btn:hover {
  opacity: 1;
}

/* Подсветка совпадений поиска */
.search-match {
  background: #fff3cd !important;
  border-radius: 3px;
}

.search-match-current {
  background: #ffe082 !important;
  box-shadow: 0 0 0 2px #ffb300;
  border-radius: 3px;
}

/* === ПЕРЕКЛЮЧАТЕЛЬ РЕЖИМА В НИЖНЕЙ ПАНЕЛИ === */
#mobileViewModeBtn {
  transition: all 0.2s;
}

#mobileViewModeBtn.active-mode {
  background: rgba(74, 144, 226, 0.15);
}

.share-btn-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-btn-header:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.share-hint {
  font-size: 12px;
  color: #999;
  font-style: italic;
}

.share-popup {
  position: fixed;
  z-index: 99999;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: all 0.2s;
}

.share-popup.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.share-popup button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  width: 100%;
}

.share-popup button:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.share-notification {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e50;
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  z-index: 99999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  white-space: nowrap;
}

.share-notification.visible {
  opacity: 1;
  visibility: visible;
  bottom: 100px;
}

/* Тёмная тема для элементов шеринга */
@media (prefers-color-scheme: dark) {
  .reading-toolbar {
    background: #1e1e1e;
    border-bottom-color: #333;
  }

  .share-hint {
    color: #666;
  }

  .share-popup {
    background: #2d2d2d;
    border-color: #444;
  }

  .share-notification {
    background: #1e1e1e;
    color: #e0e0e0;
  }
}

/* === СОДЕРЖАНИЕ ТРАНСКРИПТА (TOC) === */
.btn-danger {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #e74c3c;
  color: white;
  transition: all 0.2s;
}
.btn-danger:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

.toc-item {
  display: flex;
  align-items: flex-start;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  gap: 10px;
}
.toc-item:hover {
  background: var(--bg-hover, rgba(0,0,0,0.04));
}
.toc-item-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #666);
  white-space: nowrap;
  min-width: 42px;
  padding-top: 1px;
  font-family: monospace;
}
.toc-item-title {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-color);
}
.toc-item:hover .toc-item-title {
  color: var(--accent-color, #1976d2);
}
.toc-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary, #888);
  font-size: 14px;
}
.toc-loading {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary, #888);
}
.toc-admin-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.toc-admin-controls .btn-primary,
.toc-admin-controls .btn-secondary,
.toc-admin-controls .btn-danger {
  flex: 1;
  min-width: 120px;
}

/* === ПРИНУДИТЕЛЬНЫЙ РЕЖИМ ТЕМЫ (через класс на <html>) === */

html.theme-dark {
  --bg-body: #121212;
  --bg-surface: #1e1e1e;
  --bg-surface-hover: #2d2d2d;
  --bg-sidebar: #1e1e1e;
  --bg-header: #1e1e1e;
  --bg-muted: #2d2d2d;
  --bg-overlay: rgba(0, 0, 0, 0.7);
  --text-primary: #e0e0e0;
  --text-secondary: #b0bec5;
  --text-muted: #7f8c8d;
  --text-inverse: #ffffff;
  --border-color: #444;
  --border-color-light: #333;
  --border-focus: #5a9fd4;
}

html.theme-light {
  --bg-body: #fafafa;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f5f7fa;
  --bg-sidebar: rgba(240, 247, 255, 0.98);
  --bg-header: #f8f9fa;
  --bg-muted: #f8f9fa;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --text-primary: #2c3e50;
  --text-secondary: #5a6a7a;
  --text-muted: #7f8c8d;
  --text-inverse: #ffffff;
  --border-color: #e0e0e0;
  --border-color-light: #ecf0f1;
  --border-focus: #4a6fa5;
}

/* .theme-dark — твёрдые переопределения (копия @media prefers-color-scheme: dark) */
html.theme-dark .skeleton {
  background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
}

html.theme-dark .page-header {
  background: #1e1e1e;
  color: #e0e0e0;
  border-bottom-color: #4caf50;
}

html.theme-dark .header-btn {
  background: #555;
  color: #ccc;
  opacity: 0.7;
}

html.theme-dark .sidebar {
  background: #1e1e1e;
}

html.theme-dark .audio-item {
  background: #2d2d2d;
  color: #e0e0e0;
}

html.theme-dark .audio-item:hover {
  background: #3d3d3d;
}

html.theme-dark .audio-item.active {
  background: #3d3200;
  border-left: 4px solid #d4a017;
  color: white;
}

html.theme-dark .audio-duration {
  background: #2d3d4d;
  color: #b0c4de;
  border-color: #3d4d5d;
}

html.theme-dark .audio-item:hover .audio-duration {
  background: #3d4d5d;
  color: #c0d4ee;
  border-color: #4d5d6d;
}

html.theme-dark .audio-item.active .audio-duration {
  background: #5a4a00;
  color: #ffd700;
  border-color: #d4a017;
}

html.theme-dark .segment,
html.theme-dark .segment.unreviewed {
  background: #2d2d2d !important;
  color: #e0e0e0 !important;
  border-left-color: #4a90e2;
}

html.theme-dark .segment:hover {
  background: #3d3d3d !important;
}

html.theme-dark .segment.reviewed {
  background: #1e3a2e !important;
  border-left-color: #28a745;
}

html.theme-dark .segment.active {
  background: #3d3200 !important;
  border-left-color: #d4a017;
}

html.theme-dark .segment-text,
html.theme-dark .segment-text[contenteditable="true"] {
  color: #ffffff !important;
}

html.theme-dark .segment-text[contenteditable="true"] {
  background: rgba(255, 255, 255, 0.05);
}

html.theme-dark .segment-text[contenteditable="true"]:hover {
  background: rgba(52, 152, 219, 0.2);
}

html.theme-dark .segment-text[contenteditable="true"]:focus {
  background: #2d3d4d;
  border-color: #4a90e2;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3);
}

html.theme-dark .segment-timestamp {
  color: #b0c4de;
}

html.theme-dark .segment-timestamp .timestamp,
html.theme-dark .timestamp {
  color: #4caf50 !important;
}

html.theme-dark .reading-text-container {
  background: #2d2d2d !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

html.theme-dark .reading-text {
  color: #e0e0e0 !important;
}

html.theme-dark .reading-segment {
  color: #e0e0e0 !important;
  border-bottom-color: rgba(224, 224, 224, 0.3);
}

html.theme-dark .reading-segment:hover {
  border-bottom-color: #4a90e2;
  background: rgba(74, 144, 226, 0.15);
}

html.theme-dark .reading-segment.active {
  background: rgba(255, 193, 7, 0.2) !important;
  border-bottom-color: #ffc107;
  color: #ffffff !important;
}

html.theme-dark .reading-segment.active:hover {
  background: rgba(255, 193, 7, 0.3) !important;
}

html.theme-dark #transcript,
html.theme-dark .transcript-container {
  background: #1e1e1e !important;
  color: #e0e0e0 !important;
}

html.theme-dark .transcript-status-bar {
  background: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

html.theme-dark .status-text {
  color: #e0e0e0;
}

html.theme-dark .unreviewed-count {
  color: #ffc107;
}

html.theme-dark .btn-find-unreviewed {
  background: #4a90e2;
  color: white;
}

html.theme-dark .search-query-container,
html.theme-dark .search-results {
  background: #1e1e1e;
}

html.theme-dark #semanticSearchInput {
  background: #2d2d2d;
  color: #e0e0e0;
  border-color: #444;
}

html.theme-dark #semanticSearchInput:focus {
  border-color: #4a90e2;
}

html.theme-dark .search-placeholder {
  color: #888;
}

html.theme-dark .search-result-item {
  background: #2d2d2d;
  color: #e0e0e0;
  border-color: #444;
}

html.theme-dark .search-result-item:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

html.theme-dark .search-result-title,
html.theme-dark .search-result-context {
  color: #e0e0e0;
}

html.theme-dark .search-result-group {
  border-color: #444;
}

html.theme-dark .search-result-group-header {
  background: linear-gradient(135deg, #2d2d2d, #1e1e1e);
}

html.theme-dark .search-result-group-header:hover {
  background: #3d3d3d;
}

html.theme-dark .search-segment-divider {
  background: #444;
}

html.theme-dark #player {
  background: #121212;
}

html.theme-dark .cache-controls button {
  background: #2d2d2d;
  color: #e0e0e0;
}

html.theme-dark .cache-controls button:hover {
  background: #3d3d3d;
}

html.theme-dark .sort-select {
  background: #2d2d2d;
  color: #e0e0e0;
  border-color: #444;
}

html.theme-dark .sort-select:hover,
html.theme-dark .sort-select:focus {
  border-color: #4a90e2;
}

html.theme-dark .sort-order-toggle {
  background: #2d2d2d;
  color: #e0e0e0;
  border-color: #444;
}

html.theme-dark .sort-order-toggle:hover {
  background: #3d3d3d;
  border-color: #4a90e2;
}

html.theme-dark .sort-order-icon {
  color: #4a90e2;
}

html.theme-dark .comment-form,
html.theme-dark .comment {
  background: #2d2d2d;
}

html.theme-dark .comment {
  border-color: #444;
}

html.theme-dark .comments-desktop {
  background: #1e1e1e;
  border-color: #333;
}

html.theme-dark .comments-accordion-toggle {
  background: #2d2d2d;
  color: #e0e0e0;
}

html.theme-dark .comments-accordion-toggle:hover {
  background: #3d3d3d;
}

html.theme-dark .mobile-bottom-bar {
  background: #1e1e1e;
  border-top-color: #333;
}

html.theme-dark .mobile-nav-btn {
  color: #e0e0e0;
}

html.theme-dark .mobile-nav-btn:active {
  background: #2d2d2d;
}

html.theme-dark .more-menu {
  background: #1e1e1e;
  border-color: #333;
}

html.theme-dark .more-menu-item {
  color: #e0e0e0;
}

html.theme-dark .more-menu-item:hover {
  background: #2d2d2d;
}

html.theme-dark .more-menu-item:active {
  background: #333;
}

html.theme-dark #mobile-player {
  background: #1e1e1e;
  border-top-color: #333;
  border-bottom-color: #333;
}

html.theme-dark #mobile-player audio {
  filter: invert(1) hue-rotate(180deg);
}

html.theme-dark .modal-content {
  background: #1e1e1e;
}

html.theme-dark .modal-header {
  border-bottom-color: #333;
}

html.theme-dark .modal-header h3 {
  color: #e0e0e0;
}

html.theme-dark .modal-close {
  color: #999;
}

html.theme-dark .modal-close:hover {
  background: #2d2d2d;
  color: #fff;
}

html.theme-dark .topic-option,
html.theme-dark .sort-option {
  background: #2d2d2d;
}

html.theme-dark .topic-option:hover,
html.theme-dark .sort-option:hover {
  background: #3d3d3d;
}

html.theme-dark .topic-option span,
html.theme-dark .sort-option span {
  color: #e0e0e0;
}

html.theme-dark .sort-order-btn {
  background: #4caf50;
}

html.theme-dark .stats-table th {
  background: #2d2d2d;
  color: #e0e0e0;
}

html.theme-dark .stats-table td {
  border-bottom-color: #333;
  color: #e0e0e0;
}

html.theme-dark .stats-table tr:hover {
  background: #2d2d2d;
}

html.theme-dark .stats-count {
  color: #4caf50;
}

html.theme-dark .form-group label {
  color: #e0e0e0;
}

html.theme-dark .form-group input[type="text"],
html.theme-dark .form-group select {
  background: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

html.theme-dark .form-group input[type="text"]:focus,
html.theme-dark .form-group select:focus {
  border-color: #4caf50;
}

html.theme-dark .form-readonly {
  background: #2d2d2d;
  color: #999;
}

html.theme-dark .btn-secondary {
  background: #3d3d3d;
  color: #e0e0e0;
}

html.theme-dark .btn-secondary:hover {
  background: #4d4d4d;
}

html.theme-dark .form-message.success {
  background: #1b5e20;
  color: #a5d6a7;
}

html.theme-dark .form-message.error {
  background: #b71c1c;
  color: #ffcdd2;
}

html.theme-dark .footer-links {
  border-top-color: #444;
}

html.theme-dark .footer-link {
  color: #666;
}

html.theme-dark .footer-link:hover {
  color: #999;
}

html.theme-dark .logo-icon {
  box-shadow: 0 2px 8px rgba(255,255,255,0.1);
}

html.theme-dark .download-btn {
  color: #fff;
}

html.theme-dark .download-btn:hover,
html.theme-dark .download-btn:active {
  background-color: rgba(255, 255, 255, 0.1);
}

html.theme-dark .audio-edit-btn:hover {
  background: #3d3d3d;
}

html.theme-dark .segment-delete-btn {
  background: #c62828;
  color: #ffcdd2;
}

html.theme-dark .segment-delete-btn:hover {
  background: #b71c1c;
}

html.theme-dark .reading-toolbar {
  background: #1e1e1e;
  border-bottom-color: #333;
}

html.theme-dark .share-hint {
  color: #666;
}

html.theme-dark .share-popup {
  background: #2d2d2d;
  border-color: #444;
}

html.theme-dark .share-notification {
  background: #1e1e1e;
  color: #e0e0e0;
}

/* .theme-light — откат твёрдых переопределений тёмной темы */
html.theme-light .segment,
html.theme-light .segment.unreviewed {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-left-color: var(--color-primary);
}

html.theme-light .segment:hover {
  background: var(--bg-surface-hover) !important;
}

html.theme-light .segment.reviewed {
  background: #e8f5e9 !important;
  border-left-color: #28a745;
}

html.theme-light .segment.active {
  background: #fff8e1 !important;
  border-left-color: #d4a017;
}

html.theme-light .segment-text,
html.theme-light .segment-text[contenteditable="true"] {
  color: var(--text-primary) !important;
}

html.theme-light .segment-text[contenteditable="true"] {
  background: transparent;
}

html.theme-light .segment-text[contenteditable="true"]:focus {
  background: var(--color-primary-light);
  border-color: var(--border-focus);
  color: var(--text-primary);
}

html.theme-light .segment-timestamp .timestamp,
html.theme-light .timestamp {
  color: #2c3e50 !important;
}

html.theme-light .reading-text-container {
  background: var(--bg-surface) !important;
}

html.theme-light .reading-text {
  color: var(--text-primary) !important;
}

html.theme-light .reading-segment {
  color: var(--text-primary) !important;
}

html.theme-light #transcript,
html.theme-light .transcript-container {
  background: var(--bg-body) !important;
  color: var(--text-primary) !important;
}

html.theme-light #mobile-player audio {
  filter: none;
}

html.theme-light .skeleton {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
}
