/* Обнуление */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: none;
}

/* Убираем unsafe padding из body */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #000;
  color: #fff;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  padding-top: env(safe-area-inset-top);
}

/* Хедер — отступ сверху только через safe-area-inset */
.header {
  padding: 16px env(safe-area-inset-left) 16px env(safe-area-inset-right);
  padding-top: env(safe-area-inset-top);
  background-color: #121212;
  color: white;
  text-align: center;
  font-size: 1.2em;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Нижняя навигация — отступ снизу */
.nav {
  display: flex;
  background-color: #121212;
  border-top: 1px solid #222;
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

/* Контент — без padding-top/bottom, только лево/право */
.content {
  flex: 1;
  padding: 16px env(safe-area-inset-left) 16px env(safe-area-inset-right);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #121212;
  color: white;
  padding-bottom: 76px; /* 56px (меню) + 20px запас */
}

/* Новости */
.news-item {
  background: #1e1e1e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  margin-bottom: 16px;
}

.news-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.news-content {
  padding: 12px;
}

.news-title {
  font-size: 1.1em;
  margin-bottom: 8px;
  color: #007AFF;
}

.news-meta {
  font-size: 0.8em;
  color: #aaa;
  margin-bottom: 8px;
}

.news-excerpt {
  font-size: 0.9em;
  color: #ddd;
}

/* Поиск */
.search-box {
  width: 100%;
  padding: 12px;
  background: #222;
  border-radius: 8px;
  margin-bottom: 16px;
  color: white;
  border: none;
}

/* Ритуалы */
.ritual-card {
  background: #1e1e1e;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.ritual-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.tag {
  font-size: 0.7em;
  padding: 4px 8px;
  border-radius: 4px;
  background: #2a2a2a;
  color: #ccc;
}

.tag-primary {
  background: #007AFF;
  color: white;
}

/* Галерея */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.gallery-item {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #222;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Мастерская */
.workshop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.workshop-item {
  background: #1e1e1e;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
}

.workshop-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.workshop-name {
  font-size: 1.0em;
  margin-bottom: 4px;
  color: #007AFF;
}

.workshop-desc {
  font-size: 0.8em;
  color: #ccc;
}

/* Категории мастерской */
#workshop-categories {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 16px;
  background: #1a1a1a;
  white-space: nowrap;
  margin-bottom: 16px;
}

#workshop-categories .category-pill {
  background: #2a2a2a;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9em;
  cursor: pointer;
  white-space: nowrap;
}

#workshop-categories .category-pill.active {
  background: #007AFF;
  color: white;
}

/* Кнопка "Загрузить ещё" */
#load-more-container {
  padding: 16px;
  text-align: center;
  margin-top: 16px;
}

/* Навигация */
.nav {
  display: flex;
  background-color: #121212;
  border-top: 1px solid #222;
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.nav-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.85em;
  color: #666;
  border: none;
  background: none;
  padding: 8px 0;
  cursor: pointer;
}

.nav-button.active {
  color: #007AFF;
  font-weight: 600;
}

/* Ограничение ширины картинок и остального */
#page-detail img,
#page-detail iframe,
#page-detail video,
#page-detail embed,
#page-detail object {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 16px auto;
}

/* Адаптивный iframe (YouTube и т.п.) */
#page-detail iframe {
  aspect-ratio: 16 / 9;
  border: none;
  margin: 16px auto;
}

#page-detail {
  padding-top: env(safe-area-inset-top);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Блокируем скроллинг body, когда детальная страница открыта */
body.detail-open {
  overflow: hidden;
  height: 100vh;
}

/* Кнопка "Назад" в детальной странице */
.btn-back {
  display: block !important;
  width: 100% !important;
  padding: 16px !important;
  margin: 24px 0 0 0 !important;
  background: none !important;
  border: none !important;
  color: #007AFF !important;
  font-size: 1.1em !important;
  font-weight: 600 !important;
  text-align: center !important;
  cursor: pointer !important;
  border-top: 1px solid #333 !important;
}

.btn-back:hover {
  background: rgba(0, 122, 255, 0.1) !important;
}
.btn-load-more {
  display: block !important;
  width: 100% !important;
  padding: 16px !important;
  margin: 24px 0 0 0 !important;
  background: none !important;
  border: none !important;
  color: #007AFF !important;
  font-size: 1.1em !important;
  font-weight: 600 !important;
  text-align: center !important;
  cursor: pointer !important;
  border-top: 1px solid #333 !important;
}

/* Ритуалы */
.ritual-card {
  background: #1e1e1e;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.ritual-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.tag {
  font-size: 0.7em;
  padding: 4px 8px;
  border-radius: 4px;
  background: #2a2a2a;
  color: #ccc;
}

.tag-primary {
  background: #007AFF;
  color: white;
}

.category-pill {
  background: #2a2a2a;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9em;
  cursor: pointer;
  white-space: nowrap;
}

.category-pill.active {
  background: #007AFF;
  color: white;
}

.categories-scroll {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 16px;
  background: #1a1a1a;
  white-space: nowrap;
}

.content > div[style*="display: none"] {
  overflow: hidden;
  height: 0;
}