/* «Кожа на полотне» — галерея OneDerm.
   Музейная подача: тёмная «стена» по умолчанию, светлая «бумага» — по теме сайта.
   Заголовки — Cormorant Garamond (как этикетки в музее), текст — Source Sans 3.
   Акцент — аметист OneDerm; цвет уровня доказательности — у каждой работы. */

:root {
  --bg: #12100e;
  --bg-2: #1a1714;
  --surface: #1f1b17;
  --surface-2: #28231e;
  --line: rgba(236, 226, 210, 0.12);
  --line-2: rgba(236, 226, 210, 0.22);
  --text: #eee7dc;
  --muted: #a99f90;
  --faint: #7a7166;
  --accent: #a58cff;
  --accent-ink: #c9b9ff;
  --accent-soft: rgba(165, 140, 255, 0.16);
  --mat: #0b0a09;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --c-documented: #6cc495;
  --c-strong: #a58cff;
  --c-speculative: #e3ad55;
  --c-iconography: #8fb0cc;
  --dim: rgba(8, 7, 6, 0.62);
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Source Sans 3", "Source Sans Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
  --top-h: 60px;
  color-scheme: dark;
}

:root[saved-theme="light"] {
  --bg: #f5f1ea;
  --bg-2: #ede7dc;
  --surface: #fffdf9;
  --surface-2: #f1ebe1;
  --line: rgba(60, 44, 24, 0.12);
  --line-2: rgba(60, 44, 24, 0.24);
  --text: #211c16;
  --muted: #6c6255;
  --faint: #978b7c;
  --accent: #7656e6;
  --accent-ink: #5b3fc9;
  --accent-soft: rgba(118, 86, 230, 0.12);
  --mat: #e6dfd3;
  --shadow: 0 16px 40px rgba(60, 44, 24, 0.18);
  --c-documented: #2f9566;
  --c-strong: #7656e6;
  --c-speculative: #b9791a;
  --c-iconography: #4f7898;
  --dim: rgba(20, 16, 12, 0.55);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- шапка ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--top-h);
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand b { font-weight: 700; }
.brand-t b + * { color: var(--accent-ink); }
.top-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  font-weight: 500;
  color: var(--text);
  padding-left: 18px;
  border-left: 1px solid var(--line-2);
  white-space: nowrap;
}
.top-title:hover { text-decoration: none; color: var(--accent-ink); }
.view-switch {
  margin-left: auto;
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
}
.view-switch button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-switch button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset; }
.view-switch button:hover { color: var(--text); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

/* ---------- вступление ---------- */
.grid-view { max-width: 1760px; margin: 0 auto; padding: 0 28px 40px; }
.hero { padding: 22px 0 4px; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hero h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(38px, 3.6vw, 54px);
  line-height: 1;
  letter-spacing: -0.01em;
}
.lead { margin: 0; color: var(--muted); font-size: 16.5px; line-height: 1.5; max-width: 860px; }
.conf-dot { display: inline-block; width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--c); transform: translateY(-1px); }
[data-conf="documented"] { --c: var(--c-documented); }
[data-conf="strong"] { --c: var(--c-strong); }
[data-conf="speculative"] { --c: var(--c-speculative); }
[data-conf="iconography"] { --c: var(--c-iconography); }

/* ---------- панель фильтров ---------- */
.toolbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 14px 0 0;
}
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.toolbar-row .sort { margin-left: auto; }
.search {
  display: flex; align-items: center; gap: 10px;
  flex: 0 1 340px; padding: 0 14px; height: 38px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--faint);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; }
