/* ============================================
   БАЗА ЗНАНИЙ — СТИЛИ В СТИЛЕ NOTION DARK
   ============================================ */

/* --- CSS-переменные (цвета и шрифты) --- */
:root {
  --bg-main: #191919;
  --bg-sidebar: #202020;
  --bg-hover: #2c2c2c;
  --bg-code: #1e1e1e;
  --bg-quote: #252525;
  --text-primary: #d3d3d3;
  --text-heading: #ffffff;
  --text-muted: #787878;
  --accent: #4e9eff;
  --accent-green: #4ec994;
  --border: #2f2f2f;
  --sidebar-width: 260px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* --- Сброс стилей и базовые настройки --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ============================================
   БОКОВАЯ ПАНЕЛЬ (SIDEBAR)
   ============================================ */

#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

/* Заголовок сайдбара */
.sidebar-header {
  padding: 12px 16px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: 0.02em;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Метка раздела */
.sidebar-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 16px 4px;
  margin-top: 4px;
}

.sidebar-section-label svg {
  width: 13px;
  height: 13px;
  stroke: var(--text-muted);
  flex-shrink: 0;
}

/* Пункты меню */
.nav-item svg {
  width: 15px;
  height: 15px;
  stroke: var(--text-muted);
  flex-shrink: 0;
  transition: stroke 0.15s ease;
}

.nav-item:hover svg,
.nav-item.active svg {
  stroke: var(--text-heading);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 4px;
  margin: 1px 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-heading);
}

/* Активный пункт меню */
.nav-item.active {
  background: var(--bg-hover);
  color: var(--text-heading);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 8px;
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px;
}

.nav-item {
  position: relative;
}

/* ============================================
   ОСНОВНОЕ СОДЕРЖИМОЕ
   ============================================ */

#main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 60px 80px;
  max-width: calc(var(--sidebar-width) + 900px);
}

/* Блок с контентом страницы */
#content {
  max-width: 900px;
  animation: fadeIn 0.2s ease;
}

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

/* ============================================
   ТИПОГРАФИКА КОНТЕНТА
   ============================================ */

#content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 24px;
  line-height: 1.2;
}

#content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-top: 40px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

#content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-top: 24px;
  margin-bottom: 8px;
}

#content p {
  margin-bottom: 16px;
  color: var(--text-primary);
}

#content ul, #content ol {
  margin: 12px 0 16px 24px;
}

#content li {
  margin-bottom: 6px;
}

#content a {
  color: var(--accent);
  text-decoration: none;
}

#content a:hover {
  text-decoration: underline;
}

/* ============================================
   ЦИТАТЫ (BLOCKQUOTE)
   ============================================ */

#content blockquote {
  border-left: 3px solid var(--accent);
  background: var(--bg-quote);
  padding: 12px 16px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
  color: var(--text-primary);
  font-size: 0.95rem;
}

#content blockquote p {
  margin-bottom: 0;
}

/* ============================================
   ТАБЛИЦЫ
   ============================================ */

#content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9rem;
}

#content th {
  background: var(--bg-hover);
  color: var(--text-heading);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

#content td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

#content tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

/* ============================================
   ИНЛАЙН КОД
   ============================================ */

#content code:not(pre code) {
  background: var(--bg-code);
  color: var(--accent-green);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  border: 1px solid var(--border);
}

/* ============================================
   БЛОКИ КОДА (PRE)
   ============================================ */

.code-wrapper {
  position: relative;
  margin: 20px 0;
}

/* Кнопка "Скопировать" */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 10;
}

.copy-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.copy-btn.copied {
  background: var(--accent-green);
  color: #fff;
  border-color: var(--accent-green);
}

/* Стили блока кода (Prism перезаписывает часть, но мы задаём рамку) */
#content pre {
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ============================================
   ЭКРАН ОШИБКИ "ТЕМА НЕ НАПИСАНА"
   ============================================ */

.error-block {
  text-align: center;
  padding: 80px 20px;
}

.error-block .error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-block h2 {
  font-size: 1.4rem;
  color: var(--text-heading);
  margin-bottom: 8px;
  border: none;
  padding: 0;
}

.error-block p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Пустая секция */
.nav-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
  cursor: default;
}

.nav-empty:hover {
  background: transparent;
  color: var(--text-muted);
}

/* Подпись автора внизу сайдбара */
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.sidebar-footer span {
  color: var(--accent);
  font-weight: 500;
}

/* ============================================
   КНОПКА-БУРГЕР (ТОЛЬКО НА МОБИЛЬНЫХ)
   ============================================ */

#menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ============================================
   АДАПТИВ ДЛЯ МОБИЛЬНЫХ
   ============================================ */

@media (max-width: 768px) {
  #menu-toggle {
    display: flex;
  }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main {
    margin-left: 0;
    padding: 60px 20px 40px;
  }
}

@media (max-width: 1100px) and (min-width: 769px) {
  #main {
    padding: 40px 40px;
  }
}
