:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-raised: rgba(255, 255, 255, 0.92);
  --border: #dfdfda;
  --border-strong: #c8c8c1;
  --text: #1b1c1f;
  --text-2: #5d6066;
  --text-3: #8b8f96;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --accent-soft: #e4efe8;
  --marker: #b4532a;
  --marker-ink: #ffffff;
  --age-oldest: #e05252;
  --age-war: #e98a3f;
  --age-soviet: #3d9ed8;
  --age-recent: #79b94c;
  --danger: #a33b2c;
  --shadow-1: 0 1px 2px rgba(24, 24, 27, 0.08), 0 2px 8px rgba(24, 24, 27, 0.06);
  --shadow-2: 0 6px 24px rgba(24, 24, 27, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --tap: 44px;
  --sheet-peek: 108px;
  --sheet-half: 52vh;
  --sheet-full: 88vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #16171a;
  --surface: #1f2126;
  --surface-2: #262930;
  --surface-raised: rgba(31, 33, 38, 0.94);
  --border: #333740;
  --border-strong: #464c57;
  --text: #f0f1f3;
  --text-2: #b3b8c0;
  --text-3: #868d98;
  --accent: #64b98c;
  --accent-ink: #10231a;
  --accent-soft: #22342b;
  --marker: #d8734a;
  --marker-ink: #1b0f08;
  --danger: #e08272;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; letter-spacing: 0; color: inherit; }

/* Не отдаём двойной тап браузеру: кнопки и ссылки должны нажиматься, а не
   увеличивать всю страницу. Карта и просмотрщик ниже имеют свои жесты. */
button, a, input, label { touch-action: manipulation; }

a { color: var(--accent); }

.is-hidden { display: none !important; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- map ---------- */

.map-stage {
  position: absolute;
  inset: 0;
}

.map {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
}

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-logo { display: none !important; }

.map-overlay {
  position: absolute;
  z-index: 5;
  display: flex;
  pointer-events: none;
}

.map-overlay > * { pointer-events: auto; }

.map-overlay--top {
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.map-overlay--side {
  right: calc(var(--safe-right) + 10px);
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 14px);
  flex-direction: column;
  gap: 8px;
  transition: bottom 200ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 160ms ease;
}

/* Кнопки карты держатся над панелью; в раскрытом списке карта не видна,
   поэтому они уходят, а фильтры остаются в заголовке панели. */
.app[data-sheet="half"] .map-overlay--side {
  bottom: calc(var(--sheet-half) + var(--safe-bottom) + 14px);
}

.app[data-sheet="full"] .map-overlay--side {
  opacity: 0;
  pointer-events: none;
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--tap);
  padding: 0 4px 0 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
  width: 100%;
  transition: width 160ms ease, border-color 160ms ease;
}

.searchbar.is-collapsed {
  width: var(--tap);
  padding: 0 1px;
  align-self: flex-end;
}

.searchbar.is-collapsed .searchbar__input,
.searchbar.is-collapsed .searchbar__clear { display: none; }

.searchbar__icon,
.searchbar__clear {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.searchbar__icon:active,
.searchbar__clear:active { background: var(--surface-2); }

.searchbar__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  /* iOS автоматически увеличивает страницу при фокусе на поле меньше 16px. */
  font-size: 16px;
}

.searchbar__input::-webkit-search-cancel-button { display: none; }

.search-results {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  -webkit-overflow-scrolling: touch;
}

.search-results__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.search-results__item:last-child { border-bottom: 0; }
.search-results__item:active { background: var(--surface-2); }
.search-results__item .icon { color: var(--text-3); width: 18px; height: 18px; }

.search-results__text { min-width: 0; }

.search-results__title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-results__sub {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-results__empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-3);
}

.status-chip {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  font-size: 12.5px;
  color: var(--text-2);
  backdrop-filter: blur(12px);
}

.status-chip--warn { color: var(--danger); }

.status-chip__action {
  flex: none;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.status-chip__action--ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text-2);
}

