/* ============================================================
   ХОЧУ ПРИГЛАСИТЬ — конструктор приглашения
   Слева правки, справа то, что увидит гость.
   ============================================================ */

.ed {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 72px);
}

/* ---------- Левая панель ---------- */
.ed__rail {
  border-right: 1px solid var(--hairline-2);
  padding: var(--s-5) var(--s-5) var(--s-9);
  display: grid; gap: var(--s-3); align-content: start;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.ed__rail::-webkit-scrollbar { width: 12px; }
.ed__rail::-webkit-scrollbar-track { background: transparent; }
.ed__rail::-webkit-scrollbar-thumb {
  background: rgba(22,33,31,.20);
  border: 4px solid transparent; background-clip: content-box;
  border-radius: 99px;
}
.ed__rail::-webkit-scrollbar-thumb:hover { background: rgba(22,33,31,.36); background-clip: content-box; }

.ed__intro { display: grid; gap: var(--s-2); padding-bottom: var(--s-3); }

/* Полоса выбора шаблона */
.ed__templates {
  display: flex; gap: 10px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 10px;
  min-height: 124px;          /* лицо 87 + подпись: строка грида иначе схлопывается */
  scroll-snap-type: x mandatory;
}
.ed__templates::-webkit-scrollbar { height: 6px; }
.ed__templates::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 6px; }
.ed-tpl {
  flex: 0 0 auto; width: 62px; scroll-snap-align: start;
  border: 0; padding: 0; background: none; cursor: pointer;
  text-align: center; display: block;
}
.ed-tpl__face {
  display: block; width: 62px; height: 87px; line-height: 87px;
  border-radius: 2px;
  background: var(--t-bg); color: var(--t-fg);
  font-family: var(--t-face, serif); font-size: .62rem;
  box-shadow: 0 2px 8px rgba(22,33,31,0.13);
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color 180ms linear, transform 220ms var(--ease-paper);
}
.ed-tpl:hover .ed-tpl__face { transform: translateY(-3px); }
.ed-tpl.is-on .ed-tpl__face { outline-color: var(--brass); }
.ed-tpl__label {
  display: block; margin-top: 6px;
  font-size: .6rem; line-height: 1.2; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Раскрывающийся раздел */
.ed-group { border-top: 1px solid var(--hairline-2); }
.ed-group summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 0; cursor: pointer; list-style: none;
  font-family: var(--face-display); font-weight: 400; font-size: .96rem; letter-spacing: -.01em;
}
.ed-group summary::-webkit-details-marker { display: none; }
.ed-group__sign { position: relative; width: 16px; height: 16px; flex: none; }
.ed-group__sign::before, .ed-group__sign::after {
  content: ""; position: absolute; inset: 50% 0 auto 0; height: 1px; background: var(--ink-soft);
  transition: transform var(--t-mid) var(--ease-paper);
}
.ed-group__sign::after { transform: rotate(90deg); }
.ed-group[open] .ed-group__sign::after { transform: rotate(0deg); }
.ed-group__body { display: grid; gap: var(--s-4); padding: 4px 0 22px; }

.ed-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.ed-hint { font-size: .76rem; color: var(--ink-soft); line-height: 1.45; }

/* Палитры */
.ed-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-sw {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(22,33,31,.16);
  position: relative;
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color 180ms linear, transform 180ms var(--ease-paper);
}
.ed-sw:hover { transform: scale(1.06); }
.ed-sw.is-on { outline-color: var(--brass); }
.ed-sw.is-locked::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: rgba(255,253,248,.72);
  box-shadow: inset 0 0 0 1px var(--brass-deep);
}
.ed-sw.is-locked::before {
  content: "₽"; position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center;
  color: var(--brass); font-size: .8rem; font-weight: 600;
}

/* Кнопки-переключатели */
.ed-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-seg button {
  border: 1px solid var(--hairline); background: transparent; color: rgba(22,33,31,.75);
  border-radius: 999px; padding: 7px 14px; font-size: .8rem; cursor: pointer;
  transition: all 160ms linear;
}
.ed-seg button:hover { border-color: var(--ink-soft); color: var(--ink); }
.ed-seg button.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper-2); font-weight: 500; }
.ed-seg button.is-locked { color: var(--brass-deep); border-color: rgba(154,123,46,.4); }

