:root {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --text: #101114;
  --text-muted: #6e7180;
  --border: #eaeaee;
  --border-strong: #d8d9e2;
  --accent: #101114;
  --accent-hover: #2c2d31;
  --accent-soft: #f0f0f2;
  --accent-contrast: #ffffff;
  --danger: #e5484d;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --radius-sm: 5px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 6px;
  --pixabay: #2ecc71;
  --pexels: #05a081;
  --unsplash: #101114;
  --wikimedia: #3366cc;
  --openverse: #ff6428;
  --flickr: #ff0084;
  --shutterstock: #ee2a24;
  --pexafy: #7c5cff;
  --doodl: #06b6d4;
  --archive: #8b5e34;
  --coverr: #e8a33d;
  color-scheme: light;

  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  --icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cline x1='5' y1='5' x2='19' y2='19'/%3E%3Cline x1='19' y1='5' x2='5' y2='19'/%3E%3C/svg%3E");
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cline x1='12' y1='2' x2='12' y2='4.5'/%3E%3Cline x1='12' y1='19.5' x2='12' y2='22'/%3E%3Cline x1='2' y1='12' x2='4.5' y2='12'/%3E%3Cline x1='19.5' y1='12' x2='22' y2='12'/%3E%3Cline x1='4.9' y1='4.9' x2='6.6' y2='6.6'/%3E%3Cline x1='17.4' y1='17.4' x2='19.1' y2='19.1'/%3E%3Cline x1='4.9' y1='19.1' x2='6.6' y2='17.4'/%3E%3Cline x1='17.4' y1='6.6' x2='19.1' y2='4.9'/%3E%3C/svg%3E");
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='none'%3E%3Cpath d='M20 14.5A8.5 8.5 0 1 1 9.5 4a7 7 0 0 0 10.5 10.5Z'/%3E%3C/svg%3E");
  --icon-auto: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M12 3a9 9 0 0 1 0 18Z' fill='black'/%3E%3C/svg%3E");
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  --icon-external: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
  --icon-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
  --icon-link: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.5.5l2-2a5 5 0 0 0-7-7l-1.5 1.5'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.5-.5l-2 2a5 5 0 0 0 7 7l1.5-1.5'/%3E%3C/svg%3E");
  --icon-arrow-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='19' y1='12' x2='5' y2='12'/%3E%3Cpolyline points='12 19 5 12 12 5'/%3E%3C/svg%3E");
  --icon-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3Cpolyline points='12 5 19 12 12 19'/%3E%3C/svg%3E");
  --icon-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.6l-1-1a5.5 5.5 0 0 0-7.8 7.8l1 1L12 21l7.8-7.6 1-1a5.5 5.5 0 0 0 0-7.8Z'/%3E%3C/svg%3E");
  --icon-heart-filled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black' stroke='none'%3E%3Cpath d='M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.6l-1-1a5.5 5.5 0 0 0-7.8 7.8l1 1L12 21l7.8-7.6 1-1a5.5 5.5 0 0 0 0-7.8Z'/%3E%3C/svg%3E");
  --icon-check-square: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='4'/%3E%3Cpolyline points='7.5 12.5 10.5 15.5 16.5 9'/%3E%3C/svg%3E");
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2.5'/%3E%3Cpath d='M5 15H4.5A1.5 1.5 0 0 1 3 13.5v-9A1.5 1.5 0 0 1 4.5 3h9A1.5 1.5 0 0 1 15 4.5V5'/%3E%3C/svg%3E");
  --icon-share: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12v7a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7'/%3E%3Cpolyline points='16 6 12 2 8 6'/%3E%3Cline x1='12' y1='2' x2='12' y2='15'/%3E%3C/svg%3E");
  --icon-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='2' width='6' height='12' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0'/%3E%3Cline x1='12' y1='18' x2='12' y2='22'/%3E%3Cline x1='8' y1='22' x2='16' y2='22'/%3E%3C/svg%3E");
  --icon-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='21' x2='5' y2='11'/%3E%3Cline x1='12' y1='21' x2='12' y2='4'/%3E%3Cline x1='19' y1='21' x2='19' y2='15'/%3E%3C/svg%3E");
  --icon-filters: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='4' y1='6' x2='20' y2='6'/%3E%3Ccircle cx='9' cy='6' r='2' fill='black' stroke='none'/%3E%3Cline x1='4' y1='12' x2='20' y2='12'/%3E%3Ccircle cx='16' cy='12' r='2' fill='black' stroke='none'/%3E%3Cline x1='4' y1='18' x2='20' y2='18'/%3E%3Ccircle cx='11' cy='18' r='2' fill='black' stroke='none'/%3E%3C/svg%3E");
  --icon-layers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12 2 2 7 12 12 22 7 12 2'/%3E%3Cpolyline points='2 17 12 22 22 17'/%3E%3Cpolyline points='2 12 12 17 22 12'/%3E%3C/svg%3E");
  --icon-bolt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13.5 2.5 4.5 13.5h7l-1 8 9-11h-7l1-8Z'/%3E%3C/svg%3E");
  --icon-coffee: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h13v5a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V9Z'/%3E%3Cpath d='M17 11h1.5a2.5 2.5 0 0 1 0 5H17'/%3E%3Cline x1='8' y1='3' x2='8' y2='5.5'/%3E%3Cline x1='12' y1='3' x2='12' y2='5.5'/%3E%3C/svg%3E");
  --icon-logout: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E");
  --icon-chevron-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 15 12 9 18 15'/%3E%3C/svg%3E");
  --icon-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 20c0-4 3.5-7 8-7s8 3 8 7'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  --bg: #0b0b0f;
  --bg-elevated: #17181d;
  --text: #f4f4f6;
  --text-muted: #9799a6;
  --border: #26272f;
  --border-strong: #35363f;
  --accent: #f4f4f6;
  --accent-hover: #d7d8dc;
  --accent-soft: #232327;
  --accent-contrast: #101114;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --unsplash: #f4f4f6;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0f;
    --bg-elevated: #17181d;
    --text: #f4f4f6;
    --text-muted: #9799a6;
    --border: #26272f;
    --border-strong: #35363f;
    --accent: #f4f4f6;
    --accent-hover: #d7d8dc;
    --accent-soft: #232327;
    --accent-contrast: #101114;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --unsplash: #f4f4f6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  --font-display: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
  letter-spacing: -0.03em;
}

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  flex-shrink: 0;
}