.status-chip__spin {
  width: 13px;
  height: 13px;
  flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.fab {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.fab:active { transform: scale(0.96); }
.fab.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
/* Исторических карт для этого места нет: кнопка тише, но по-прежнему нажимается. */
.fab.is-dim { color: var(--text-3); }

.fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--marker);
  color: var(--marker-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.attribution {
  position: absolute;
  left: calc(var(--safe-left) + 10px);
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 4px);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 62vw;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--text-3);
  text-shadow: 0 1px 2px var(--bg);
  transition: bottom 200ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 160ms ease;
}

.app[data-sheet="half"] .attribution {
  bottom: calc(var(--sheet-half) + var(--safe-bottom) + 4px);
}

.app[data-sheet="full"] .attribution { opacity: 0; }

/* С включённой подложкой атрибуция поднимается над полоской прозрачности. */
.app[data-hist="on"] .attribution {
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 106px);
}

.app[data-hist="on"][data-sheet="half"] .attribution {
  bottom: calc(var(--sheet-half) + var(--safe-bottom) + 106px);
}

.attribution a { color: inherit; text-decoration: underline; }

.attribution__hist { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- историческая подложка: полоска управления ---------- */

/*
  Полоска живёт над нижней панелью: прозрачность — самый частый жест при
  работе с подложкой, поэтому ползунок держится под большим пальцем,
  а не в углу экрана.
*/
.histbar {
  position: absolute;
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 14px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
  transition: bottom 200ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 160ms ease;
}

.app[data-sheet="half"] .histbar {
  bottom: calc(var(--sheet-half) + var(--safe-bottom) + 14px);
}

.app[data-sheet="full"] .histbar { opacity: 0; pointer-events: none; }

/* Кнопки карты уступают место полоске, когда подложка включена. */
.app[data-hist="on"] .map-overlay--side {
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 106px);
}

.app[data-hist="on"][data-sheet="half"] .map-overlay--side {
  bottom: calc(var(--sheet-half) + var(--safe-bottom) + 106px);
}

.histbar__head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.histbar__toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

.histbar__toggle:active { background: var(--surface-2); }

.histbar__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--marker);
  background: var(--marker);
  transition: background 140ms ease;
}

.histbar__toggle[aria-pressed="false"] .histbar__dot { background: transparent; }

.histbar__title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 34px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.histbar__year {
  flex: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--marker);
  font-variant-numeric: tabular-nums;
}

.histbar__name {
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.histbar__close { width: 34px; height: 34px; }

/* Слой включён, но в этом месте у него нет тайлов — говорим об этом в полоске. */
.histbar__flag {
  flex: none;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}

/* На узком экране пометка важнее названия: два ярлыка рядом сжимают
   название до нечитаемых нескольких букв. */
@media (max-width: 360px) {
  .histbar:has(.histbar__flag:not(.is-hidden)) .histbar__name { display: none; }
}

/* Пустое состояние панели: районы, где исторические карты есть. */
.hist-regions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 16px;
}

.hist-region {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.hist-region:active { background: var(--surface-2); }

.hist-region__count {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.histbar__slider {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
}

.histbar__edge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.histbar__edge:active { background: var(--surface-2); }
.histbar__edge .icon { width: 17px; height: 17px; }

.histbar__slider input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.histbar__slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--marker) var(--fill, 75%), var(--border) var(--fill, 75%));
}

.histbar__slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.histbar__slider input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border);
}

.histbar__slider input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--marker);
}

.histbar__slider input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.histbar__value {
  flex: none;
  width: 38px;
  text-align: right;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.histbar.is-off .histbar__slider { opacity: 0.4; pointer-events: none; }
.histbar.is-off .histbar__year { color: var(--text-3); }

/* ---------- markers ---------- */

.photo-pin {
  position: absolute;
  --pin-size: 54px;
  width: var(--pin-size);
  height: var(--pin-size);
  filter: drop-shadow(0 2px 3px rgba(20, 20, 20, 0.2));
}

.photo-pin.is-zoom-hidden { display: none; }

.photo-pin--compact { --pin-size: 46px; }
.photo-pin--dot { --pin-size: 14px; }

.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--photo-color, var(--marker));
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), 0 2px 7px rgba(20, 20, 20, 0.3);
  cursor: pointer;
  transition: box-shadow 120ms ease, filter 120ms ease;
}

