/* ===== Wallpaper Studio (/wallpaper-studio) =====
   Только эта страница. palette-legacy.css сюда не подключается (план, раздел 2),
   поэтому кнопки и ползунки повторены здесь в том же виде, что на
   /gradient-creator: те же размеры, скругления и цвета. */

.ws-page {
  --ws-line: #e8e8e8;
  --ws-ink: #111827;
  --ws-muted: #667085;
  --ws-soft: #8b95a7;
  --ws-accent: #45c463;
  padding-bottom: 64px;
}

/* Атрибут hidden должен прятать и то, у чего свой display (карточки, строки). */
.ws-page [hidden] {
  display: none !important;
}

.ws-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.ws-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ----- Верхняя панель ----- */

.ws-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px 28px;
  flex-wrap: wrap;
  padding: 24px 0 18px;
}

.ws-topbar__group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.ws-topbar__group--end {
  margin-left: auto;
}

.ws-find {
  width: 200px;
  height: 46px;
  padding: 0 24px;
  border-radius: 14px;
  border: 1px solid var(--ws-line);
  background: #ffffff;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.ws-find:hover {
  color: #ffffff;
  border-color: transparent;
  background-image: linear-gradient(to right,
    #FF8C00 0 16.65%, #FF5B2E 16.65% 33.3%, #FF2F86 33.3% 49.95%,
    #9B42FF 49.95% 66.6%, #2563EB 66.6% 83.25%, #16C7E8 83.25% 100%);
  background-size: 260px 100%;
  animation: wsFindDance 2s linear infinite;
  transform: scale(1.04) translateY(-1px);
}

.ws-find:hover .ws-find__icon {
  filter: brightness(0) invert(1);
}

.ws-find:active {
  transform: scale(0.96);
}

.ws-find__icon {
  width: 17px;
  height: 17px;
  display: block;
}

@keyframes wsFindDance {
  to { background-position: 260px 0; }
}

.ws-space-hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #777777;
  font-size: 13px;
  font-weight: 600;
}

.ws-space-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  background: #fafafa;
  border: 1px solid var(--ws-line);
  color: #666666;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* Выбор размера — тот же вид, что на /gradient-creator (.gradient-size* в
   gradient-legacy.css): значок формы, группа и пиксели на кнопке, список
   с подзаголовками групп, выбранный пункт тёмный. */
.ws-size {
  position: relative;
}

.ws-size__btn {
  height: 46px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--ws-line);
  background: #ffffff;
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.ws-size__btn:hover {
  background: #fafafa;
  transform: translateY(-2px);
}

.ws-size__btn[aria-expanded="true"] {
  border-color: #d5d5d5;
  transform: none;
}

/* Значок формы: скрипт задаёт ширину и высоту по пропорции размера. */
.ws-size__shape {
  flex: 0 0 auto;
  width: 18px;
  height: 12px;
  border: 1.6px solid currentColor;
  border-radius: 3px;
  opacity: 0.5;
}

.ws-size__dims {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: #8a8a8a;
}

.ws-size__caret {
  flex: 0 0 auto;
  opacity: 0.5;
}

.ws-size__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 90;
  min-width: 272px;
  max-height: 72vh;
  overflow: auto;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid #ececec;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.ws-size__group {
  padding: 10px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a0a0a0;
}

.ws-size__item {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-align: left;
  cursor: pointer;
}

.ws-size__item:hover {
  background: #f6f6f6;
}

.ws-size__item.is-active {
  background: #111111;
  color: #ffffff;
}

.ws-size__item-dims {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: #8a8a8a;
}

.ws-size__item.is-active .ws-size__item-dims {
  color: rgba(255, 255, 255, 0.72);
}

.ws-custom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ws-custom__input {
  width: 92px;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--ws-line);
  border-radius: 14px;
  color: #1a1a1a;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ws-custom__x {
  color: var(--ws-muted);
  font-weight: 700;
}

.ws-history {
  display: inline-flex;
  gap: 8px;
}