/* ---------- Layout ---------- */
.app {
  --app-pad-x: 32px;
  margin: 0 auto;
  padding: 20px var(--app-pad-x) 48px;
}

/* ---------- Фоновое фото (тёмная тема, главный экран; см. js/background.js) ----------
   Появляется "из дымки": из размытого, чуть увеличенного и прозрачного
   состояния плавно становится чётким. Это единственное размытие на сайте
   (tests/check.js пускает blur() только сюда). Поверх — лёгкое зерно и
   затемнение с виньеткой, которое держит контраст текста. В светлой теме и
   в результатах поиска фото нет. */
.bg-photo {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg) center / cover no-repeat;
  opacity: 0;
  transform: scale(1.1);
  filter: blur(28px) saturate(1.5);
  transition:
    opacity 1.6s ease-out,
    transform 3.4s cubic-bezier(0.16, 1, 0.3, 1),
    filter 2.4s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Уход в результаты поиска — быстро, чтобы не мешать выдаче. */
body:not(.is-home) .bg-photo { transition: opacity 0.4s ease, filter 0.4s ease, transform 0.4s ease; }
/* Зерно: шум из SVG-фильтра, плиткой по всему экрану. */
.bg-photo::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") repeat;
  background-size: 200px 200px;
  opacity: 0.1;
}
.bg-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 95% at 50% 30%, rgba(11, 11, 15, 0.58) 0%, rgba(11, 11, 15, 0.8) 65%, rgba(11, 11, 15, 0.93) 100%);
}
:root[data-theme="dark"] .bg-photo { display: block; }
.bg-photo.is-shown {
  opacity: 1;
  transform: scale(1);
  filter: none;
}
@media (prefers-reduced-motion: reduce) {
  .bg-photo { transform: none; filter: none; transition: opacity 0.8s ease-out; }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 4px;
  position: sticky;
  top: 0;
  z-index: 40;
}
/* Подложка шапки при прокрутке: цвет фона сверху (в тёмной теме тёмный, в
   светлой светлый), к низу плавно тает в прозрачность. Шире самой шапки —
   на всю ширину экрана, за пределы боковых отступов .app. */