.photo-preview:active { filter: brightness(0.9); }

.photo-pin.is-selected { z-index: 2; }

.photo-pin.is-selected .photo-preview {
  box-shadow: 0 0 0 2px #ffffff, 0 4px 12px rgba(20, 20, 20, 0.38);
  filter: brightness(1.08);
}

.photo-preview--compact {
  border-width: 2px;
}

.photo-preview--dot {
  border-width: 2px;
  background: var(--photo-color, var(--marker));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 1px 4px rgba(20, 20, 20, 0.42);
}

.photo-preview--dot img { display: none; }

.photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

.photo-pin__direction {
  position: absolute;
  inset: -8px;
  display: none;
  pointer-events: none;
  transform: rotate(var(--photo-bearing, 0deg));
}

.photo-pin.has-direction .photo-pin__direction { display: block; }

.photo-pin__direction::before {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 8px solid var(--photo-color, var(--marker));
  border-left: 5px solid transparent;
  content: '';
  filter: drop-shadow(0 -1px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 1px 2px rgba(20, 20, 20, 0.38));
  transform: translateX(-50%);
}

.photo-pin--dot .photo-pin__direction {
  inset: -7px;
}

.photo-pin--dot .photo-pin__direction::before {
  top: 0;
  border-right-width: 4px;
  border-bottom-width: 7px;
  border-left-width: 4px;
}

.photo-pin--spider { z-index: 4; }

.photo-pin--spider::before {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: var(--spider-length);
  height: 1px;
  background: rgba(35, 38, 42, 0.55);
  content: '';
  transform: rotate(var(--spider-angle));
  transform-origin: 0 50%;
}

.photo-spider-more {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  font-weight: 700;
}

.you-dot {
  position: absolute;
  inset: 0;
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2f80ed;
  border: 3px solid #ffffff;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.you-dot__pulse {
  position: absolute;
  display: block;
  inset: -9px;
  border-radius: 50%;
  background: rgba(47, 128, 237, 0.22);
  /* Пульсация — подсказка «это вы», а не постоянное движение в кадре:
     она мешала бы разглядывать снимки и старую карту под точкой. */
  animation: pulse 1.4s ease-out 1;
  animation-fill-mode: forwards;
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(1.45); opacity: 0; }
}

.you-heading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 14px solid #2f80ed;
  transform-origin: 50% 100%;
  transform: translate(-50%, -26px);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
  /* Компас отдаёт значения рывками — сглаживаем поворот. */
  transition: transform 220ms ease-out;
}

/* ---------- bottom sheet ---------- */

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  height: var(--sheet-peek);
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: height 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
  touch-action: none;
}

.sheet.is-dragging { transition: none; }
.sheet[data-state="half"] { height: var(--sheet-half); }
.sheet[data-state="full"] { height: var(--sheet-full); }

.sheet__grabber {
  display: grid;
  place-items: center;
  height: 22px;
  flex: none;
  cursor: grab;
}

.sheet__grabber-bar {
  width: 38px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  flex: none;
  padding: 0 12px 8px;
}

.sheet__filters {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
}

.sheet__filters.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sheet__filters .fab__badge { top: -6px; right: -6px; }

.sheet__titles { min-width: 0; }

.sheet__title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet__subtitle {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segmented {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.segmented__btn {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.segmented__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
  font-weight: 600;
}

.segmented--wide { width: 100%; }
.segmented--wide .segmented__btn { flex: 1 1 0; height: 36px; }

.sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.sheet__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 12px;
  touch-action: pan-y;
}

.sheet__body[data-mode="grid"] .sheet__scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  /* Скролл-контейнер, который сам является сеткой, иначе делит свою высоту
     между строками и схлопывает карточки. */
  grid-auto-rows: max-content;
  gap: 8px;
  align-content: start;
}

.sheet__body[data-mode="list"] .sheet__scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet[data-state="peek"] .sheet__body[data-mode="grid"] .sheet__scroll,
.sheet[data-state="peek"] .sheet__body[data-mode="list"] .sheet__scroll {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
}