/* Список строк (программа, вопросы, фото) */
.ed-list { display: grid; gap: 8px; }
.ed-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start;
  padding: 10px; border: 1px solid var(--hairline-2); border-radius: 8px;
  background: var(--paper-2);
}
.ed-item__fields { display: grid; gap: 6px; }
.ed-del {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  border: 1px solid var(--hairline-2); background: transparent; color: var(--ink-soft);
  cursor: pointer; display: grid; place-items: center;
}
.ed-del:hover { border-color: var(--wax-hi); color: var(--wax-hi); }
.ed-add {
  border: 1px dashed var(--hairline); background: transparent; color: var(--ink-soft);
  border-radius: 8px; padding: 11px; cursor: pointer; font-size: .84rem;
  transition: all 160ms linear;
}
.ed-add:hover { border-color: var(--ink-soft); color: var(--ink); }

/* Переключатели блоков */
.ed-toggles { display: grid; gap: 2px; }
.ed-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--hairline-2);
  font-size: .9rem; cursor: pointer;
}
.ed-toggle:last-child { border-bottom: 0; }
.ed-switch {
  width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: rgba(22,33,31,.14); position: relative; transition: background-color 200ms linear;
}
.ed-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--ink-soft);
  transition: transform 220ms var(--ease-snap), background-color 200ms linear;
}
.ed-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ed-toggle input:checked + .ed-switch { background: rgba(94,138,80,.30); }
.ed-toggle input:checked + .ed-switch::after { transform: translateX(18px); background: var(--stem); }
.ed-toggle input:focus-visible + .ed-switch { outline: 2px solid var(--wax); outline-offset: 2px; }

/* ---------- Правая часть: предпросмотр ---------- */
.ed__preview {
  position: sticky; top: 72px;
  height: calc(100vh - 72px);
  display: grid; grid-template-rows: auto 1fr;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(154,123,46,.05), transparent 60%),
    var(--paper-deep);
}
.pv__bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: 12px var(--s-5);
  border-bottom: 1px solid var(--hairline-2);
}
.pv__frame-wrap {
  overflow: auto; padding: var(--s-5);
  display: grid; place-items: start center;
}
.pv__frame {
  position: relative;
  width: 100%; max-width: 720px;
  background: var(--card);
  border-radius: 4px;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(22,33,31,0.18);
  transition: max-width 320ms var(--ease-paper), border-radius 320ms linear;
}
.pv__frame.is-phone {
  max-width: 390px;
  height: min(760px, calc(100vh - 190px));
  border-radius: 22px;
}

/* Полоса прокрутки внутри предпросмотра — своя: тонкая, скруглённая и
   отодвинутая от края «экрана» прозрачной рамкой, чтобы не липла к рамке
   телефона и не спорила с бумагой приглашения. */
.pv__frame {
  scrollbar-width: thin;
  scrollbar-color: rgba(22,33,31,.26) transparent;
}
.pv__frame::-webkit-scrollbar { width: 12px; }
.pv__frame::-webkit-scrollbar-track { background: transparent; }
.pv__frame::-webkit-scrollbar-thumb {
  background: rgba(22,33,31,.22);
  border: 4px solid transparent;   /* и есть тот самый отступ от края */
  background-clip: content-box;
  border-radius: 99px;
  transition: background-color 160ms linear;
}
.pv__frame::-webkit-scrollbar-thumb:hover {
  background: rgba(22,33,31,.42);
  background-clip: content-box;
}

/* Внутри рамки перекрытия должны быть локальными, а не на весь экран */
.pv__frame .inv-cover,
.pv__frame .inv-music { position: absolute; }
.pv__frame .invite { min-height: 100%; }

/* ---------- Адаптив ---------- */
@media (max-width: 1080px) {
  .ed { grid-template-columns: 1fr; }
  .ed__rail { max-height: none; overflow: visible; border-right: 0; order: 2; }
  .ed__preview {
    position: static; height: auto; order: 1;
    border-bottom: 1px solid var(--hairline-2);
  }
  .pv__frame.is-phone { height: 620px; }
}
