/* Холст · Mini App. Цвета берём из темы Telegram, запасные значения для обычного браузера */

:root {
  --fb-bg: #f2f3f5;
  --fb-surface: #ffffff;
  --fb-text: #10141a;
  --fb-hint: #7c8591;
  --fb-accent: #2f7cf6;
  --fb-accent-text: #ffffff;
  --fb-link: #2b74ec;
  --fb-danger: #e5484d;
  --fb-sep: rgba(16, 20, 26, .08);

  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-surface)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --accent: var(--tg-theme-button-color, var(--fb-accent));
  --accent-text: var(--tg-theme-button-text-color, var(--fb-accent-text));
  --link: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, var(--fb-link)));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));
  --sep: var(--tg-theme-section-separator-color, var(--fb-sep));

  --tint: rgba(118, 128, 142, .10);
  --tint-2: rgba(118, 128, 142, .17);
  --accent-soft: rgba(47, 124, 246, .12);
  --ok: #2fb36b;
  --scrim: rgba(10, 12, 16, .42);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .14), 0 1px 3px rgba(16, 24, 40, .06);
  --card-line: transparent;

  --r-card: 18px;
  --r-tile: 12px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur: .22s;

  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --safe-left: max(var(--tg-safe-area-inset-left, 0px), env(safe-area-inset-left, 0px));
  --safe-right: max(var(--tg-safe-area-inset-right, 0px), env(safe-area-inset-right, 0px));
  --bb-h: 0px;
  --tabbar-h: 64px;
  --maxw: 760px;

  color-scheme: light;
}

:root.dark {
  --fb-bg: #0f1115;
  --fb-surface: #1a1d23;
  --fb-text: #eceff3;
  --fb-hint: #8b939e;
  --fb-accent: #4a8dff;
  --fb-link: #6ea4ff;
  --fb-danger: #ff6369;
  --fb-sep: rgba(255, 255, 255, .08);
  --tint: rgba(150, 160, 175, .12);
  --tint-2: rgba(150, 160, 175, .20);
  --accent-soft: rgba(74, 141, 255, .16);
  --ok: #3ccf7e;
  --scrim: rgba(0, 0, 0, .6);
  --shadow: none;
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  --card-line: rgba(255, 255, 255, .05);
  color-scheme: dark;
}

@supports (color: color-mix(in srgb, red, blue)) {
  :root { --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent); }
  :root.dark { --accent-soft: color-mix(in srgb, var(--accent) 20%, transparent); }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
img { display: block; max-width: 100%; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.xs { width: 15px; height: 15px; stroke-width: 2.1; }
svg.i.lg { width: 28px; height: 28px; stroke-width: 1.7; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- каркас ---------- */
#app { position: fixed; inset: 0 0 var(--bb-h) 0; display: flex; flex-direction: column; }
.topbar {
  flex: none; position: relative; z-index: 5;
  padding: calc(var(--safe-top) + 10px) calc(16px + var(--safe-right)) 6px calc(16px + var(--safe-left));
  display: flex; align-items: center; gap: 8px;
  max-width: calc(var(--maxw) + 32px); width: 100%; margin: 0 auto;
}
.topbar h1 { margin: 0; flex: 1; font-size: 28px; line-height: 1.15; font-weight: 750; letter-spacing: -0.025em; min-width: 0; }
.topbar .icon-btn { margin-right: -8px; }
.status-dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--hint); box-shadow: 0 0 0 2px var(--bg); }
.status-dot.on { background: var(--ok); }

#views { position: relative; flex: 1; min-height: 0; }
.view {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 4px calc(16px + var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 28px) calc(16px + var(--safe-left));
  visibility: hidden; opacity: 0; transform: translateY(6px);
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility 0s .18s;
}
.view.active { visibility: visible; opacity: 1; transform: none; transition: opacity .2s var(--ease), transform .2s var(--ease); }
.view > .wrap { max-width: var(--maxw); margin: 0 auto; }

.tabbar {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-bottom));
  width: min(calc(100% - 24px - var(--safe-left) - var(--safe-right)), 440px);
  height: var(--tabbar-h); padding: 6px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--surface); border-radius: 999px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--card-line);
}
/* под плавающей панелью вкладок — фон страницы с мягким переходом: содержимое не просвечивает вокруг неё
   и между ней и кнопками внизу */
#app::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; pointer-events: none;
  height: calc(var(--tabbar-h) + var(--safe-bottom) + 30px);
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  background: linear-gradient(to top, var(--bg) 62%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 999px; color: var(--hint); font-size: 11px; font-weight: 600; letter-spacing: 0;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tab svg.i { width: 23px; height: 23px; }
/* фото открыто в правке: вкладок нет, «Назад» в шапке (в Telegram — его кнопка), место под картинку и инструменты */
body.editing .tabbar { display: none; }
body.editing #app::after { height: calc(var(--safe-bottom) + 14px); }
body.editing .view { padding-bottom: calc(var(--safe-bottom) + 24px); }
.tab[aria-selected="true"] { color: var(--link); background: var(--accent-soft); }
.tab:active { transform: scale(.96); }

/* ---------- нижняя панель кнопок вне Telegram (как MainButton) ---------- */
#bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 10px calc(16px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
  background: var(--bg); display: flex; gap: 10px; justify-content: center;
  border-top: 1px solid var(--sep);
}
#bottombar .bb { flex: 1; max-width: 360px; height: 48px; border-radius: 14px; font-weight: 650; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: opacity .15s, transform .1s; }
#bottombar .bb:active { transform: scale(.985); }
#bottombar .bb-main { background: var(--accent); color: var(--accent-text); }
#bottombar .bb-sec { background: var(--surface); color: var(--link); box-shadow: inset 0 0 0 1px var(--sep); flex: .7; }
#bottombar .bb:disabled { opacity: .5; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- общие элементы ---------- */
.label { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .045em; color: var(--hint); margin: 22px 4px 8px; display: flex; align-items: center; gap: 8px; }
.label .spacer { flex: 1; }
.label a, .label button.link { text-transform: none; letter-spacing: -0.01em; font-size: 14px; font-weight: 550; color: var(--link); text-decoration: none; padding: 6px 0; }
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow), inset 0 0 0 1px var(--card-line); }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }

