:root {
  /* тёмная база как в Telegram, пепельно-розовые акценты */
  --bg:      var(--tg-theme-secondary-bg-color, #18222d);
  --card:    var(--tg-theme-bg-color, #212d3b);
  --card-2:  #1c2836;
  --line:    rgba(255,255,255,.07);
  --ink:     var(--tg-theme-text-color, #f4eef0);
  --mute:    var(--tg-theme-hint-color, #8b97a3);
  --pink:    #eccfd6;   /* пепельно-розовый акцент */
  --pink-2:  #d9b3bc;
  --btn:     #f2d9de;   /* большая нижняя кнопка */
  --btn-fg:  #2c2226;
  --ok:      #a8bf9a;
  --err:     #d99a90;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 14px 110px; }

/* ── заголовки секций ────────────────────────────────────────────── */
.section-label {
  color: var(--mute);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 18px 6px 8px;
}
.wrap > .section-label:first-child { margin-top: 4px; }

/* ── кнопка загрузки фото ────────────────────────────────────────── */
.attach-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: 14px;
  padding: 15px 18px;
  color: var(--pink);
  font-size: 17px;
  cursor: pointer;
  user-select: none;
}
.attach-btn:active { filter: brightness(1.15); }
.clip { width: 24px; height: 24px; flex: none; }

.gate-hint { color: var(--mute); font-size: 15px; margin: 12px 8px; }

/* ── превью: SVG-шаблон ThemePreviewBot ──────────────────────────── */
.preview-stage { margin: 18px 0 8px; }
.preview-stage svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 6px 26px rgba(0,0,0,.4);
}

/* ── карточки ─────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 6px;
}
.card-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.palette-ico {
  width: 44px; height: 44px; border-radius: 11px;
  background: var(--card-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex: none;
}
.card-title { font-size: 17px; font-weight: 600; }
.card-sub { color: var(--mute); font-size: 14px; margin-top: 2px; }

.row-btn {
  display: block; width: 100%; text-align: left;
  background: none; border: none;
  border-bottom: 1px solid var(--line);
  color: var(--pink);
  font-size: 17px; font-family: inherit;
  padding: 15px 16px;
  cursor: pointer;
}
.row-btn.last { border-bottom: none; }
.row-btn:active { background: rgba(255,255,255,.04); }

/* ── radio-строки ─────────────────────────────────────────────────── */
.radios .radio-row {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  cursor: pointer;
}
.radios .radio-row.last { border-bottom: none; }
.radio-row input { display: none; }
.rdot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--mute);
  flex: none;
  position: relative;
}
.radio-row input:checked + .rdot,
.preset-row input:checked + .rdot { border-color: var(--pink); }
.radio-row input:checked + .rdot::after,
.preset-row input:checked + .rdot::after {
  content: ''; position: absolute; inset: 3px;
  border-radius: 50%; background: var(--pink-2);
}

/* ── слайдер прозрачности ────────────────────────────────────────── */
.slider-card { padding: 18px 16px 12px; }
.ticks {
  display: flex; justify-content: space-between;
  height: 14px; margin: 0 9px -14px;
  pointer-events: none;
}
.ticks span { width: 2px; height: 14px; background: var(--pink-2); opacity: .65; border-radius: 1px; }
input[type=range] {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: transparent; height: 30px; position: relative; z-index: 1;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: var(--pink-2);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: #ffffff; margin-top: -11px;
  box-shadow: 0 1px 5px rgba(0,0,0,.45);
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--pink-2); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border: none; border-radius: 50%; background: #fff; }
.slider-value { color: var(--mute); font-size: 15px; margin-top: 8px; }
.hint { color: var(--mute); font-size: 13px; margin-top: 8px; }

/* ── нижняя кнопка ───────────────────────────────────────────────── */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  z-index: 40;
}
.create-btn {
  display: block; width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--btn); color: var(--btn-fg);
  border: none; border-radius: 15px;
  font-size: 19px; font-weight: 600; font-family: inherit;
  padding: 15px;
  cursor: pointer;
}
.create-btn:disabled { opacity: .55; }
.create-btn:active { filter: brightness(.95); }

.status { min-height: 22px; font-size: 15px; margin: 10px 6px 0; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.footer-note { color: var(--mute); font-size: 12px; text-align: center; margin-top: 14px; opacity: .7; }

/* ── шторка выбора цвета ─────────────────────────────────────────── */
.sheet-dim {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--card-2);
  border-radius: 18px 18px 0 0;
  padding: 14px 14px calc(90px + env(safe-area-inset-bottom));
  max-height: 78vh; overflow-y: auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet .section-label { margin-top: 2px; }

.preset-row {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  cursor: pointer;
}
.preset-row:last-child { border-bottom: none; }
.preset-name { flex: 1; }
.preset-chip { width: 30px; height: 30px; border-radius: 50%; flex: none; border: 1px solid rgba(255,255,255,.12); }
.custom-wheel {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  padding: 0; border: none; background: none; cursor: pointer;
  position: relative; overflow: hidden;
}
.custom-wheel::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}
.custom-wheel::after {
  content: ''; position: absolute; inset: 5px; border-radius: 50%;
  background: var(--custom-color, #EFEFF4);
}
.custom-wheel input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── чипсы палитр ────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 2px 2px; }
.chip {
  background: var(--card); color: var(--pink);
  border: 1px solid rgba(236,207,214,.25); border-radius: 999px;
  font-family: inherit; font-size: 14px;
  padding: 8px 15px; cursor: pointer;
}
.chip:active { background: rgba(236,207,214,.12); }

/* чекбоксы устройств */
.cbox { border-radius: 7px; }
.radio-row input:checked + .cbox::after { border-radius: 4px; }

/* панель «готово» */
.done-panel {
  background: var(--card); border-radius: 14px;
  padding: 18px 16px; margin-top: 12px; text-align: center;
}
.done-title { font-size: 19px; font-weight: 600; color: var(--pink); }
.done-sub { color: var(--mute); font-size: 14px; margin: 6px 0 12px; }

/* публикация в каталог с экрана «готово» */
.pub-inline { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.cat-input {
  background: var(--card-2); border: none; border-radius: 10px;
  color: var(--ink); font-size: 15px; font-family: inherit;
  padding: 11px 14px; outline: none; appearance: none;
}
.cat-input::placeholder { color: var(--mute); }
.pub-inline .chip { align-self: center; }

/* история генераций */
.hist-row { display: flex; align-items: center; gap: 8px; padding: 13px 6px;
  border-bottom: 1px solid var(--line); cursor: pointer; }
.hist-dot { width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1px solid rgba(255,255,255,.15); }
.hist-date { flex: 1; color: var(--mute); font-size: 14px; margin-left: 6px; }
.hist-apply { color: var(--pink); font-size: 14px; }
