/* Стили для приватной библиотеки */

/* ===================
   ОБЩИЕ СТИЛИ КНОПОК
   =================== */
.btn-secondary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  background: #e2e8f0;
  color: #334155;
}

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

.btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  display: inline-block;
  background: var(--color-button-yellow, #fbbf24);
  color: var(--color-button-text-yellow, #1f2933);
}

.btn-primary:hover {
  background: var(--color-button-yellow-dark, #eab308);
  transform: translateY(-1px);
}

.btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7a1f2b;
  color: #fff;
}

.btn-danger:hover {
  background: #651a24;
  transform: translateY(-1px);
}

.btn-icon-round {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: none;
  color: var(--color-text-secondary, #9ca3af);
  border: 1px solid var(--color-border, #dee2e6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.btn-icon-round:hover {
  background: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  border-color: var(--color-text-secondary, #9ca3af);
}

.btn-icon-round i {
  width: 16px;
  height: 16px;
}

.tool-palette {
  position: fixed;
  top: 84px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10050;
  background: var(--color-panel-bg, #fff);
  border: 1px solid var(--color-border, #dee2e6);
  border-radius: 14px;
  padding: 10px;
}

.tool-palette.tool-palette--desk {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 5;
}

.tool-palette-separator {
  width: 100%;
  height: 1px;
  background: var(--color-border, #dee2e6);
  opacity: 0.8;
  margin: 2px 0;
}

.tool-palette-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  padding: 0;
}

.tool-palette-btn:hover {
  background: var(--color-hover, #f8f9fa);
  border-color: var(--color-text-secondary, #9ca3af);
  color: var(--color-text, #1f2933);
  transform: translateY(-1px);
}

/* РАБОЧИЙ СТОЛ: растянуть на всё окно */
.page-index .panel {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  padding-left: clamp(16px, 3vw, 32px);
  padding-right: clamp(16px, 3vw, 32px);
}

.page-index .desk-zone {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.page-index .desk-zone {
  position: relative;
}

.page-index .desk-scroll-container {
  flex: 1;
  min-height: 0;
  height: auto;
}

/* Безопасная зона, чтобы палитра не перекрывала первую карточку */
.page-index .desk-cards-container {
  padding-left: 96px;
  padding-top: 12px;
}

/* Масштабируем карточки вместе с сеткой (Railway-like zoom) */
.page-index .desk-zone .shorts-grid {
  zoom: var(--desk-zoom, 1);
}

@supports not (zoom: 1) {
  .page-index .desk-zone .shorts-grid {
    transform: scale(var(--desk-zoom, 1));
    transform-origin: top left;
  }
}

.tool-palette-btn i {
  width: 18px;
  height: 18px;
}

#loading-overlay {
  position: fixed !important;
  z-index: 99999 !important;
}

/* Модальное окно домашней библиотеки */
#home-library-modal {
  position: fixed !important;
  top: var(--topbar-height, 56px) !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100% - var(--topbar-height, 56px)) !important;
  z-index: 10000 !important;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Модальное окно удаления диктанта (должно быть поверх домашней библиотеки) */
#delete-dictation-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10060;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
}

#delete-dictation-modal[style*="flex"],
#delete-dictation-modal.show {
  display: flex !important;
}

#delete-dictation-modal .modal-content {
  position: relative;
  z-index: 10061;
  width: min(520px, 92vw);
  margin: auto;
  background: #f7f1e3;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

#delete-dictation-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #f7f1e3;
}

#delete-dictation-modal .modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #7a1f2b;
}

#delete-dictation-modal .modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.6);
  color: #7a1f2b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#delete-dictation-modal .modal-close:hover {
  background: rgba(255, 255, 255, 0.9);
}

#delete-dictation-modal .modal-body {
  padding: 18px 20px;
  color: #1f2933;
}

#delete-dictation-modal #delete-dictation-question {
  font-size: 16px;
  line-height: 1.4;
}

#delete-dictation-modal #delete-dictation-name {
  color: #7a1f2b;
  font-weight: 800;
}

#delete-dictation-modal .form-actions {
  padding: 14px 20px 18px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #f7f1e3;
}

.home-library-modal-content {
  max-width: 95vw;
  width: 95vw;
  max-height: 90vh;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.home-library-modal-content .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light, #dee2e6);
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}

.home-library-modal-content .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