@media (max-width: 899px) {
  .sheet[data-state="peek"] .sheet__subtitle,
  .sheet[data-state="peek"] .segmented { display: none; }

  .sheet[data-state="peek"] .sheet__grabber { height: 16px; }
  .sheet[data-state="peek"] .sheet__head { padding-bottom: 5px; align-items: center; }
  .sheet[data-state="peek"] .sheet__title { font-size: 14px; }
  .sheet[data-state="peek"] .sheet__filters { width: 30px; height: 30px; }
  .sheet[data-state="peek"] .sheet__scroll { padding-bottom: 8px; }
  .sheet[data-state="peek"] .sheet__body .card { width: 104px; }
  .sheet[data-state="peek"] .card__body { display: none; }
  .sheet[data-state="peek"] .card__thumb { aspect-ratio: 4 / 3; }
}

.sheet[data-state="peek"] .card {
  width: 132px;
  flex: none;
  flex-direction: column;
}

/* ---------- photo cards ---------- */

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  padding: 0;
  cursor: pointer;
  contain: content;
}

.card:active { border-color: var(--border-strong); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  flex: none;
  background: var(--surface-2);
  overflow: hidden;
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 180ms ease;
}

.card__img.is-loaded { opacity: 1; }

.card__year {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(20, 20, 22, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.card__source {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(20, 20, 22, 0.68);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.card__dist {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(20, 20, 22, 0.6);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.card__body {
  padding: 6px 8px 8px;
  min-width: 0;
}

.card__title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.sheet__body[data-mode="list"] .card {
  flex-direction: row;
  align-items: stretch;
}

.sheet__body[data-mode="list"] .card__thumb {
  width: 104px;
  flex: none;
  aspect-ratio: 4 / 3;
}

.sheet__body[data-mode="list"] .card__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 8px 10px;
}

.sheet__body[data-mode="list"] .card__title { font-size: 14px; -webkit-line-clamp: 3; }

.card__meta {
  display: none;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.sheet__body[data-mode="list"] .card__meta { display: flex; }

.empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: var(--text-3);
  text-align: center;
}

.empty .icon { width: 26px; height: 26px; }
.empty__text { font-size: 13.5px; max-width: 34ch; }

.skeleton {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
  aspect-ratio: 4 / 3.5;
}

.sheet[data-state="peek"] .skeleton { width: 132px; flex: none; }

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -20% 0; }
}

/* ---------- panels ---------- */

.scrim {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: rgba(16, 17, 19, 0.42);
  backdrop-filter: blur(2px);
}

.panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: slide-up 200ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes slide-up {
  from { transform: translateY(12px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  padding: 12px 10px 8px 16px;
  border-bottom: 1px solid var(--border);
}

.panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.panel__titles { min-width: 0; }

.panel__subtitle {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel--tall { height: 78vh; }

.panel__toolbar {
  flex: none;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1px;
}

.chips--scroll::-webkit-scrollbar { display: none; }
.chips--scroll .chip { flex: none; }

.panel__body--flush {
  padding: 8px;
  gap: 6px;
}

/* ---------- список исторических подложек ---------- */

.hist-item {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  /* Родитель — flex-колонка со скроллом: без этого строки делят высоту
     между собой и схлопываются в полоски. */
  flex: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.hist-item:active { border-color: var(--border-strong); }

.hist-item.is-active {
  border-color: var(--marker);
  box-shadow: 0 0 0 1px var(--marker);
  background: var(--surface-2);
}

.hist-item__preview {
  position: relative;
  width: 82px;
  min-height: 72px;
  flex: none;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  border-right: 1px solid var(--border);
}

.hist-item__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 200ms ease;
}

.hist-item__preview img.is-loaded { opacity: 1; }

/* Тайла в этом месте нет — рисуем спокойную штриховку, а не пустоту. */
.hist-item__preview.is-empty {
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 4px,
    color-mix(in srgb, var(--text) 9%, transparent) 4px,
    color-mix(in srgb, var(--text) 9%, transparent) 8px
  );
}

.hist-item__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  min-width: 0;
  padding: 9px 10px 9px 0;
}

.hist-item__top {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.hist-item__year {
  flex: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hist-item.is-active .hist-item__year { color: var(--marker); }

.hist-item__kind {
  flex: none;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.hist-item.is-active .hist-item__kind { background: var(--surface); }

.hist-item__title {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.hist-item__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
}

.hist-item__coverage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hist-item__bar {
  width: 26px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--border);
  overflow: hidden;
}

.hist-item__bar span {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--text-3);
}

.hist-item__zoomhint { color: var(--danger); }

.panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.panel__foot {
  display: flex;
  gap: 8px;
  flex: none;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.icon-btn:active { background: var(--surface-2); }
.icon-btn.is-active { color: var(--marker); }
.icon-btn.is-active .icon { fill: var(--marker); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn--primary {
  flex: 1 1 auto;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--ghost { color: var(--text-2); }
.btn:active { transform: scale(0.99); }

.field { display: flex; flex-direction: column; gap: 10px; }

fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field__value {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.source-field { gap: 4px; }

.source-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 0;
  cursor: pointer;
}

.source-option input { position: absolute; opacity: 0; pointer-events: none; }

.source-option__mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
}

.source-option input:checked + .source-option__mark {
  border-color: var(--accent);
  background: var(--accent);
}

.source-option input:checked + .source-option__mark::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: translateY(-1px) rotate(-45deg);
}

.source-option__text { display: flex; flex-direction: column; min-width: 0; }
.source-option__text strong { font-size: 14px; font-weight: 600; }
.source-option__text small { font-size: 12px; color: var(--text-3); }
.source-field__hint { min-height: 16px; margin: 0; font-size: 12px; color: var(--danger); }

.range {
  position: relative;
  height: 34px;
}

.range__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 15px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border);
}

.range__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

.range input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 34px;
  margin: 0;
  background: transparent;
  appearance: none;
  pointer-events: none;
}

.range input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  pointer-events: auto;
  cursor: grab;
}