.search input::placeholder { color: var(--faint); }
.filters-panel { display: contents; }
.filters-toggle { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar .chips { gap: 4px; }
.toolbar .chip { gap: 4px; padding: 3px 7px; font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .conf-dot { box-shadow: 0 0 0 2px var(--bg); }
.chip small { font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 14px; }
.sort select {
  padding: 6px 30px 6px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--text); font: inherit; font-size: 14px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
}

/* ---------- сетка (выровненные ряды) ---------- */
.grid { position: relative; }
.grid-section { margin: 0 0 30px; }
.grid-section h2 {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 12px;
  font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.1;
}
.grid-section h2 small { font-family: var(--sans); font-size: 14px; color: var(--faint); font-weight: 400; }
.rows { display: flex; flex-direction: column; gap: var(--gap, 14px); }
.row { display: flex; gap: var(--gap, 14px); }

.card {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: inherit;
  cursor: pointer;
}
.card:hover { text-decoration: none; }
.card .pic {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--mat);
  box-shadow: 0 1px 0 var(--line) inset;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s;
}
.card:hover .pic, .card:focus-visible .pic { transform: translateY(-3px); box-shadow: var(--shadow); }
.card img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s; }
.card img.is-loaded { opacity: 1; }
.card .cap { padding: 9px 2px 0; min-width: 0; }
.card .cap-t {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.2;
}
.card .cap-a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.card .cap-d {
  display: flex; gap: 7px; align-items: baseline; margin-top: 4px;
  font-size: 13.5px; color: var(--text); line-height: 1.35;
}
.card .cap-d span:last-child { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- подсветка признака ---------- */
.spot {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.spot .dim { fill: var(--dim); }
.spot .ring { fill: none; stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.spot .ring-glow { fill: none; stroke: var(--accent); stroke-width: 7; stroke-opacity: 0.55; vector-effect: non-scaling-stroke; filter: blur(3px); }
.is-spot .spot { opacity: 1; }
.spot .spot-mask.is-inactive { fill: #fff; }
.spot .ring.is-inactive, .spot .ring-glow.is-inactive, .spot-label.is-inactive { display: none; }
.spot.is-area .ring { stroke-dasharray: 7 5; }
.spot.is-area .ring-glow { stroke-opacity: 0.2; }
.spot-label small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.75; }
@media (max-width: 860px) { .spot-label small .wide { display: none; } }
.dx-area { margin: 10px 0 0; font-size: 13px; line-height: 1.4; opacity: 0.75; }
.spot-labels { position: absolute; inset: 0; pointer-events: none; }
.canvas.is-spot .spot-label:not(.is-inactive) { pointer-events: auto; cursor: zoom-in; }
.canvas .spot-label:hover { background: var(--accent); color: #14101f; }
.canvas.is-over-spot { cursor: pointer; }
.spot-label {
  position: absolute;
  width: max-content;
  max-width: min(260px, 60%);
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(14, 12, 10, 0.86);
  color: #f6f0e6;
  font-size: 13px;
  line-height: 1.3;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s 0.08s, transform 0.3s 0.08s;
  white-space: normal;
}
.is-spot .spot-label { opacity: 1; transform: none; }
.spot-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; opacity: 0; transition: opacity 0.3s 0.08s; }
.spot-leaders line { stroke: #fff; stroke-width: 1.25; opacity: 0.8; filter: drop-shadow(0 0 2px #000); }
.spot-leaders line.is-inactive { display: none; }
.is-spot .spot-leaders { opacity: 1; }

/* ---------- по одной ---------- */
.single-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  height: calc(100vh - var(--top-h));
  height: calc(100dvh - var(--top-h));
}
.stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--bg-2) 70%, transparent) 0%, transparent 70%),
    var(--bg);
}
.frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  margin: 0;
  padding: 28px 84px 14px;
}
.canvas {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.25);
  background: var(--mat);
  cursor: zoom-in;
}
.canvas img { display: block; width: 100%; height: 100%; }
.canvas .lo { position: absolute; inset: 0; filter: blur(8px); transform: scale(1.01); }
.canvas .hi { position: relative; opacity: 0; transition: opacity 0.4s; }
.canvas .hi.is-loaded { opacity: 1; }
.canvas.is-entering { animation: enter 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes enter { from { opacity: 0; transform: translateX(var(--dir, 0)) scale(0.985); } to { opacity: 1; transform: none; } }

.nav-btn {
  position: absolute; top: 50%; z-index: 3;
  display: grid; place-items: center;
  width: 48px; height: 48px; margin-top: -48px;
  border: 1px solid var(--line); border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.nav-btn:hover { background: var(--surface-2); transform: scale(1.05); }
.nav-btn.prev { left: 18px; }
.nav-btn.next { right: 18px; }
.nav-btn:disabled { opacity: 0.3; cursor: default; transform: none; }

/* ---------- кнопки признака: одни и те же под картиной и во весь экран ---------- */
.spot-bar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 10px; padding: 6px 16px 10px;
}
.spot-bar > * { grid-row: 1; }
.spot-bar [data-spot-toggle] { grid-column: 2; }
.spot-bar .spot-zoom { grid-column: 3; justify-self: start; }
.spot-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 44px; min-width: 190px; padding: 0 20px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.spot-btn.spot-zoom { min-width: 160px; }
.spot-btn:hover { border-color: var(--accent); }
.spot-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.spot-btn[aria-pressed="true"] .pill-dot { background: var(--accent); }
.spot-btn:disabled { opacity: 0.4; cursor: default; }
.info-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 22px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
  padding: 7px 14px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pill:hover { border-color: var(--accent); }
.pill-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--accent); }
.pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.pill[aria-pressed="true"] .pill-dot { background: var(--accent); }
.pill:disabled { opacity: 0.4; cursor: default; }
.picture-state { margin: 0; text-align: center; color: var(--accent-ink); font-size: 14px; }
.filter-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 8px 0 10px; color: var(--muted); font-size: 14px; }
.filter-summary p { margin: 0; }
.link-btn { padding: 2px 0; border: 0; background: none; color: var(--accent-ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.counter { grid-column: 1; justify-self: end; color: var(--faint); font-size: 14px; font-variant-numeric: tabular-nums; }

.strip {
  display: flex; gap: 6px;
  padding: 8px 16px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}
.strip button {
  flex: none;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  background: var(--mat);
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.2s, outline-color 0.2s;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.strip button:hover { opacity: 0.85; }
.strip button[aria-current="true"] { opacity: 1; outline-color: var(--accent); }
.strip img { display: block; height: 100%; width: auto; }

.info {
  overflow-y: auto;
  padding: 30px 30px 40px;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  scrollbar-width: thin;
}
.info-cat { margin: 0 0 8px; color: var(--accent-ink); font-size: 12.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.info h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.05; }
.info .orig { margin: 6px 0 0; font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--muted); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 20px 0 22px; font-size: 15px; }
.meta dt { color: var(--faint); }
.meta dd { margin: 0; }

.dx {
  position: relative;
  margin: 0 0 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.dx.is-hot { box-shadow: 0 0 0 3px var(--accent-soft); }
.dx-k { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.dx-k .lvl { margin-left: auto; color: var(--c); font-weight: 600; }
.dx-v { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.15; }
.dx-signs { margin: 10px 0 0; font-size: 15px; }
.dx-spots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dx-spots button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--text); font-size: 13px; text-align: left;
  cursor: pointer;
}
.dx-spots button:hover, .dx-spots button.is-active { border-color: var(--accent); background: var(--accent-soft); }
.dx-spots button::before { content: ""; width: 9px; height: 9px; flex: none; border-radius: 50%; border: 2px solid var(--accent); }

.sec { margin: 0 0 22px; }
.sec h3 {
  margin: 0 0 6px;
  color: var(--faint);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
}
.sec p { margin: 0; font-size: 15.5px; line-height: 1.6; }
.sec p + p { margin-top: 8px; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 14px !important; }
.refs { margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.45; }
.refs li { position: relative; padding-left: 16px; margin-bottom: 7px; }
.refs li::before { content: "↗"; position: absolute; left: 0; color: var(--faint); font-size: 12px; }
.refs a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.refs a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.refs .y { color: var(--faint); }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related button {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; text-align: left;
  cursor: pointer;
}
.related button:hover { border-color: var(--accent); }
.related img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; }
.info-foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; }
.info-foot a { color: var(--muted); }