.ws-icon-btn {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--ws-line);
  border-radius: 14px;
  background: #ffffff;
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ws-icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ws-icon-btn:hover:not(:disabled) {
  background: #fafafa;
}

.ws-icon-btn:disabled {
  color: #c4c9d2;
  cursor: default;
}

.ws-btn {
  height: 46px;
  padding: 0 22px;
  border-radius: 14px;
  border: 1px solid var(--ws-line);
  background: #ffffff;
  color: #1a1a1a;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  min-width: 150px;
  transition: background 0.25s ease, transform 0.25s ease;
}

.ws-btn:hover:not(:disabled) {
  background: #fafafa;
  transform: translateY(-2px);
}

.ws-btn:disabled {
  cursor: progress;
  color: #98a2b3;
}

/* ----- Сцена -----
   Форма сцены = форма выбранного размера файла (--ws-ar ставит скрипт).
   Высота ограничена, ширина считается по пропорции и не шире страницы. */

.ws-stage-wrap {
  --ws-ar: 1.7778;
  --ws-max-h: min(64vh, 780px);
}

.ws-stage-wrap.is-portrait {
  --ws-max-h: min(78vh, 900px);
}

.ws-stage {
  position: relative;
  width: min(100%, calc(var(--ws-max-h) * var(--ws-ar)));
  aspect-ratio: var(--ws-ar);
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0b10;
}

.ws-stage__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ws-stage__message {
  position: absolute;
  inset: auto 16px 16px 16px;
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ws-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

/* ----- Стили: карточки с настоящими превью ----- */

.ws-styles {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.ws-style {
  display: grid;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.ws-style__img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  background: #15151c center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ws-style:hover .ws-style__img {
  transform: translateY(-2px);
}

.ws-style.is-active .ws-style__img {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #111827;
}

.ws-style.is-active {
  color: var(--ws-ink);
}

.ws-style__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Карточки настроек ----- */

.ws-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 32px 44px;
  margin-top: 32px;
}

.ws-card {
  min-width: 0;
  display: grid;
  align-content: start;
  row-gap: 18px;
}

.ws-card__header {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ws-card__title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ws-ink);
}

/* Палитры: полоска цвета и название под ней */
.ws-palettes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.ws-palette {
  display: grid;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ws-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.ws-palette__bar {
  display: block;
  height: 30px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.ws-palette.is-active .ws-palette__bar {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #111827;
}

.ws-palette.is-active {
  color: var(--ws-ink);
}

/* Переключатель */
.ws-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.ws-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.ws-switch__track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #d0d5dd;
  transition: background 0.2s ease;
}

.ws-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
  transition: transform 0.2s ease;
}

.ws-switch input:checked + .ws-switch__track {
  background: var(--ws-accent);
}

.ws-switch input:checked + .ws-switch__track::after {
  transform: translateX(18px);
}

.ws-switch input:focus-visible + .ws-switch__track {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Ползунки */
.ws-sliders {
  display: grid;
  gap: 18px;
}

.ws-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 16px;
}

.ws-row__label {
  color: #344054;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.ws-row__value {
  color: var(--ws-muted);
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ws-range {
  width: 100%;
  height: 6px;
  margin: 0;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: #f1f1f1;
  cursor: pointer;
}

.ws-range::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--ws-accent);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18);
  -webkit-appearance: none;
  appearance: none;
}

.ws-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--ws-accent);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18);
}

