/* ─── Reference tray ─────────────────────────────────────────────────────── */

body.app-slava-restraint .reference-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 6px 10px;
}

body.app-slava-restraint .reference-tray__chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  border: 1px solid var(--sr-edge);
  overflow: hidden;
  background: var(--sr-glass-raised);
}

body.app-slava-restraint .reference-tray__thumb {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
}

body.app-slava-restraint .reference-tray__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 40px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--sr-edge);
  color: var(--sr-ink-meta);
  cursor: pointer;
  flex-shrink: 0;
}

body.app-slava-restraint .reference-tray__remove:hover {
  color: var(--sr-ink);
  background: var(--sr-glass);
}

/* ─── Composer new controls ──────────────────────────────────────────────── */

body.app-slava-restraint .create-composer__attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--sr-glass-raised);
  border: 1px solid var(--sr-edge);
  border-radius: 10px;
  color: var(--sr-ink-meta);
  cursor: pointer;
  flex-shrink: 0;
}

body.app-slava-restraint .create-composer__attach:hover {
  border-color: var(--sr-edge-strong);
  color: var(--sr-ink);
}

body.app-slava-restraint .create-composer__qty {
  display: inline-flex;
  align-items: center;
  background: var(--sr-glass-raised);
  border: 1px solid var(--sr-edge);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

body.app-slava-restraint .create-composer__qty button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--sr-ink-meta);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

body.app-slava-restraint .create-composer__qty button:hover:not(:disabled) {
  color: var(--sr-ink);
  background: var(--sr-glass);
}

body.app-slava-restraint .create-composer__qty button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

body.app-slava-restraint .create-composer__qty span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  font-size: 13px;
  color: var(--sr-ink);
  user-select: none;
}

/* ─── Results gallery ────────────────────────────────────────────────────── */

body.app-slava-restraint .results-gallery {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body.app-slava-restraint .results-gallery__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.app-slava-restraint .results-gallery__count {
  font-size: 13px;
  color: var(--sr-ink-meta);
}

body.app-slava-restraint .results-gallery__layout {
  display: inline-flex;
  gap: 4px;
}

body.app-slava-restraint .results-gallery__layout button {
  background: transparent;
  border: 1px solid var(--sr-edge);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--sr-ink-meta);
  cursor: pointer;
}

body.app-slava-restraint .results-gallery__layout button:hover {
  border-color: var(--sr-edge-strong);
  color: var(--sr-ink);
}

body.app-slava-restraint .results-gallery__layout button.is-active {
  border-color: var(--sr-accent);
  color: var(--sr-ink-bold);
}

body.app-slava-restraint .results-gallery__items--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

body.app-slava-restraint .results-gallery__items--list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── Results gallery tabs ───────────────────────────────────────────────── */

body.app-slava-restraint .results-gallery__tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--sr-glass-raised);
  border: 1px solid var(--sr-edge);
  border-radius: 9px;
  padding: 3px;
}

body.app-slava-restraint .results-gallery__tab {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--sr-ink-meta);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

body.app-slava-restraint .results-gallery__tab:hover {
  color: var(--sr-ink);
  background: var(--sr-glass);
}

body.app-slava-restraint .results-gallery__tab.is-active {
  background: var(--sr-glass-strong);
  border: 1px solid var(--sr-edge-strong);
  color: var(--sr-ink-bold);
}

/* ─── Selected-only toggle ───────────────────────────────────────────────── */

body.app-slava-restraint .results-gallery__selected-toggle {
  background: transparent;
  border: 1px solid var(--sr-edge);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 11px;
  color: var(--sr-ink-meta);
  cursor: pointer;
  white-space: nowrap;
}

body.app-slava-restraint .results-gallery__selected-toggle:hover {
  border-color: var(--sr-edge-strong);
  color: var(--sr-ink);
}

/* ─── Per-tab empty state ────────────────────────────────────────────────── */

body.app-slava-restraint .results-gallery__empty {
  padding: 32px 0;
  text-align: center;
  font-size: 13px;
  color: var(--sr-ink-faint);
}

/* ─── Result card ────────────────────────────────────────────────────────── */

body.app-slava-restraint .result-card {
  position: relative;
  border-radius: 10px;
  border: 1px solid var(--sr-edge);
  background: var(--sr-glass);
  overflow: hidden;
}

body.app-slava-restraint .result-card__media {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--sr-glass-raised);
}

body.app-slava-restraint .results-gallery__items--list .result-card__media {
  aspect-ratio: unset;
  min-height: 80px;
  max-height: 200px;
}

body.app-slava-restraint .result-card__actions {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2; /* above the full-area zoom overlay (z-index: 1) so actions stay clickable */
  padding: 6px;
  gap: 4px;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
}

/* Full-area invisible click target that opens the lightbox (images only). */
body.app-slava-restraint .result-card__zoom-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 0;
  background: transparent;
  border: none;
  cursor: zoom-in;
}

/* Corner expand affordance, shown on hover (images + video). */
body.app-slava-restraint .result-card__zoom-btn {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
}

body.app-slava-restraint .result-card:hover .result-card__zoom-btn {
  display: inline-flex;
}

body.app-slava-restraint .result-card__zoom-btn:hover {
  background: rgba(0, 0, 0, 0.65);
}

body.app-slava-restraint .result-card:hover .result-card__actions {
  display: flex;
}

body.app-slava-restraint .result-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 7px;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

body.app-slava-restraint .result-card__btn:hover {
  background: rgba(255,255,255,0.22);
}

