/* Базовая дизайн-система для всех страниц */
:root {
  --color-bg:        #f7f8fa;   /* фон страницы */
  --color-surface:   #ffffff;   /* фон карточек/секций */
  --color-border:    #e0e4ea;   /* рамки */
  --color-text:      #2c2f36;   /* основной текст */
  --color-muted:     #6b7280;   /* вспомогательный текст */
  --color-primary:   #4a7fc1;   /* акцент: кнопки, ссылки */
  --color-primary-h: #3a6aaa;   /* hover акцента */

  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);

  --font-base: 'Segoe UI', Arial, sans-serif;
  --font-size-base: 16px;
  --line-height: 1.6;
}

body {
  background: var(--color-bg);
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: var(--line-height);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Mobile-first: одна колонка, контент на всю ширину с отступами */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Сайдбар: на мобиле — drawer (скрыт слева), на десктопе — колонка слева */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  width: 260px;
  max-width: 85vw;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 16px 12px;
  box-shadow: var(--shadow-md);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
}

.sidebar-logo:hover {
  color: var(--color-primary);
}

.sidebar-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.sidebar-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.sidebar-nav {
  margin: 0;
}

.sidebar-heading {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 8px;
  padding: 0;
}

.sidebar-heading:first-child {
  margin-top: 0;
}

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-list li {
  margin: 2px 0;
}

.sidebar-nav a {
  display: block;
  padding: 10px 12px;
  min-height: 44px;
  box-sizing: border-box;
  line-height: 1.4;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  background: transparent;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: #eef3fb;
  color: var(--color-primary);
}

.sidebar-nav a[aria-current="page"] {
  font-weight: 600;
  color: var(--color-primary);
  background: #eef3fb;
}

/* Оверлей при открытом drawer на мобиле */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* Кнопка «Меню» для мобилы — только в узком экране */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.25rem;
  cursor: pointer;
  margin-right: 12px;
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: #eef3fb;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Основной контент */
.main-content {
  flex: 1;
  padding: 16px;
  min-width: 0;
}

.main-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
}

/* Хлебные крошки */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--color-muted);
  margin: 0 0 20px 0;
  flex: 1;
  min-width: 0;
}

.breadcrumb a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

.breadcrumb-current,
.breadcrumb span {
  color: var(--color-text);
}

/* Сетка карточек генераторов (темы) */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.topic-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.topic-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.topic-card__icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.topic-card__title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.topic-card__desc {
  font-size: 0.82rem;
  color: var(--color-muted);
  line-height: 1.4;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text);
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 16px;
}

nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

nav a {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
  background: var(--color-surface);
  transition: background 0.15s, border-color 0.15s;
}

nav a:hover {
  background: #eef3fb;
  border-color: var(--color-primary);
}

section#master {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin: 24px 0;
}

button.quantity-btn,
button.operation-btn,
button.format-btn,
button.variant-btn {
  padding: 8px 20px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

button.quantity-btn:hover,
button.operation-btn:hover,
button.format-btn:hover,
button.variant-btn:hover {
  background: #eef3fb;
  border-color: var(--color-primary);
}

button.quantity-btn[aria-pressed="true"],
button.operation-btn[aria-pressed="true"],
button.format-btn[aria-pressed="true"],
button.variant-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

#download-pdf {
  padding: 10px 28px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

#download-pdf:hover {
  background: var(--color-primary-h);
  box-shadow: var(--shadow-md);
}

#download-pdf:active {
  transform: translateY(1px);
  box-shadow: none;
}

#quantity-buttons,
#operation-buttons,
#format-buttons,
#variant-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.main-content > p {
  margin-bottom: 12px;
}

/* Десктоп: двухколоночный layout, сайдбар слева всегда виден */
@media (min-width: 641px) {
  .page-wrapper {
    flex-direction: row;
  }

  .sidebar {
    position: relative;
    transform: none;
    width: 220px;
    flex-shrink: 0;
    box-shadow: none;
    padding: 24px 16px;
  }

  .sidebar.open {
    transform: none;
  }

  .mobile-menu-btn {
    display: none;
  }

  .sidebar-close {
    display: none;
  }

  .sidebar-overlay.visible {
    display: none !important;
  }

  .main-content {
    max-width: 760px;
    padding: 28px 32px;
  }

  .breadcrumb {
    margin-bottom: 4px;
  }
}

/* --- Страница «Политика конфиденциальности» --- */
.privacy-page {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
}

.privacy-page h1 {
  font-size: 1.5rem;
  border-bottom: 3px solid var(--color-primary);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.privacy-page h2 {
  font-size: 1.1rem;
  margin-top: 24px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.privacy-page h2::before {
  content: "▸";
  color: var(--color-primary);
  margin-right: 8px;
  font-size: 1.1rem;
}

.privacy-page .muted {
  color: var(--color-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.privacy-page .box {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 16px 0;
}

.privacy-page .box-grey {
  background: #f3f4f6;
  border-left: 4px solid var(--color-primary);
}

.privacy-page .box-yellow {
  background: #fef9c3;
  border-left: 4px solid #eab308;
}

.privacy-page .box-blue {
  background: #e0f2fe;
  border-left: 4px solid #0284c7;
}

.privacy-page code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
}

.privacy-page ul {
  padding-left: 20px;
  margin: 10px 0;
}

.privacy-page li {
  margin: 8px 0;
}

@media (min-width: 641px) {
  .privacy-page {
    padding: 32px 28px;
  }

  .privacy-page h1 {
    font-size: 1.75rem;
  }

  .privacy-page h2 {
    font-size: 1.15rem;
  }
}

/* --- Модальное окно согласия на использование данных в метриках --- */
.consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.consent-overlay[aria-hidden="true"] {
  display: none;
}

.consent-dialog {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-width: 480px;
  width: 100%;
  padding: 24px;
}

.consent-dialog h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: var(--color-text);
}

.consent-dialog p {
  margin: 0 0 20px;
  color: var(--color-text);
  line-height: 1.5;
  font-size: 0.95rem;
}

.consent-dialog a {
  font-size: 0.9rem;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.consent-actions button {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
}

.consent-actions .consent-btn-yes {
  background: var(--color-primary);
  color: #fff;
}

.consent-actions .consent-btn-yes:hover {
  background: var(--color-primary-h);
}

.consent-actions .consent-btn-no {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.consent-actions .consent-btn-no:hover {
  background: #e8eaee;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  background: transparent;
  padding: 16px;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.site-footer__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-footer__brand {
  white-space: nowrap;
}

.site-footer a {
  color: var(--color-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: var(--color-primary);
}