.icon-btn { position: relative; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text); flex: none; transition: background .15s; }
.icon-btn:hover { background: var(--tint); }
.icon-btn:active { background: var(--tint-2); }
.icon-btn.on { color: var(--link); background: var(--accent-soft); }
.icon-btn:disabled { opacity: .35; background: none; }

.btn { min-height: 44px; padding: 0 18px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 15px; white-space: nowrap; transition: transform .1s, background .15s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.soft { background: var(--tint); color: var(--text); }
.btn.soft:hover { background: var(--tint-2); }
.btn.accent { background: var(--accent-soft); color: var(--link); }
.btn.danger { background: var(--tint); color: var(--danger); }
.btn.ghost { color: var(--link); padding: 0 10px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: -4px -16px -8px; padding: 4px 16px 8px; scroll-padding: 16px; position: relative; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip {
  flex: none; min-height: 40px; padding: 0 15px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text); font-weight: 550; font-size: 14.5px; box-shadow: var(--shadow), inset 0 0 0 1px var(--card-line);
  transition: background .15s, color .15s, box-shadow .15s;
}
.chip.flat { background: var(--tint); box-shadow: none; }
.chip[aria-pressed="true"], .chip.sel { color: var(--link); background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip:active { transform: scale(.97); }
.chip .ar { display: inline-block; border: 1.8px solid currentColor; border-radius: 3px; opacity: .8; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--accent-soft); color: var(--link); white-space: nowrap; }
.badge.gray { background: var(--tint); color: var(--hint); }
.badge.ok { background: rgba(47, 179, 107, .14); color: var(--ok); }
.badge.warn { background: rgba(229, 72, 77, .12); color: var(--danger); }

/* сгруппированный список */
.list { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow), inset 0 0 0 1px var(--card-line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 14px 8px 16px; position: relative; width: 100%; text-align: left; }
button.row:active, a.row:active { background: var(--tint); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 1px; background: var(--sep); }
.row.noicon + .row::before, .list.noicon .row + .row::before { left: 16px; }
.row .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--link); flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; }
.row .value { color: var(--hint); text-align: right; min-width: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
/* строка «заголовок … значение»: заголовок не сжимается и не залезает под значение, ужимается значение */
.row > .grow:has(+ .value) { flex: 1 0 auto; max-width: 62%; }
.row .sub { color: var(--hint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--hint); opacity: .7; margin-left: -4px; }
.row .value.strong { color: var(--text); font-weight: 550; }

.stepper { display: inline-flex; align-items: center; background: var(--tint); border-radius: 999px; height: 40px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--link); }
.stepper button:disabled { color: var(--hint); opacity: .5; }
.stepper output { min-width: 26px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }

/* поле ввода */
.field { position: relative; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow), inset 0 0 0 1px var(--card-line); transition: box-shadow .15s; }
.field:focus-within { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--accent); }
.field textarea, .field input {
  display: block; width: 100%; border: 0; outline: 0; background: transparent; resize: none;
  font-size: 16.5px; line-height: 1.45; padding: 14px 16px 6px; min-height: 52px; color: var(--text);
}
.field input { padding: 14px 16px; }
.field textarea::placeholder, .field input::placeholder { color: var(--hint); opacity: .85; }
.field .tools { display: flex; align-items: center; gap: 4px; padding: 4px 8px 8px; min-height: 48px; }
.field .tools .spacer { flex: 1; }
.field .counter { font-size: 12px; color: var(--hint); padding: 0 6px; }
.field.shake { animation: shake .36s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.input { width: 100%; height: 44px; border-radius: 12px; border: 0; outline: 0; padding: 0 12px; background: var(--tint); font-size: 16px; color: var(--text); }
.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.4; resize: vertical; }

/* сегменты */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--tint); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { position: relative; z-index: 1; height: 38px; border-radius: 9px; font-weight: 600; font-size: 14.5px; color: var(--text); padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
:root.dark .seg button[aria-pressed="true"] { background: var(--tint-2); }

/* ползунок */
.slider { display: flex; align-items: center; gap: 10px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 32px; background: transparent; margin: 0; --p: 50%;
}
input[type=range]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--tint-2) var(--p)); }
input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p), var(--tint-2) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10.5px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .06); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .28); }

.progress { height: 4px; border-radius: 2px; background: var(--tint-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s var(--ease); }
.progress.indet > i { width: 35% !important; animation: indet 1.3s var(--ease) infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 16px; background: var(--tint); margin-top: 14px; }
.banner .ic { color: var(--hint); margin-top: 1px; }
.banner b { display: block; font-weight: 650; }
.banner span { color: var(--hint); font-size: 14px; }
.banner.warn { background: rgba(229, 72, 77, .09); }
.banner.warn .ic { color: var(--danger); }

.empty { text-align: center; color: var(--hint); padding: 28px 16px; font-size: 14.5px; }
.empty .ic { width: 52px; height: 52px; border-radius: 16px; background: var(--tint); display: grid; place-items: center; margin: 0 auto 12px; color: var(--hint); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; font-weight: 650; }

.sk { background: var(--tint); position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent); animation: shimmer 1.4s infinite; }
:root.dark .sk::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 14px; border-radius: 7px; }

