/* ============================================================================
 * Стили страницы-кастомайзера (в виджет не попадают)
 * Палитра и сетка — как у прежнего configurator.html.
 * ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }   /* условные поля: hidden сильнее display:flex у .row */
html, body { height: 100%; background: #0f1226; }
body { font-family: 'Nunito', system-ui, sans-serif; color: #e8e9ff; overflow: hidden; }

.app { display: grid; grid-template-columns: 420px 1fr; height: 100vh; }

/* ---- левая колонка: настройки ---- */
.panel { padding: 18px 16px 60px; background: #151936; border-right: 1px solid #262b52;
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: #343a70 transparent; }
.panel h1 { font-family: 'Comfortaa', sans-serif; font-size: 19px; margin-bottom: 4px; }
.panel .sub { font-size: 12px; color: #9aa0d0; margin-bottom: 14px; }

.topcard { border: 1px solid #343a70; background: linear-gradient(180deg, #1d2250, #181c42);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 9px;
  position: sticky; top: -18px; z-index: 5; box-shadow: 0 8px 18px rgba(8,10,30,.45); }
.toprow { display: flex; align-items: center; gap: 10px; }
.toplabel { flex: 0 0 auto; width: 118px; font-size: 12px; color: #aab0e8; font-weight: 700; letter-spacing: .02em; }
.toprow .toplabel { width: auto; }
.toprow .seg { flex: none; flex-wrap: nowrap; }
.toprow .seg button { padding: 5px 8px; white-space: nowrap; }
button.dice { margin-left: auto; padding: 7px 12px; border-radius: 10px; font-size: 12.5px; white-space: nowrap;
  background: #1a1f45; border: 1px solid #3a4180; color: #e8e9ff; }
button.dice:hover { background: #252b5e; border-color: #5561c9; }
button.dice:active { transform: scale(.97); }

.group { margin-bottom: 12px; border: 1px solid #262b52; border-radius: 12px; overflow: hidden; }
.group > summary {
  cursor: pointer; padding: 10px 12px; background: #1b2043; font-weight: 700;
  font-family: 'Comfortaa', sans-serif; font-size: 13.5px; list-style: none; user-select: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: "▸ "; color: #8b93e0; }
.group[open] > summary::before { content: "▾ "; }
.group > .body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.group-file { border-color: #3b4590; }
.group-file > summary { background: #222a5e; }

.row { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.row > label { flex: 1; font-size: 12.5px; color: #c3c8f0; min-width: 0; }
.row input[type="text"], .row input[type="number"], .row select {
  width: 150px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px;
  background: #0f1330; color: #e8e9ff; border: 1px solid #303663; font-family: inherit;
}
.row select { cursor: pointer; }
.row input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid #303663;
  border-radius: 6px; background: #0f1330; cursor: pointer; flex: none; }
.row input[type="range"] { width: 120px; accent-color: #7d87ff; }
.row input[type="checkbox"] { width: 16px; height: 16px; accent-color: #7d87ff; }
.row .val { width: 44px; text-align: right; font-size: 12px; color: #9aa0d0; }
.row input.num { width: 58px; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.row .unit { width: 18px; font-size: 11px; color: #8b91c4; margin-left: -4px; }
.row.bad input { border-color: #c04a68 !important; }
.row .qi { display: inline-block; width: 15px; height: 15px; margin-left: 4px; border-radius: 50%;
  background: #2a305c; color: #aab0e8; font-size: 10px; line-height: 15px; text-align: center; cursor: help; vertical-align: 1px; }

.subhead { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #8b93e0;
  margin-top: 4px; padding-top: 8px; border-top: 1px dashed #2a305c; }

.hint { font-size: 11.5px; color: #8b91c4; line-height: 1.45; }
.warn { font-size: 11.5px; color: #ffc9a8; line-height: 1.45; }
.muted { font-size: 11.5px; color: #7f86bd; }

button {
  padding: 8px 12px; border: 0; border-radius: 9px; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 700; color: #fff; background: #4b58c8;
}
button:hover { background: #5c69dc; }
button.ghost { background: #2a305c; }
button.ghost:hover { background: #353c6f; }
button.mini { padding: 4px 8px; font-size: 12px; background: #2a305c; }
button.mini:hover { background: #3a4180; }
button.big { width: 100%; padding: 13px 14px; font-size: 14px; letter-spacing: .02em;
  background: linear-gradient(135deg, #5b6bff, #9a6bff); box-shadow: 0 6px 18px rgba(110,100,255,.35); }
button.big:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.curbtns { display: flex; gap: 4px; }

.status { font-size: 12px; line-height: 1.5; padding: 8px 10px; border-radius: 8px;
  background: #0f1330; border: 1px solid #303663; min-height: 34px; white-space: pre-wrap; }
.status:empty { display: none; }
.status.ok  { border-color: #2e7d5b; color: #a8f0cd; }
.status.err { border-color: #7d2e3e; color: #ffb4c0; }
.status.info { border-color: #3b4590; color: #cdd2ff; }

textarea { width: 100%; height: 240px; background: #0f1330; color: #cfd3ff;
  border: 1px solid #303663; border-radius: 8px; padding: 10px; font-size: 11.5px;
  font-family: ui-monospace, Consolas, monospace; resize: vertical; }

/* ---- сегменты ---- */
.seg { display: inline-flex; background: #0f1330; border: 1px solid #303663; border-radius: 9px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 5px 9px; font-size: 12px; background: transparent; color: #aab0e8; border-radius: 7px; font-weight: 700; }
.seg button:hover { background: #222850; }
.seg button.on { background: #4b58c8; color: #fff; }
.seg-big { flex: 1; display: flex; }
.seg-big button { flex: 1; padding: 7px 10px; font-size: 13px; }

/* ---- переключатель (компактный: не растягивается вместе с подписями) ---- */
.switch { position: relative; width: 34px; height: 19px; flex: 0 0 34px !important; margin-left: auto; }
.decor .dhead .switch, .row > .switch:first-child { margin-left: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #2a305c; border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 13px; height: 13px; border-radius: 50%;
  background: #cfd3ff; transition: transform .15s; }
.switch input:checked + span { background: #5b6bff; }
.switch input:checked + span::after { transform: translateX(15px); background: #fff; }

/* ---- цвет: квадрат + прозрачность + текст ---- */
.colorctl { display: flex; align-items: center; gap: 6px; }
.colorctl input[type="range"] { width: 70px !important; }
.colorctl input.ctext { width: 128px !important; font-family: ui-monospace, Consolas, monospace; font-size: 11px !important; }
.colorctl .clr { padding: 3px 7px; font-size: 11px; }

.paintbox { border: 1px solid #262b52; border-radius: 10px; padding: 8px 9px; display: flex; flex-direction: column; gap: 7px; background: #131733; }
.paintbox .swatch { height: 14px; border-radius: 6px; border: 1px solid #303663;
  background-image: repeating-conic-gradient(#d8d8e4 0 25%, #ffffff 0 50%); background-size: 12px 12px; position: relative; overflow: hidden; }
.paintbox .swatch i { position: absolute; inset: 0; }
.paintbox .row > label { color: #aab0e8; font-size: 12px; }

/* ---- карточки (пресеты, формы, макеты) ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 7px; }
.cards.layouts { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.card { background: #0f1330; border: 1px solid #2a305c; border-radius: 10px; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; align-items: stretch; text-align: left; color: #cfd3ff; font-weight: 600; }
.card:hover { border-color: #5561c9; background: #141a3e; }
.card.on { border-color: #8b93ff; box-shadow: 0 0 0 1px #8b93ff inset, 0 0 14px rgba(120,130,255,.25); }
.card .thumb { height: 54px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3c7fa0, #6a54b8 60%, #2c3a6e); overflow: hidden; }
.card .thumb svg { display: block; }
.card .nm { font-size: 11.5px; line-height: 1.2; }
.card .ds { font-size: 10.5px; color: #8b91c4; font-weight: 400; line-height: 1.25; }
.card pre { font-family: ui-monospace, Consolas, monospace; font-size: 8.5px; line-height: 1.35; color: #cfd3ff;
  background: #171c44; border-radius: 6px; padding: 5px 4px; white-space: pre; overflow: hidden; min-height: 44px; }

/* ---- вложенные блоки ---- */
.nest { border: 1px solid #242a55; border-radius: 10px; background: #12163a; }
.nest > summary { cursor: pointer; padding: 7px 10px; font-size: 12.5px; font-weight: 700; color: #c3c8f0; list-style: none; }
.nest > summary::-webkit-details-marker { display: none; }
.nest > summary::before { content: "▸ "; color: #6f78d0; }
.nest[open] > summary::before { content: "▾ "; }
.nest > .nbody { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 8px; }

.decor { border: 1px solid #242a55; border-radius: 10px; background: #12163a; padding: 6px 9px; display: flex; flex-direction: column; gap: 7px; }
.decor .dhead { display: flex; align-items: center; gap: 8px; }
.decor .dhead label { flex: 1; font-size: 12.5px; font-weight: 700; color: #d5d9ff; }
.decor .dhead input[type="range"] { width: 110px; accent-color: #7d87ff; }
.decor .dhead input.num { width: 46px; padding: 4px 6px; border-radius: 8px; font-size: 12.5px; text-align: right;
  background: #0f1330; color: #e8e9ff; border: 1px solid #303663; font-family: inherit; }
.decor.off .dhead label { color: #7f86bd; }
.decor .dbody { display: flex; flex-direction: column; gap: 7px; padding-top: 4px; border-top: 1px dashed #262b52; }
.decor.off .dbody { display: none; }

.checks { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.checks label { font-size: 12px; color: #c3c8f0; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.checks input { accent-color: #7d87ff; }

/* слои */
.layers { display: flex; flex-direction: column; gap: 4px; }
.layer { display: flex; align-items: center; gap: 6px; background: #0f1330; border: 1px solid #262b52; border-radius: 8px; padding: 4px 6px; }
.layer.off { opacity: .5; }
.layer .eye { width: 26px; padding: 3px 0; font-size: 12px; background: #2a305c; }
.layer .lname { flex: 1; font-size: 12px; color: #cfd3ff; }
.layer input[type="range"] { width: 80px; accent-color: #7d87ff; }
.layer .lv { width: 32px; font-size: 11px; color: #8b91c4; text-align: right; }
.layer button.mv { width: 24px; padding: 3px 0; font-size: 11px; background: #22284f; }

/* ---- украшения: галерея библиотеки ---- */
.orngal { display: flex; flex-direction: column; gap: 8px; }
.orncats { display: flex; flex-wrap: wrap; gap: 5px; }
.orncats .chip { padding: 4px 9px; border-radius: 99px; font-size: 11.5px; background: #1a1f47; color: #c3c8f0; border: 1px solid #2a305c; }
.orncats .chip:hover { border-color: #5561c9; }
.orncats .chip.on { background: #5b6bff; color: #fff; border-color: #8b93ff; }
.ornbar { display: flex; gap: 6px; }
.ornbar select, .ornbar input { padding: 6px 8px; border-radius: 8px; font-size: 12.5px;
  background: #0f1330; color: #e8e9ff; border: 1px solid #303663; font-family: inherit; }
.ornbar select { flex: 0 0 auto; max-width: 48%; cursor: pointer; }
.ornbar input { flex: 1; min-width: 0; }
.orngrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 7px; max-height: 560px; overflow-y: auto;
  padding-right: 2px; overscroll-behavior: contain; }
.orncard { position: relative; background: #0f1330; border: 1px solid #2a305c; border-radius: 10px; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; color: #cfd3ff; font-weight: 600; outline: none; }
.orncard:hover, .orncard:focus-visible { border-color: #5561c9; background: #141a3e; }
.orncard.on { border-color: #8b93ff; box-shadow: 0 0 0 1px #8b93ff inset, 0 0 14px rgba(120,130,255,.25); }
.orncard.bad { opacity: .45; cursor: not-allowed; }
.orncard .thumb, .ornhead .thumb { border-radius: 7px; overflow: hidden; aspect-ratio: 9 / 5;
  background: linear-gradient(135deg, #2f5c7d, #4f3f8f 60%, #232c57); }
.orncard .thumb svg, .ornhead .thumb svg { display: block; width: 100%; height: 100%; }
.orncard .nm { font-size: 11.5px; line-height: 1.2; }
.orncard .ds { font-size: 10px; color: #8b91c4; font-weight: 400; line-height: 1.25; }
.orncard .badge { position: absolute; top: 9px; right: 9px; font-size: 10px; padding: 1px 6px; border-radius: 99px; background: #5b6bff; color: #fff; }
.orncard .ornbtns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.orncard .ornbtns .mini { padding: 3px 6px; font-size: 10.5px; }
.orncard .ornbtns .mini.on { background: #5b6bff; color: #fff; }
.ornfoot { font-size: 11.5px; color: #8b91c4; }
.linkbtn { background: none !important; border: 0; padding: 0; color: #9aa3ff; text-decoration: underline; cursor: pointer; font-size: inherit; }
.ornactive { display: flex; flex-wrap: wrap; gap: 5px; }
.ornchip { display: inline-flex; align-items: center; border-radius: 99px; background: #1d2350; border: 1px solid #3a4290; overflow: hidden; }
.ornchip button { background: none; border: 0; color: #dfe2ff; font-size: 11.5px; padding: 4px 8px; cursor: pointer; }
.ornchip button.x { padding: 4px 8px 4px 2px; color: #9aa3ff; }
.ornchip.bad { border-color: #8a5a2a; opacity: .7; }
.ornhead { display: flex; gap: 9px; align-items: flex-start; }
.ornhead .thumb { width: 126px; flex: none; }
.ornhead .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ornhead .nm { font-size: 13px; font-weight: 700; color: #e8e9ff; }
.ornhead .ds { font-size: 11px; color: #8b91c4; }
.hint.warn { color: #ffcf8a; }
.nest.ornslot { border-color: #3a4290; }

/* картинки */
.assetlist { display: flex; flex-direction: column; gap: 6px; }
.asset { display: flex; align-items: center; gap: 8px; background: #0f1330; border: 1px solid #262b52; border-radius: 8px; padding: 5px 7px; }
.asset img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px;
  background: repeating-conic-gradient(#d8d8e4 0 25%, #ffffff 0 50%) 0 0 / 10px 10px; flex: none; }
.asset .ainfo { flex: 1; min-width: 0; font-size: 11.5px; color: #cfd3ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset .ainfo small { display: block; color: #8b91c4; }

.uplist { display: flex; flex-direction: column; gap: 5px; }
.upitem { display: flex; align-items: center; gap: 5px; background: #0f1330; border: 1px solid #262b52; border-radius: 8px; padding: 5px 7px; }
.upitem .uname { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upitem .badge { font-size: 10px; padding: 1px 6px; border-radius: 99px; background: #2a305c; color: #aab0e8; }
.upitem button { padding: 4px 7px; font-size: 11px; }

.numprev { font-size: 12px; color: #cfd3ff; background: #0f1330; border: 1px dashed #303663; border-radius: 8px; padding: 6px 9px; font-variant-numeric: tabular-nums; }

/* ---- видимость по типу и режиму ---- */
.type-hidden { display: none !important; }
.panel[data-mode="simple"] .adv { display: none !important; }

/* ---- правая колонка: превью ---- */
.right { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.bar { padding: 9px 16px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid #262b52; background: #151936; }
.bar span { font-size: 12.5px; color: #9aa0d0; }
.bar button { padding: 6px 10px; font-size: 12px; }
.bar select, .bar input[type="number"] { padding: 5px 7px; border-radius: 8px; font-size: 12px;
  background: #0f1330; color: #e8e9ff; border: 1px solid #303663; font-family: inherit; }
.bar input.tiny { width: 66px; }
.bar input.mid { width: 84px; }
.bar input[type="range"] { width: 150px; accent-color: #7d87ff; }
.bar .sep { width: 1px; height: 20px; background: #2a305c; margin: 0 4px; }
.bar b { font-size: 13px; color: #fff; min-width: 58px; font-variant-numeric: tabular-nums; }
.bar .quick { display: inline-flex; gap: 3px; }
.bar .quick button { padding: 4px 6px; font-size: 11px; background: #2a305c; }
.bar .chk { display: flex; gap: 5px; align-items: center; font-size: 12.5px; color: #9aa0d0; cursor: pointer; }

.preview { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.scene-box { position: relative; }
.scene { position: absolute; left: 0; top: 0; transform-origin: 0 0; border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(140,150,255,.35), 0 18px 40px rgba(0,0,0,.35); }
.scene iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.scene.plain { background: #f2f0fb; }
.scene.light { background:
  radial-gradient(500px 420px at 72% 26%, #ffb347, transparent 60%),
  radial-gradient(520px 440px at 18% 78%, #2ec5ff, transparent 60%),
  linear-gradient(135deg, #0d7a4f, #1b9c8a 60%, #0a5f6e); }
.scene.dark { background:
  radial-gradient(500px 420px at 30% 24%, #7a3cff, transparent 60%),
  radial-gradient(500px 440px at 82% 80%, #ff3c7a, transparent 60%),
  linear-gradient(135deg, #0d1030, #241a4a 60%, #0b0817); }
.scene.checker { background: repeating-conic-gradient(#d8d8e4 0 25%, #ffffff 0 50%) 0 0 / 28px 28px; }
.scene-label { position: absolute; right: 14px; bottom: 10px; font-size: 11.5px; color: #8b91c4;
  background: rgba(15,18,38,.75); padding: 3px 8px; border-radius: 6px; }

.drop-hint { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 50;
  background: rgba(30,36,90,.75); color: #fff; font: 700 20px 'Comfortaa', sans-serif; border: 3px dashed #8b93ff; }
body.dragging .drop-hint { display: flex; }

@media (max-width: 980px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; }
  .panel { overflow: visible; }
  .right { height: 80vh; position: sticky; top: 0; order: -1; }
}

/* карточки материалов */
.card .thumb .matsw { display: block; width: 96px; height: 30px; border-radius: 15px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -2px 4px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.35); }

/* баланс декора */
.balance { background: #0f1330; border: 1px solid #2a305c; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.balance .bhead { font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.balance .bbar { height: 6px; border-radius: 4px; background: #1c2250; overflow: hidden; }
.balance .bbar i { display: block; height: 100%; width: 0; background: #5ad19a; border-radius: 4px; transition: width .25s, background .25s; }
.balance[data-level="ok"] .bbar i { background: #8bd15a; }
.balance[data-level="dense"] .bbar i { background: #e8b84a; }
.balance[data-level="overload"] .bbar i { background: #ee6a5a; }
.balance .bbody { margin-top: 5px; font-size: 11px; color: #aeb4e6; }
.balance .tip { margin-top: 2px; color: #e8c97a; }
.balance .bact { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* вторая кнопка в верхней строке («Другая гамма») стоит рядом с кубиком, без своего авто-отступа */
button.dice.dice2 { margin-left: 0; width: 100%; }
.toprow2 { margin-top: 8px; }