.topbar::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -24px;
  bottom: -88px;
  left: calc(-1 * var(--app-pad-x, 32px));
  right: calc(-1 * var(--app-pad-x, 32px));
  pointer-events: none;
  /* Много промежуточных точек по плавной кривой — так переход не читается
     как край полосы, а просто растворяется. */
  background: linear-gradient(180deg,
    var(--bg) 0,
    color-mix(in srgb, var(--bg) 96%, transparent) calc(100% - 128px),
    color-mix(in srgb, var(--bg) 88%, transparent) calc(100% - 112px),
    color-mix(in srgb, var(--bg) 77%, transparent) calc(100% - 96px),
    color-mix(in srgb, var(--bg) 64%, transparent) calc(100% - 80px),
    color-mix(in srgb, var(--bg) 50%, transparent) calc(100% - 64px),
    color-mix(in srgb, var(--bg) 36%, transparent) calc(100% - 48px),
    color-mix(in srgb, var(--bg) 23%, transparent) calc(100% - 34px),
    color-mix(in srgb, var(--bg) 12%, transparent) calc(100% - 20px),
    color-mix(in srgb, var(--bg) 4%, transparent) calc(100% - 8px),
    transparent 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.topbar.is-scrolled::before { opacity: 1; }

.brand {
  display: flex;
  align-items: center;
  /* flex-basis: 0 — оба этих блока растут ОТ НУЛЯ поровну, поэтому в итоге
     получают одинаковую итоговую ширину (basis: auto растил бы каждый от
     его естественного размера, а он у иконки и у 4 кнопок разный — тогда
     строка поиска между ними съезжала бы влево). */
  flex: 1 1 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.brand:hover { opacity: 0.7; }
.brand:active { transform: scale(0.97); }
.brand-mark {
  width: 26px;
  height: 26px;
  background-color: var(--text);
  -webkit-mask: url("../icons/logo-mark.png") center / contain no-repeat;
  mask: url("../icons/logo-mark.png") center / contain no-repeat;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.brand:hover .brand-mark { transform: rotate(-6deg); }

.topbar-actions {
  flex: 1 1 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Шапка справа: «молния», профиль, меню ---------- */
/* Окна всех трёх кнопок прижаты к правому краю группы кнопок (а не к
   своей кнопке) — так «молния» на телефоне не уводит окно за левый край. */
.topbar-pop-wrap { flex-shrink: 0; }
/* Через id — чтобы общие правила .icon-btn (в том числе на главном экране)
   не перебивали вид этих трёх кнопок. */
#aboutToggle,
#authToggle {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--text) 22%, transparent);
  overflow: hidden;
}
#aboutToggle:hover,
#authToggle:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.topbar-bolt .icon-bolt { width: 20px; height: 20px; background-color: currentColor; -webkit-mask: var(--icon-bolt) center / contain no-repeat; mask: var(--icon-bolt) center / contain no-repeat; }
#mainMenuToggle { width: 32px; background: transparent; color: var(--text-muted); }
#mainMenuToggle:hover, #mainMenuToggle[aria-expanded="true"] { background: transparent; color: var(--text); }
.topbar-chevron .icon-chevron,
.menu-item-chevron { background-color: currentColor; -webkit-mask: var(--icon-chevron) center / contain no-repeat; mask: var(--icon-chevron) center / contain no-repeat; transition: transform 0.2s ease; }
.topbar-chevron .icon-chevron { width: 22px; height: 22px; }
.topbar-chevron[aria-expanded="true"] .icon-chevron,
.menu-item[aria-expanded="true"] .menu-item-chevron { transform: rotate(180deg); }

.topbar-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: max-content;
  min-width: 250px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: left;
  letter-spacing: normal;
}
.topbar-popover[hidden] { display: none; }
.topbar-popover:not([hidden]) { animation: dropdownIn 0.15s ease; }
.about-popover, .auth-popover { padding: 14px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-item[hidden] { display: none; }
.menu-item .icon { width: 18px; height: 18px; flex-shrink: 0; background-color: currentColor; }
.menu-item-label { flex: 1; min-width: 0; }
.menu-item-value { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.menu-item-chevron { width: 16px !important; height: 16px !important; color: var(--text-muted); }
.menu-item[aria-pressed="true"] { font-weight: 600; }
.menu-item .icon-coffee { -webkit-mask: var(--icon-coffee) center / contain no-repeat; mask: var(--icon-coffee) center / contain no-repeat; }
.menu-item .icon-logout { -webkit-mask: var(--icon-logout) center / contain no-repeat; mask: var(--icon-logout) center / contain no-repeat; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.insights-panel { padding: 0 10px 8px 40px; font-size: 13px; }
.insights-panel[hidden] { display: none; }
.insights-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  color: var(--text-muted);
}

.about-heading { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.about-text { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--text); }
.about-contacts { display: flex; flex-wrap: wrap; gap: 6px; }
.about-contacts .about-text { margin: 0; color: var(--text-muted); }
.about-contact {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
}
.about-contact:hover { background: var(--accent-soft); }
.auth-soon { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); }
.auth-soon[hidden] { display: none; }
.insights-row strong { color: var(--text); font-weight: 600; }
.insights-sep { height: 1px; background: var(--border); margin: 4px 0; }

.searchbar {
  /* Фиксированная база 640px, без роста — растут только .brand и
     .topbar-actions по бокам, поровну, поэтому строка поиска остаётся
     точно по центру шапки. */
  flex: 0 1 640px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  /* Максимально скруглённая форма (капсула) — сознательно отдельно от
     --radius-pill, которым скруглены чипы/кнопки в остальном интерфейсе. */
  border-radius: 999px;
  padding: 6px 8px 6px 18px;
  transition: background 0.15s ease;
}
.searchbar:focus-within {
  background: var(--accent-soft);
}
.searchbar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background-color: var(--text-muted);
  -webkit-mask: var(--icon-search) center / contain no-repeat;
  mask: var(--icon-search) center / contain no-repeat;
}
.searchbar-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  padding: 10px 0;
  min-width: 0;
}
.searchbar-input::placeholder { color: var(--text-muted); }
.searchbar-clear {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.searchbar-clear:hover { background: var(--border-strong); color: var(--text); }
.searchbar-clear[hidden] { display: none; }
.searchbar-mic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.searchbar-mic[hidden] { display: none; }
.searchbar-mic:hover { background: var(--accent-soft); color: var(--text); }
.searchbar-mic:active { transform: scale(0.9); }
.searchbar-mic.is-listening { color: var(--danger); animation: micPulse 1.4s ease-in-out infinite; }
@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.searchbar-mic .icon { background-color: currentColor; -webkit-mask: var(--icon-mic) center / contain no-repeat; mask: var(--icon-mic) center / contain no-repeat; width: 16px; height: 16px; }
.searchbar-clear::before {
  content: "";
  width: 10px;
  height: 10px;
  background: currentColor;
  -webkit-mask: var(--icon-close) center / contain no-repeat;
  mask: var(--icon-close) center / contain no-repeat;
}
.searchbar-submit {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.searchbar-submit:hover { background: var(--accent-hover); }
.searchbar-submit:active { transform: scale(0.87); }
.searchbar-submit:active { transform: scale(0.94); }
.searchbar-submit .icon { background-color: currentColor; -webkit-mask: var(--icon-search) center / contain no-repeat; mask: var(--icon-search) center / contain no-repeat; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

/* ---------- Переключатели-«таблетки» в меню (тема, размер сетки) ---------- */
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 6px 6px 10px; }
.menu-row-label { font-size: 14px; color: var(--text); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); }
.seg-btn {
  width: 36px; height: 30px; border: none; border-radius: 999px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }
.seg-btn .icon { width: 17px; height: 17px; background-color: currentColor; }
.seg .icon-sun { -webkit-mask: var(--icon-sun) center / contain no-repeat; mask: var(--icon-sun) center / contain no-repeat; }
.seg .icon-moon { -webkit-mask: var(--icon-moon) center / contain no-repeat; mask: var(--icon-moon) center / contain no-repeat; }
.seg .icon-auto { -webkit-mask: var(--icon-auto) center / contain no-repeat; mask: var(--icon-auto) center / contain no-repeat; }
.seg-bars { display: inline-flex; gap: 3px; }
.seg-bars i { display: block; width: 2px; height: 13px; border-radius: 1px; background: currentColor; }

/* ---------- Смена темы (см. transitionTheme в app.js) ----------
   Новая тема проявляется поверх снимка старой кругом от кнопки. Край круга
   мягкий: маска — радиальный градиент, сплошной до 70% радиуса и тающий к
   краю (0.7 = THEME_REVEAL_SOLID в app.js). Размер и положение маски
   анимирует app.js, здесь — стартовое состояние "круг нулевого размера". */
:root.theme-reveal::view-transition-old(root),
:root.theme-reveal::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
:root.theme-reveal::view-transition-new(root) {
  -webkit-mask: radial-gradient(circle closest-side, #000 70%, rgba(0, 0, 0, 0.5) 86%, transparent 100%) 0 0 / 0 0 no-repeat;
  mask: radial-gradient(circle closest-side, #000 70%, rgba(0, 0, 0, 0.5) 86%, transparent 100%) 0 0 / 0 0 no-repeat;
}
/* Браузеры без View Transitions: цвета просто плавно перетекают. */
:root.theme-fading,
:root.theme-fading *,
:root.theme-fading *::before,
:root.theme-fading *::after {
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease !important;
}

#favoritesToggle .icon-heart,
#selectModeToggle .icon-check-square {
  background-color: currentColor;
}
#favoritesToggle .icon-heart { -webkit-mask: var(--icon-heart) center / contain no-repeat; mask: var(--icon-heart) center / contain no-repeat; }
#favoritesToggle[aria-pressed="true"] .icon-heart { -webkit-mask-image: var(--icon-heart-filled); mask-image: var(--icon-heart-filled); }
#selectModeToggle .icon-check-square { -webkit-mask: var(--icon-check-square) center / contain no-repeat; mask: var(--icon-check-square) center / contain no-repeat; }
#filtersToggle .icon-filters,
#iconFiltersToggle .icon-filters,
#videoFiltersToggle .icon-filters { background-color: currentColor; -webkit-mask: var(--icon-filters) center / contain no-repeat; mask: var(--icon-filters) center / contain no-repeat; }
#insightsToggle .icon-chart { background-color: currentColor; -webkit-mask: var(--icon-chart) center / contain no-repeat; mask: var(--icon-chart) center / contain no-repeat; }

/* ---------- Вход (Supabase: Google / почта) ---------- */
#authToggle .icon-user { background-color: currentColor; -webkit-mask: var(--icon-user) center / contain no-repeat; mask: var(--icon-user) center / contain no-repeat; }
#authToggle .icon-user[hidden] { display: none; }
.auth-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent) center / cover no-repeat;
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.auth-avatar[hidden] { display: none; }
.auth-popover { display: flex; flex-direction: column; gap: 10px; }
.auth-popover .about-heading { margin: 0; }
.auth-google-btn { width: 100%; justify-content: center; }
.auth-google-icon { width: 16px; height: 16px; flex-shrink: 0; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-email-form { display: flex; flex-direction: column; gap: 8px; }
.auth-email-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
.auth-email-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.auth-email-submit { width: 100%; justify-content: center; }
.auth-email-note { margin: 0; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.auth-email-label {
  margin: 0 0 4px;
  padding: 0 2px;
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
}
.auth-admin-link { width: 100%; justify-content: center; }
#authLoggedIn { display: flex; flex-direction: column; gap: 6px; }
#authLoggedIn[hidden], #authLoggedOut[hidden] { display: none; }

/* ---------- Translated query hint ---------- */
.translated-hint {
  max-width: 640px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.translated-hint strong { color: var(--text); font-weight: 600; }
.translated-hint button {
  margin-left: 8px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.translated-hint[hidden] { display: none; }

/* ---------- Toolbar: sources + filters ---------- */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0 24px;
}
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
/* Строка "источники + кнопка фильтров" не должна переноситься на вторую
   строку — источники сами скроллятся внутри (.toolbar-row-scroll), а
   кнопка фильтров всегда остаётся прижатой к правому краю. */
.toolbar-row-main { flex-wrap: nowrap; }
.toolbar-row-scroll {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}
.toolbar-row-scroll::-webkit-scrollbar { display: none; }

.sources {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
/* Явные [hidden]-переопределения — атрибут hidden сам по себе проигрывает
   авторским правилам display, заданным на этих же классах (см. app.js:
   переключение режима Фото/Иконки скрывает/показывает эти элементы через
   .hidden = true/false). */
.sources[hidden], .toolbar-row[hidden], .icon-btn[hidden] { display: none; }

.mode-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.mode-tab {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.mode-tab:active { transform: scale(0.93); }
.mode-tab:hover { color: var(--text); }
.mode-tab.is-active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.sources-sep {
  width: 1px;
  height: 20px;
  background: var(--border-strong);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ---------- Единая кнопка "Источники" (popover со списком чекбоксов) ----------
   Раньше это был ряд из 9 всегда видимых плашек-переключателей фотостоков.
   Один popover с чекбоксами компактнее и явно показывает лимит выбора. */
.sources-menu-wrap { position: relative; flex-shrink: 0; }
.sources-menu-toggle { gap: 6px; }
.sources-menu-toggle .icon {
  width: 15px; height: 15px;
  background-color: currentColor;
  -webkit-mask: var(--icon-layers) center / contain no-repeat;
  mask: var(--icon-layers) center / contain no-repeat;
}
.sources-menu-badge {
  position: static;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.sources-menu-popover { min-width: 250px; }
.sources-menu-note {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.source-checklist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  /* Все 8 источников с подписями помещаются без прокрутки; на низких
     экранах список всё равно ограничен и прокручивается. */
  max-height: min(420px, 65vh);
  overflow-y: auto;
}
.source-check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  transition: background 0.15s ease, opacity 0.15s ease;
}
.source-check-row:hover { background: var(--accent-soft); }
.source-check-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.source-check-name { line-height: 1.25; }
.source-check-desc { font-size: 12px; line-height: 1.25; color: var(--text-muted); }
.source-check-row:has(> input[hidden]) { display: none; }
.source-check-row.is-capped { opacity: 0.45; }
.source-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}
.source-chip[hidden] { display: none; }
.source-chip:active { transform: scale(0.94); }
.source-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
.dot-pixabay { background: var(--pixabay); }
.dot-pexels { background: var(--pexels); }
.dot-unsplash { background: var(--unsplash); }
.dot-wikimedia { background: var(--wikimedia); }
.dot-openverse { background: var(--openverse); }
.dot-flickr { background: var(--flickr); }
.dot-shutterstock { background: var(--shutterstock); }
.dot-pexafy { background: var(--pexafy); }
.dot-doodl { background: var(--doodl); }
.dot-archive { background: var(--archive); }
.dot-coverr { background: var(--coverr); }
.source-chip[aria-pressed="true"] {
  color: var(--text);
  background: var(--accent-soft);
}
.source-chip[aria-pressed="true"] .dot { opacity: 1; }
/* Максимум одновременно выбранных источников (см. MAX_ACTIVE_SOURCES в
   app.js) — остальные чипы визуально притушены, пока лимит не освободится,
   но клик по ним всё равно работает (показывает тост с объяснением). */
.source-chip.is-capped:not([aria-pressed="true"]) { opacity: 0.4; }
.source-chip-external {
  color: var(--text-muted);
}
.source-chip-external:hover { color: var(--text); background: var(--accent-soft); }
.source-chip-external .icon { width: 14px; height: 14px; background-color: currentColor; -webkit-mask: var(--icon-external) center / contain no-repeat; mask: var(--icon-external) center / contain no-repeat; }

/* ---------- Единая кнопка фильтров ----------
   Раньше качество/ориентация/сортировка/люди/цвет были пятью всегда
   видимыми плашками в отдельной строке. Теперь это один popover за одной
   иконкой справа (см. #filtersToggle/#filtersPopover в index.html) —
   внутри те же самые .dropdown-блоки, просто в вертикальный список
   вместо горизонтального ряда, и вся генерическая логика открытия/выбора
   в app.js остаётся прежней (она работает с .dropdown по data-атрибуту,
   а не по тому, где именно он расположен на странице). */
.filters-popover-wrap { position: relative; flex-shrink: 0; }
.filters-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.filters-badge.is-pop { animation: heartPop 0.4s ease; }
#filtersToggle.has-active-filters, #iconFiltersToggle.has-active-filters, #videoFiltersToggle.has-active-filters { color: var(--accent); background: var(--accent-soft); }
.filters-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 230px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 8px;
  z-index: 30;
}
.filters-popover:not([hidden]) { animation: dropdownIn 0.15s ease; }
.filters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.dropdown { position: relative; }
.dropdown-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.dropdown-btn:hover { background: var(--accent-soft); }
.dropdown-btn:active { transform: scale(0.96); }
.dropdown-value { color: var(--text); font-weight: 600; }
.dropdown-btn .icon-chevron {
  width: 14px; height: 14px;
  background-color: var(--text-muted);
  -webkit-mask: var(--icon-chevron) center / contain no-repeat;
  mask: var(--icon-chevron) center / contain no-repeat;
  transition: transform 0.15s ease;
}
.dropdown.is-open .icon-chevron { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  z-index: 30;
}
.dropdown.is-open .dropdown-menu { display: block; animation: dropdownIn 0.15s ease; }
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--accent-soft); }
.dropdown-item.is-active { color: var(--accent); font-weight: 600; }

.dropdown-menu-colors {
  min-width: 220px;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  background: var(--accent-soft);
}
.dropdown.is-open .dropdown-menu-colors {
  display: grid;
}
.dropdown-menu-colors .dropdown-item.is-any {
  grid-column: 1 / -1;
  display: block;
}
.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: block;
  position: relative;
  overflow: hidden;
  text-indent: -9999px;
  white-space: nowrap;
  transition: transform 0.1s ease;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.is-active { transform: scale(1.15); }
.color-swatch.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 13px;
  height: 13px;
  background-color: #fff;
  mix-blend-mode: difference;
  -webkit-mask: var(--icon-check-square) center / contain no-repeat;
  mask: var(--icon-check-square) center / contain no-repeat;
}

.toolbar-status {
  justify-content: flex-start;
  gap: 16px;
  min-height: 20px;
}
.results-count { color: var(--text-muted); font-size: 13.5px; }
.provider-warnings { color: var(--danger); font-size: 13px; }

/* ---------- Empty state / hero ---------- */
.empty-state {
  position: relative;
  text-align: center;
  padding: 72px 20px 60px;
  max-width: 600px;
  margin: 0 auto;
}
.empty-state h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 600;
  margin: 0 0 12px;
}
.empty-state p { color: var(--text-muted); font-size: 15.5px; line-height: 1.55; margin: 0; }

.suggestions {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.suggestions-label { color: var(--text-muted); font-size: 13px; margin-right: 4px; }
.suggestion-chip {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.suggestion-chip:hover { background: var(--accent-soft); transform: translateY(-1px); }

/* ---------- Главный экран (body.is-home, см. applyHomeLayout в app.js) ----------
   По центру — надпись, подзаголовок, крупная строка поиска, вкладки режимов
   и "Источники"; внизу — "Попробуйте:" простыми ссылками. Строка поиска,
   вкладки и "Источники" — те же узлы, что в шапке/панели, просто перенесены
   сюда, пока нет результатов. */
.home-hero {
  max-width: none;
  padding: 0 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100svh - 150px);
}
/* display:flex выше перебил бы атрибут hidden — без этого главный экран
   оставался бы на месте после поиска, а выдача уезжала вниз. */
.home-hero[hidden] { display: none; }
.home-main {
  /* Выше блока подсказок: иначе строки "Недавние"/"Попробуйте" рисуются
     поверх открытого окна "Источники". fill-mode backwards (не both) —
     после анимации она не должна держать отдельный слой (stacking context),
     внутри которого z-index окна ничего бы не значил. */
  position: relative;
  z-index: 2;
  margin-top: auto;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: homeIn 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}
@keyframes homeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.home-hero .home-wordmark {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(40px, 5.5vw, 60px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
}
.home-wordmark-strong { font-weight: 600; }
.home-hero .home-tagline {
  margin: 10px 0 34px;
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--text-muted);
}
.home-search-slot { width: 100%; }
.is-home .searchbar {
  width: 100%;
  max-width: none;
  height: 58px;
  padding: 6px 8px 6px 20px;
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  box-shadow: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.is-home .searchbar:focus-within {
  background: var(--bg-elevated);
  border-color: color-mix(in srgb, var(--text) 32%, transparent);
}
.is-home .searchbar-input { font-size: 16px; }
.is-home .searchbar-submit { width: 42px; height: 42px; }
.is-home .searchbar-submit .icon { -webkit-mask-image: var(--icon-arrow-right); mask-image: var(--icon-arrow-right); }

.home-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 26px;
}
.home-controls-sep {
  width: 1px;
  height: 26px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
}
.home-controls-sep[hidden] { display: none; }
.is-home .mode-switch { background: transparent; padding: 0; gap: 14px; }
.is-home .mode-tab {
  position: relative;
  padding: 8px 10px;
  border-radius: 0;
  font-size: 14.5px;
}
.is-home .mode-tab.is-active { background: transparent; }
.is-home .mode-tab.is-active::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: -5px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}
.is-home .sources-menu-toggle { background: transparent; color: var(--text); font-size: 14.5px; }
.is-home .sources-menu-toggle:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.is-home .sources-menu-badge {
  position: static;
  background: color-mix(in srgb, var(--text) 14%, transparent);
  color: var(--text);
}
.is-home .sources-menu-toggle::after {
  content: "";
  width: 11px;
  height: 11px;
  background-color: currentColor;
  opacity: 0.7;
  -webkit-mask: var(--icon-chevron) center / contain no-repeat;
  mask: var(--icon-chevron) center / contain no-repeat;
}
.is-home .sources-menu-popover { right: auto; left: 50%; margin-left: -125px; text-align: left; }
.home-hero .home-sources-list {
  margin: 18px 0 0;
  min-height: 1.4em;
  font-size: 13.5px;
  color: var(--text-muted);
}

.home-suggest {
  margin-top: auto;
  padding-top: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.is-home .suggestions { margin-top: 0; gap: 2px; }
.is-home .suggestion-chip {
  background: transparent;
  padding: 4px 4px;
  font-size: 13.5px;
  opacity: 0.85;
}
.is-home .suggestion-chip:hover {
  background: transparent;
  transform: none;
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.is-home .suggestion-chip + .suggestion-chip::before {
  content: "·";
  display: inline-block;
  margin-right: 10px;
  color: var(--text-muted);
}

.is-home .topbar .icon-btn { background: transparent; }
.is-home .topbar .icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.is-home .toolbar,
.is-home #translatedHint,
.is-home #spellHint { display: none; }

@media (max-width: 680px) {
  .home-hero { min-height: calc(100svh - 110px); }
  .home-hero .home-tagline { margin-bottom: 26px; }
  .is-home .searchbar { height: 54px; }
  .home-controls { gap: 8px 12px; margin-top: 20px; }
  .home-controls-sep { display: none; }
  .is-home .mode-switch { gap: 4px; }
  .home-suggest { padding-top: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-main { animation: none; }
}

/* ---------- Grid ---------- */
/* Размер сетки из меню: I — крупные фото, II — средние, III — мелкие. */
:root { --grid-min: 240px; }
:root[data-grid="1"] { --grid-min: 360px; }
:root[data-grid="3"] { --grid-min: 170px; }
@media (max-width: 680px) {
  :root { --grid-min: 150px; }
  :root[data-grid="1"] { --grid-min: 100%; }
  :root[data-grid="3"] { --grid-min: 100px; }
}
.grid {
  /* CSS-колонки (columns:) заполняются СВЕРХУ ВНИЗ по одной колонке за раз —
     карточка №2 уходила под №1 в том же левом столбце, а не вправо от неё.
     Обычный грид читается слева направо построчно, как и ожидает глаз, а
     "масонри"-эффект (разная высота карточек) даёт grid-auto-rows с мелким
     шагом + JS выставляет карточке нужный row-span по её реальной высоте
     (см. masonryObserver в app.js). Заодно так виднее, что несколько
     превью грузятся параллельно — они теперь физически в одном верхнем
     ряду, а не друг под другом в одной колонке. */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 240px), 1fr));
  grid-auto-rows: 4px;
  gap: 12px; /* = GRID_GAP в app.js */
}
@media (max-width: 680px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 150px), 1fr)); }
  /* На узких карточках рядом с плашкой источника — два круглых действия
     (сердце/скачать), места мало; длинные имена вроде "Shutterstock" иначе
     переносятся на вторую строку внутри пилюли. */
  .card-source-badge { max-width: 76px; }
}