/* ---------- Создать ---------- */
.prompt-field textarea { min-height: 112px; max-height: 42vh; }
.aspect-chips .chip { padding: 0 13px; }
.results-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .results-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .results-grid { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; aspect-ratio: 1; border-radius: var(--r-tile); overflow: hidden; background: var(--tint); }
.tile img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s var(--ease); }
.tile img.ld { opacity: 1; }
.tile.new { animation: pop .45s var(--ease); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
button.tile:active { transform: scale(.98); }
.tile .tag { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 999px; background: rgba(0, 0, 0, .5); color: #fff; backdrop-filter: blur(6px); }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #e6e8ec 25%, transparent 25%, transparent 75%, #e6e8ec 75%), linear-gradient(45deg, #e6e8ec 25%, transparent 25%, transparent 75%, #e6e8ec 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
:root.dark .checker { background-color: #24272d; background-image: linear-gradient(45deg, #2e3239 25%, transparent 25%, transparent 75%, #2e3239 75%), linear-gradient(45deg, #2e3239 25%, transparent 25%, transparent 75%, #2e3239 75%); }

/* живая карточка задачи */
.jobs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.jobs:empty { display: none; }
.job { padding: 10px; min-width: 0; }
/* готовые картинки из нескольких, пока рисуются остальные */
.job-parts { display: flex; gap: 6px; padding: 8px 2px 0; overflow-x: auto; scrollbar-width: none; }
.job-parts::-webkit-scrollbar { display: none; }
.job-parts .tile { width: 64px; flex: none; border-radius: 10px; }
.job-media { position: relative; margin: 0 auto; border-radius: 12px; overflow: hidden; background: var(--tint); max-height: 420px; max-width: 100%; }
.job-media > img.pv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(var(--blur, 6px)) saturate(1.05); transform: scale(1.04); transition: filter .6s var(--ease); }
.job-media .wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--hint); }
.job-media .glow { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%); background-size: 250% 100%; animation: sweep 2.2s linear infinite; }
:root.dark .job-media .glow { background-image: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .06) 50%, transparent 70%); }
@keyframes sweep { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.job-media .cancel { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px); }
.job-media .cancel::after { content: ""; position: absolute; inset: -4px; }
.job-info { display: flex; align-items: center; gap: 10px; padding: 10px 4px 2px; }
.job-info .grow { flex: 1; min-width: 0; }
.job-info .jstage { font-weight: 600; font-size: 14.5px; }
.job-info .meta { color: var(--hint); font-size: 13px; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.job .progress { margin: 8px 4px 2px; }
.job-err { display: flex; gap: 12px; align-items: flex-start; padding: 14px; }
.job-err .ic { color: var(--danger); margin-top: 1px; }
.job-err .grow { flex: 1; min-width: 0; }
.job-err p { margin: 2px 0 10px; color: var(--hint); font-size: 14px; }
.job-done-grid { display: grid; gap: 6px; grid-template-columns: repeat(var(--n, 1), 1fr); }
.job-done-grid .tile { aspect-ratio: auto; }
.job-done-grid .tile img { height: auto; max-height: 420px; object-fit: contain; }
.job-done-grid .tile.sized img { height: 100%; max-height: none; }
.job-actions { display: flex; gap: 8px; padding: 10px 2px 2px; flex-wrap: wrap; }

/* ---------- настройки (лист) ---------- */
.param { padding: 14px 0 16px; border-bottom: 1px solid var(--sep); }
.param:last-child { border-bottom: 0; }
.param-head { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.param-head .name { font-weight: 600; flex: 1; min-width: 0; }
.param-head .val { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.param-head .info { width: 40px; height: 40px; margin: -8px -10px -8px 0; color: var(--hint); border-radius: 50%; display: grid; place-items: center; }
.param-head .info[aria-expanded="true"] { color: var(--link); }
.hint { font-size: 13.5px; color: var(--hint); margin: 4px 0 8px; line-height: 1.4; }
.rec { font-size: 13px; color: var(--hint); margin-top: 4px; display: flex; align-items: center; gap: 6px; min-height: 22px; }
.rec button { color: var(--link); font-weight: 600; font-size: 13px; padding: 4px 0; }
.param .changed-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.param .slider .mini { width: 36px; height: 36px; border-radius: 50%; background: var(--tint); color: var(--link); display: grid; place-items: center; flex: none; }
.seed-row { display: flex; gap: 8px; align-items: center; }
.seed-row .input { flex: 1; font-variant-numeric: tabular-nums; }
.opt-list { display: grid; gap: 6px; margin-top: 6px; }
.opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--tint); min-height: 48px; width: 100%; }
.opt .radio { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--hint); flex: none; transition: box-shadow .15s; }
.opt[aria-checked="true"] .radio { box-shadow: inset 0 0 0 6px var(--accent); }
.opt .grow { flex: 1; min-width: 0; }
.opt .t { font-weight: 600; font-size: 14.5px; }
.opt .d { color: var(--hint); font-size: 13px; }
.size-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.size-row span { color: var(--hint); }
.lora { background: var(--tint); border-radius: 14px; padding: 10px 12px; margin-top: 8px; }
.lora-head { display: flex; align-items: center; gap: 8px; }
.lora-head .grow { flex: 1; min-width: 0; font-weight: 600; }
.lora .trig { font-size: 13px; color: var(--hint); margin-top: 2px; }
.lora .trig code { font: 600 12.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tint-2); padding: 2px 6px; border-radius: 6px; color: var(--text); }

