/* Панель настройки искр / логотипа — только десктоп */
.spark-tune {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  right: auto;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  top: auto;
  z-index: 9500;
  width: min(320px, calc(100vw - 1.5rem));
  max-width: min(320px, calc(100vw - 1.5rem));
  max-height: min(82vh, 720px);
  height: auto;
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 22, 0.92);
  color: #e8eef4;
  border: 1px solid rgba(120, 200, 255, 0.28);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  font-size: 0.76rem;
  line-height: 1.3;
  overflow: hidden;
  min-height: 0;
}

.spark-tune__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.spark-tune__head strong {
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #9ad4ff;
  pointer-events: none;
}

.spark-tune__dev {
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-left: 0.35rem;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-size: 0.62rem;
  vertical-align: 0.05em;
}
.spark-tune[data-device="mobile"] .spark-tune__dev {
  color: #0c1218;
  background: #d4a845;
}
.spark-tune[data-device="web"] .spark-tune__dev {
  color: #0c1218;
  background: #9ad4ff;
}

.spark-tune.is-dragging {
  user-select: none;
}

.spark-tune.is-dragging .spark-tune__head {
  cursor: grabbing;
}

.spark-tune__min {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  touch-action: manipulation;
}

.spark-tune__pick {
  display: grid;
  gap: 0.25rem;
  padding: 0.45rem 0.7rem 0.15rem;
  flex-shrink: 0;
}
.spark-tune__pick > span {
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(154, 212, 255, 0.85);
}
.spark-tune__select {
  width: 100%;
  min-height: 2.15rem;
  border: 1px solid rgba(120, 200, 255, 0.35);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.95);
  color: #e8eef4;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
}
.spark-tune__select:focus {
  outline: 2px solid rgba(78, 184, 255, 0.55);
  outline-offset: 1px;
}
.spark-tune__select option {
  background: #121820;
  color: #e8eef4;
}

.spark-tune.is-min .spark-tune__pick {
  display: none;
}

.spark-tune__body {
  padding: 0.5rem 0.7rem 0.7rem;
  display: grid;
  gap: 0.42rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 200, 255, 0.45) rgba(255, 255, 255, 0.06);
}
.spark-tune__body::-webkit-scrollbar {
  width: 8px;
}
.spark-tune__body::-webkit-scrollbar-thumb {
  background: rgba(120, 200, 255, 0.4);
  border-radius: 8px;
}

.spark-tune.is-min .spark-tune__body {
  display: none;
}

.spark-tune__row {
  display: grid;
  gap: 0.18rem;
}

.spark-tune__row span {
  display: flex;
  justify-content: space-between;
  color: rgba(232, 238, 244, 0.78);
  font-size: 0.72rem;
}

.spark-tune__row b {
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.spark-tune__row input[type="range"] {
  width: 100%;
  accent-color: #4eb8ff;
  cursor: pointer;
  height: 1.1rem;
}

.spark-tune__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.15rem;
  position: sticky;
  bottom: 0;
  padding-top: 0.35rem;
  background: linear-gradient(180deg, transparent, rgba(12, 16, 22, 0.95) 30%);
}

.spark-tune__reset,
.spark-tune__ok {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  font-weight: 650;
  font-size: 0.8rem;
}

.spark-tune__reset {
  background: rgba(255, 255, 255, 0.06);
  color: #d5dde6;
}

.spark-tune__ok {
  background: #1a7fd4;
  border-color: #1a7fd4;
  color: #fff;
}

.spark-tune__ok:hover {
  background: #2b8fe6;
}

.spark-tune__hint {
  margin: 0;
  font-size: 0.65rem;
  color: rgba(200, 210, 220, 0.55);
  text-align: center;
}

.spark-tune__palettes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.spark-tune__swatch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.3rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(230, 236, 242, 0.9);
  font-size: 0.7rem;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}

.spark-tune__swatch:hover {
  border-color: rgba(120, 200, 255, 0.35);
}

.spark-tune__swatch.is-on {
  background: rgba(30, 120, 200, 0.4);
  border-color: rgba(120, 200, 255, 0.5);
  color: #fff;
}

.spark-tune__swatch-ico {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, #f6f3ee 50%, #b8882c 50%);
}

.spark-tune__swatch-ico[data-p="tseh"] { background: linear-gradient(135deg, #f6f3ee 50%, #b8882c 50%); }
.spark-tune__swatch-ico[data-p="stal"] { background: linear-gradient(135deg, #f1f3f5 50%, #6e8498 50%); }
.spark-tune__swatch-ico[data-p="lazer"] { background: linear-gradient(135deg, #152a55 50%, #1aa0b8 50%); }
.spark-tune__swatch-ico[data-p="okalina"] { background: linear-gradient(135deg, #3a2418 50%, #b86838 50%); }
.spark-tune__swatch-ico[data-p="sinka"] { background: linear-gradient(135deg, #0b3a6e 50%, #4a9ad4 50%); }
.spark-tune__swatch-ico[data-p="iskra"] { background: linear-gradient(135deg, #2a2218 50%, #d48a18 50%); }
.spark-tune__swatch-ico[data-p="nerzh"] { background: linear-gradient(135deg, #1a3a3c 50%, #3a9a94 50%); }
.spark-tune__swatch-ico[data-p="chugun"] { background: linear-gradient(135deg, #22201c 50%, #a89050 50%); }
.spark-tune__swatch-ico[data-p="grafit"] { background: linear-gradient(135deg, #2a2a2a 50%, #8a8a8a 50%); }
.spark-tune__swatch-ico[data-p="maslo"] { background: linear-gradient(135deg, #2a3220 50%, #a88828 50%); }
.spark-tune__swatch-ico[data-p="plazma"] { background: linear-gradient(135deg, #1a1040 50%, #c43aa8 50%); }
.spark-tune__swatch-ico[data-p="prokat"] { background: linear-gradient(135deg, #3a4450 50%, #8a96a4 50%); }
.spark-tune__swatch-ico[data-p="bronza"] { background: linear-gradient(135deg, #3a2a18 50%, #b87828 50%); }
.spark-tune__swatch-ico[data-p="titan"] { background: linear-gradient(135deg, #2a2838 50%, #8a7aa0 50%); }
.spark-tune__swatch-ico[data-p="azot"] { background: linear-gradient(135deg, #0e3a48 50%, #2a98b0 50%); }

/* Скрыто, пока нет data-spark-tune (гамма всегда; FX — только ?tune=1).
   Важно: flex, не block — иначе body не сжимается и не скроллится. */
.spark-tune {
  display: none !important;
}
html[data-spark-tune="1"] .spark-tune {
  display: flex !important;
  flex-direction: column;
}
.spark-tune--palette-only .spark-tune__dev {
  display: none;
}

@media (max-width: 760px) {
  html[data-spark-tune="1"] .spark-tune {
    left: 0.5rem;
    right: 0.5rem;
    bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px));
    top: auto;
    width: auto;
    max-height: min(58vh, 480px);
  }
  html[data-spark-tune="1"] .spark-tune.is-moved {
    /* после перетаскивания — координаты из JS */
    right: auto;
  }
}

/* подсветка фото, к которому перешли из списка спецэффектов */
[data-sparks].is-fx-focus,
.o2-brand.is-fx-focus,
.o2-hero.is-fx-focus {
  outline: 2px solid #d4a845 !important;
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(212, 168, 69, 0.28);
  transition: outline 0.2s ease, box-shadow 0.2s ease;
}