.range input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  pointer-events: auto;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__text { display: flex; flex-direction: column; min-width: 0; }
.switch__title { font-size: 14px; font-weight: 550; }

.switch__ui {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--border);
  transition: background 140ms ease;
}

.switch__ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform 140ms ease;
}

.switch input:checked + .switch__ui { background: var(--accent); }
.switch input:checked + .switch__ui::after { transform: translateX(18px); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.tile.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.tile__preview {
  height: 56px;
  background-size: cover;
  background-position: center;
}

.tile__name {
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}

/* ---------- viewer ---------- */

.viewer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #0d0e10;
  color: #f2f2f3;
}

.viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
  padding: calc(var(--safe-top) + 4px) 6px 4px;
}

.viewer__bar .icon-btn { color: #f2f2f3; }
.viewer__bar .icon-btn:active { background: rgba(255, 255, 255, 0.12); }
.viewer__bar-actions { display: flex; gap: 2px; }

.viewer__counter {
  font-size: 13px;
  color: rgba(242, 242, 243, 0.7);
  font-variant-numeric: tabular-nums;
}

.viewer__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}

.viewer__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 40px;
  height: 56px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(20, 20, 22, 0.5);
  color: #fff;
  cursor: pointer;
}

.viewer__nav--prev { left: 6px; }
.viewer__nav--next { right: 6px; }
.viewer__nav[disabled] { opacity: 0.25; }