/* ---------- слои: листы и экраны ---------- */
#layers { position: fixed; inset: 0 0 var(--bb-h) 0; z-index: 40; pointer-events: none; }
/* каждый слой — свой контекст наложения: z-index внутри (полосы просмотра, стрелки) не вылезает поверх следующих слоёв */
.layer { position: absolute; inset: 0; pointer-events: auto; z-index: 0; isolation: isolate; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .25s var(--ease); }
.layer.open .scrim { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  max-height: calc(100% - var(--safe-top) - 36px); display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .32s var(--ease);
  padding-bottom: var(--safe-bottom);
}
.layer.open .sheet { transform: none; }
.sheet.dragging { transition: none; }
.sheet-grab { position: absolute; top: 0; left: 0; right: 0; height: 22px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet-grab::before { content: ""; width: 38px; height: 5px; border-radius: 3px; background: var(--tint-2); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 22px 12px 8px 20px; touch-action: none; }
.sheet-head .grow { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 720; letter-spacing: -0.02em; }
.sheet-head .sub { color: var(--hint); font-size: 13.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 20px; -webkit-overflow-scrolling: touch; }
.sheet-body > .card, .sheet-body > .list { margin-top: 8px; }
.sheet-foot { padding: 10px 16px 12px; display: flex; gap: 8px; border-top: 1px solid var(--sep); }
@media (min-width: 700px) and (min-height: 560px) {
  .sheet { bottom: 50%; border-radius: 22px; max-height: min(82vh, 760px); transform: translateY(calc(50% + 24px)) scale(.98); opacity: 0; transition: transform .25s var(--ease), opacity .2s var(--ease); padding-bottom: 0; width: min(560px, calc(100% - 48px)); }
  .layer.open .sheet { transform: translateY(50%); opacity: 1; }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 16px; }
}

.screen {
  position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .3s var(--ease);
}
.layer.open .screen { transform: none; }
.screen .topbar h1 { font-size: 24px; }
.screen-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left)); }
.screen-body > .wrap { max-width: var(--maxw); margin: 0 auto; }
.back-btn { margin-left: -10px; }