.ws-adjust-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.ws-adjust-row__item {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.ws-seg button {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: #fafafa;
  color: #3f4654;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.ws-seg button:hover {
  background: #f4f5f7;
}

.ws-seg button.is-active {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #e3e3e3;
  color: var(--ws-ink);
}

/* Frosted Glass: ряды кнопок Shape и Glass — подпись слева, как у ползунков */
.ws-options {
  display: grid;
  gap: 12px;
}

.ws-option {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

/* Свои цвета фигур и фона: кружок с выбором цвета и кнопка Auto */
.ws-own-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
}

.ws-color {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ws-color__label {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.ws-color__swatch {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.ws-color__swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.ws-color__chip {
  display: block;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.ws-color__swatch:focus-within {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.ws-color__auto {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #fafafa;
  color: #3f4654;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ws-color__auto:hover {
  background: #f4f5f7;
}

.ws-color__auto.is-active {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #e3e3e3;
  color: var(--ws-ink);
}

/* ----- Узкие экраны ----- */

@media (max-width: 1100px) {
  .ws-styles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .ws-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 640px) {
  .ws-wrap {
    padding: 0 16px;
  }

  .ws-topbar {
    padding-top: 12px;
  }

  .ws-space-hint {
    display: none;
  }

  .ws-find {
    width: auto;
    flex: 1 1 auto;
    font-size: 18px;
  }

  .ws-topbar__group,
  .ws-topbar__group--end {
    width: 100%;
    margin-left: 0;
  }

  .ws-size {
    flex: 1 1 auto;
  }

  .ws-size__btn {
    width: 100%;
    justify-content: center;
  }

  .ws-size__menu {
    left: 50%;
    transform: translateX(-50%);
  }

  .ws-custom {
    flex: 1 1 100%;
  }

  .ws-custom__field,
  .ws-custom__input {
    flex: 1 1 0;
    width: 100%;
  }

  .ws-history {
    flex: 0 0 auto;
  }

  .ws-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 12px;
  }

  .ws-stage-wrap,
  .ws-stage-wrap.is-portrait {
    --ws-max-h: 70vh;
  }

  /* Стили — лента с прокруткой вбок, чтобы не занимать полэкрана. */
  .ws-styles {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
  }

  .ws-style {
    flex: 0 0 132px;
    scroll-snap-align: start;
  }

  .ws-row {
    grid-template-columns: 64px minmax(0, 1fr) 44px;
    gap: 12px;
  }
}

/* ----- Line Loops: карточка Shape и рамка выделенной фигуры ----- */

.ws-mini {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ws-line);
  border-radius: 10px;
  background: #ffffff;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ws-mini:hover:not(:disabled) {
  background: #fafafa;
}

.ws-mini:disabled {
  opacity: 0.4;
  cursor: default;
}

.ws-lines-hint {
  margin: 4px 0 0;
  color: var(--ws-muted);
  font-size: 14px;
}

.ws-lines-sub {
  margin: 0 0 -6px;
  color: var(--ws-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ws-lines-edit {
  display: grid;
  gap: 18px;
}

.ws-lines-edit[hidden] {
  display: none;
}

.ws-lines-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.ws-lines-chip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.ws-lines-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ws-lines-overlay__under {
  fill: none;
  stroke: rgba(0, 0, 0, 0.45);
  stroke-width: 3;
}

.ws-lines-overlay__line {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}

/* Пока фигура выделена, палец по превью двигает её, а не листает страницу. */
.ws-stage.is-editing {
  touch-action: none;
}

/* ----- Липкое превью -----
   Когда сцена ушла за верх экрана, сверху закрепляется её копия: настройки
   видны вместе с картинкой. Ширина — по пропорции кадра, не шире страницы.
   Так же устроено на /pattern-studio (.ps-peek). */

.ws-peek {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 8px 16px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ws-peek.is-visible {
  opacity: 1;
  transform: none;
}

.ws-peek__art {
  display: block;
  height: var(--ws-peek-h, min(30vh, 260px));
  width: auto;
  max-width: 100%;
  aspect-ratio: var(--ws-ar, 1.7778);
  border-radius: 10px;
  background: #0b0b0d;
}

@media (max-width: 640px) {
  .ws-peek__art {
    --ws-peek-h: 24vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ws-peek { transition: none; }
  .ws-find:hover { animation: none; }
  .ws-find, .ws-btn, .ws-size__btn, .ws-style__img, .ws-switch__track, .ws-switch__track::after { transition: none; }
}
