:root {
  --bg: #100d18;        /* тёмный с лёгким фиолетовым подтоном */
  --card: #1c1826;      /* карточки — тёмно-фиолетово-серые */
  --accent: #7c3aed;        /* фиолетовый — как плашка гео/адреса */
  --accent-press: #6d28d9;  /* нажатое состояние — темнее */
  --text: #f3f4f6;
  --muted: #9ca3af;
  --error: #ef4444;
  /* поверхности/границы (переопределяются в светлой теме) */
  --surface: #241f30;
  --surface-press: #2e2740;
  --toolbar-bg: #0d0b13;
  --input-bg: #141019;
  --border: #2c313c;
  --switch-off: #3a3f4b;
  --li-text: #d1d5db;
}
/* Светлая тема (по желанию, в настройках). Камера всегда остаётся тёмной. */
html[data-theme="light"] {
  --bg: #f4f2f8;
  --card: #ffffff;
  --text: #1c1826;
  --muted: #6b6577;
  --surface: #e6e1f0;
  --surface-press: #d7d0e8;
  --toolbar-bg: #f7f5fb;
  --input-bg: #f2f0f7;
  --border: #cfc8de;
  --switch-off: #cbc7d6;
  --li-text: #3a3546;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
}
.screen.active { display: flex; }

/* --- Авторизация --- */
#screen-auth { align-items: center; justify-content: center; padding: 24px; }
.card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.logo { font-size: 48px; margin-bottom: 8px; }
.card h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 20px; }

input[type=text] {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  letter-spacing: 2px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  margin-bottom: 16px;
}
input[type=text]:focus { outline: none; border-color: var(--accent); }
/* Поле произвольного текста — многострочное, обычный регистр (капс только у кода доступа) */
#text-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
  resize: vertical;
  margin-bottom: 16px;
  text-transform: none; letter-spacing: normal; text-align: left;
}
#text-input:focus { outline: none; border-color: var(--accent); }
#pin-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  margin-bottom: 12px;
}
#pin-input:focus { outline: none; border-color: var(--accent); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); font-size: 15px; margin: 12px 0; cursor: pointer; }

button { font-family: inherit; cursor: pointer; border: none; }
.primary {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: 12px;
  transition: background .15s;
}
.primary:active { background: var(--accent-press); }
.primary:disabled { opacity: .6; }
.error { color: var(--error); font-size: 14px; min-height: 20px; margin-top: 12px; }

/* --- Главный --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
}
.hello { font-weight: 600; }
.link { background: none; color: var(--muted); font-size: 14px; }
.topbtn {
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
}
.topbtn:active { background: var(--accent-press); }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.photo-big {
  width: 200px; height: 200px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 2px;
  box-shadow: 0 12px 40px rgba(124,58,237,.45);
  transition: transform .1s, background .15s;
}
.photo-big:active { transform: scale(.96); background: var(--accent-press); }
.secondary-btn {
  margin-top: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}
.secondary-btn:active { background: var(--surface-press); }

/* --- Sheet выбора категории --- */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: flex-end;
  z-index: 50;
}
.sheet.active { display: flex; }

/* Панель параметров: не затемняем фон и делаем меню полупрозрачным,
   чтобы видеть изменения на фото вживую. */
