/* ==================================================================
   Kawaii Pastel Goth Linktree — кастомизируемый
   Цвета управляются через CSS-переменные (меняются из редактора)
   ================================================================== */

:root {
  --accent:  #c77dff;
  --accent2: #ff5fa2;
  --accent3: #7ee8fa;
  --overlay: 0.55;
  --bg-image: none;

  --ink: #f3eaff;
  --ink-dim: #b9a8d8;
  --card-glass: rgba(20, 12, 34, 0.55);
  --card-border: rgba(255, 255, 255, 0.14);
  --radius: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  font-family: "Baloo 2", "Comic Neue", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #120a1e;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Фон ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  transition: background-image 0.4s ease;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(18,10,30,var(--overlay)), rgba(18,10,30,calc(var(--overlay) + 0.15))),
    radial-gradient(700px circle at 50% -5%, rgba(199,125,255,0.25), transparent 60%);
}
/* Плейсхолдер-фон, пока картинка не сгенерирована */
.bg.empty {
  background:
    radial-gradient(600px circle at 20% 10%, rgba(199,125,255,0.35), transparent 55%),
    radial-gradient(600px circle at 85% 25%, rgba(255,95,162,0.30), transparent 55%),
    radial-gradient(700px circle at 50% 100%, rgba(126,232,250,0.20), transparent 55%),
    #160c26;
}

/* ---------- Контейнер ---------- */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 18px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------- Аватар ---------- */
.avatar-wrap { position: relative; width: 118px; height: 118px; margin-bottom: 14px; }
.avatar-ring {
  position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent2), var(--accent3), var(--accent));
  animation: spin 7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.avatar {
  position: absolute; inset: 0; width: 118px; height: 118px;
  border-radius: 50%; object-fit: cover; object-position: center 20%;
  border: 4px solid #160c26; background: #241536;
}
.vibe-badge {
  position: absolute; right: -6px; bottom: 6px;
  background: linear-gradient(120deg, var(--accent2), var(--accent));
  color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 20px; border: 2px solid #160c26;
  box-shadow: 0 0 14px var(--accent2);
}

/* ---------- Имя ---------- */
.name {
  font-size: 34px; font-weight: 800; letter-spacing: .5px; line-height: 1.1;
  background: linear-gradient(120deg, var(--accent3), var(--accent2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(199,125,255,.55));
  margin-bottom: 2px;
}
.handle { font-size: 13px; font-weight: 700; color: var(--accent2); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 14px; }

/* ---------- Welcome ---------- */
.welcome {
  display: inline-block; padding: 9px 20px; border-radius: 30px;
  background: var(--card-glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border); font-size: 14px; font-weight: 600;
  margin-bottom: 16px; box-shadow: 0 0 20px rgba(199,125,255,.2);
}

/* ---------- Теги ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.tag {
  font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 20px;
  background: rgba(255,255,255,.06); border: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
}

/* ---------- Статистика ---------- */
.stats { display: flex; gap: 10px; margin-bottom: 22px; }
.stat {
  min-width: 78px; padding: 10px 14px; border-radius: 16px;
  background: var(--card-glass); border: 1px solid var(--card-border); backdrop-filter: blur(10px);
}
.stat b { display: block; font-size: 19px; font-weight: 800; color: var(--accent3); }
.stat span { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--ink-dim); text-transform: uppercase; }

