/* ===== ЦВЕТА ===== */
:root {
  --green: #2e7d32;
  --green-light: #a5d6a7;
  --cream: #f5e6c8;
  --red: #d32f2f;
  --white: #ffffff;
  --text: #1b1b1b;
  --bg: #f8fbf8;
  --card: #ffffff;
  --border: #e0e0e0;
  --muted: #777;
}

/* Тёмная тема */
html[data-theme="dark"] {
  --text: #f0f0f0;
  --bg: #121512;
  --card: #1e241f;
  --border: #2e3a31;
  --muted: #9aa89d;
  --white: #1e241f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 90px;
  transition: background .25s, color .25s;
}

/* ВЕРХНЯЯ ПАНЕЛЬ */
.topbar {
  background: var(--green);
  color: #fff;
  padding: 14px 16px;
  font-weight: bold;
  font-size: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 10px;
  padding: 6px 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.theme-toggle svg { width: 20px; height: 20px; }
html[data-theme="light"] #icon-moon { display: none; }
html[data-theme="dark"]  #icon-sun  { display: none; }

/* СТРАНИЦЫ */
.page { display: none; padding: 16px; animation: fade .25s ease; }
.page.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 20px;
  margin: 16px 0 12px;
  color: var(--green);
}

/* ГЛАВНАЯ */
.hero-banner {
  background: linear-gradient(135deg, var(--green), var(--green-light));
  color: #fff;
  border-radius: 20px;
  padding: 32px 20px;
  text-align: center;
}
.hero-banner h1 { font-size: 26px; margin-bottom: 8px; }
.hero-banner p { opacity: .95; font-size: 15px; }

.biok-teaser {
  margin-top: 16px;
  background: var(--card);
  border: 2px solid var(--green-light);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--green);
}

/* Сетка объявлений */
.ads-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* КНОПКА "ПОКАЗАТЬ ЕЩЁ" */
.btn-more {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity .2s;
}
.btn-more:hover { opacity: .9; }

/* ===== СТИЛИ ДЛЯ КАРТОЧЕК ===== */
.ad-card {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: transform .2s ease, box-shadow .2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.ad-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

.ad-media {
  position: relative;
  background: #f0f4f1;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
}
html[data-theme="dark"] .ad-media {
  background: #2a332c;
}

.ad-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.badge {
  font-size: 10px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 20px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge.care-easy { background: #4caf50; }
.badge.care-medium { background: #ff9800; }
.badge.care-hard { background: #f44336; }
.badge.stock.in { background: #2e7d32; }
.badge.stock.out { background: #9e9e9e; }

.ad-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.ad-tags { margin-bottom: 8px; }
.tag {
  background: var(--green-light);
  color: #1b1b1b;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: bold;
  display: inline-block;
}
html[data-theme="dark"] .tag {
  background: #3a5a40;
  color: #e0e0e0;
}
.ad-title {
  font-weight: bold;
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 6px;
  flex-grow: 1;
}
.ad-price {
  color: var(--green);
  font-weight: 900;
  font-size: 18px;
}
html[data-theme="dark"] .ad-price {
  color: #81c784;
}

/* ===== КАТАЛОГ ===== */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.catalog-tile {
  border-radius: 18px;
  padding: 24px 16px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s;
}
.catalog-tile:hover { transform: scale(1.03); }
.catalog-tile.easy   { background: var(--green); color: #fff; }
.catalog-tile.medium { background: var(--cream); color: var(--green); border: 2px solid var(--green); }
.catalog-tile.hard   { background: var(--red); color: #fff; }

/* Кнопка Назад в каталоге */
.btn-back {
  background: none;
  border: none;
  color: var(--green);
  font-size: 16px;
  font-weight: bold;
  padding: 8px 0;
  margin-bottom: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-back:hover { text-decoration: underline; }

/* ===== СООБЩЕСТВО ===== */
#page-community { background: var(--cream); min-height: calc(100vh - 160px); }
html[data-theme="dark"] #page-community { background: var(--bg); }
.empty-hint { color: var(--muted); font-size: 15px; }

/* ===== BIOK ===== */
.chat-box {
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  min-height: 300px;
}
.chat-msg {
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 8px;
  max-width: 80%;
}
.chat-msg.bot  { background: var(--green-light); color: #1b1b1b; }
.chat-msg.user { background: var(--green); color: #fff; margin-left: auto; }

/* ===== АККАУНТ ===== */
.account-menu { list-style: none; }
.account-menu li {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 10px;
  font-size: 16px;
}

/* ===== НИЖНЯЯ НАВИГАЦИЯ ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 6px;
  transition: color .2s;
}
.nav-btn.active { color: var(--green); font-weight: bold; }
.nav-icon { width: 24px; height: 24px; display: block; }
.nav-label { font-size: 11px; }
/* ===== СТРАНИЦА ТОВАРА ===== */
.ad-detail-media {
  background: #f0f4f1;
  border-radius: 20px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
html[data-theme="dark"] .ad-detail-media { background: #2a332c; }
.ad-detail-emoji { font-size: 100px; }

.ad-detail-tags { margin-bottom: 12px; }
.ad-detail-price {
  font-size: 28px;
  font-weight: 900;
  color: var(--green);
  margin-bottom: 8px;
}
html[data-theme="dark"] .ad-detail-price { color: #81c784; }

.ad-detail-title {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 4px;
}
.ad-detail-latin {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 24px;
}

.ad-detail-section {
  margin-bottom: 20px;
}
.ad-detail-section h3 {
  font-size: 16px;
  color: var(--green);
  margin-bottom: 8px;
}
.ad-detail-section p {
  font-size: 15px;
  line-height: 1.5;
}

.danger-block h3 { color: var(--red); }

.ad-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 32px 0 20px;
}
.btn-ai-helper {
  background: var(--card);
  border: 2px solid var(--green);
  color: var(--green);
  padding: 14px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}
.btn-checkout {
  background: var(--green);
  border: none;
  color: #fff;
  padding: 14px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

.ad-detail-seller {
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  font-size: 15px;
}
/* ===== ОФОРМЛЕНИЕ ЗАКАЗА ===== */
.checkout-section {
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.checkout-section h3 {
  font-size: 16px;
  color: var(--green);
  margin-bottom: 12px;
}
.checkout-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  margin-top: 4px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 15px;
  cursor: pointer;
}
.checkout-total {
  font-size: 20px;
  text-align: right;
  padding: 16px;
  background: var(--card);
  border-radius: 16px;
  border: 2px solid var(--green);
}
#checkout-final-price { color: var(--green); }