.home-library-modal-content .modal-close {
  background: none;
  border: none;
  color: var(--color-text, #1f2933);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-library-modal-content .modal-close:hover {
  background: var(--color-panel-bg, #fff);
}

.home-library-modal-content .modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

#home-library-modal .library-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* ===================
   ЗОНА 2: Мои книги
   =================== */
.books-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  gap: 16px;
}

.books-zone-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

.books-language-selector {
  flex-shrink: 0;
  min-width: 120px;
  min-height: 32px;
}

.books-zone-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.books-language-selector .language-selector-group {
  margin: 0;
}

.btn-new-book {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: var(--color-button-yellow, #fbbf24);
  color: var(--color-button-text-yellow, #1f2933);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.btn-new-book:hover {
  background: var(--color-button-yellow-dark, #eab308);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-new-book i {
  width: 18px;
  height: 18px;
}

/* ===================
   СТРУКТУРА КНИГИ (РАЗДЕЛЫ)
   =================== */
.book-structure-list {
  padding: 0;
  background: var(--color-panel-bg, #fff);
}

.structure-item {
  margin-bottom: 0;
}

.structure-item:first-child .structure-item-header {
  border-radius: 0 0 0 12px;
  border-top: none;
}

.structure-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  padding: 8px 12px;
  background: var(--color-hover, #f8f9fa);
  border-radius: 0;
  border: 1px solid var(--color-border, #e2e8f0);
  border-top: none;
}

.structure-item-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary, #64748b);
  transition: transform 0.2s;
}

.structure-item-toggle:hover {
  color: var(--color-text, #1f2933);
}

.structure-item-toggle.expanded {
  transform: rotate(90deg);
}

.structure-item-toggle i {
  width: 16px;
  height: 16px;
}

.structure-item-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text, #1f2933);
}

.structure-item-actions {
  display: flex;
  gap: 4px;
}

.section-actions-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  margin-top: 0;
  background-color: var(--color-panel-bg, #fff);
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  z-index: 1200;
  overflow: hidden;
}

.btn-icon-sm {
  min-width: 24px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 4px;
  color: var(--color-text-secondary, #64748b);
  transition: all 0.2s;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.btn-icon-sm:hover {
  background: var(--color-hover, #f1f5f9);
  color: var(--color-text, #1f2933);
}

.btn-icon-sm i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ===================
   КАРТОЧКИ ДИКТАНТОВ (как в индексе)
   =================== */
.shorts-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px;
}

.short-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 16px;
  padding: 12px;
  background: var(--color-panel-bg, #fff);
  border: 2px solid var(--color-border, #e2e8f0);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .06);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  overflow: visible;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  min-height: 210px;
  height: auto;
  box-sizing: border-box;
}

.short-card.short-card--menu-open {
  z-index: 5000;
}

.short-card.short-card--on-desk:not(.desk-card) {
  background: #ffffff;
}

.short-card.short-card--off-desk:not(.desk-card) {
  background: var(--color-hover, #f8f9fa);
}



.short-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.short-card.short-card--selected:not(.desk-card) {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 3px;
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.16);
}

.short-thumb {
  width: calc(100% + 24px); /* Компенсируем padding карточки (12px * 2) */
  height: 120px;
  border-radius: 14px 14px 0 0; /* Скругление немного меньше, чем у карточки (16px), чтобы совпадало визуально */
  overflow: hidden;
  background: #f2f2f2;
  aspect-ratio: unset;
  padding: 0;
  margin: -12px -12px 0 -12px; /* Компенсируем padding карточки */
  display: block;
  box-sizing: border-box;
  position: relative;
  cursor: pointer;
}

.short-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center; /* Центрируем картинку, чтобы не вылезала */
  display: block;
}

.short-in-work-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--color-hover, #f8f9fa);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.short-in-work-indicator i {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  color: var(--color-text-secondary, #6b7280);
}

.short-title {
  font-size: 14px;
  line-height: 1.3;
  margin: 0;
  margin-top: 8px;
  font-weight: 700;
  color: var(--color-text, #222);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Уменьшенные отступы для карточек на рабочем столе */
.desk-card .short-title {
  margin-top: 0;
}

.desk-card .short-id-container {
  margin-top: 0;
  margin-bottom: 0;
}

.desk-card .short-stats {
  margin-top: 0;
  margin-bottom: 0;
}

.desk-card .short-actions {
  padding-top: 0;
}

.short-title a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

.short-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary, #6b7280);
}

.short-meta:not(.short-meta--row) .short-action-btn {
  padding: 4px;
  margin-left: auto;
}

.short-meta--row {
  justify-content: space-between;
  width: 100%;
}

.short-meta-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.short-meta-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.short-meta .short-action-btn i {
  width: 14px;
  height: 14px;
}

.short-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.short-actions .btn-secondary {
  flex: 1;
  padding: 6px 12px;
  font-size: 12px;
  text-align: center;
}

.short-id-container {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 0;
}

.short-sentences-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary, #6b7280);
}

.short-sentences-count i {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}

.short-dikt-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary, #6b7280);
  /* margin-left: auto; */
  text-align: right;
}

.short-completion-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 8px;
  background: var(--color-hover-panel);
  color: var(--color-button-text-yellow);
  /* border: 1px solid var(--color-button-text-yellow); */
  font-size: 12px;
  font-weight: 800;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); */
  z-index: 10;
}

/* .short-completion-badge i {
  width: 16px;
  height: 16px;
  stroke-width: 3;
  color: var(--color-button-text-yellow);
} */

.short-completion-badge .completion-count {
  line-height: 1;
}

.desk-show-in-book-highlight {
  outline: 2px solid rgba(122, 31, 43, 0.55);
  outline-offset: 3px;
  box-shadow: 0 10px 26px rgba(122, 31, 43, 0.18);
  border-radius: 16px;
  transition: outline-color 0.2s ease;
}

.short-stats {
  margin-top: 8px;
  margin-bottom: 4px;
  min-height: 28px;
}

.desk-card .short-stats {
  min-height: 28px;
}

.short-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.short-footer .short-dikt-number {
  margin-left: 0; 
  text-align: left;
}

.short-footer .short-dikt-number {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.short-desk-toggle-btn {
  flex-shrink: 0;
}

.short-footer .short-actions-menu-wrapper {
  margin-left: auto;
}

.short-action-btn--kebab {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--color-border, #dee2e6);
  background: transparent;
  color: var(--color-text-secondary, #6b7280);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.short-action-btn--kebab:hover {
  background: var(--color-hover, #f8f9fa);
  color: var(--color-text, #1f2933);
}

.short-action-btn--kebab i {
  width: 18px;
  height: 18px;
}

.stats-placeholder {
  height: 1px;
}

.stats-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-secondary, #6b7280);
}

.stat-icon i {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.stat-icon-perfect {
  color: var(--color-button-mint, #6ee7b7);
}

.stat-icon-perfect i {
  color: var(--color-button-mint, #6ee7b7);
}

.stat-icon-corrected {
  color: var(--color-button-lightgreen, #86efac);
}

.stat-icon-corrected i {
  color: var(--color-button-lightgreen, #86efac);
}

.stat-icon-audio {
  color: var(--color-button-purple, #a78bfa);
}

.stat-icon-audio i {
  color: var(--color-button-purple, #a78bfa);
}

.short-lang-flags {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.short-level {
  font-weight: 600;
}

.short-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 6px;
  line-height: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  color: var(--color-text, #1f2933);
  text-decoration: none;
}

.short-action-btn:visited {
  color: var(--color-text, #1f2933);
}

.short-action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.short-action-btn.danger {
  background: rgba(0, 0, 0, 0.05);
  color: #ad5544;
}

.short-action-btn.danger:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #9a4b3b;
}

.short-action-btn i {
  width: 18px;
  height: 18px;
}

/* ===================
   ЗОНА 1: Рабочий стол
   =================== */
.desk-zone {
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.page-index .desk-zone {
  background: var(--color-hover, #f8f9fa);
  background-image:
    radial-gradient(rgba(0, 0, 0, var(--desk-dot-alpha, 0.18)) 1px, transparent 1px);
  background-size: calc(var(--desk-grid-step, 24px) * var(--desk-zoom, 1)) calc(var(--desk-grid-step, 24px) * var(--desk-zoom, 1));
  background-position: 0 0;
  transition: background-size 120ms ease;
}

.desk-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.desk-zone-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  display: flex;
  align-items: center;
  gap: 8px;
}

.desk-zone-header h3 i {
  width: 20px;
  height: 20px;
}

.desk-scroll-container {
  position: relative;
  width: 100%;
  height: 280px; /* Фиксированная высота на одну карточку диктанта */
  overflow-x: auto; /* Горизонтальная прокрутка на родительском контейнере */
  overflow-y: hidden; /* Вертикальная прокрутка отключена */
  scroll-behavior: smooth;
}

/* Главная: карточки на столе должны переноситься на следующую строку (как книги) */
.page-index .desk-scroll-container {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.page-index .desk-zone {
  position: relative;
}

/* Скроллбар для WebKit браузеров */
.desk-scroll-container::-webkit-scrollbar {
  height: 8px;
}

.desk-scroll-container::-webkit-scrollbar-track {
  background: var(--color-panel-bg, #fff);
  border-radius: 4px;
}

.desk-scroll-container::-webkit-scrollbar-thumb {
  background: var(--color-border, #dee2e6);
  border-radius: 4px;
}

.desk-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary, #6b7280);
}

/* Для Firefox */
.desk-scroll-container {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border, #dee2e6) var(--color-panel-bg, #fff);
}

.desk-cards-container {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap; /* Карточки в одну строку */
  gap: 12px;
  padding: 12px;
  height: 100%;
  box-sizing: border-box;
  width: max-content; /* Ширина по содержимому - ключевой момент для прокрутки */
}

/* Главная: отключаем layout "в одну линию" и используем .shorts-grid (flex-wrap) */
.page-index .desk-cards-container {
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
}

.page-index .desk-cards-container .shorts-grid {
  width: 100%;
  box-sizing: border-box;
}


.desk-card {
  flex: 0 0 180px; /* Фиксированная ширина, не сжимается и не растягивается */
  width: 180px;
  min-width: 180px; /* Минимальная ширина для гарантии */
  background: var(--color-panel-bg, #fff);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--color-border, #dee2e6);
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: visible;
}

.desk-card .short-thumb {
  overflow: hidden;
}

/* Специальные стили для картинок в desk-card */
.desk-card .short-thumb {
  width: calc(100% + 24px); /* Компенсируем padding карточки (12px * 2) */
  border-radius: 6px 6px 0 0; /* Скругление немного меньше, чем у карточки (8px) */
  margin: -12px -12px 0 -12px; /* Компенсируем padding карточки */
}

.desk-card .short-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center; /* Центрируем, чтобы не вылезала */
  display: block;
}

.desk-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.desk-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desk-card-meta {
  font-size: 12px;
  color: var(--color-text-secondary, #6b7280);
}

/* ===================
   ЗОНА 2 и 3: Двухпанельная структура
   =================== */
.library-content {
  display: flex !important;
  flex-direction: row !important;
  gap: 0;
  height: calc(100vh - 320px);
  min-height: 500px;
  position: relative;
}

/* ЗОНА 2: Список книг */
.books-zone {
  flex: 1;
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  overflow: hidden;
  transition: flex-basis 0.2s ease;
}

.books-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--color-border, #dee2e6);
  gap: 16px;
}

.books-zone-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

.books-zone-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.books-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 12px;
}

.books-list::-webkit-scrollbar {
  width: 6px;
}

.books-list::-webkit-scrollbar-track {
  background: transparent;
}

.books-list::-webkit-scrollbar-thumb {
  background: var(--color-border, #dee2e6);
  border-radius: 3px;
}

/* Минимальная карточка книги */
.book-card-mini {
  width: 100px;
  min-height: 100px;
  background: var(--color-panel-bg, #fff);
  border-radius: 12px;
  overflow: hidden; /* Изменено с visible на hidden, чтобы не было обрезанного эффекта */
  cursor: pointer;
  transition: none;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
}

.book-card-mini:hover {
  box-shadow: none;
  transform: none;
}

#public-library-modal .book-card-mini:hover {
  transform: none;
}

.book-card-mini.active {
  border-color: var(--color-text, #1f2933); /* Цвет как у названия книги в ЗОНА 3 */
  box-shadow: none;
}

/* Чужие книги - белый фон как в ЗОНА 2 */
.book-card-mini.foreign {
  background: var(--color-panel-bg, #fff);
}

.book-card-mini-cover-wrapper {
  width: 100px;
  height: 100px;
  position: relative;
  overflow: hidden;
  border-radius: 10px 10px 0 0; /* Скругление немного меньше, чем у карточки (12px), чтобы не было щели */
  background: var(--color-hover, #f8f9fa);
  flex-shrink: 0;
}

.book-card-mini-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center; /* Центрируем картинку */
  display: block; /* Убираем возможные зазоры */
}

.book-card-mini-cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--color-hover, #f8f9fa);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card-mini-cover-placeholder i {
  width: 48px;
  height: 48px;
  color: var(--color-text-secondary, #6b7280);
}

.book-card-mini-creator-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: none;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.book-card-mini-creator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-panel-bg, #fff);
  border: 2px solid var(--color-panel-bg, #fff);
  overflow: hidden;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.book-card-mini-creator img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card-mini-creator-name {
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.book-card-mini-creator-placeholder {
  width: 24px;
  height: 24px;
  background: var(--color-hover, #f8f9fa);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card-mini-creator-placeholder i {
  width: 16px;
  height: 16px;
  color: var(--color-text-secondary, #6b7280);
}

.book-card-mini-title {
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #1f2933;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: inherit;
  line-height: 1.2;
  border-radius: 0 0 12px 12px; /* Скругление снизу, чтобы совпадало с рамкой карточки */
}

.book-card-mini-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.book-card-mini-actions .dropdown-menu-wrapper {
  position: relative;
}

.book-card-mini-actions .dropdown-toggle {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: none;
}

.book-card-mini-actions .dropdown-toggle:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: none;
}

.book-card-mini-actions .dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  z-index: 1000;
}

/* ЗОНА 3: Активная книга (публичная библиотека) */
.public-library-content .active-book-zone {
  flex: 1;
  background: var(--color-hover, #f8f9fa);
  border-radius: 0 12px 12px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none;
  min-width: 300px;
}

.active-book-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, #dee2e6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.btn-header-action {
  background: none;
  border: 1px solid var(--color-border, #dee2e6);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--color-text-secondary, #9ca3af);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-header-action:hover {
  background: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  border-color: var(--color-text-secondary, #9ca3af);
}

.btn-add-section {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-add-section span {
  font-size: 13px;
  font-weight: 500;
}

.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--color-hover, #f8f9fa);
  border-radius: 8px;
  padding: 4px;
}

.btn-view {
  background: none;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--color-text-secondary, #9ca3af);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-view:hover {
  background: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
}

.btn-view.active {
  background: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-close-zone {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.btn-close-zone:hover {
  background: var(--color-hover, #f8f9fa);
}

.btn-close-zone i {
  width: 20px;
  height: 20px;
  color: var(--color-text, #1f2933);
}

/* Максимальная карточка книги */
.active-book-card {
  padding: 16px;
  border-bottom: 1px solid var(--color-border, #dee2e6);
  background: var(--color-hover, #f8f9fa);
}

.book-card-max {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.book-card-max-cover-wrapper {
  position: relative;
  flex: 0 0 200px;
}

.book-card-max-cover {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  overflow: visible;
  background: var(--color-hover, #f8f9fa);
  position: relative;
}

.book-card-max-cover img,
.book-card-max-cover a {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  overflow: hidden;
  display: block;
}

.book-card-max-cover a {
  text-decoration: none;
}

.book-card-max {
  position: relative;
}

.book-card-max-visibility-badge {
  background: var(--color-hover, #f8f9fa);
  border-radius: 6px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  flex-shrink: 0;
  margin-right: 8px;
}

.book-card-max-visibility-badge i {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  color: var(--color-text-secondary, #6b7280);
}

.book-card-max-creator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 0 0 8px 8px;
}

.book-card-max-creator-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-panel-bg, #fff);
  border: 2px solid var(--color-panel-bg, #fff);
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.book-card-max-creator-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card-max-creator-avatar i {
  width: 16px;
  height: 16px;
  color: var(--color-text-secondary, #9ca3af);
}

.book-card-max-creator-name {
  color: #ffffff !important;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  display: block;
}

.book-card-max-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-card-max-cover-placeholder i {
  width: 48px;
  height: 48px;
  color: var(--color-text-secondary, #6b7280);
}

.book-card-max-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0; /* Убираем лишние отступы между элементами */
  position: relative;
  padding-bottom: 40px; /* Минимум места для кнопки действий внизу */
}

.book-card-max-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  min-height: auto; /* Убираем фиксированную минимальную высоту */
}

.book-card-max-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0;
  flex: 1;
}

.book-card-max-title-author-wrapper {
  flex: 1;
}

.book-card-max-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  color: var(--color-text-secondary, #6b7280);
  z-index: 10;
}

.book-card-max-close-btn:hover {
  background: var(--color-hover, #f8f9fa);
  color: var(--color-text, #1f2933);
}

.book-card-max-close-btn i {
  width: 20px;
  height: 20px;
}

.book-card-max-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text, #1f2933);
  margin: 0;
  text-align: left;
}

.book-card-max-author {
  font-size: 14px;
  color: var(--color-text-secondary, #6b7280);
  margin: 2px 0 0 0; /* Небольшой отступ сверху от названия */
  font-style: italic;
}

.book-card-max-description {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
  margin: 4px 0 0 0; /* Уменьшаем отступ сверху */
  line-height: 1.5;
  max-width: 500px;
  max-height: 156px; /* Примерно 6 строк (13px * 1.5 * 6 = ~117px) + немного запас */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
}

.book-card-max-description::-webkit-scrollbar {
  width: 6px;
}

.book-card-max-description::-webkit-scrollbar-track {
  background: transparent;
}

.book-card-max-description::-webkit-scrollbar-thumb {
  background: var(--color-border, #dee2e6);
  border-radius: 3px;
}

.book-card-max-description::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary, #6b7280);
}

.book-card-max-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}

.book-card-max-btn {
  background: none;
  border: 1px solid var(--color-border, #dee2e6);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.book-card-max-btn:hover {
  background: var(--color-hover, #f8f9fa);
  border-color: var(--color-text-secondary, #6b7280);
}

.book-card-max-btn i {
  width: 16px;
  height: 16px;
  color: var(--color-text, #1f2933);
}

/* Контент активной книги */
.active-book-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}

/* .book-structure - стили для структуры книги (главы + диктанты) будут добавлены позже */

/* Адаптивность */

/* ===================
   МОДАЛЬНОЕ ОКНО РЕДАКТИРОВАНИЯ КНИГИ
   =================== */
#book-edit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  z-index: 10081;
  background-color: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overflow-x: hidden;
}

#book-edit-modal[style*="flex"],
#book-edit-modal.show {
  display: flex !important;
}

#book-edit-modal .book-edit-modal-content {
  position: relative;
  z-index: 10081;
  margin: auto;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  background-color: var(--color-panel-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#book-edit-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: none;
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px 12px 0 0;
}

.book-edit-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#book-edit-unsaved-star {
  margin-left: 6px;
  font-weight: 900;
  color: var(--color-button-text-yellow, #f9c609);
}

#book-edit-modal .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

#book-edit-modal .modal-close {
  background: none;
  border: none;
  color: var(--color-text, #1f2933);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  line-height: 1;
}

#book-edit-modal .modal-close i {
  width: 18px;
  height: 18px;
}

#book-edit-modal .modal-close:hover {
  background: var(--color-panel-bg, #fff);
}

/* ===================
   МОДАЛЬНОЕ ОКНО ПРОСМОТРА КНИГИ (СТРУКТУРА)
   =================== */
#book-view-modal {
  display: none;
  position: fixed;
  top: var(--topbar-height, 56px);
  left: 0;
  width: 100%;
  height: calc(100% - var(--topbar-height, 56px));
  justify-content: flex-end;
  align-items: stretch;
  z-index: 10020 !important;
  background-color: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overflow-x: hidden;
}

#book-view-modal[style*="flex"],
#book-view-modal.show {
  display: flex !important;
}

#book-view-modal .book-view-modal-content {
  position: relative;
  z-index: 10021 !important;
  margin: 0;
  max-width: 75vw;
  width: 75vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-panel-bg, #fff);
  border-radius: 0;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.25);
}

#book-view-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border-light, #e2e8f0);
  flex-shrink: 0;
}

#book-view-modal .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

#book-view-modal .modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--color-border, #dee2e6);
  background: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

#book-view-modal .modal-close:hover {
  background: var(--color-hover, #f8f9fa);
}

#book-view-modal .modal-close i {
  width: 18px;
  height: 18px;
}

#book-view-modal .book-view-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#book-view-modal #bookViewCard {
  flex-shrink: 0;
}

#book-view-modal #bookViewStructure {
  flex: 1;
}

/* Структура формы с обложкой слева */
.book-edit-modal-body {
  padding: 0 !important;
}

/* Стили для полей ввода в модальном окне редактирования книги */
#book-edit-modal .form-row {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#book-edit-modal .form-row.form-row-textarea {
  flex-direction: column;
  align-items: flex-start;
}

#book-edit-modal .form-row label {
  flex: 0 0 200px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  margin: 0;
}

#book-edit-modal .form-row.form-row-textarea label {
  flex: none;
  margin-bottom: 8px;
}

#book-edit-modal .form-row input[type="text"],
#book-edit-modal .form-row input[type="url"],
#book-edit-modal .form-row textarea,
#book-edit-modal .form-row select {
  flex: 1;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  background-color: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

#book-edit-modal .form-row textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
}

#book-edit-modal .form-row select {
  height: 44px;
}

#book-edit-modal .form-row #book-visibility-input {
  height: 44px;
}

#book-edit-modal .language-selector-wrapper {
  flex: 0 0 200px;
  width: 200px;
}

#book-edit-modal .form-row input[type="text"]:focus,
#book-edit-modal .form-row input[type="url"]:focus,
#book-edit-modal .form-row textarea:focus,
#book-edit-modal .form-row select:focus {
  outline: none;
  border-color: var(--color-button-text-yellow, #f9c609);
}

#book-edit-modal .form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border-light, #dee2e6);
}

#book-edit-modal .form-actions .btn-primary {
  background-color: var(--color-hover, #f8f9fa);
  color: var(--color-text, #1f2933);
  border: 1px solid var(--color-border-light, #dee2e6);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#book-edit-modal .form-actions .btn-primary:hover {
  background-color: var(--color-panel-bg, #fff);
  border-color: var(--color-text-secondary, #9ca3af);
}

.book-edit-form-container {
  display: flex;
  gap: 24px;
  padding: 24px;
}

.book-edit-form-left {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-edit-form-right {
  flex: 1;
  min-width: 0;
}

.book-cover-upload-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.book-cover-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text, #1f2933);
}

.book-cover-preview-wrapper {
  width: 200px;
  height: 200px;
  border: 2px dashed var(--color-border, #dee2e6);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease;
  background: var(--color-hover, #f8f9fa);
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-cover-preview-wrapper:hover {
  border-color: var(--color-primary, #2563eb);
}

.book-cover-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text-secondary, #6b7280);
}

.book-cover-placeholder i {
  width: 48px;
  height: 48px;
}

.book-cover-placeholder span {
  font-size: 12px;
}

/* Адаптивность для маленьких экранов */
@media (max-width: 768px) {
  .book-edit-form-container {
    flex-direction: column;
  }
  
  .book-edit-form-left {
    flex: 0 0 auto;
    width: 100%;
  }
  
  .book-edit-form-right {
    flex: 0 0 auto;
    width: 100%;
  }
}

/* ===================
   МОДАЛЬНОЕ ОКНО РАЗДЕЛА
   =================== */
#section-edit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  z-index: 10082;
  background-color: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

#section-edit-modal[style*="flex"],
#section-edit-modal.show {
  display: flex !important;
}

.section-edit-modal-content {
  position: relative;
  z-index: 10083;
  margin: auto;
  max-width: 500px;
  width: 90%;
  background-color: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.section-edit-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light, #dee2e6);
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px 12px 0 0;
  position: relative;
}

.section-edit-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  text-align: center;
}

.section-edit-modal-close {
  background: none;
  border: none;
  color: var(--color-text, #1f2933);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
}

.section-edit-modal-close:hover {
  background-color: var(--color-border-light, #e9ecef);
}

.section-edit-modal-body {
  padding: 24px;
}

#section-edit-form .section-edit-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

#section-edit-form .section-edit-form-row label {
  flex: 0 0 140px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  margin: 0;
}

#section-edit-form #section-number-input {
  flex: 0 0 120px;
  width: 120px;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  background-color: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

#section-edit-form #section-title-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  background-color: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

#section-edit-form #section-number-input:focus,
#section-edit-form #section-title-input:focus {
  outline: none;
  border-color: var(--color-button-text-yellow, #f9c609);
}

.section-edit-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border-light, #dee2e6);
}

.section-edit-submit {
  background-color: var(--color-hover, #f8f9fa);
  color: var(--color-text, #1f2933);
  border: 1px solid var(--color-border-light, #dee2e6);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.section-edit-submit:hover {
  background-color: var(--color-panel-bg, #fff);
  border-color: var(--color-text-secondary, #9ca3af);
}

/* ===================
   МОДАЛЬНОЕ ОКНО ОБРЕЗКИ ИЗОБРАЖЕНИЯ
   =================== */
#crop-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  z-index: 10100;
  background-color: rgba(0, 0, 0, 0.7);
  overflow-y: auto;
}

#crop-modal[style*="flex"],
#crop-modal.show {
  display: flex !important;
}

.crop-modal-content {
  position: relative;
  z-index: 10101;
  margin: auto;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  background-color: var(--color-panel-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.crop-modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
}

.crop-container {
  width: 100%;
  height: 500px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-container img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.crop-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .crop-container {
    height: 300px;
  }
}

/* Выпадающее меню действий */
.dropdown-menu-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background-color: var(--color-panel-bg, #fff);
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  z-index: 6000;
  overflow: hidden;
  display: none;
}

.dropdown-menu.show {
  display: block !important;
}

.dropdown-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text, #1f2933);
  transition: background-color 0.2s ease;
}

.dropdown-menu-item:hover {
  background-color: var(--color-hover, #f8f9fa);
}

.dropdown-menu-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--color-text-secondary, #6b7280);
}

.dropdown-menu-item span {
  flex: 1;
}

.dropdown-menu-item-danger {
  color: var(--color-error, #dc2626);
}

.dropdown-menu-item-danger:hover {
  background-color: rgba(220, 38, 38, 0.1);
}

.dropdown-menu-item-danger i {
  color: var(--color-error, #dc2626);
}

/* Выпадающее меню для большой карточки книги */
.book-card-max-actions .dropdown-menu {
  right: 0;
  top: calc(100% + 4px);
}

/* Выпадающее меню для разделов */
.structure-item-actions .dropdown-menu {
  right: 0;
  top: calc(100% + 4px);
}

/* Модальное окно перемещения диктанта */
#move-dictation-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10030;
  align-items: center;
  justify-content: center;
}

#move-dictation-modal.show {
  display: flex !important;
}

#move-dictation-modal .move-dictation-modal-content {
  position: relative;
  z-index: 10031;
  margin: auto;
  max-width: 800px;
  width: 90%;
  background-color: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

#move-dictation-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light, #dee2e6);
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px 12px 0 0;
  position: relative;
}

#move-dictation-modal .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  text-align: center;
}

#move-dictation-modal .modal-close {
  background: none;
  border: none;
  color: var(--color-text, #1f2933);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
}

#move-dictation-modal .modal-close:hover {
  background-color: var(--color-border-light, #e9ecef);
}

#move-dictation-modal .move-dictation-modal-body {
  padding: 24px;
}

#move-dictation-modal .move-dictation-book-row {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#move-dictation-modal .move-dictation-book-row label {
  display: inline-block;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
  white-space: nowrap;
  flex-shrink: 0;
}

#move-dictation-modal .move-dictation-book-select {
  flex: 1;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  background-color: var(--color-panel-bg, #fff);
  color: var(--color-text, #1f2933);
  cursor: pointer;
  transition: border-color 0.2s ease;
  min-width: 0;
}

#move-dictation-modal .move-dictation-book-select:hover,
#move-dictation-modal .move-dictation-book-select:focus {
  border-color: var(--color-button-text-yellow, #f9c609);
  outline: none;
}

#move-dictation-modal .move-dictation-sections-container {
  margin-top: 20px;
  margin-bottom: 20px;
}

#move-dictation-modal .move-dictation-sections-container label {
  display: block;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

#move-dictation-modal .move-dictation-sections-list {
  background-color: var(--color-panel-bg, #fff);
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  min-height: 50px;
}

#move-dictation-modal .move-dictation-sections-list:empty::before {
  content: 'Нет разделов';
  display: block;
  color: var(--color-text-secondary, #6b7280);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.move-dictation-section-item {
  padding: 10px 12px;
  margin: 4px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.move-dictation-section-item:hover {
  background-color: var(--color-hover, #f8f9fa);
}

.move-dictation-section-item.selected {
  background-color: var(--color-button-text-yellow, #f9c609);
  color: var(--color-text, #1f2933);
}

.move-dictation-section-item[data-level="1"] {
  padding-left: 12px;
}

.move-dictation-section-item[data-level="2"] {
  padding-left: 32px;
}

.move-dictation-section-item[data-level="3"] {
  padding-left: 52px;
}

.move-dictation-section-item[data-level="4"] {
  padding-left: 72px;
}

.move-dictation-section-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.move-dictation-section-toggle:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.move-dictation-section-toggle i {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.move-dictation-section-toggle.expanded i {
  transform: rotate(90deg);
}

.move-dictation-section-children {
  display: none;
  margin-left: 0;
}

.move-dictation-section-children.expanded {
  display: block;
}

.move-dictation-section-title {
  flex: 1;
  font-size: 15px;
  color: var(--color-text, #1f2933);
}

.move-dictation-section-title {
  flex: 1;
  font-size: 15px;
}

#move-dictation-modal .move-dictation-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-light, #dee2e6);
}

#move-dictation-modal .move-dictation-submit {
  padding: 10px 24px;
  font-size: 16px;
  font-weight: 600;
  background-color: var(--color-hover, #f8f9fa);
  color: var(--color-text, #1f2933);
  border: 1px solid var(--color-border-light, #dee2e6);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#move-dictation-modal .move-dictation-submit:hover {
  background-color: var(--color-panel-bg, #fff);
  border-color: var(--color-button-text-yellow, #f9c609);
}

/* Стили для индикатора загрузки */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

/* Модальное окно публичной библиотеки */
#public-library-modal {
  position: fixed !important;
  top: var(--topbar-height, 56px) !important;
  left: 0 !important;
  width: 100% !important;
  height: calc(100% - var(--topbar-height, 56px)) !important;
  z-index: 9999 !important;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.public-library-modal-content {
  max-width: 95vw;
  width: 95vw;
  max-height: 90vh;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.public-library-modal-content .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light, #dee2e6);
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}

.public-library-modal-content .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text, #1f2933);
}

.public-library-modal-content .modal-close {
  background: none;
  border: none;
  color: var(--color-text, #1f2933);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.public-library-modal-content .modal-close:hover {
  background: var(--color-panel-bg, #fff);
}

.public-library-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.public-library-content {
  display: flex;
  flex-direction: row;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ЗОНА 2: Список публичных книг */
.public-books-zone {
  flex: 1;
  background: var(--color-hover, #f8f9fa);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: flex-basis 0.2s ease;
}

.public-books-zone .books-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 12px;
}

.btn-play-audio {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary, #6b7280);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-play-audio:hover {
  background-color: var(--color-hover, #f8f9fa);
  color: var(--color-text, #1f2933);
}

.btn-play-audio i {
  width: 20px;
  height: 20px;
}

.loading-content {
  background: var(--color-panel-bg, #fff);
  padding: 30px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border, #dee2e6);
  border-top: 4px solid var(--color-primary, #2563eb);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

.loading-text {
  color: var(--color-text, #1f2933);
  font-size: 16px;
  font-weight: 500;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