/* ---------- Общая ширина контента ---------- */
.col { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- VIP ---------- */
.vip {
  display: block; text-decoration: none; color: var(--ink);
  padding: 16px; border-radius: var(--radius); font-size: 16px; font-weight: 800;
  background: linear-gradient(120deg, rgba(199,125,255,.28), rgba(255,95,162,.18));
  border: 1px solid rgba(199,125,255,.5); backdrop-filter: blur(12px);
  box-shadow: 0 0 24px rgba(199,125,255,.35), inset 0 0 30px rgba(255,95,162,.1);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.vip:hover { transform: translateY(-3px); box-shadow: 0 0 36px rgba(199,125,255,.6); }

/* ---------- Карточки-офферы 2x2 ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  --c: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 92px; padding: 16px; border-radius: var(--radius);
  text-decoration: none; color: #1a0f2e; font-weight: 800; font-size: 15px;
  background: var(--c); border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.4);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), filter .3s var(--ease);
}
.card:hover { transform: translateY(-4px) rotate(-1deg); filter: brightness(1.05); box-shadow: 0 14px 34px rgba(0,0,0,.45); }
.card .c-icon { display: grid; place-items: center; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.card.c3 { color: #2a1840; } /* белая карточка — тёмный текст */

/* Иконки в тегах / заголовках / VIP / дневнике */
.tag { display: inline-flex; align-items: center; gap: 5px; }
.tag svg { display: block; }
.h-ico { display: inline-grid; place-items: center; color: var(--accent2); vertical-align: middle; }
.vip-ico { display: inline-grid; place-items: center; color: var(--accent2); }
.vip { display: flex; align-items: center; justify-content: center; gap: 10px; }
.d-ico { display: inline-grid; place-items: center; color: var(--accent2); flex-shrink: 0; }

/* ---------- Соцсети (обычные кнопки) ---------- */
.social {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px; border-radius: var(--radius);
  text-decoration: none; color: var(--ink); font-weight: 700; font-size: 15px;
  background: var(--card-glass); border: 1px solid var(--card-border); backdrop-filter: blur(12px);
  transition: transform .3s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.social:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 26px rgba(0,0,0,.4), 0 0 0 1px var(--accent) inset; }
.social .icon { width: 22px; height: 22px; display: grid; place-items: center; flex-shrink: 0; color: var(--accent2); }
.social .icon svg { width: 22px; height: 22px; }
.social .label { flex: 1; text-align: left; }
.social .arrow { opacity: .4; transition: transform .3s var(--ease), opacity .3s var(--ease); }
.social:hover .arrow { opacity: 1; transform: translateX(3px); }

/* ---------- Нижний ряд: Diary + Gallery ---------- */
.bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .bottom { grid-template-columns: 1fr; } }

.panel {
  padding: 18px; border-radius: var(--radius); text-align: left;
  background: var(--card-glass); border: 1px solid var(--card-border); backdrop-filter: blur(12px);
}
.panel h3 { font-size: 17px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }

.diary-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed rgba(255,255,255,.1); font-size: 13.5px; }
.diary-row:last-child { border-bottom: none; }
.diary-row b { color: var(--accent2); font-weight: 800; }
.online { margin-top: 12px; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: #7dffa8; }
.online .dot { width: 9px; height: 9px; border-radius: 50%; background: #4dff88; box-shadow: 0 0 8px #4dff88; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.gallery-img { position: relative; width: 100%; border-radius: 14px; overflow: hidden; aspect-ratio: 3/4; background: #241536; }
.gallery-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-badge { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: #fff; color: #1a0f2e; font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 20px; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.3); }

/* ---------- Появление ---------- */
.reveal { opacity: 0; transform: translateY(16px); animation: reveal .6s var(--ease) forwards; }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* ==================================================================
   РЕДАКТОР
   ================================================================== */
.edit-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff; font-size: 24px; display: none; place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 0 20px var(--accent);
  transition: transform .3s var(--ease);
}
.edit-fab.show { display: grid; }
.edit-fab:hover { transform: scale(1.08) rotate(20deg); }

.editor {
  position: fixed; top: 0; right: 0; z-index: 60; height: 100dvh; width: min(400px, 92vw);
  background: #160c26; border-left: 1px solid var(--card-border);
  box-shadow: -20px 0 60px rgba(0,0,0,.6);
  transform: translateX(105%); transition: transform .4s var(--ease);
  display: flex; flex-direction: column;
}
.editor.open { transform: translateX(0); }
.editor-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--card-border); }
.editor-head h2 { font-size: 17px; font-weight: 800; }
.editor-close { background: none; border: none; color: var(--ink); font-size: 24px; cursor: pointer; line-height: 1; }
.editor-body { padding: 14px 18px 30px; overflow-y: auto; flex: 1; }