/* ---------- лупа во весь экран ---------- */
/* Шапка и кнопки — своими рядами; масштаб — столбиком в углу картины. */
.zoom {
  position: fixed; inset: 0; z-index: 60; background: #070605; color: #f1ebe1;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  --text: #f1ebe1; --line: rgba(255, 255, 255, 0.14); --line-2: rgba(255, 255, 255, 0.26); --surface: rgba(255, 255, 255, 0.08); --accent-soft: rgba(165, 140, 255, 0.28);
}
.zoom-heading { display: flex; align-items: center; gap: 16px; padding: 10px 14px 10px 20px; }
.zoom-names { flex: 1; min-width: 0; }
.zoom-title { flex: 1; min-width: 0; margin: 0; font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.zoom-close {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); color: var(--text); cursor: pointer;
}
.zoom-close:hover { border-color: var(--accent); background: var(--accent-soft); }
.zoom-stage { position: relative; min-height: 0; }
.zoom-surface { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.zoom-surface.is-zoomed { cursor: grab; }
.zoom-surface.is-outside { cursor: default; }
.zoom-surface.is-over-spot { cursor: zoom-in; }
.zoom-surface.is-dragging { cursor: grabbing; }
.zoom-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.zoom-layer img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.zoom-layer .lo { position: absolute; inset: 0; }
.zoom-layer .hi { position: relative; }
.zoom-layer .spot-labels { display: none; }
.zoom .spot .ring { stroke-width: 2.5; }
.viewer .zoom-caption {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: max-content; max-width: min(620px, calc(100% - 140px)); margin: 0; padding: 8px 14px;
  border-radius: 10px; background: rgba(14, 12, 10, 0.88); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  font-size: 15px; line-height: 1.35; text-align: center; pointer-events: none;
  display: flex; align-items: center; gap: 14px;
}
.viewer .zoom-caption p { margin: 0; }
.viewer .zoom-caption button {
  flex: none; min-height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap;
  cursor: pointer; pointer-events: auto;
}
.viewer .zoom-caption button:hover { border-color: var(--accent); }
.spot-zoom.is-out .plus { display: none; }
.zoom-tools {
  position: absolute; right: 14px; bottom: 12px; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line-2); border-radius: 14px; background: rgba(24, 21, 18, 0.92);
}
.zoom-tools button { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.zoom-tools button + button { border-top: 1px solid var(--line); }
.zoom-tools button:hover:not(:disabled) { background: var(--accent-soft); }
.zoom-tools button:focus-visible { outline-offset: -3px; }
.zoom-tools button:disabled { opacity: 0.35; cursor: default; }
.zoom-bar { min-height: 68px; padding: 10px 16px 14px; }
.versions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.version-note { margin: 0 0 20px; }

/* ---------- подвал ---------- */
.foot { max-width: 860px; margin: 40px 0 0; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.foot b { color: var(--text); }
.foot-meta { color: var(--faint); font-size: 13.5px; }
.empty { padding: 40px 0; color: var(--muted); text-align: center; }

/* ---------- адаптив ---------- */
@media (min-width: 861px) and (max-width: 1180px) {
  .toolbar-row .chips-conf { order: 3; flex-basis: 100%; }
}

@media (max-width: 1100px) {
  .single-view { grid-template-columns: minmax(0, 1fr) 380px; }
  .frame { padding: 22px 70px 10px; }
}

@media (max-width: 860px) {
  :root { --top-h: 54px; }
  .top { gap: 10px; padding: 0 12px; }
  .brand-t { display: none; }
  .top-title { padding-left: 10px; font-size: 19px; }
  .view-switch button { padding: 6px 10px; }
  .view-switch button span { display: none; }
  .grid-view { padding: 0 12px 32px; }
  /* Шапка уезжает вместе со страницей: прилипшая отнимала высоту, а в iOS Safari
     над ней ещё и просвечивал текст. */
  .top { position: relative; height: calc(var(--top-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  /* Название уже есть в шапке — вступление остаётся только для читалок экрана. */
  .hero { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .toolbar { gap: 8px; padding-top: 8px; }
  .toolbar-row { gap: 8px; }
  .search { flex: 1 1 0; min-width: 0; height: 40px; }
  .filters-toggle {
    position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); cursor: pointer;
  }
  .filters-toggle[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
  .filters-toggle.is-active::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  .filters-panel { display: none; }
  .filters-panel.is-open { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; flex: 1 1 100%; }
  .filter-summary { display: none; }
  .grid-view.is-filtered .filter-summary, .grid-view.filters-open .filter-summary { display: flex; margin: 8px 0 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips { margin: 0 -12px; padding-inline: 12px; }
  .filters-panel .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .toolbar-row .sort { margin-left: 0; }
  .grid-section { margin-bottom: 22px; }
  .grid-section h2 { margin: 12px 0 8px; font-size: 22px; }
  .card .cap-t { font-size: 17px; }
  .card .cap-a, .card .cap-d { font-size: 12.5px; }

  .single-view { display: block; height: auto; }
  .stage { grid-template-rows: auto auto auto; }
  .frame { grid-template-columns: minmax(0, 1fr); padding: 8px 10px 4px; }
  .canvas {
    --max-h: min(68vh, 640px);
    width: min(100%, calc(var(--max-h) * var(--ar, 1)));
    max-height: none; aspect-ratio: var(--ar, 1);
  }
  @supports (height: 1svh) { .canvas { --max-h: min(68svh, 640px); } }
  .canvas .hi { position: absolute; inset: 0; }
  .nav-btn { display: none; }
  .strip { padding: 6px 12px 12px; }
  .strip button { height: 46px; }
  .info { border-left: 0; border-top: 1px solid var(--line); padding: 22px 18px 40px; overflow: visible; }
  .info h2 { font-size: 30px; }
  .zoom-title { font-size: 16px; }
  .zoom-heading { padding: 8px 10px 8px 14px; gap: 10px; }
  .zoom-tools { right: 10px; bottom: 10px; }
  .zoom-tools button { width: 42px; height: 42px; }
  .viewer .zoom-caption { left: 10px; transform: none; max-width: calc(100% - 76px); font-size: 14px; text-align: left; }
  .spot-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 6px 12px 10px; }
  .spot-bar .counter { order: -1; flex-basis: 100%; text-align: center; font-size: 13px; line-height: 1.2; }
  .spot-btn { flex: 1 1 0; min-width: 0; padding: 0 10px; }
  .spot-btn.spot-zoom { min-width: 0; }
  .info-actions .pill { min-height: 44px; }
  .edit-label span { display: none; }
  .edit-label.is-signs textarea { max-height: 22vh; }
  .edit-buttons .pill { padding: 6px 11px; }
  .dx-k { flex-wrap: wrap; }
  .dx-spots button { min-height: 44px; }
  .search input { font-size: 16px; }
}

@media (max-width: 420px) {
  .top-title { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

[data-conf="refuted"] { --c: #b89494; }
.share-fallback { max-width: 100%; min-width: 0; padding: 8px; font: inherit; }

/* ---------- редактор овалов ---------- */
.stage-edit { position: absolute; top: 14px; right: 14px; z-index: 4; min-height: 40px; box-shadow: var(--shadow); }
.editor-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 14px 0 0; padding: 12px 16px;
  border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft); font-size: 15px; font-weight: 600;
}
@media (max-width: 860px) {
  .stage-edit { position: static; justify-self: end; margin: 8px 10px 0; box-shadow: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
}
.editor .zoom-surface { cursor: grab; }
.editor .zoom-caption { margin: 3px 0 0; font-size: 14px; line-height: 1.3; color: #c8bfb2; }
.editor .zoom-caption.is-error { color: #ffb4a8; }
.edit-marks { position: absolute; inset: 0; }
.edit-spot {
  position: absolute; border-radius: 50%; cursor: move;
  border: calc(2px * var(--k)) solid #fff;
  box-shadow: 0 0 0 calc(2px * var(--k)) rgba(165, 140, 255, 0.75), inset 0 0 0 calc(1px * var(--k)) rgba(0, 0, 0, 0.45);
  outline: 0;
}
/* зона захвата не меньше пальца даже у крошечного овала */
.edit-spot::before {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(100%, calc(32px * var(--k))); height: max(100%, calc(32px * var(--k))); border-radius: 50%;
}
.edit-spot.is-selected { z-index: 2; border-color: #ffe27a; }
.edit-handle {
  position: absolute; display: none; z-index: 1;
  width: calc(14px * var(--k)); height: calc(14px * var(--k)); border-radius: 50%;
  background: #ffe27a; border: calc(2px * var(--k)) solid #1a1410;
  transform: translate(-50%, -50%);
}
.edit-handle::before { content: ""; position: absolute; inset: calc(-9px * var(--k)); border-radius: 50%; }
.edit-spot.is-selected .edit-handle { display: block; }
/* маркеры вынесены за овал, чтобы не перекрывать признак и «перемещение» */
.edit-handle.is-e { left: calc(100% + 18px * var(--k)); top: 50%; cursor: ew-resize; }
.edit-handle.is-s { left: 50%; top: calc(100% + 18px * var(--k)); cursor: ns-resize; }
.edit-handle.is-se { left: calc(85.4% + 14px * var(--k)); top: calc(85.4% + 14px * var(--k)); cursor: nwse-resize; }
.edit-panel {
  display: grid; gap: 8px; justify-items: center; padding: 8px 10px 10px;
  --text: #f1ebe1; --line: rgba(255, 255, 255, 0.14); --line-2: rgba(255, 255, 255, 0.24); --surface: rgba(255, 255, 255, 0.06); --bg-2: rgba(255, 255, 255, 0.06); --muted: #c8bfb2;
}
.edit-label { display: flex; align-items: center; gap: 10px; width: min(560px, 100%); color: #c8bfb2; font-size: 13px; }
.edit-label input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.edit-label input:disabled { opacity: 0.5; }
.edit-label.is-signs textarea {
  flex: 1; min-width: 0; padding: 8px 12px; resize: vertical; max-height: 30vh;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; line-height: 1.3;
}
.edit-label > span { flex: 0 0 118px; line-height: 1.25; }
.edit-buttons { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.edit-buttons .pill { min-height: 40px; }
.edit-buttons button:disabled { opacity: 0.4; cursor: default; }
.pill.is-primary { background: #7656e6; border-color: #7656e6; color: #fff; }
a.pill:hover { text-decoration: none; }

@media (max-width: 860px) {
  .toolbar .chip { padding: 6px 11px; }
}
