/* ============================================================================
 * GOAL UX · оболочка кастомайзера Donation Goal
 * ----------------------------------------------------------------------------
 * Грамматика: рейка (6 групп) · ОДНА панель 320–380 px · превью-холст.
 * Меньше рамок, чипов и акцентов: слои различаются фоном, а не линиями;
 * один акцентный цвет (выбор и главное действие).
 * Грузится ПОСЛЕ configurator.css и core/ux-kit.css и переопределяет их.
 * ========================================================================== */
:root {
  --panel-w: clamp(320px, 26vw, 380px);
  --rail-w: 76px;
  --g-bg: #0e1124;
  --g-bar: #12163a;
  --g-panel: #151936;
  --g-raise: #1b2046;
  --g-field: #0f1330;
  --g-line: #262b52;
  --g-text: #e8e9ff;
  --g-muted: #9aa0d0;
  --g-dim: #7f86bd;
  --g-accent: #7d87ff;
  --g-accent-2: #5b6bff;
  --g-accent-soft: rgba(125, 135, 255, .16);
  --g-ok: #5ad19a;
  --g-radius: 12px;
  --ux-bg: var(--g-panel); --ux-bg2: #1b2046; --ux-bg3: var(--g-field);
  --ux-border: #343a70; --ux-accent: var(--g-accent);
}

/* ---- каркас ---------------------------------------------------------------- */
html, body { background: var(--g-bg); }
body.ux { overflow: hidden; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 12px; border-radius: 8px; background: var(--g-accent-2); color: #fff; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 8px; }

.app { display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: var(--rail-w) var(--panel-w) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; grid-row: 1; }
.randbar { grid-column: 1 / -1; grid-row: 2; }
.rail { grid-column: 1; grid-row: 3; }
.panel { grid-column: 2; grid-row: 3; }
.right { grid-column: 3; grid-row: 3; height: auto; min-height: 0; min-width: 0; }
body.panel-hidden .app { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr); }
body.panel-hidden .panel { display: none; }
body.focus .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
body.focus .topbar, body.focus .rail, body.focus .panel, body.focus .randbar, body.focus .pv-tools, body.focus .scene-label { display: none !important; }
body.focus .right { grid-column: 1; grid-row: 1; }