.ed-group { margin-bottom: 18px; border: 1px solid var(--card-border); border-radius: 14px; overflow: hidden; }
.ed-group > summary { list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 800; font-size: 14px; background: rgba(255,255,255,.04); display: flex; justify-content: space-between; align-items: center; }
.ed-group > summary::-webkit-details-marker { display: none; }
.ed-group[open] > summary { border-bottom: 1px solid var(--card-border); }
.ed-group .ed-inner { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.ed-field { display: flex; flex-direction: column; gap: 4px; }
.ed-field label { font-size: 11px; font-weight: 700; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .5px; }
.ed-field input[type=text], .ed-field input[type=url], .ed-field textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; font-size: 13px; font-family: inherit;
  background: rgba(255,255,255,.06); border: 1px solid var(--card-border); color: var(--ink); outline: none;
}
.ed-field input:focus, .ed-field textarea:focus { border-color: var(--accent); }
.ed-field textarea { resize: vertical; min-height: 54px; }
.ed-row { display: flex; gap: 8px; }
.ed-row .ed-field { flex: 1; }
.ed-color { display: flex; align-items: center; gap: 8px; }
.ed-color input[type=color] { width: 40px; height: 34px; border: none; border-radius: 8px; background: none; cursor: pointer; padding: 0; }

.ed-item { padding: 10px; border: 1px dashed var(--card-border); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.ed-item .ed-del { position: absolute; top: 6px; right: 6px; background: rgba(255,95,162,.2); border: none; color: var(--accent2); border-radius: 6px; width: 22px; height: 22px; cursor: pointer; font-weight: 800; }
.ed-add { padding: 8px; border-radius: 10px; border: 1px dashed var(--accent); background: rgba(199,125,255,.12); color: var(--ink); font-weight: 700; font-size: 12.5px; cursor: pointer; }

/* Выбор иконки */
.icon-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.ico-btn {
  aspect-ratio: 1; display: grid; place-items: center; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--card-border); color: var(--ink-dim);
  background: rgba(255,255,255,.04); transition: all .2s var(--ease);
}
.ico-btn:hover { color: var(--ink); border-color: var(--accent); }
.ico-btn.active { color: #160c26; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* Статистика кликов */
.stat-total { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.stat-total b { color: var(--accent3); }
.stat-row { position: relative; display: flex; align-items: center; gap: 8px; padding: 9px 11px; margin-bottom: 5px; border-radius: 9px; background: rgba(255,255,255,.04); overflow: hidden; font-size: 13px; }
.stat-bar { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, rgba(199,125,255,.30), rgba(255,95,162,.12)); z-index: 0; transition: width .4s var(--ease); }
.stat-label { position: relative; z-index: 1; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-num { position: relative; z-index: 1; color: var(--accent3); font-weight: 800; }

.btn {
  padding: 10px 12px; border-radius: 10px; border: none; cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff;
}
.btn.ghost { background: rgba(255,255,255,.06); border: 1px solid var(--card-border); color: var(--ink); }
.btn.full { width: 100%; }
.bg-preview { width: 100%; aspect-ratio: 16/10; border-radius: 10px; background-size: cover; background-position: center; border: 1px solid var(--card-border); background-color: #241536; display: grid; place-items: center; font-size: 12px; color: var(--ink-dim); }
.hint { font-size: 11px; color: var(--ink-dim); line-height: 1.4; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .avatar-ring { animation: none; }
  .reveal { animation: none; opacity: 1; transform: none; }
  * { transition: none !important; }
}