.viewer__meta {
  flex: none;
  max-height: 40vh;
  overflow-y: auto;
  padding: 10px 16px calc(var(--safe-bottom) + 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #14151800;
}

.viewer__title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.viewer__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.viewer__fact {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(242, 242, 243, 0.86);
  font-variant-numeric: tabular-nums;
}

.viewer__desc {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(242, 242, 243, 0.78);
  overflow-wrap: anywhere;
}

.viewer__desc a { color: #8fd3ad; }

.viewer__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.viewer__action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #f2f2f3;
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}

.viewer__action .icon { width: 17px; height: 17px; }

.viewer__action--primary {
  border-color: rgba(121, 185, 76, 0.65);
  background: rgba(121, 185, 76, 0.18);
}

/* ---------- repeat frame camera ---------- */

.repeat-frame {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #090a0b;
  color: #ffffff;
}

.repeat-frame.is-reviewing { grid-template-rows: 1fr; }
.repeat-frame.is-reviewing > .repeat-frame__bar,
.repeat-frame.is-reviewing > .repeat-frame__stage,
.repeat-frame.is-reviewing > .repeat-frame__controls { display: none; }

.repeat-frame__bar {
  z-index: 2;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 132px;
  align-items: center;
  min-height: calc(var(--safe-top) + 52px);
  padding: var(--safe-top) 6px 0;
  background: rgba(9, 10, 11, 0.94);
}

.repeat-frame__title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repeat-frame__tools {
  display: flex;
  justify-content: flex-end;
}

.repeat-frame__bar .icon-btn { color: #ffffff; }
.repeat-frame__bar .icon-btn.is-active { background: rgba(255, 255, 255, 0.16); }

.repeat-frame__stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #000000;
  touch-action: none;
}

.repeat-frame__stage video,
.repeat-frame__stage > img,
.repeat-frame__stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.repeat-frame__stage video { object-fit: cover; }

.repeat-frame__stage > img {
  z-index: 1;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center;
}

.repeat-frame__stage > canvas {
  z-index: 1;
  pointer-events: none;
}

.repeat-frame[data-compare="edges"] > .repeat-frame__stage > img,
.repeat-frame[data-compare="difference"] > .repeat-frame__stage > img { opacity: 0 !important; }

.repeat-frame[data-compare="overlay"] #repeat-edges,
.repeat-frame[data-compare="wipe"] #repeat-edges { display: none; }

.repeat-frame[data-compare="wipe"] > .repeat-frame__stage > img {
  clip-path: inset(0 calc(100% - var(--wipe, 50%)) 0 0);
  opacity: 1 !important;
}

.repeat-frame__divider {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: var(--wipe, 50%);
  display: none;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.repeat-frame[data-compare="wipe"] .repeat-frame__divider { display: block; }

.repeat-frame.is-peeking > .repeat-frame__stage > img,
.repeat-frame.is-peeking > .repeat-frame__stage > canvas,
.repeat-frame.is-peeking .repeat-frame__divider { visibility: hidden; }

.repeat-frame__grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    linear-gradient(to right, transparent 33.1%, rgba(255, 255, 255, 0.52) 33.2%, rgba(255, 255, 255, 0.52) 33.5%, transparent 33.6%, transparent 66.4%, rgba(255, 255, 255, 0.52) 66.5%, rgba(255, 255, 255, 0.52) 66.8%, transparent 66.9%),
    linear-gradient(to bottom, transparent 33.1%, rgba(255, 255, 255, 0.52) 33.2%, rgba(255, 255, 255, 0.52) 33.5%, transparent 33.6%, transparent 66.4%, rgba(255, 255, 255, 0.52) 66.5%, rgba(255, 255, 255, 0.52) 66.8%, transparent 66.9%);
}

.repeat-frame__crop {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.2);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.repeat-frame__message {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(300px, calc(100% - 40px));
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(12, 13, 15, 0.84);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  transform: translate(-50%, -50%);
}

.repeat-frame__controls {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 10px 12px calc(var(--safe-bottom) + 74px);
  background: rgba(9, 10, 11, 0.96);
}

.repeat-modes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
}

.repeat-modes button {
  min-width: 0;
  height: 34px;
  padding: 0 5px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repeat-modes button.is-active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.repeat-control {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.repeat-control output {
  color: rgba(255, 255, 255, 0.64);
  font-variant-numeric: tabular-nums;
}

.repeat-control input {
  width: 100%;
  accent-color: #79b94c;
}

.repeat-frame__options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.repeat-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  height: 36px;
  padding: 0 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repeat-option .icon { width: 16px; height: 16px; }
.repeat-option.is-active { border-color: rgba(121, 185, 76, 0.7); color: #ffffff; }
.repeat-option--system { border-color: rgba(255, 255, 255, 0.28); }

.repeat-camera-settings { display: grid; gap: 8px; }

.repeat-frame__capture {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 10px);
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: transparent;
  transform: translateX(-50%);
}

.repeat-frame__capture span {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
}

.repeat-frame__capture:active span { transform: scale(0.9); }

.repeat-frame__capture:disabled { opacity: 0.45; }

.repeat-review {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #090a0b;
}

.repeat-review img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.repeat-review__close {
  position: absolute;
  z-index: 1;
  top: calc(var(--safe-top) + 8px);
  left: calc(var(--safe-left) + 8px);
  background: rgba(9, 10, 11, 0.72);
  color: #ffffff;
}

.repeat-review__hint {
  position: absolute;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 66px);
  left: 12px;
  margin: 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: rgba(9, 10, 11, 0.82);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  text-align: center;
}

.repeat-review__actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 8px;
  padding: 10px 12px calc(var(--safe-bottom) + 10px);
  background: rgba(9, 10, 11, 0.98);
}

