/* Раздел «Шпаргалки» в кабинете — светлая тема, как весь кабинет. */

.chs-card h2 { margin-bottom: 4px; }
.chs-lead {
  margin: 0 0 14px;
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
}

.chs-list { display: flex; flex-direction: column; gap: 8px; }

.chs-subject {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface, #fff);
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.chs-subject.chs-flash {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.chs-subject-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text, #111827);
}
.chs-subject-header:hover { background: rgba(0, 0, 0, 0.02); }
.chs-subject-icon { font-size: 0.75rem; color: var(--text-secondary, #6b7280); width: 12px; flex: 0 0 auto; }
.chs-subject-emoji { font-size: 1.05rem; flex: 0 0 auto; }
/* min-width:0 обязателен: без него длинное название предмета («Пропедевтика
   внутренних болезней») задаёт min-content ширину строки и карточка вылезает
   за экран телефона. */
.chs-subject-name { font-weight: 600; font-size: 0.9375rem; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.chs-subject-count { margin-left: auto; margin-bottom: 0; white-space: nowrap; flex: 0 0 auto; }

.chs-subject-body { display: none; padding: 0 14px 14px; }
.chs-subject-body.visible { display: block; }

.chs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.chs-tile {
  position: relative;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius-sm, 10px);
  background: #fff;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.chs-tile:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10); transform: translateY(-1px); }

.chs-tile-main {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
  text-align: left;
}
.chs-thumb {
  display: block;
  position: relative;
  width: 100%;
  height: 0;
  background: #f3f4f6;
  overflow: hidden;
}
.chs-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.chs-tile-title {
  display: block;
  padding: 9px 10px 34px;
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--text, #111827);
}

.chs-tile-dl {
  position: absolute;
  left: 10px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px;
  background: #fff;
  color: var(--text-secondary, #6b7280);
  font-size: 0.75rem;
  text-decoration: none;
}
.chs-tile-dl:hover { color: var(--accent, #2563eb); border-color: var(--accent, #2563eb); }

/* Строка «Шпаргалки по предмету» внутри предмета в «Материалах» */
.chs-inline-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 8px;
  padding: 9px 12px;
  border: 1px dashed var(--border, #e5e7eb);
  border-radius: var(--radius-sm, 10px);
  background: rgba(37, 99, 235, 0.04);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text, #111827);
  text-align: left;
}
.chs-inline-link:hover { border-color: var(--accent, #2563eb); background: rgba(37, 99, 235, 0.08); }
.chs-inline-text { flex: 1 1 auto; min-width: 0; }
.chs-inline-count { margin-left: auto; font-size: 0.75rem; color: var(--text-secondary, #6b7280); white-space: nowrap; }

/* ——— Просмотр ——— */

body.chs-viewer-on { overflow: hidden; }

.chs-viewer {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* иначе широкая панель/картинка растягивают оверлей за экран */
  background: rgba(15, 23, 42, 0.92);
}
.chs-viewer[hidden] { display: none; }

.chs-viewer-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
}
.chs-viewer-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chs-viewer-actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.chs-viewer-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  text-decoration: none;
  cursor: pointer;
}
.chs-viewer-btn:hover { background: rgba(255, 255, 255, 0.14); }
.chs-viewer-dl { background: #fff; color: #111827; border-color: #fff; font-weight: 600; }
.chs-viewer-dl:hover { background: #e5e7eb; }
.chs-viewer-close { font-size: 1rem; line-height: 1; padding: 6px 10px; }

.chs-viewer-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.chs-viewer-stage.dragging { cursor: grabbing; }
.chs-viewer-img {
  max-width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  cursor: zoom-in;
  margin: auto;
}
.chs-viewer-img.zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  cursor: grab;
  margin: 0;
}

.chs-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}
.chs-viewer-nav:hover { background: rgba(15, 23, 42, 0.8); }
.chs-viewer-prev { left: 10px; }
.chs-viewer-next { right: 10px; }

.chs-viewer-hint {
  padding: 6px 14px 10px;
  text-align: center;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .chs-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .chs-viewer-title { display: none; }
  .chs-viewer-hint { display: none; }
  /* «Открыть оригинал» и «Скачать» на телефоне делают одно и то же — оставляем одну. */
  .chs-viewer-orig { display: none; }
  .chs-viewer-bar { padding: 8px 10px; }
  .chs-viewer-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .chs-viewer-stage { padding: 8px; }
  .chs-viewer-img { max-height: calc(100vh - 80px); }
  .chs-viewer-nav { width: 36px; height: 36px; font-size: 1.4rem; }
}