body.app-slava-restraint .result-card__btn--danger:hover {
  background: rgba(220, 50, 50, 0.45);
  border-color: rgba(220, 50, 50, 0.6);
}

/* Download-format menu (raster gallery results) */
.result-card__dl {
  position: relative;
  display: inline-flex;
}
.result-card__dl-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 92px;
  padding: 4px;
  border-radius: 8px;
}
.result-card__dl-item {
  display: block;
  padding: 5px 9px;
  font-size: 12px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
}
body.app-slava-restraint .result-card__dl-menu {
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
body.app-slava-restraint .result-card__dl-item {
  color: #e6e6e6;
}
body.app-slava-restraint .result-card__dl-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ─── Styles button ──────────────────────────────────────────────────────── */

body.app-slava-restraint .create-composer__styles {
  background: var(--sr-glass-raised);
  border: 1px solid var(--sr-edge);
  border-radius: 10px;
  padding: 7px 12px;
  color: var(--sr-ink);
  font-size: 13px;
  cursor: pointer;
}
body.app-slava-restraint .create-composer__styles:hover { border-color: var(--sr-edge-strong); }

body.app-slava-restraint .create-composer__enhance {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--sr-glass-raised);
  border: 1px solid var(--sr-edge);
  border-radius: 10px;
  padding: 7px 12px;
  color: var(--sr-ink);
  font-size: 13px;
  cursor: pointer;
}
body.app-slava-restraint .create-composer__enhance:hover:not(:disabled) { border-color: var(--sr-edge-strong); }
body.app-slava-restraint .create-composer__enhance:disabled { opacity: 0.5; cursor: default; }
body.app-slava-restraint .create-composer__enhance-undo {
  background: none;
  border: none;
  color: var(--sr-accent);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
}
body.app-slava-restraint .create-composer__enhance-error {
  color: var(--sr-warning);
  font-size: 12px;
  align-self: center;
}

/* ─── Preset library popover ─────────────────────────────────────────────── */

body.app-slava-restraint .preset-library {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 48px));
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: var(--sr-glass-strong);
  border: 1px solid var(--sr-edge-strong);
  border-radius: 16px;
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  z-index: 60;
  overflow: hidden;
}
body.app-slava-restraint .preset-library__top { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--sr-edge); }
body.app-slava-restraint .preset-library__search { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--sr-ink-meta); }
body.app-slava-restraint .preset-library__search input { flex: 1; background: transparent; border: none; outline: none; color: var(--sr-ink); font-family: inherit; font-size: 13px; }
body.app-slava-restraint .preset-library__save { display: inline-flex; align-items: center; gap: 6px; background: var(--sr-glass-raised); border: 1px solid var(--sr-edge); border-radius: 9px; padding: 6px 10px; color: var(--sr-ink); font-size: 12px; cursor: pointer; }
body.app-slava-restraint .preset-library__cats { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--sr-edge); }
body.app-slava-restraint .preset-library__cat { background: transparent; border: 1px solid var(--sr-edge); border-radius: 999px; padding: 4px 11px; color: var(--sr-ink-meta); font-size: 12px; cursor: pointer; }
body.app-slava-restraint .preset-library__cat.is-active { border-color: var(--sr-accent); color: var(--sr-ink-bold); }
body.app-slava-restraint .preset-library__grid { overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
body.app-slava-restraint .preset-library__empty { grid-column: 1 / -1; text-align: center; color: var(--sr-ink-faint); padding: 28px 0; font-size: 13px; }

/* ─── Preset card ────────────────────────────────────────────────────────── */

body.app-slava-restraint .preset-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: 4 / 3;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--sr-edge);
  background: var(--sr-glass);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
}
body.app-slava-restraint .preset-card__gradient,
body.app-slava-restraint .preset-card__thumb {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
}
body.app-slava-restraint .preset-card__gradient {
  background: linear-gradient(150deg,
    hsl(var(--preset-hue, 20) 55% 22%) 0%,
    hsl(calc(var(--preset-hue, 20) + 40) 45% 12%) 100%);
}
body.app-slava-restraint .preset-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.6), transparent 60%); z-index: 1; }
body.app-slava-restraint .preset-card__name { position: relative; z-index: 2; color: #fff; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
body.app-slava-restraint .preset-card__category { position: relative; z-index: 2; color: rgba(255,255,255,0.7); font-size: 11px; }
body.app-slava-restraint .preset-card:hover { border-color: var(--sr-accent); }

/* ─── Lightbox (fullscreen viewer) ───────────────────────────────────────── */

body.app-slava-restraint.lightbox-open { overflow: hidden; }

body.app-slava-restraint .lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  animation: lightbox-fade 140ms ease-out;
}

@keyframes lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.app-slava-restraint .lightbox__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 92vh;
}

body.app-slava-restraint .lightbox__media {
  max-width: 92vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

body.app-slava-restraint .lightbox__close {
  position: absolute;
  top: 18px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
}

body.app-slava-restraint .lightbox__close:hover { background: rgba(255, 255, 255, 0.2); }

body.app-slava-restraint .lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
}

body.app-slava-restraint .lightbox__nav:hover { background: rgba(255, 255, 255, 0.2); }
body.app-slava-restraint .lightbox__nav--prev { left: 20px; }
body.app-slava-restraint .lightbox__nav--next { right: 20px; }

body.app-slava-restraint .lightbox__counter {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 12px;
  border-radius: 999px;
}