#params-sheet { background: transparent; }  /* фон не затемняем, но тап по нему закрывает */
#params-sheet .sheet-inner {
  background: rgba(28, 24, 38, 0.82);
  padding-top: 16px;
}
/* Панель всегда тёмная (поверх фото) — текст форсим светлым в любой теме */
#params-sheet .sheet-inner, #params-sheet h2, #params-sheet .ctl-row { color: #f3f4f6; }
#params-sheet .ghost { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.22); color: rgba(255,255,255,.85); }
#params-sheet .ctl-row { margin-bottom: 10px; }
.sheet-inner {
  width: 100%;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-inner h2 { margin: 0 0 16px; font-size: 18px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.cat-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}
.cat-btn:active { border-color: var(--accent); }
.cat-btn img { width: 32px; height: 32px; }
.ghost { width: 100%; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font-size: 16px; font-weight: 600; }
.ghost:active { background: var(--surface-press); }

/* --- Камера --- */
.camera { background: #000; container-type: size; container-name: cam; }
#video { width: 100%; height: 100%; object-fit: cover; touch-action: none; }
.cam-zoom {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px;
  background: rgba(0,0,0,.55); color: #fff; font-weight: 700;
  padding: 5px 11px; border-radius: 14px; font-size: 14px;
  z-index: 6; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.cam-zoom.show { opacity: 1; }
/* Прицел по центру кадра */
.cam-center {
  position: absolute;
  top: 50%; left: 50%;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}
.cam-center::before, .cam-center::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,.85);
  box-shadow: 0 0 2px rgba(0,0,0,.8);
}
.cam-center::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
.cam-center::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }
.cam-badge {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 16px;
}
.cam-cats {
  position: absolute;
  /* привязка к КАДРУ (cqh), а не к окну — кнопки всегда под плашкой гео */
  top: calc(8.5cqh + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 7;
}
.cam-cat {
  background: rgba(0,0,0,.32);
  color: rgba(255,255,255,.92);
  /* мягкое масштабирование от кадра с ограничением (clamp) — без резких скачков */
  padding: clamp(8px, 2.4cqw, 11px) clamp(18px, 5.6cqw, 26px);
  border-radius: 20px;
  font-weight: 700;
  font-size: clamp(14px, 4.2cqw, 18px);
  min-width: clamp(110px, 31cqw, 150px);
}
.cam-cat:active { background: rgba(124,58,237,.5); }
.cam-cat.hidden { display: none; }
/* Живое превью оверлея на камере (полупрозрачное, доли как при запекании) */
.cam-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.cam-overlay { opacity: .65; }                  /* всё превью более полупрозрачное */
/* Все размеры — в долях КАДРА камеры (cqw/cqh), как при запекании на фото,
   чтобы превью и итоговое фото совпадали при любом разрешении/соотношении. */
.ov-geo {
  position: absolute; top: 0; left: 0; width: 100%; height: 7.14cqh;
  display: flex; align-items: center; justify-content: center;
  background: rgba(124, 58, 237, 0.38);
  color: #fff; font-weight: 600; font-size: 4.2cqh;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  white-space: nowrap; overflow: hidden;
}
.ov-cat1 { position: absolute; top: 2cqw; right: 2cqw; width: 25cqw; height: 25cqw; object-fit: contain; }
.ov-cat2 {
  position: absolute; top: 5cqw; left: 2cqw;
  font-weight: 700; font-size: 6cqw; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
/* подпись и профиль приподняты над нижней плашкой адреса (~6.1cqh) */
.ov-caption {
  position: absolute; left: 2cqw; bottom: calc(6.1cqh + 5cqw);
  font-weight: 700; font-size: 4cqw; color: #fff; max-width: 60%;
  white-space: pre-wrap; text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.ov-profile { position: absolute; right: 2cqw; bottom: calc(6.1cqh + 2cqw); width: 18cqw; }
/* Адрес — нижняя плашка во всю ширину (зеркало гео сверху) */
.ov-addr {
  position: absolute; left: 0; right: 0; bottom: 0; height: 6.12cqh;
  display: flex; align-items: center; justify-content: center;
  background: rgba(124, 58, 237, 0.38);
  color: #fff; font-weight: 600; font-size: 3.6cqh;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  white-space: nowrap; overflow: hidden; padding: 0 4cqw;
}

.cam-geo {
  position: absolute;
  bottom: calc(130px + 6.12cqh);   /* над кнопками, которые подняты выше плашки адреса */
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55);
  color: #fff;
  padding: clamp(5px, 1.6cqw, 8px) clamp(12px, 3.8cqw, 18px);
  border-radius: 16px;
  font-size: clamp(12px, 3.6cqw, 16px);
  font-weight: 700;
  z-index: 6;
}
.cam-geo.good { background: rgba(5,150,105,.85); }     /* зелёный — точно */
.cam-geo.med  { background: rgba(202,138,4,.85); }     /* жёлтый — средне */
.cam-geo.bad, .cam-geo.wait { background: rgba(220,38,38,.85); } /* красный — плохо/поиск */
.cam-wait {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,.78);
  color: #fff;
  padding: 16px 18px;
  border-radius: 14px;
  font-size: 15px;
  z-index: 8;
  width: min(86vw, 320px);
  text-align: center;
}
.cam-wait.show { display: flex; }
.cam-wait-row { display: flex; align-items: center; gap: 10px; }
.cam-wait-bar { width: 100%; height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; overflow: hidden; }
.cam-wait-bar > span { display: block; height: 100%; width: 0; background: var(--accent); }
.cam-wait.show .cam-wait-bar > span { animation: cam-progress 2s linear forwards; }
@keyframes cam-progress { from { width: 0; } to { width: 100%; } }
.cam-wait-btn {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.cam-wait-btn.ghost2 { background: rgba(255,255,255,.15); font-weight: 500; font-size: 13px; }

/* Лоадер дозахвата гео в редакторе */
.edit-geo {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 64px);   /* ниже плашки гео */
  left: 50%; transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,.6);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  z-index: 25;
}
.edit-geo.show { display: flex; }
.cam-spin {
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cam-controls {
  position: absolute;
  /* выше плашки адреса (6.12cqh) + отступ, чтобы кнопки её не перекрывали */
  bottom: calc(6.12cqh + max(28px, env(safe-area-inset-bottom)) + 10px);
  left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 24px;
  z-index: 8;   /* кнопки поверх превью-оверлея, чтобы стикеры их не перекрывали */
}
.shutter {
  width: clamp(64px, 19cqw, 84px); height: clamp(64px, 19cqw, 84px);
  border-radius: 50%;
  background: #fff;
  border: 5px solid rgba(255,255,255,.4);
  transition: transform .1s;
}
.shutter:active { transform: scale(.9); }
.shutter:disabled { opacity: .5; }
.round {
  width: clamp(46px, 14cqw, 60px); height: clamp(46px, 14cqw, 60px);
  border-radius: 50%;
  font-size: clamp(18px, 5.6cqw, 24px);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0;   /* иконка ровно по центру кружка */
}
.secondary { background: rgba(0,0,0,.45); }
.shutter { opacity: .9; }
.cam-status {
  position: absolute;
  bottom: calc(130px + 6.12cqh);
  left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-size: clamp(12px, 3.6cqw, 16px);
  text-shadow: 0 1px 4px #000;
}

/* --- Редактор / предпросмотр --- */
.edit { background: #000; }
.stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
  padding-top: max(8px, env(safe-area-inset-top));
}
.stage {
  position: relative;
  background: #111;
  touch-action: none; /* чтобы перетаскивание не скроллило страницу */
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  border-radius: 8px;
}
#stage-img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.el {
  position: absolute;
  cursor: move;
  touch-action: none;
}
.el.sticker img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.el.text {
  white-space: pre;
  font-weight: 700;
  line-height: 1.15;
  text-align: left;          /* выравнивание задаётся инлайн (по умолчанию слева) */
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
  font-family: 'PlayBold', -apple-system, Roboto, sans-serif;
}
/* «Как подпись»: горизонтальный градиент + белая обводка (ширина задаётся инлайн) */
.el.text.styled {
  background: linear-gradient(90deg, #2347c9 0%, #1a93c4 38%, #c84fd0 66%, #6a2ac0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 6px rgba(124, 95, 208, 0.5);
}
.el.selected { outline: 2px dashed #7c3aed; outline-offset: 2px; }
.el-btn {
  position: absolute;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 26px;
  text-align: center;
  color: #fff;
  border: none;
  display: none;
  z-index: 3;
  padding: 0;
  /* сброс наследуемого стиля текста (обводка/градиент) от произвольного текста */
  -webkit-text-fill-color: #fff;
  -webkit-text-stroke: 0;
  paint-order: normal;
  text-shadow: none;
  background-clip: border-box;
  -webkit-background-clip: border-box;
}
.el.selected .el-btn { display: block; }
.el-del { top: -13px; right: -13px; background: #dc2626; }
.el-edit { top: -13px; left: -13px; background: #6d28d9; }
.el-resize { bottom: -13px; right: -13px; background: #059669; cursor: nwse-resize; touch-action: none; }
.el-replace { top: -13px; left: -13px; background: #7c3aed; }
.el-rotate { background: #0ea5e9; cursor: grab; touch-action: none; }
.el-rotate.tl { bottom: -13px; left: -13px; }
.el-rotate.bl { bottom: -13px; left: -13px; }

/* --- Обрезка --- */
.stage.cropping .el { pointer-events: none; }
.crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 4000px rgba(0,0,0,.55);
  box-sizing: border-box;
  cursor: move;
  touch-action: none;
  z-index: 20;
}
.crop-h {
  position: absolute;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 3px rgba(0,0,0,.6);
  touch-action: none;
}
.crop-h.tl { left: -10px; top: -10px; cursor: nwse-resize; }
.crop-h.tr { right: -10px; top: -10px; cursor: nesw-resize; }
.crop-h.bl { left: -10px; bottom: -10px; cursor: nesw-resize; }
.crop-h.br { right: -10px; bottom: -10px; cursor: nwse-resize; }
.crop-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--toolbar-bg);
  z-index: 30;
}
.crop-bar .tool { flex: 1; min-width: 64px; }
.crop-bar[hidden] { display: none; }  /* перебиваем display:flex, чтобы скрывалась по hidden */

.edit-status {
  /* фиксированная высота под 2 строки — чтобы смена текста не меняла размер фото */
  height: 40px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  padding: 2px 12px;
  overflow: hidden;
  text-shadow: 0 1px 4px #000;
}
.edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 12px 6px;
  background: var(--toolbar-bg);
}
.edit-toolbar .tool { flex: 1 1 22%; }
/* Группа «Отменить/Вернуть» занимает один слот; внутри — две стрелки */
.edit-toolbar .undo-group { flex: 1 1 22%; display: flex; gap: 6px; }
.ubtn {
  flex: 1;
  padding: 13px 4px;
  line-height: 19px;        /* фикс высоты: смена кегля (текст↔стрелка) не меняет высоту ряда */
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.ubtn.icon-only { font-size: 19px; }
.ubtn:active { background: var(--surface-press); }
.ubtn:disabled { opacity: .5; }
.edit-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--toolbar-bg);
}
.edit-actions .tool { padding: 16px 6px; font-size: 16px; }
.tool {
  flex: 1;
  padding: 14px 6px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.tool:active { background: var(--surface-press); }
.tool.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool.primary:active { background: var(--accent-press); }
.tool.danger { background: rgba(220,38,38,.16); border-color: rgba(220,38,38,.55); color: #dc2626; }
.tool.danger:active { background: rgba(220,38,38,.30); }
.tool:disabled { opacity: .5; }

.sticker-grid { grid-template-columns: repeat(4, 1fr); }
.sticker-grid button {
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.sticker-grid img { width: 44px; height: 44px; }
.sticker-grid button:active { border-color: var(--accent); }

.ctl-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
  color: var(--text);
}
.ctl-row span { width: 64px; font-size: 15px; }
.ctl-row input[type=range] { flex: 1; }
.ctl-row input[type=color] {
  width: 48px; height: 36px; padding: 0; border: none; background: none;
}
.ctl-row select {
  flex: 1; padding: 9px 10px; border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 15px; font-weight: 600;
}
#text-sheet .ctl-row span { width: 104px; }
.align-btns { display: flex; gap: 8px; flex: 1; }
.align-btn {
  flex: 1; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px;
}
.align-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.row-btns { display: flex; gap: 10px; }
.row-btns .ghost, .row-btns .primary { flex: 1; }

/* --- Карта --- */
.map { background: #000; }
#map { flex: 1; width: 100%; }
.map-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--toolbar-bg);
}
.map-bar .tool { flex: 1; padding: 14px 8px; }
.map-hint-float {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  z-index: 1000;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}

/* --- Экран-обманка (галерея) --- */
.decoy {
  background: #f5f5f4;
  color: #1c1917;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.decoy-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px calc(40px + env(safe-area-inset-bottom));
}
.decoy-head { text-align: center; padding: 16px 0 8px; }
.decoy-logo {
  display: inline-block;
  font-weight: 900;
  letter-spacing: 3px;
  font-size: 22px;
  color: #fff;
  background: #1c1917;
  padding: 8px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  cursor: pointer;
}
.decoy-head h1 { margin: 4px 0; font-size: 26px; font-weight: 800; }
.decoy-sub { color: #78716c; margin: 4px 0 0; font-size: 15px; }
.decoy-intro {
  max-width: 720px;
  margin: 18px auto 26px;
  text-align: center;
  color: #44403c;
  line-height: 1.55;
  font-size: 15px;
}
.decoy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.decoy-card {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.decoy-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #e7e5e4;
}
.decoy-card .body { padding: 12px 14px 16px; }
.decoy-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.decoy-card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.decoy-card .meta { margin: 0; color: #78716c; font-size: 13px; }
.decoy-foot {
  text-align: center;
  color: #a8a29e;
  font-size: 13px;
  margin-top: 32px;
}

/* --- Галерея отложенных --- */
.gallery { background: var(--bg); }
.gallery-upload { margin: 8px 12px 0; align-self: stretch; text-align: center; }
.storage-warn {
  margin: 8px 12px 0;
  background: rgba(220, 38, 38, .15);
  border: 1px solid rgba(220, 38, 38, .5);
  color: #fecaca;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.gallery-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 16px;
}
.gallery-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px;
}
.ghead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 2px 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}
.ghead-title { font-weight: 800; font-size: 15px; }
.ghead-sel {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  flex: 0 0 auto;
}
.ghead-sel:active { background: var(--accent-press); }
.gcard {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 10px;
}
.gcheck { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--accent); }
.gthumb-wrap { position: relative; flex: 0 0 auto; }
.gthumb {
  width: 84px; height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  display: block;
}
.gerr {
  position: absolute;
  top: -6px; left: -6px;
  width: 22px; height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 13px;
}
.gerr-txt { color: #fca5a5; font-weight: 700; font-size: 12px; margin-bottom: 2px; }
.gmeta { flex: 1; min-width: 0; }
.gcats { font-weight: 700; font-size: 15px; }
.gdate { color: var(--muted); font-size: 12px; margin-top: 4px; }
/* Сплошной красный с белой иконкой — чётко видно в обеих темах */
.gdel {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: none;
  background: #dc2626;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.gdel:active { background: #b91c1c; }
.gallery-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--toolbar-bg);
}
.gallery-bar .tool { flex: 1 1 40%; padding: 14px 8px; }
#cap-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
#cap-input:focus { outline: none; border-color: var(--accent); }
.cap-stick { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); font-size: 15px; margin-bottom: 14px; cursor: pointer; }
/* Тумблер в стиле iOS (единый вид на всех устройствах) */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--switch-off); border-radius: 999px; transition: background .2s; }
.switch .slider::before {
  content: ''; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* --- Инструкция --- */
.help { background: var(--bg); }
.help-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  line-height: 1.5;
}
.help-note {
  margin: 10px 0 4px;
  background: rgba(220, 38, 38, .14);
  border: 1px solid rgba(220, 38, 38, .45);
  color: #fde2e2;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
}
.help-note b { color: #fff; }
/* Светлая тема: тёмно-красный текст вместо белого — читаемо на светлом фоне */
html[data-theme="light"] .help-note { background: rgba(220,38,38,.10); color: #991b1b; }
html[data-theme="light"] .help-note b { color: #7f1d1d; }
html[data-theme="light"] .storage-warn { background: rgba(220,38,38,.10); color: #991b1b; }
.help-body h3 { margin: 18px 0 6px; font-size: 17px; color: var(--accent); }
.help-body p { margin: 4px 0; color: var(--text); }
.help-body ul { margin: 4px 0; padding-left: 20px; }
.help-body li { margin: 6px 0; color: var(--li-text); }
.help-body b { color: var(--text); }

/* --- Тост --- */
.toast {
  position: fixed;
  bottom: 40px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #065f46; }
.toast.err { background: #7f1d1d; }