.repeat-review__actions .btn--ghost {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

@media (min-width: 700px) {
  .repeat-frame__controls {
    grid-template-columns: minmax(280px, 420px) minmax(280px, 420px);
    justify-content: center;
    gap: 20px;
  }

  .repeat-modes,
  .repeat-frame__options,
  .repeat-camera-settings { grid-column: 1 / -1; }
}

@media (max-width: 360px) {
  .repeat-frame__controls { max-height: 46vh; }
  .repeat-modes button,
  .repeat-option { font-size: 10.5px; }
  .repeat-option { gap: 3px; }
  .repeat-option span { display: none; }
}

/* ---------- tooltips (pointer devices only) ---------- */

@media (hover: hover) and (pointer: fine) {
  [data-tooltip] { position: relative; }

  [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--text);
    color: var(--surface);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
  }

  [data-tooltip]:hover::after { opacity: 1; }

  .sheet [data-tooltip]::after,
  .viewer [data-tooltip]::after {
    right: auto;
    left: 50%;
    top: calc(100% + 6px);
    transform: translateX(-50%);
  }
}

/* ---------- wide screens ---------- */

@media (min-width: 900px) {
  :root { --sheet-peek: 0px; }

  .app[data-sheet="half"] .map-overlay--side,
  .app[data-sheet="full"] .map-overlay--side {
    bottom: 24px;
    opacity: 1;
    pointer-events: auto;
  }

  .app[data-sheet="half"] .attribution,
  .app[data-sheet="full"] .attribution { bottom: 8px; opacity: 1; }

  .sheet {
    left: 12px;
    top: 12px;
    bottom: 12px;
    right: auto;
    width: 380px;
    height: auto !important;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding-bottom: 0;
  }

  .sheet__grabber { display: none; }
  .sheet__head { padding-top: 12px; }

  .sheet[data-state="peek"] .sheet__body[data-mode="grid"] .sheet__scroll {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    grid-auto-rows: max-content;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sheet[data-state="peek"] .sheet__body[data-mode="list"] .sheet__scroll {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sheet[data-state="peek"] .card { width: auto; }
  .sheet[data-state="peek"] .skeleton { width: auto; }

  .map-overlay--top {
    left: 408px;
    right: 12px;
    top: 12px;
    max-width: 420px;
  }

  .map-overlay--side { right: 12px; bottom: 24px; }
  .attribution { left: 408px; bottom: 8px; max-width: 40vw; }
  .histbar {
    left: 408px;
    right: auto;
    bottom: 32px;
    width: 340px;
  }

  .app[data-sheet="half"] .histbar,
  .app[data-sheet="full"] .histbar { bottom: 32px; opacity: 1; pointer-events: auto; }

  .app[data-hist="on"] .map-overlay--side,
  .app[data-hist="on"][data-sheet="half"] .map-overlay--side { bottom: 24px; }

  .app[data-hist="on"] .attribution { bottom: 8px; }
  .panel--tall { height: auto; max-height: 82vh; }

  .panel {
    left: auto;
    right: 12px;
    bottom: 12px;
    width: 380px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .viewer { display: grid; grid-template-columns: 1fr 340px; grid-template-rows: auto 1fr; }
  .viewer__bar { grid-column: 1 / -1; padding-left: 12px; padding-right: 12px; }
  .viewer__stage { grid-column: 1; }
  .viewer__meta { grid-column: 2; grid-row: 2; max-height: none; border-top: 0; border-left: 1px solid rgba(255, 255, 255, 0.1); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