/* ---- верхняя панель --------------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 54px; background: var(--g-bar); border-bottom: 1px solid var(--g-line); flex-wrap: nowrap;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.topbar::-webkit-scrollbar { display: none; }
.topbar > * { flex-shrink: 0; }
.topbar > .tb-sp { flex: 1 1 0; min-width: 0; }
.tb-brand { display: flex; flex-direction: column; line-height: 1.1; margin-right: 4px; min-width: 0; }
.tb-brand b { font: 700 14px 'Comfortaa', 'Nunito', sans-serif; letter-spacing: .01em; white-space: nowrap; }
.tb-brand small { font-size: 10.5px; color: var(--g-dim); }
.tb-sp { flex: 1; }
.tb-search { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; background: var(--g-field); color: var(--g-muted);
  border: 1px solid var(--g-line); font-weight: 600; min-width: 190px; max-width: 280px; flex: 0 1 240px; justify-content: flex-start; }
.tb-search:hover { background: #151a42; color: var(--g-text); }
.tb-search-t { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-search kbd, .hk kbd { font: 600 10.5px ui-monospace, Consolas, monospace; padding: 2px 6px; border-radius: 6px; background: #232a58; color: #c3c8f0; white-space: nowrap; }
.tb-pair { display: inline-flex; gap: 2px; }
.tb-ic { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
  border-radius: 10px; background: transparent; color: var(--g-text); }
.tb-ic:hover { background: #232a58; }
.tb-ic:disabled { opacity: .3; background: transparent; }
.tb-ic[aria-pressed="true"], .tb-ic.on { background: var(--g-accent-soft); color: #fff; }
.tb-btn { padding: 7px 11px; border-radius: 10px; background: transparent; color: var(--g-text); font-weight: 700; white-space: nowrap; }
.tb-btn:hover { background: #232a58; }
.tb-chip { padding: 6px 8px; border-radius: 9px; background: transparent; color: var(--g-muted); font-size: 12px; }
.tb-chip.on { color: #fff; background: var(--g-accent-soft); }
.tb-random { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 12px; border: 1px solid #3a4290; background: rgba(91, 107, 255, .1); }
.tb-random .tb-btn { color: #fff; }
.tb-random .tb-btn:hover { background: rgba(125, 135, 255, .28); }
.tb-mode { flex: none; }
.tb-mode button { padding: 5px 10px; }
.tb-primary { padding: 9px 15px; border-radius: 11px; font-weight: 800; white-space: nowrap;
  background: linear-gradient(135deg, #5b6bff, #9a6bff); box-shadow: 0 6px 16px rgba(110, 100, 255, .32); }
.tb-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #5b6bff, #9a6bff); }
.toast-area { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 70; display: flex; gap: 8px; align-items: center; pointer-events: none; max-width: 92vw; }
.toast-area > * { pointer-events: auto; }
.toast-area .ux-notice { max-width: min(64ch, 80vw); padding: 8px 14px; font-size: 12.5px; background: #1b2046; border-color: #3a4290; box-shadow: var(--ux-shadow); white-space: normal; }
.toast-undo { padding: 8px 12px; border-radius: 99px; background: var(--g-accent-2); color: #fff; font-weight: 800; font-size: 12.5px; box-shadow: var(--ux-shadow); }
.toast-undo:hover { background: #6e7dff; }
body.focus .toast-area { bottom: 54px; }
.topbar .toprow { display: none; }

/* ---- полоса случайного дизайна ---------------------------------------------- */
.randbar { display: flex; align-items: center; gap: 10px; padding: 7px 16px; background: #1a1f54; border-bottom: 1px solid #3a4290; font-size: 12.5px; flex-wrap: wrap; }
.randbar #randbar-text { flex: 1; min-width: 160px; color: #dfe2ff; }
.randbar button { padding: 6px 11px; border-radius: 9px; background: rgba(255, 255, 255, .08); }
.randbar button:hover { background: rgba(255, 255, 255, .16); }
.randbar .rb-main { background: var(--g-accent-2); }
.randbar .rb-main:hover { background: #6e7dff; }

/* ---- рейка ------------------------------------------------------------------- */
.rail { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 6px; background: var(--g-bar); border-right: 1px solid var(--g-line); overflow-y: auto; scrollbar-width: none; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 7px; border-radius: 12px; background: transparent; color: var(--g-muted);
  font-weight: 700; position: relative; }
.rail-btn:hover { background: #1c2250; color: var(--g-text); }
.rail-btn .ri { font-size: 19px; line-height: 1; }
.rail-btn .rl { font-size: 10px; line-height: 1.1; text-align: center; letter-spacing: -.01em; }
.rail-btn.on { background: var(--g-accent-soft); color: #fff; }
.rail-btn.on::before { content: ""; position: absolute; left: -6px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--g-accent); }

/* ---- панель ------------------------------------------------------------------ */
.panel { display: flex; flex-direction: column; padding: 0; background: var(--g-panel); border-right: 1px solid var(--g-line); overflow: hidden; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px; }
.ph-text { flex: 1; min-width: 0; }
.panel .panel-head h1 { font: 700 17px 'Comfortaa', 'Nunito', sans-serif; margin: 0; line-height: 1.2; }
.ph-sub { font-size: 11.5px; color: var(--g-dim); margin-top: 2px; }
.ph-back { width: 32px; height: 32px; padding: 0; border-radius: 10px; background: #232a58; font-size: 16px; }
.ph-reset { padding: 5px 9px; font-size: 11.5px; border-radius: 9px; background: transparent; color: var(--g-muted); border: 1px solid var(--g-line); }
.ph-reset:hover { background: #232a58; color: #fff; }
.panel-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--g-line); overflow-x: auto; scrollbar-width: none; flex: none; }
.panel-tabs::-webkit-scrollbar { display: none; }
.pt { padding: 8px 8px 9px; background: transparent; color: var(--g-muted); font-size: 12.5px; font-weight: 700; border-radius: 8px 8px 0 0; white-space: nowrap; position: relative; flex: none; }
.pt:hover { background: #1c2250; color: var(--g-text); }
.pt.on { color: #fff; }
.pt.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--g-accent); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 14px 80px; scrollbar-width: thin; scrollbar-color: #343a70 transparent; }
.sec { display: flex; flex-direction: column; gap: 14px; }
.sec[hidden] { display: none; }
.page { display: flex; flex-direction: column; gap: 14px; }
.page[hidden] { display: none; }

/* блоки: без рамок, различаются отступом и заголовком */
.blk { display: flex; flex-direction: column; gap: 9px; }
.blk + .blk, .page > .blk:not(:first-child) { padding-top: 12px; border-top: 1px solid var(--g-line); }
.blk-title { font: 800 11px 'Nunito', sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--g-dim); }
.blk-danger { padding: 12px; border: 1px solid #4a2c44; border-radius: var(--g-radius); background: rgba(120, 40, 70, .1); border-top: 1px solid #4a2c44 !important; }
.hint.lead { color: var(--g-muted); font-size: 12.5px; }
.empty { padding: 18px 10px; text-align: center; font-size: 12.5px; color: var(--g-dim); border: 1px dashed var(--g-line); border-radius: var(--g-radius); }
.sec .row { min-height: 30px; }
.sec .row > label { font-size: 12.5px; }

/* кнопки внутри панели — спокойные; ярким остаётся только главное действие */
.panel button { background: #232a58; color: var(--g-text); font-weight: 700; }
.panel button:hover { background: #2d3570; }
.panel button.ghost { background: transparent; border: 1px solid var(--g-line); color: var(--g-muted); }
.panel button.ghost:hover { background: #1c2250; color: #fff; }
.panel button.wide { width: 100%; }
.panel button.big { background: linear-gradient(135deg, #5b6bff, #9a6bff); }
.panel .seg { background: var(--g-field); }
.panel .seg button { background: transparent; color: var(--g-muted); }
.panel .seg button:hover { background: #1c2250; }
.panel .seg button.on { background: var(--g-accent-2); color: #fff; }
.panel .row input[type="text"], .panel .row input[type="number"], .panel .row select { background: var(--g-field); border-color: #2c3260; }
.panel .row input:focus-visible, .panel .row select:focus-visible, .gal-q:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 1px; }
.panel button:focus-visible, .tb-search:focus-visible, .rail-btn:focus-visible, .pt:focus-visible, .tb-ic:focus-visible, .tb-btn:focus-visible, .tb-primary:focus-visible,
.qe-chip:focus-visible, .chip:focus-visible, .tile:focus-visible, .randbar button:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 1px; }

/* только для простого режима: расширенное прячется на страницах, внутри инспектора оно под «Расширенные ▸» */
.panel[data-mode="simple"] .adv { display: none !important; }
.panel[data-mode="simple"] #sec-inspector .adv { display: block !important; }
.panel[data-mode="simple"] #sec-inspector .row.adv, .panel[data-mode="simple"] #sec-inspector .checks.adv,
.panel[data-mode="simple"] #sec-inspector .dbody.adv { display: flex !important; }
.panel[data-mode="simple"] #sec-inspector .decor.off .dbody { display: none !important; }

/* группы прежнего кода, перенесённые в аккордеон */
.adv-acc { display: flex; flex-direction: column; gap: 8px; }
.adv-title { font: 800 11px 'Nunito', sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--g-dim); }
.group { margin: 0; border: 0; border-radius: var(--g-radius); background: var(--g-raise); }
.group > summary { background: transparent; padding: 10px 12px; font: 700 13px 'Nunito', sans-serif; border-radius: var(--g-radius); }
.group > summary:hover { background: #1f2552; }
.group > .body { padding: 4px 12px 12px; }
.group.flat { background: transparent; }
.group.flat > summary { display: none; }
.group.flat > .body { padding: 0; }
.nest { border: 0; background: var(--g-raise); }
.nest > summary { padding: 8px 11px; }
.decor { border: 0; background: var(--g-raise); }
details.more > summary, details.insp-adv > summary { cursor: pointer; list-style: none; padding: 7px 2px; font-size: 12px; font-weight: 800; color: var(--g-accent); user-select: none; }
details.more > summary::-webkit-details-marker, details.insp-adv > summary::-webkit-details-marker { display: none; }
details.more > summary::before, details.insp-adv > summary::before { content: "▸ "; }
details.more[open] > summary::before, details.insp-adv[open] > summary::before { content: "▾ "; }
.insp-adv-body, .more-body { display: flex; flex-direction: column; gap: 9px; padding: 4px 0 4px 10px; border-left: 2px solid var(--g-line); }
.st-det { margin-top: 2px; }

/* ---- «↺» у параметра ----------------------------------------------------------- */
.row > .rst { flex: none; width: 22px; height: 22px; padding: 0; border-radius: 7px; font-size: 12px; background: transparent; color: var(--g-accent); opacity: .0; }
.row:hover > .rst, .row:focus-within > .rst, .row > .rst:focus-visible { opacity: 1; }
.row > .rst:hover { background: var(--g-accent-soft); }
@media (hover: none) { .row > .rst { opacity: 1; } }
.flash { animation: g-flash 1.7s ease-out; border-radius: 8px; }
@keyframes g-flash { 0%, 55% { background: rgba(125, 135, 255, .35); box-shadow: 0 0 0 4px rgba(125, 135, 255, .35); } 100% { background: transparent; box-shadow: 0 0 0 4px transparent; } }

/* ---- галерея стилей ------------------------------------------------------------ */
.gal { display: flex; flex-direction: column; gap: 10px; }
.gal-bar { display: flex; gap: 6px; }
.gal-bar .gal-q { flex: 1; min-width: 0; }
.gal-theme { flex: 0 0 118px; max-width: 40%; padding: 8px 8px; border-radius: 10px; background: var(--g-field); color: var(--g-text); border: 1px solid #2c3260; font: 600 12.5px 'Nunito', sans-serif; }
.gal-q { width: 100%; padding: 9px 11px; border-radius: 10px; font: 600 13px 'Nunito', sans-serif; background: var(--g-field); color: var(--g-text); border: 1px solid #2c3260; }
.gal-chips, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; border-radius: 99px; font-size: 12px; font-weight: 700; background: #1c2250; color: var(--g-muted); border: 0; }
.panel .chip { background: #1c2250; color: var(--g-muted); }
.panel .chip:hover { background: #262d63; color: #fff; }
.panel .chip.on, .chip.on { background: var(--g-accent-2); color: #fff; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: 9px; }
.gcard { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 8px; border-radius: var(--g-radius); background: var(--g-raise);
  cursor: pointer; border: 1px solid transparent; transition: background .12s, border-color .12s; text-align: left; }
.gcard:hover { background: #222956; }
.gcard.on { border-color: var(--g-accent); background: #1f2560; }
.g-thumb { border-radius: 8px; overflow: hidden; aspect-ratio: 168 / 92; background: linear-gradient(135deg, #2f5c7d, #4f3f8f 60%, #232c57); }
.g-thumb svg { display: block; width: 100%; height: 100%; }
.g-nm { font-size: 12.5px; font-weight: 800; line-height: 1.2; color: var(--g-text); padding: 0 3px; }
.g-tag { margin-left: 6px; font-size: 9.5px; font-weight: 800; padding: 1px 6px; border-radius: 99px; background: rgba(125, 135, 255, .22); color: #cfd4ff; vertical-align: 1px; }
.g-ds { font-size: 11px; line-height: 1.3; color: var(--g-dim); padding: 0 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.g-fav { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; padding: 0; border-radius: 50%; font-size: 14px; line-height: 1;
  background: rgba(15, 18, 38, .7); color: #cfd3ff; opacity: 0; transition: opacity .12s; }
.gcard:hover .g-fav, .g-fav:focus-visible, .g-fav.on, .ap-card:hover .g-fav { opacity: 1; }
.g-fav.on { color: #ffd266; }
.md-act { display: flex; gap: 4px; padding: 2px 3px 0; }
.md-act .mini { padding: 3px 7px; }
@media (hover: none) { .g-fav { opacity: 1; } }

/* ---- первый запуск ------------------------------------------------------------- */
.firstrun { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--g-radius); background: linear-gradient(135deg, rgba(91, 107, 255, .2), rgba(154, 107, 255, .12)); }
.fr-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; list-style: none; counter-reset: fr; }
.fr-steps li { counter-increment: fr; font-size: 12.5px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.fr-steps li::before { content: counter(fr); width: 20px; height: 20px; border-radius: 50%; background: var(--g-accent-2); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.fr-act { display: flex; gap: 6px; flex-wrap: wrap; }
.fr-line { font-size: 12.5px; font-weight: 700; line-height: 1.4; }
.firstrun .fr-act button:not(.ghost) { background: var(--g-accent-2); color: #fff; }

/* ---- палитра ------------------------------------------------------------------- */
.pal { display: flex; flex-direction: column; gap: 8px; }
.hue-chips { display: flex; flex-direction: column; gap: 6px; }
.mini-cap { font-size: 11.5px; color: var(--g-dim); }
.hue { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .2); }
.panel .hue:hover { transform: scale(1.12); }
.panel .colorctl input[type="range"] { width: 56px !important; }
.panel .colorctl input.ctext { width: 112px !important; }
.paintbox > .row:first-child { flex-wrap: wrap; }
.paintbox > .row:first-child > label { flex: 1 1 100%; }
.pal .colorctl input[type="range"] { display: none; }
.pal .colorctl input.ctext { width: 138px !important; }
.pal .row > label { flex: 0 0 74px; }
.lvl .seg { flex: none; }
.lvl .seg button { padding: 5px 8px; }

/* ---- плитки элементов ---------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { display: flex; gap: 9px; align-items: center; padding: 10px; border-radius: var(--g-radius); background: var(--g-raise); text-align: left; min-width: 0; }
.panel .tile { background: var(--g-raise); }
.panel .tile:hover { background: #222956; }
.t-ic { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 800; background: #262d63; flex: none; }
.t-tx { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.t-t { font-size: 12.5px; font-weight: 800; color: var(--g-text); }
.t-s { font-size: 11px; font-weight: 600; color: var(--g-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- выбор украшения ----------------------------------------------------------- */
.apick { display: flex; flex-direction: column; gap: 5px; }
.ap-label { font-size: 12.5px; color: #c3c8f0; }
.ap-body { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--g-radius); background: var(--g-raise); }
.ap-thumb { width: 84px; flex: none; aspect-ratio: 9 / 5; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg, #2f5c7d, #4f3f8f 60%, #232c57); display: flex; align-items: center; justify-content: center; }
.ap-thumb svg { display: block; width: 100%; height: 100%; }
.ap-none { font-size: 11px; color: #cfd3ff; opacity: .7; }
.ap-info { flex: 1; min-width: 0; }
.ap-name { font-size: 12.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-sub { font-size: 11px; color: var(--g-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-act { display: flex; gap: 4px; flex: none; }
.apop { display: flex; flex-direction: column; gap: 9px; }
.ap-title { font: 800 11px 'Nunito', sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--g-dim); }
.ap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 7px; max-height: 340px; overflow-y: auto; padding-right: 2px; }
.ap-card { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 6px; border-radius: 10px; background: var(--g-field); cursor: pointer; text-align: left; border: 1px solid transparent; color: var(--g-text); }
.ap-card:hover { background: #151a42; }
.ap-card.on { border-color: var(--g-accent); }
.ap-card .thumb { border-radius: 7px; overflow: hidden; aspect-ratio: 9 / 5; background: linear-gradient(135deg, #2f5c7d, #4f3f8f 60%, #232c57); }
.ap-card .thumb svg { display: block; width: 100%; height: 100%; }
.ap-card .nm { font-size: 11.5px; font-weight: 700; line-height: 1.2; }
.ux-pop .chip, .ux-pop button { font-family: inherit; }
.ux-pop button { background: #232a58; color: var(--g-text); border: 0; border-radius: 9px; padding: 6px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.ux-pop button:hover { background: #2d3570; }
.ux-pop .chip { background: #1c2250; color: var(--g-muted); }
.ux-pop .chip.on { background: var(--g-accent-2); color: #fff; }
.ux-pop .ap-card, .ux-pop .g-fav { padding: 6px; }
.ux-pop .g-fav { padding: 0; background: rgba(15, 18, 38, .7); }
.ux-pop .gal-q { background: var(--g-field); }
.ux-pop .empty { grid-column: 1 / -1; }

/* ---- превью-холст -------------------------------------------------------------- */
.right { display: flex; flex-direction: column; background: var(--g-bg); }
.pv-tools { display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex-wrap: wrap; border-bottom: 1px solid var(--g-line); background: var(--g-bar); }
.qe { display: flex; gap: 6px; flex-wrap: wrap; }
.qe-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; background: #1c2250; color: var(--g-text); font-weight: 700; font-size: 12.5px; }
.qe-chip:hover { background: #262d63; }
.qe-chip[aria-expanded="true"] { background: var(--g-accent-2); color: #fff; }
.qi { font-size: 13px; }
.pv-view { display: inline-flex; align-items: center; gap: 6px; }
.pv-lab { font-size: 12px; color: var(--g-dim); }
.pv-view select { padding: 6px 8px; border-radius: 9px; background: var(--g-field); color: var(--g-text); border: 1px solid #2c3260; font: 600 12.5px 'Nunito', sans-serif; max-width: 190px; }
.preview { background: radial-gradient(1200px 700px at 50% 0%, #151a3e, var(--g-bg) 70%); }
.scene-label { background: rgba(14, 17, 36, .7); }
.focus-exit { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 8px 14px; border-radius: 99px; background: rgba(21, 25, 54, .88); color: #fff; z-index: 5; }
.focus-exit:hover { background: rgba(35, 42, 88, .95); }

/* всплывающие панели Quick Edit, «Тест», «Вид» */
.qe-pop, .tp { display: flex; flex-direction: column; gap: 9px; }
.qe-title, .tp-title { font: 800 11px 'Nunito', sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--g-dim); }
.tp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.tp-row > label { color: #c3c8f0; min-width: 84px; }
.tp-row input[type="number"], .tp-row select { padding: 6px 8px; border-radius: 8px; background: var(--g-field); color: var(--g-text); border: 1px solid #2c3260; font: 600 12.5px 'Nunito', sans-serif; }
.tp-row input.mid { width: 88px; }
.tp-row input.tiny { width: 70px; }
.tp #demo-level { width: 100%; accent-color: var(--g-accent); }
.tp .quick { display: flex; gap: 4px; flex-wrap: wrap; }
.tp .quick button { padding: 4px 7px; font-size: 11.5px; }
.tp .chk, .locks .chk { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 12.5px; color: #c3c8f0; }
.tp .chk input, .locks .chk input { accent-color: var(--g-accent); width: 16px; height: 16px; }
.hk { justify-content: space-between; }
.hk span { color: var(--g-muted); text-align: right; }
.ux-menu { display: flex; flex-direction: column; gap: 2px; margin: -4px; }
.ux-menu .mi { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 8px 10px; border-radius: 9px; background: transparent !important; font-size: 13px; font-weight: 700; }
.ux-menu .mi:hover, .ux-menu .mi:focus-visible { background: #262d63 !important; }
.ux-menu .mi small { font-size: 11px; font-weight: 600; color: var(--g-dim); }
.ux-menu .sep { height: 1px; margin: 4px 6px; background: var(--g-line); }

/* ---- лёгкая правка прежних частей --------------------------------------------- */
.cards { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.card { background: var(--g-raise); border-color: transparent; }
.card:hover { background: #222956; border-color: transparent; }
.card.on { border-color: var(--g-accent); box-shadow: none; }
.orngrid { max-height: none; }
.orncard { background: var(--g-raise); border-color: transparent; }
.orncard.on { border-color: var(--g-accent); box-shadow: none; }
.status { background: var(--g-field); }
.balance { background: var(--g-raise); border-color: transparent; }
.panel textarea { height: 200px; }

/* ---- средняя ширина: верхняя панель компактнее ------------------------------- */
@media (max-width: 1100px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .tb-brand, .tb-search-t, .tb-search kbd { display: none; }
  .tb-search { min-width: 0; flex: none; padding: 7px 9px; }
  .ux-save [data-save-text] { display: none; }
  .tb-btn { padding: 7px 8px; }
}

/* ---- планшет: панель выезжает поверх превью ---------------------------------- */
@media (max-width: 900px) {
  body.ux { overflow: hidden; }
  .app { height: 100vh; height: 100dvh; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .panel { position: fixed; left: var(--rail-w); top: 54px; bottom: 0; width: min(380px, calc(100vw - var(--rail-w))); z-index: 30; grid-column: auto; box-shadow: 18px 0 40px rgba(5, 7, 24, .5); overflow: hidden; }
  .right { grid-column: 2; height: auto; position: static; order: 0; }
  body.panel-hidden .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  #btn-recolor { display: none; }
}

/* ---- телефон: рейка снизу, панель — шторка ----------------------------------- */

@media (max-width: 700px) {
  .app, body.panel-hidden .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .tb-lbl, .tb-mode, #btn-recolor, .ux-save { display: none !important; }
  .tb-random { padding: 1px; }
  .rail { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; top: auto; flex-direction: row; justify-content: space-around; padding: 4px 6px;
    border-right: 0; border-top: 1px solid var(--g-line); }
  .rail-btn { flex: 1; padding: 6px 2px 5px; }
  .rail-btn.on::before { left: 14px; right: 14px; top: -5px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail-btn .ri { font-size: 17px; }
  .panel { left: 0; right: 0; top: auto; bottom: 58px; width: auto; height: min(62vh, 560px); border-radius: 16px 16px 0 0; border-right: 0; box-shadow: 0 -14px 40px rgba(5, 7, 24, .55); }
  body.panel-hidden .panel { display: none; }
  .right { grid-column: 1; padding-bottom: 58px; }
  .tb-primary { padding: 8px 10px; font-size: 0; }
  .tb-primary::before { content: "⬇"; font-size: 15px; }
  .pv-tools { padding: 6px 8px; }
  .qe { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .qe-chip { flex: none; }
  .pv-lab { display: none; }
  .fr-steps { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .flash, .ux-pop { animation: none !important; }
  .gcard, .g-fav { transition: none; }
}
