/* === Библиотека === */

/* Поиск */
.lib-search-wrap { margin: 10px 0 14px; }
.lib-search {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}
.lib-search:focus { border-color: var(--gold); }
.lib-search::placeholder { color: var(--muted); }

/* Результаты поиска */
.lib-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}
.lib-result:hover { border-color: var(--gold-dim); }
.lib-result-title { font-weight: 600; color: var(--gold-bright); }
.lib-result-cat { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.lib-result-snippet { font-size: 13px; color: var(--text); line-height: 1.5; }
.lib-result-snippet mark, .lib-lesson mark {
  background: var(--gold-dim);
  color: #fff;
  border-radius: 3px;
  padding: 0 2px;
}

/* Контент лекции */
.lib-lesson {
  line-height: 1.6;
  font-size: 15px;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.lib-lesson h1, .lib-lesson h2, .lib-lesson h3 { color: var(--gold-bright); line-height: 1.3; }
.lib-lesson h1 { font-size: 20px; }
.lib-lesson h2 { font-size: 18px; }
.lib-lesson h3 { font-size: 16px; }
.lib-lesson p { margin: 10px 0; }
.lib-lesson table { border-collapse: collapse; width: 100%; margin: 12px 0; display: block; overflow-x: auto; }
.lib-lesson td, .lib-lesson th { border: 1px solid var(--border); padding: 6px 8px; font-size: 14px; }
.lib-lesson ul, .lib-lesson ol { padding-left: 22px; }

/* Картинки в лекции */
.lib-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 10px 0;
  cursor: zoom-in;
  display: block;
}

/* Справочник-картинка (сетка, чертежи) */
.lib-figure { text-align: center; margin-top: 8px; }
.lib-figure-img { margin: 0 auto; max-height: 70vh; object-fit: contain; }

/* Целевой абзац при переходе из поиска */
.lib-lesson .lib-hit {
  background: rgba(201, 176, 106, .16);
  border-left: 3px solid var(--gold);
  padding-left: 10px;
  margin-left: -13px;
  border-radius: 4px;
  animation: lib-hit-pulse 1.6s ease-out 1;
}
@keyframes lib-hit-pulse {
  0% { background: rgba(201, 176, 106, .42); }
  100% { background: rgba(201, 176, 106, .16); }
}

/* Кнопка перехода к тестам */
.lib-tests-btn { margin-top: 18px; }

/* Зум-оверлей с жестами */
.lib-zoom {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.94);
  overflow: hidden;
  touch-action: none;
}
.lib-zoom-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.lib-zoom-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  touch-action: none; transform-origin: center center;
  will-change: transform; user-select: none; -webkit-user-drag: none;
}
.lib-zoom-close {
  position: fixed; right: 16px; z-index: 2;
  top: max(58px, calc(env(safe-area-inset-top, 0px) + 12px)); /* ниже чёлки/Dynamic Island */
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); font-size: 20px; cursor: pointer;
}
.lib-zoom-ctrl {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; gap: 12px;
}
.lib-zoom-ctrl button {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--surface-2); color: var(--gold-bright);
  border: 1px solid var(--border); font-size: 24px; line-height: 1; cursor: pointer;
}
.lib-zoom-ctrl button:active { background: var(--surface); }