/* всплывающие сообщения */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--bb-h) + var(--tabbar-h) + var(--safe-bottom) + 22px); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { max-width: 440px; padding: 11px 16px; border-radius: 14px; background: rgba(28, 30, 34, .92); color: #fff; font-size: 14.5px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); backdrop-filter: blur(10px); animation: toastin .3s var(--ease); pointer-events: auto; display: flex; gap: 12px; align-items: center; }
.toast button { color: #8cb8ff; font-weight: 650; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s var(--ease); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* диалог подтверждения вне Telegram */
.dialog { position: absolute; left: 50%; top: 50%; width: min(340px, calc(100% - 48px)); transform: translate(-50%, -46%) scale(.96); opacity: 0; transition: all .2s var(--ease); background: var(--surface); border-radius: 18px; padding: 20px 18px 14px; box-shadow: var(--shadow-lg); }
.layer.open .dialog { transform: translate(-50%, -50%); opacity: 1; }
.dialog h3 { margin: 0 0 6px; font-size: 17px; }
.dialog p { margin: 0 0 16px; color: var(--hint); font-size: 14.5px; }
.dialog .btn-row { justify-content: flex-end; }

/* ---------- модели ---------- */
.choice { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 13px 14px; position: relative; }
.choice + .choice::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--sep); }
.choice:active { background: var(--tint); }
.choice .grow { flex: 1; min-width: 0; }
.choice .t { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.choice .d { color: var(--hint); font-size: 13.5px; margin-top: 2px; }
.choice .m { color: var(--hint); font-size: 12.5px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.choice .m span { display: inline-flex; align-items: center; gap: 4px; }
.choice .check { color: var(--link); margin-top: 2px; }
.worker-card { padding: 16px; }
.worker-top { display: flex; align-items: center; gap: 12px; }
.worker-top .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--tint); display: grid; place-items: center; color: var(--hint); flex: none; }
.worker-top .ic.on { color: var(--ok); background: rgba(47, 179, 107, .12); }
.worker-top b { display: block; font-size: 16px; font-weight: 680; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--tint); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat .k { font-size: 12px; color: var(--hint); font-weight: 600; }
.stat .v { font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .progress { margin-top: 7px; }
.model { padding: 14px; }
.model + .model { border-top: 1px solid var(--sep); }
.model-top { display: flex; gap: 10px; align-items: flex-start; }
.model-top .grow { flex: 1; min-width: 0; }
.model .t { font-weight: 650; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.model .d { color: var(--hint); font-size: 13.5px; margin-top: 3px; }
.model .m { color: var(--hint); font-size: 12.5px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.model .m.lic { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.model .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.model .task { margin-top: 10px; }
.model .task .small { margin-top: 5px; display: flex; justify-content: space-between; gap: 8px; }
.trigs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.trigs code { font: 600 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tint); padding: 1px 7px; border-radius: 6px; }
.toggle { position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--tint-2); flex: none; transition: background .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.toggle[aria-checked="true"] { background: var(--ok); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- правка ---------- */
.pick { display: grid; gap: 10px; margin-top: 8px; }
.pick-hero { padding: 26px 20px 20px; text-align: center; }
.pick-hero .ic { width: 60px; height: 60px; border-radius: 18px; background: var(--accent-soft); color: var(--link); display: grid; place-items: center; margin: 0 auto 14px; }
.pick-hero h2 { margin: 0 0 6px; font-size: 19px; font-weight: 700; }
.pick-hero p { margin: 0 0 18px; color: var(--hint); font-size: 14.5px; }
.pick-hero .btn-row { justify-content: center; }
.recent-strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.recent-strip::-webkit-scrollbar { display: none; }
.recent-strip .tile { width: 84px; flex: none; }

.stage {
  position: relative; margin-top: 12px; border-radius: 16px; overflow: hidden; background: var(--tint);
  height: min(46vh, 480px); touch-action: none; user-select: none; -webkit-user-select: none;
}
.stage .world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.stage .world img, .stage .world canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.stage .world img { pointer-events: none; }
.stage canvas.mask { opacity: .5; }
.stage .cursor { position: absolute; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); pointer-events: none; transform: translate(-50%, -50%); display: none; }
.stage .zoom-badge { position: absolute; left: 10px; top: 10px; font-size: 12px; font-weight: 650; padding: 4px 9px; border-radius: 999px; background: rgba(0, 0, 0, .5); color: #fff; pointer-events: none; transition: opacity .3s; }
.stage .busy { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(0, 0, 0, .28); color: #fff; font-weight: 600; text-align: center; padding: 20px; }
.stage .busy .inner { display: flex; flex-direction: column; align-items: center; gap: 10px; background: rgba(0, 0, 0, .45); padding: 14px 18px; border-radius: 14px; backdrop-filter: blur(8px); min-width: 180px; }
.stage .busy .progress { width: 140px; background: rgba(255, 255, 255, .25); }
.stage .busy .progress > i { background: #fff; }
.stage .stage-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; width: max-content; max-width: calc(100% - 24px); padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .5); color: #fff; font-size: 13px; font-weight: 550; text-align: center; pointer-events: none; backdrop-filter: blur(8px); }
.stage .fit { position: absolute; right: 8px; top: 8px; width: 38px; height: 38px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px); }

.outpaint .frame { position: absolute; border-radius: 4px; outline: 2px dashed var(--accent); outline-offset: 0; }
.outpaint .frame-fill { position: absolute; inset: 0; opacity: .9; }
.outpaint .img-box { position: absolute; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.outpaint .img-box img { width: 100%; height: 100%; }
.outpaint .h { position: absolute; width: 44px; height: 44px; display: grid; place-items: center; touch-action: none; cursor: grab; transform: translate(-50%, -50%); }
.outpaint .h::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2.5px var(--accent), 0 2px 6px rgba(0, 0, 0, .3); }
.outpaint .h.v::before { width: 26px; height: 10px; border-radius: 5px; }
.outpaint .h.hz::before { width: 10px; height: 26px; border-radius: 5px; }
.outpaint .dims { position: absolute; left: 10px; top: 10px; font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; pointer-events: none; white-space: nowrap; }

.toolbar { display: flex; align-items: center; gap: 2px; margin-top: 10px; padding: 4px; }
.toolbar .slider { flex: 1; min-width: 0; padding: 0 4px; gap: 4px; }
.slider input[type=range] { min-width: 0; width: 100%; }
.toolbar .slider .dotprev { width: 22px; height: 22px; display: grid; place-items: center; flex: none; }
.toolbar .slider .dotprev i { display: block; border-radius: 50%; background: var(--text); opacity: .7; }
.toolbar .sep { width: 1px; height: 24px; background: var(--sep); margin: 0 2px; flex: none; }
.toolbar .sizes { flex: 1; display: flex; justify-content: center; gap: 2px; min-width: 0; }
.toolbar .icon-btn { width: 40px; height: 40px; }
.toolbar .size-btn i { display: block; border-radius: 50%; background: currentColor; }
.mask-action { margin-top: 12px; }
.erase-hint { margin: 10px 2px 0; }
@media (max-width: 370px) { .toolbar .icon-btn { width: 36px; height: 36px; } .toolbar .sep { margin: 0 1px; } }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick button { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow), inset 0 0 0 1px var(--card-line); font-size: 14px; font-weight: 600; text-align: left; line-height: 1.2; }
.quick button > span:first-child { display: grid; place-items: center; flex: none; }
.quick button svg { color: var(--link); }
.quick button:active { transform: scale(.98); }
.panel-gap { height: 12px; }
.editor-top { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.editor-top .seg { flex: 1; }
.presets { margin-top: 10px; }

/* правка: выделить по описанию одним касанием */
.select-chips { margin-top: 10px; align-items: center; }
.select-chips .chip { min-height: 36px; padding: 0 13px; font-size: 14px; }
.chips-label { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 2px 0 4px; color: var(--hint); font-size: 13.5px; font-weight: 600; }
.chips-label svg { color: var(--link); }

/* правка: описание и «насколько менять» одной карточкой */
.field.compose { margin-top: 12px; }
.field .strength { margin: 6px 16px 0; padding: 8px 0 10px; border-top: 1px solid var(--sep); }
.strength .param-head { min-height: 28px; }
.strength .param-head .name { font-size: 14.5px; }
.strength .param-head .val { margin-left: auto; color: var(--link); font-size: 14px; font-weight: 650; }
.strength .seg { margin: 4px 0 8px; }
.strength .rec { margin-top: 0; }
.strength .rec .grow { flex: 1; min-width: 0; }
.slider.ticked { position: relative; }
.slider.ticked input { position: relative; z-index: 1; }
/* метка рекомендованного значения: центр бегунка ходит от 13px до (ширина − 13px) */
.slider.ticked .rec-tick { position: absolute; top: 50%; left: calc(13px + (100% - 26px) * var(--at, .5)); width: 3px; height: 13px; margin: -6.5px 0 0 -1.5px; border-radius: 2px; background: var(--hint); opacity: .55; pointer-events: none; }

/* правка: быстрые действия в один ряд */
.quick.three { grid-template-columns: repeat(3, 1fr); }
.quick.three button { flex-direction: column; justify-content: center; text-align: center; gap: 6px; min-height: 76px; padding: 10px 6px; font-size: 13.5px; }
.quick.four { grid-template-columns: repeat(4, 1fr); }
.quick.four button { flex-direction: column; justify-content: center; text-align: center; gap: 6px; min-height: 76px; padding: 10px 4px; font-size: 12.5px; }

/* ---------- текст ---------- */
.result-card { padding: 16px; margin-top: 14px; }
.result-card .txt { white-space: pre-wrap; word-wrap: break-word; font-size: 15.5px; line-height: 1.5; user-select: text; -webkit-user-select: text; }
.result-card .sub-h { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .045em; color: var(--hint); margin: 14px 0 6px; }
.result-card .sub-h:first-child { margin-top: 0; }
.result-card .btn-row { margin-top: 14px; }

/* ---------- галерея ---------- */
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 4px -12px 0; border-radius: 4px; }
@media (min-width: 560px) { .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 4px 0 0; } }
@media (min-width: 900px) { .gallery-grid { grid-template-columns: repeat(5, 1fr); } }
.gallery-grid .tile { border-radius: 4px; }
.sentinel { height: 1px; }
.load-more { display: flex; justify-content: center; padding: 18px; color: var(--hint); }

/* ---------- просмотр ---------- */
.viewer { position: absolute; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column; opacity: 0; transition: opacity .22s var(--ease); touch-action: none; }
.layer.open .viewer { opacity: 1; }
.viewer .v-top { position: absolute; z-index: 3; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-top) + 8px) 8px 8px; background: linear-gradient(rgba(0, 0, 0, .55), transparent); transition: opacity .2s; }
.viewer .v-top .count { flex: 1; text-align: center; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.viewer .slide { position: absolute; inset: 0; overflow: hidden; will-change: transform; }
.viewer .slide.anim, .viewer .zl.anim { transition: transform .26s var(--ease); }
.viewer .slide .zl { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.viewer .slide .zl img { width: 100%; height: 100%; max-width: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; pointer-events: none; }
.viewer .v-bottom { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; padding: 26px 8px calc(var(--safe-bottom) + 10px); background: linear-gradient(transparent, rgba(0, 0, 0, .65)); transition: opacity .2s; }
.viewer .v-prompt { max-width: 640px; margin: 0 auto 10px; padding: 0 10px; font-size: 13.5px; color: rgba(255, 255, 255, .82); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.viewer .v-acts { display: flex; justify-content: center; gap: 2px; max-width: 560px; margin: 0 auto; }
.viewer .v-acts button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border-radius: 12px; font-size: 11.5px; font-weight: 600; color: #fff; min-height: 56px; }
.viewer .v-acts button:active, .viewer .v-acts button:hover { background: rgba(255, 255, 255, .12); }
.viewer.chrome-off .v-top, .viewer.chrome-off .v-bottom { opacity: 0; pointer-events: none; }
/* поверх просмотра открыт лист или диалог: полосы и стрелки прячем, чтобы не просвечивали */
.layer.under .viewer .v-top, .layer.under .viewer .v-bottom, .layer.under .viewer .nav { opacity: 0; pointer-events: none; }
.viewer .nav { position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; display: none; place-items: center; }
.viewer .nav.prev { left: 14px; } .viewer .nav.next { right: 14px; }
@media (hover: hover) and (min-width: 700px) { .viewer .nav { display: grid; } }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14.5px; }
.info-grid dt { color: var(--hint); }
.info-grid dd { margin: 0; text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; word-break: break-word; }
.prompt-box { background: var(--tint); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }

/* ---------- вход ---------- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); z-index: 80; }
.gate .ic { width: 72px; height: 72px; border-radius: 22px; background: var(--accent-soft); color: var(--link); display: grid; place-items: center; margin: 0 auto 18px; }
.gate h1 { margin: 0 0 8px; font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.gate p { margin: 0 auto 22px; color: var(--hint); max-width: 320px; }
.gate .btn { min-width: 220px; height: 50px; }

/* загрузка при старте */
.boot-sk { display: grid; gap: 12px; padding-top: 4px; max-width: var(--maxw); margin: 0 auto; }
.boot-sk .sk { border-radius: var(--r-card); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 700px) {
  .topbar h1 { font-size: 30px; }
  .view { padding-top: 8px; }
}

/* 18+ под размытием: первое нажатие показывает */
.tile.nsfw img, .zl.nsfw img { filter: blur(22px) saturate(.85); transform: scale(1.12); }
.tile.nsfw { overflow: hidden; }
.nsfw-tag { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; pointer-events: none; backdrop-filter: blur(6px); }
.zl.nsfw { overflow: hidden; }
.nsfw-show { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; padding: 12px 18px; border-radius: 999px;
  background: rgba(0, 0, 0, .6); color: #fff; font-weight: 650; font-size: 15px; backdrop-filter: blur(8px); white-space: nowrap; }
.gallery-bar { display: flex; justify-content: flex-end; margin: 2px 0 10px; }
.chip.nsfw-mode { min-height: 34px; padding: 0 13px; font-size: 13.5px; }
.nsfw-box { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.nsfw-box .nsfw-show { position: static; transform: none; }
.nsfw-all { padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, .45); color: rgba(255, 255, 255, .9); font-size: 13.5px; font-weight: 550; backdrop-filter: blur(8px); white-space: nowrap; }

/* ---------- стили в одно касание (Создать) ---------- */
.style-pick { margin-top: 10px; }
.chips.style-chips { align-items: center; margin-top: 0; }
.style-chips .chips-label { flex: none; font-size: 13px; font-weight: 650; color: var(--hint); padding: 0 2px 0 4px; }
.style-chips .chip { min-height: 36px; padding: 0 13px; font-size: 14px; gap: 6px; }
.style-chips .chip.flat { color: var(--link); padding-left: 11px; }
.style-hint { display: flex; align-items: baseline; gap: 10px; margin: 2px 4px 0; font-size: 13px; line-height: 1.35; color: var(--hint); }
.style-hint .t { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.style-hint .link { flex: none; color: var(--link); font-weight: 600; font-size: 13px; padding: 4px 0; }
.style-form { padding: 4px 16px 14px; }
.style-form .f { display: block; margin-top: 12px; }
.style-form .f > span { display: block; font-size: 13px; font-weight: 600; color: var(--hint); margin: 0 2px 6px; }
.style-form .hint { margin: 6px 2px 8px; }
.one-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- избранное ---------- */
.fav-tag { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .45); color: #fff; backdrop-filter: blur(6px); pointer-events: none; }
.fav-tag svg.i { width: 13px; height: 13px; fill: currentColor; stroke-width: 1.6; }
.fav-chip[aria-pressed="true"] svg.i, .viewer .v-fav.fav-on svg.i { fill: currentColor; }
.fav-btn.fav-on, .sel-fav.fav-on { color: var(--link); }
.fav-btn.fav-on svg.i, .sel-fav.fav-on svg.i { fill: currentColor; }

/* ---------- удалить и в избранное: карточка правки, выбор в галерее ---------- */
.icon-btn.sm { width: 36px; height: 36px; }
.job-tools { margin-left: auto; display: flex; gap: 2px; }
.job-tools .icon-btn { color: var(--hint); }
.job-tools .fav-btn.fav-on { color: var(--link); }
.job-tools .job-del:hover, .job-tools .job-del:active { color: var(--danger); }

.g-sel { flex: none; height: 42px; padding: 0 4px 0 8px; color: var(--link); font-size: 15px; font-weight: 600; }
.gallery-grid .tile { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.tile .pick { position: absolute; left: 6px; top: 6px; z-index: 2; width: 24px; height: 24px; border-radius: 50%; display: none; place-items: center;
  background: rgba(0, 0, 0, .2); color: transparent; box-shadow: inset 0 0 0 2px #fff, 0 1px 3px rgba(0, 0, 0, .3); pointer-events: none; }
.tile .pick svg.i { width: 14px; height: 14px; stroke-width: 2.6; }
.selecting .tile .pick { display: grid; }
.selecting .tile img { transition: opacity .3s var(--ease), transform .15s var(--ease); }
.selecting .tile.picked { background: var(--accent-soft); }
.selecting .tile.picked img { transform: scale(.9); border-radius: 4px; }
.selecting .tile.picked .pick { background: var(--accent); color: var(--accent-text); }
.selecting .tile .nsfw-tag { display: none; }
.sel-bar {
  position: absolute; z-index: 7; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-bottom));
  width: min(calc(100% - 24px - var(--safe-left) - var(--safe-right)), 440px);
  height: var(--tabbar-h); padding: 6px 8px 6px 22px;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-radius: 999px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--card-line);
  animation: pop .2s var(--ease);
}
.sel-bar .sel-count { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.sel-bar .icon-btn { width: 48px; height: 48px; }
.sel-bar .icon-btn:disabled { opacity: .35; }
.sel-bar .sel-del { color: var(--danger); }

/* ---------- галерея: поиск и фильтры ---------- */
.g-tools { margin: 2px 0 10px; }
.g-row { display: flex; align-items: center; gap: 6px; }
.g-search { flex: 1; min-width: 0; height: 42px; display: flex; align-items: center; gap: 6px; padding: 0 4px 0 12px; border-radius: 12px; cursor: text;
  background: var(--surface); box-shadow: var(--shadow), inset 0 0 0 1px var(--card-line); transition: box-shadow .15s; }
.g-search:focus-within { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--accent); }
.g-search .g-ic { display: grid; color: var(--hint); }
.g-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); -webkit-appearance: none; appearance: none; }
.g-search input::-webkit-search-cancel-button, .g-search input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.g-search input::placeholder { color: var(--hint); opacity: .9; }
.g-clear { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--hint); flex: none; }
.g-clear:active { background: var(--tint); }
.g-fbtn { margin-right: -6px; }
.g-fbtn .g-dot { position: absolute; top: 10px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.chips.g-filters { margin-top: 4px; padding-top: 8px; }
.g-filters .chip { min-height: 36px; padding: 0 13px; font-size: 14px; gap: 6px; }
.g-filters .chip .ci, .g-filters .chip .dd { display: grid; }
.g-filters .chip .dd { opacity: .65; margin-right: -4px; }
.g-filters .chip .lbl { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-count { align-self: center; color: var(--hint); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.choice .check:empty { width: 18px; }

/* ---------- просмотр: избранное, «до и после», «взять настройки» ---------- */
.viewer .v-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; backdrop-filter: blur(8px); transition: background .15s, color .15s; }
.viewer .v-pill:hover { background: rgba(255, 255, 255, .22); }
.viewer .v-pill[aria-pressed="true"] { background: #fff; color: #111; }
.viewer .v-line { max-width: 640px; margin: 0 auto 10px; padding: 0 10px; display: flex; align-items: center; gap: 12px; }
.viewer .v-line .v-prompt { flex: 1; min-width: 0; margin: 0; padding: 0; }
.viewer .v-take { height: 32px; padding: 0 11px; font-size: 13px; }
@media (max-width: 374px) { .viewer .v-top .v-pill span { display: none; } .viewer .v-top .v-pill { padding: 0 9px; } }

.cmp { position: absolute; inset: 0; overflow: hidden; cursor: ew-resize; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.cmp img { position: absolute; max-width: none; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.cmp .cmp-after { inset: 0; width: 100%; height: 100%; }
.cmp-before { position: absolute; inset: 0; background: #15171b; }
.cmp-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; pointer-events: none;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .3), 0 0 14px rgba(0, 0, 0, .35); }
.cmp-knob { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: #111; box-shadow: 0 2px 12px rgba(0, 0, 0, .35); transition: transform .15s var(--ease); }
.cmp.drag .cmp-knob { transform: scale(1.1); }
.cmp-tag { position: absolute; top: calc(50% + 30px); padding: 3px 9px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 12px; font-weight: 650; white-space: nowrap; backdrop-filter: blur(6px); transition: opacity .15s; }
.cmp-tag.l { right: 10px; }
.cmp-tag.r { left: 10px; }
.cmp.at-l .cmp-tag.l, .cmp.at-r .cmp-tag.r { opacity: 0; }
.cmp:focus-visible .cmp-knob { box-shadow: 0 0 0 3px var(--accent), 0 2px 12px rgba(0, 0, 0, .35); }
.stage.nsfw .world img, .stage.nsfw .world canvas, .stage.nsfw .img-box img { filter: blur(22px) saturate(.85); }
.nsfw-box.cover { inset: 0; left: 0; top: 0; transform: none; justify-content: center; }
.stage.nsfw .nsfw-box { z-index: 7; }
.stage.nsfw { pointer-events: auto; }

/* ---------- Telegram во весь экран (телефон): шапка встаёт в строку его кнопок ----------
   Слева «Закрыть»/«Назад», справа «⌄ ⋮» — их рисует Telegram. Заголовок и значок моделей
   по центру между ними, контент сразу под этой строкой. Вне полного экрана всё как было. */
body.tg-fullscreen .topbar {
  height: calc(var(--tg-safe-area-inset-top, 0px) + max(46px, var(--tg-content-safe-area-inset-top, 0px)));
  padding: var(--tg-safe-area-inset-top, 0px) 0 0; justify-content: center; gap: 2px; max-width: none;
}
body.tg-fullscreen .topbar h1 { flex: none; max-width: 40vw; font-size: 17px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.tg-fullscreen .topbar .icon-btn { width: 38px; height: 38px; margin: 0; }
body.tg-fullscreen .topbar .icon-btn svg.i { width: 20px; height: 20px; }
body.tg-fullscreen .status-dot { top: 7px; right: 6px; width: 8px; height: 8px; }
/* значок справа от заголовка: слева такой же пустой, чтобы заголовок стоял ровно по центру */
body.tg-fullscreen #app > .topbar::before { content: ""; width: 38px; flex: none; }
body.tg-fullscreen .view { padding-top: 2px; }
body.tg-fullscreen .back-btn { display: none; }

body.tg-fullscreen .viewer .v-top {
  padding: var(--tg-safe-area-inset-top, 0px) 0 10px; justify-content: center; gap: 2px;
  min-height: calc(var(--tg-safe-area-inset-top, 0px) + max(46px, var(--tg-content-safe-area-inset-top, 0px)) + 10px);
}
body.tg-fullscreen .viewer .v-close { display: none; }
body.tg-fullscreen .viewer .v-top .count { flex: none; padding: 0 6px; font-size: 15px; }
body.tg-fullscreen .viewer .v-top .icon-btn { width: 38px; height: 38px; }
body.tg-fullscreen .viewer .v-top .icon-btn svg.i { width: 21px; height: 21px; }
body.tg-fullscreen .viewer .v-top .v-pill { height: 32px; padding: 0 9px; }
body.tg-fullscreen .viewer .v-top .v-pill span { display: none; }
/* на узком экране между кнопками Telegram тесно: «Подробнее» остаётся в «Ещё» */
@media (max-width: 379px) { body.tg-fullscreen .viewer .v-info { display: none; } }

/* подделка кнопок Telegram для проверки в браузере (?mock=1&fs=1) */
.fs-emu { position: fixed; z-index: 100; left: 0; right: 0; top: var(--tg-safe-area-inset-top, 0px); height: var(--tg-content-safe-area-inset-top, 46px);
  display: flex; align-items: center; justify-content: space-between; padding: 0 8px; pointer-events: none; }
.fs-emu::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: var(--tg-safe-area-inset-top, 0px); background: rgba(128, 128, 128, .12); }
.fs-emu-btn { pointer-events: auto; height: 30px; min-width: 76px; padding: 0 12px; gap: 10px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(60, 64, 72, .28); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; backdrop-filter: blur(14px); }
:root.dark .fs-emu-btn { background: rgba(255, 255, 255, .14); }

/* ---------- образцы (По образцу) ---------- */
.refs { margin-top: 10px; }
.field .refs { margin: 0; padding: 2px 14px 4px; }
.refs-row { display: flex; align-items: center; gap: 8px; }
.ref-tile { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: var(--tint); flex: none; }
.ref-tile img { width: 100%; height: 100%; object-fit: cover; }
.ref-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px); }
.ref-x::after { content: ""; position: absolute; inset: -8px; }
.ref-more { display: grid; place-items: center; color: var(--link); background: var(--accent-soft); }
.refs-hint { color: var(--hint); font-size: 13px; margin-left: 2px; }
.refs-note { margin-top: 6px; color: var(--danger); font-size: 13px; }
.refs-about { margin: 6px 4px 0; }

/* ---------- лента правок и листы действий ---------- */
.job-note { padding: 8px 4px 0; color: var(--hint); font-size: 13px; }
.choice .choice-ic { display: grid; place-items: center; color: var(--link); margin-top: 1px; }
.choice .chev { align-self: center; color: var(--hint); opacity: .7; }
.choice[disabled] { cursor: default; }
.choice[disabled] .t, .choice[disabled] .choice-ic { opacity: .45; }
.choice[disabled] .chev { visibility: hidden; }

/* 18+ в строке поиска галереи: компактно, иконкой */
.g-nsfw { display: contents; }
.g-row .chip.nsfw-mode { min-height: 42px; padding: 0 12px; gap: 6px; border-radius: 12px; font-size: 14px; }

/* строка списка с отдельной кнопкой справа (LoRA: открыть лист или сразу выключить) */
.row.split { padding: 0 4px 0 0; gap: 0; }
.row.split > .row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 8px 8px 16px; text-align: left; }
.row.split > .row-main:active { background: var(--tint); }
.row-main > .grow:has(+ .value) { flex: 1 0 auto; max-width: 62%; }
.row.split .row-x { color: var(--hint); }

/* LoRA в листе настроек: строка с переключателем, у включённой ниже вес */
.lora { padding: 0; overflow: hidden; }
.lora-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 12px 8px 14px; text-align: left; }
.lora-row:active { background: var(--tint-2); }
.lora-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lora-row .t { font-weight: 600; }
.lora-row .d { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lora-row .toggle { pointer-events: none; }
.lora-w { padding: 0 14px 12px; }
.lora-w .slider .lbl { flex: none; font-size: 13px; color: var(--hint); }
.lora-w .slider .val { flex: none; min-width: 34px; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ряды чипов, которые листаются вбок: мягкий край вместо резкого обреза */
.chips:not(.wrap) { -webkit-mask-image: linear-gradient(to right, transparent, #000 14px, #000 calc(100% - 16px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 14px, #000 calc(100% - 16px), transparent); }