.card {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-elevated);
  cursor: pointer;
}
.card.is-img-loading {
  background: linear-gradient(100deg, var(--border) 30%, var(--border-strong) 50%, var(--border) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.card img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 1;
  transform: scale(1);
  transition: transform 0.4s ease, opacity 0.35s ease;
}
/* Лёгкий "проявочный" эффект вместо простого fade — превью чуть подрастает
   до полного размера, пока проявляется. */
.card.is-img-loading img { opacity: 0; transform: scale(0.96); }
/* При наведении — ровная полупрозрачная тёмная заливка всей карточки, без
   движения и градиентов. */
.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px;
}
.card:hover .card-overlay { opacity: 1; }
.card-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.92);
  color: #101114;
  font-size: 11px;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.card-source-badge .dot { width: 6px; height: 6px; border-radius: 50%; }
/* Обёртка вместо одиночного badge слева — так бейдж "AI" встаёт рядом с
   источником, не отнимая место у круглых кнопок справа (justify-content:
   space-between у .card-overlay всё равно держит их по разным краям). */
.card-badges { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.card-ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(139, 92, 246, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.card-actions-bottom { display: flex; gap: 6px; }
.card-round-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.95);
  color: #101114;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.card-round-btn:hover { background: #fff; }
.card-round-btn:active { transform: scale(0.92); }
.card-round-btn .icon { width: 16px; height: 16px; background-color: currentColor; }
.card-download .icon { -webkit-mask: var(--icon-download) center / contain no-repeat; mask: var(--icon-download) center / contain no-repeat; }
.card-heart .icon { -webkit-mask: var(--icon-heart) center / contain no-repeat; mask: var(--icon-heart) center / contain no-repeat; }
.card-heart.is-active { color: #ff3366; }
.card-heart.is-active .icon { -webkit-mask-image: var(--icon-heart-filled); mask-image: var(--icon-heart-filled); }
.card-heart.is-pop .icon, .lightbox-heart.is-pop .icon { animation: heartPop 0.4s ease; }
@keyframes heartPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.4); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.card-select {
  position: absolute;
  top: 10px;
  left: 10px;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.card-select .icon {
  width: 14px; height: 14px;
  background-color: #fff;
  -webkit-mask: var(--icon-check-square) center / contain no-repeat;
  mask: var(--icon-check-square) center / contain no-repeat;
  opacity: 0;
}
.is-select-mode .card-select { display: flex; }
.card-select.is-checked { background: var(--accent); }
.card-select.is-checked .icon { opacity: 1; }
/* В режиме выбора кнопки видны всегда, а заливка — только под курсором. */
.is-select-mode .card-overlay { opacity: 1; background: transparent; }
.is-select-mode .card:hover .card-overlay { background: rgba(0, 0, 0, 0.4); }

.card-skeleton {
  border-radius: 4px;
  background: linear-gradient(100deg, var(--border) 30%, var(--border-strong) 50%, var(--border) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 150% 0; } 100% { background-position: -50% 0; } }

/* ---------- Video grid (режим "Видео") ----------
   Видео-превью в отличие от фото почти всегда 16:9 — фиксированный
   аспект вместо JS-считаемого masonry-span (см. .grid/masonryObserver
   в app.js), поэтому .video-card сама задаёт себе высоту через CSS. */
.grid.video-grid { grid-auto-rows: auto; }
@media (max-width: 680px) {
  .grid.video-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
.video-card {
  aspect-ratio: 16 / 9;
  background: #0b0b0d;
}
.video-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transform: none;
}
.video-card.is-img-loading img { opacity: 0; }
.video-card-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.2s ease, background 0.2s ease;
}
.video-card:hover .video-card-play { background: rgba(0,0,0,0.75); }
.video-card-play::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 3px;
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent #fff;
}
.video-card-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.video-card .card-source-badge { background: rgba(0,0,0,0.55); color: #fff; }

/* ---------- Video lightbox ---------- */
.video-lightbox-wrap {
  flex: 1.6;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.video-lightbox-player {
  max-width: 100%;
  max-height: 88vh;
  width: 100%;
  display: block;
}
.lightbox-duration-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lightbox-duration-badge[hidden] { display: none; }

/* ---------- Icon grid (режим "Иконки") ----------
   В отличие от фото-сетки (masonry-колонки под разную высоту фото), иконки
   все примерно квадратные — обычная равномерная сетка подходит лучше. */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  columns: unset;
}
.icon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 1;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.15s ease;
}
.icon-card:hover { background: var(--accent-soft); }
.icon-card-svg {
  width: 40%;
  height: 40%;
  color: var(--text);
  display: flex;
}
.icon-card-svg svg { width: 100%; height: 100%; display: block; }
.icon-card-label {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}
.icon-card-source-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.icon-card:hover .icon-card-source-badge { opacity: 1; }
.icon-card-skeleton {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background: linear-gradient(100deg, var(--border) 30%, var(--border-strong) 50%, var(--border) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

/* ---------- Icon lightbox ---------- */
.icon-lightbox-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.icon-lightbox-svg {
  width: min(45vh, 220px);
  height: min(45vh, 220px);
  color: var(--text);
}
.icon-lightbox-svg svg { width: 100%; height: 100%; display: block; }
.icon-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.icon-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease;
}
.icon-color-swatch:hover { transform: scale(1.1); }
.icon-color-swatch.is-active { border-color: var(--text); }
.icon-color-swatch-auto {
  background: linear-gradient(135deg, #fff 50%, #161616 50%);
}

.load-more-wrap { display: flex; justify-content: center; padding: 30px 0 10px; }
.load-more-wrap[hidden] { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn .icon { width: 16px; height: 16px; background-color: currentColor; }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- Bulk selection bar ---------- */
.bulk-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 22px;
  background: var(--bg-elevated);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
}
.bulk-bar[hidden] { display: none; }
.bulk-count { font-size: 14px; font-weight: 600; white-space: nowrap; }
.bulk-actions { display: flex; gap: 8px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 11, 0.82);
}
.lightbox-dialog {
  position: relative;
  display: flex;
  max-width: 1100px;
  width: 100%;
  max-height: 88vh;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: lightboxIn 0.2s cubic-bezier(.2,.8,.2,1);
}
@keyframes lightboxIn {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.lightbox-backdrop { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox-image-wrap {
  flex: 1.6;
  background: #0b0b0d;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 0;
}
.lightbox-image {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  display: block;
}
.lightbox-spinner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.lightbox-spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox-heart {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(20,20,26,0.55);
  color: #fff;
}
.lightbox-heart:hover { background: rgba(20,20,26,0.8); }
.lightbox-heart[aria-pressed="true"] { color: #ff3366; }
.lightbox-heart .icon { background-color: currentColor; -webkit-mask: var(--icon-heart) center / contain no-repeat; mask: var(--icon-heart) center / contain no-repeat; }
.lightbox-heart[aria-pressed="true"] .icon { -webkit-mask-image: var(--icon-heart-filled); mask-image: var(--icon-heart-filled); }

.lightbox-panel {
  flex: 1;
  min-width: 300px;
  max-width: 340px;
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lightbox-panel-top { display: flex; flex-direction: column; gap: 12px; }
.lightbox-badges-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lightbox-badges-row .card-ai-badge[hidden] { display: none; }
.source-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.source-badge a { color: inherit; text-decoration: none; }
.source-badge a:hover { text-decoration: underline; }
.lightbox-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lightbox-actions .btn { flex: 1; justify-content: center; white-space: nowrap; padding-left: 12px; padding-right: 12px; }
.lightbox-actions .btn[hidden] { display: none; }

.lightbox-title { font-size: 17px; font-weight: 700; margin: 0; }
.lightbox-description { font-size: 13.5px; color: var(--text-muted); margin: 0; line-height: 1.5; }

.license-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.license-badge a { color: var(--accent); text-decoration: none; font-weight: 600; }
.license-badge a:hover { text-decoration: underline; }
.license-flag {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  font-weight: 600;
  white-space: nowrap;
}
.license-flag-warn { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.lightbox-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.lightbox-tag {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-muted);
}

.lightbox-meta {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.lightbox-author { color: var(--text); text-decoration: none; font-weight: 600; }
.lightbox-author:hover { text-decoration: underline; }
.lightbox-source-link {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.lightbox-source-link:hover { text-decoration: underline; }
.lightbox-source-link .icon { width: 13px; height: 13px; background-color: currentColor; -webkit-mask: var(--icon-external) center / contain no-repeat; mask: var(--icon-external) center / contain no-repeat; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: rgba(20,20,26,0.55);
  color: #fff;
}
.lightbox-nav:hover { background: rgba(20,20,26,0.8); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-nav .icon { background-color: currentColor; }
#lbPrev .icon { -webkit-mask: var(--icon-arrow-left) center / contain no-repeat; mask: var(--icon-arrow-left) center / contain no-repeat; }
#lbNext .icon { -webkit-mask: var(--icon-arrow-right) center / contain no-repeat; mask: var(--icon-arrow-right) center / contain no-repeat; }

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  background: rgba(20,20,26,0.55);
  color: #fff;
}
.lightbox-close:hover { background: rgba(20,20,26,0.8); }
.lightbox-close .icon { background-color: currentColor; -webkit-mask: var(--icon-close) center / contain no-repeat; mask: var(--icon-close) center / contain no-repeat; }

#lbCopy .icon { -webkit-mask: var(--icon-link) center / contain no-repeat; mask: var(--icon-link) center / contain no-repeat; }
#lbCopyImage .icon { -webkit-mask: var(--icon-copy) center / contain no-repeat; mask: var(--icon-copy) center / contain no-repeat; }
#lbShare .icon { -webkit-mask: var(--icon-share) center / contain no-repeat; mask: var(--icon-share) center / contain no-repeat; }
#lbDownload .icon { -webkit-mask: var(--icon-download) center / contain no-repeat; mask: var(--icon-download) center / contain no-repeat; }

@media (max-width: 760px) {
  .lightbox-dialog { flex-direction: column; max-height: 92vh; overflow-y: auto; }
  .lightbox-image-wrap { min-height: 260px; }
  .lightbox-image { max-height: 50vh; }
  .lightbox-panel { max-width: none; }
  .lightbox-nav { top: 130px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 780px) {
  .topbar { flex-wrap: wrap; }
  .searchbar { order: 3; max-width: none; flex-basis: 100%; }
  .app { --app-pad-x: 16px; padding: 16px; }
  .icon-btn { width: 44px; height: 44px; }
  .source-chip, .dropdown-btn { padding-top: 10px; padding-bottom: 10px; }
  .bulk-bar { left: 16px; right: 16px; transform: none; bottom: 16px; justify-content: space-between; }
}

/* ---------- Кнопка «Наверх» ----------
   Пилюля снизу по центру: в тёмной теме белая, в светлой — чёрная.
   Появляется после прокрутки (класс .is-visible ставит app.js). Пока внизу
   панель массового скачивания — не показывается. */
.back-to-top {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.15s ease;
}
.back-to-top.is-visible { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.back-to-top:hover { background: var(--accent-hover); }
.back-to-top:active { transform: translate(-50%, 0) scale(0.96); }
.back-to-top .icon { width: 18px; height: 18px; background-color: currentColor; -webkit-mask: var(--icon-chevron-up) center / contain no-repeat; mask: var(--icon-chevron-up) center / contain no-repeat; }
.bulk-bar:not([hidden]) ~ .back-to-top { display: none; }
/* Уведомление не должно лечь поверх кнопки. */
.back-to-top.is-visible ~ .toast { bottom: 84px; }

/* ---------- Курсор-точка (только главный экран, см. js/cursor.js) ----------
   Белая точка в режиме "difference" — на тёмном фоне светлая, на светлом
   тёмная, над фото инвертирует цвета. Над кнопками и ссылками раздувается,
   над полем ввода перетекает в тонкую вертикальную черту (текстовый
   курсор). На телефоне — крупнее, под палец. */
body.magic-cursor-on,
body.magic-cursor-on * { cursor: none !important; }
.magic-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  width: 0;
  height: 0;
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: transform;
}
.magic-cursor.is-visible { opacity: 1; }
.magic-cursor-dot {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 5px;
  background: #fff;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.25),
    width 0.25s cubic-bezier(0.2, 0.9, 0.3, 1),
    height 0.25s cubic-bezier(0.2, 0.9, 0.3, 1),
    left 0.25s cubic-bezier(0.2, 0.9, 0.3, 1),
    top 0.25s cubic-bezier(0.2, 0.9, 0.3, 1),
    border-radius 0.25s ease;
}
.magic-cursor.is-hover .magic-cursor-dot { transform: scale(4); }
.magic-cursor.is-down .magic-cursor-dot { transform: scale(0.55); }
.magic-cursor.is-hover.is-down .magic-cursor-dot { transform: scale(3.3); }
.magic-cursor.is-text .magic-cursor-dot {
  left: -1px;
  top: -12px;
  width: 2px;
  height: 24px;
  border-radius: 1px;
  transform: none;
}
.magic-cursor.is-touch .magic-cursor-dot { transform: scale(2.2); }
.magic-cursor.is-touch.is-down .magic-cursor-dot { transform: scale(1.7); }
