/* ===== Редактор: система разделов (client/src/editor/ui_kit.rs, web/edui.js) =====
   Вкладка → раздел (.ui-sec: рамка-карточка, иконка, пиксельный заголовок, акцент фракции)
   → подраздел (.ui-sub: меньший заголовок, линия слева) → группа (.ui-grp: подпись над рядом)
   → элементы (карточки .cards, ползунки .sline, переключатели .seg). Файл подключён после
   style.css/ui.css/g2.css и перекрывает их только внутри #editor и #ed-big. */
:root {
  --ui-acc: #e8c45a;          /* акцент фракции: полоса и иконка раздела */
  --ui-sel: #e8c45a;          /* выбранное */
  --ui-sub: #6fdcff;          /* подраздел */
  --ui-pane: #0f0c1e;         /* фон панели вкладки */
  --ui-card: #17122e;         /* фон раздела */
  --ui-card-h: #1d1740;       /* шапка раздела */
  --ui-item: #1b1634;         /* карточка выбора */
  --ui-item-h: #251e4a;       /* наведено */
  --ui-item-on: #30265c;      /* выбрано */
  --ui-line: #3a3266;
  --ui-line2: #2a2450;
}
body[data-edfac="0"] { --ui-acc: #ff4a50; }
body[data-edfac="1"] { --ui-acc: #b06aff; }
body[data-edfac="2"] { --ui-acc: #9fb4cf; }

/* ---- шапка вкладок: вкладка «прирастает» к панели */
#editor .ed-tabs { gap: 3px; margin: 0; padding: 0 2px; border-bottom: 2px solid var(--ui-line); flex-wrap: wrap; }
#editor .ed-tabs button { position: relative; margin: 0 0 -2px; padding: 9px 12px 8px; border: 2px solid transparent; border-bottom: 0; border-radius: 0; background: transparent; color: var(--dim); font-size: 13px; font-weight: bold; }
#editor .ed-tabs button:hover { color: var(--text); background: #1a1534; }
#editor .ed-tabs button.on { color: var(--gold); background: var(--ui-pane); border-color: var(--ui-line); box-shadow: inset 0 3px 0 var(--ui-acc); }
#editor .ed-tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--ui-pane); }

/* ---- полоса разделов текущей вкладки (строит edui.js) */
.ui-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 6px; background: var(--ui-pane); border: 2px solid var(--ui-line); border-top: 0; border-bottom: 1px solid var(--ui-line2); }
.ui-nav[hidden] { display: none; }
.ui-nav::-webkit-scrollbar { display: none; }
.ui-nav button { flex: none; display: inline-flex; align-items: center; gap: 6px; margin: 0; min-height: 30px; padding: 3px 10px; border: 1px solid var(--ui-line); border-radius: 0; background: #16122c; color: var(--dim); font-size: 12px; white-space: nowrap; }
.ui-nav button i { font-style: normal; color: var(--ui-acc); }
.ui-nav button:hover { color: var(--text); border-color: #6a5fb0; }
.ui-nav button.on { color: #120e04; background: var(--gold); border-color: var(--gold); }
.ui-nav button.on i { color: #120e04; }

/* ---- панель вкладки */
#editor #ed-pane { background: var(--ui-pane); border: 2px solid var(--ui-line); border-top: 0; padding: 6px 8px 10px; }
#editor .ed-right { display: flex; flex-direction: column; min-width: 0; }

/* ---- раздел */
.ui-sec { margin: 8px 0 12px; background: var(--ui-card); border: 2px solid var(--ui-line); box-shadow: 0 0 0 2px #06050c, 0 4px 14px rgba(0,0,0,.35); }
.ui-sec > summary { list-style: none; }
.ui-sec > summary::-webkit-details-marker, .ui-sub > summary::-webkit-details-marker { display: none; }
.ui-sh { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px 6px 8px; cursor: pointer; user-select: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--ui-acc) 26%, var(--ui-card-h)) 0, var(--ui-card-h) 46%, var(--ui-card) 100%);
  border-left: 4px solid var(--ui-acc); }
.ui-sec[open] > .ui-sh { border-bottom: 2px solid var(--ui-line2); }
.ui-sh:hover { filter: brightness(1.12); }
.ui-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; font-style: normal; font-size: 16px; line-height: 1; color: var(--gold);
  background: #0a0816; border: 2px solid var(--ui-acc); box-shadow: inset 0 0 0 2px #000, 0 0 10px color-mix(in srgb, var(--ui-acc) 45%, transparent); }
.ui-sh > .ui-t { flex: 1 1 auto; min-width: 0; font-family: "Press Start 2P", monospace; font-size: 11px; line-height: 1.55; letter-spacing: .5px; color: var(--gold); text-shadow: 2px 2px 0 #000; font-weight: normal; overflow-wrap: anywhere; }
.ui-x { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; font: 12px/1.3 "Ubuntu Mono", ui-monospace, monospace; color: var(--dim); text-shadow: none; }
.ui-x button { margin: 0; }
.ui-n { display: inline-block; min-width: 24px; padding: 1px 6px; text-align: center; background: #0a0816; border: 1px solid var(--ui-line); color: var(--gold); font-weight: bold; }
.ui-chev { flex: none; width: 9px; height: 9px; margin: 0 4px 3px 2px; border-right: 3px solid var(--dim); border-bottom: 3px solid var(--dim); transform: rotate(-45deg); transition: transform .15s; }
details[open] > summary > .ui-chev { transform: rotate(45deg); margin-bottom: 6px; }
.ui-sb { padding: 8px 10px 10px; }
.ui-sb > :first-child, .ui-ssb > :first-child { margin-top: 0; }

/* ---- подраздел */
.ui-sub { margin: 12px 0 6px; }
.ui-sub:first-child { margin-top: 2px; }
.ui-ssh { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 6px 4px 10px; cursor: pointer; user-select: none;
  background: linear-gradient(90deg, #1f1a40, rgba(31,26,64,0)); border-left: 3px solid var(--ui-sub); }
.ui-ssh:hover { background: linear-gradient(90deg, #28225a, rgba(40,34,90,0)); }
.ui-ssh > .ui-t { flex: 1 1 auto; min-width: 0; color: #c9f2ff; font-size: 14px; font-weight: bold; letter-spacing: .3px; }
.ui-ssh .ui-chev { border-color: #6f86a8; width: 8px; height: 8px; border-width: 0 2px 2px 0; }
.ui-ssb { margin-left: 1px; padding: 8px 0 4px 12px; border-left: 2px solid var(--ui-line2); }

/* ---- группа: подпись над рядом элементов (и старые .sec/label внутри разделов) */
.ui-grp, .ui-sb > label:not(.chk):not(.fbtn), .ui-ssb > label:not(.chk):not(.fbtn), .ui-sb > .sec, .ui-ssb > .sec {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; padding: 0; color: #a9a2cc; font-size: 13px; font-weight: bold; letter-spacing: .3px; }
.ui-grp { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.ui-grp::after, .ui-sb > label:not(.chk):not(.fbtn)::after, .ui-ssb > label:not(.chk):not(.fbtn)::after, .ui-sb > .sec::after, .ui-ssb > .sec::after {
  content: ""; flex: 1 1 20px; min-width: 20px; height: 2px; background: linear-gradient(90deg, var(--ui-line), transparent); }
.ui-grp > span:first-child { flex: none; }
.ui-grp .ui-x { text-transform: none; letter-spacing: 0; order: 3; }
.ui-sb > label b, .ui-ssb > label b { color: var(--gold); }
.ui-note { position: relative; padding: 6px 8px 6px 26px; background: #120f24; border: 1px dashed #2e2856; color: #9c96c0; }
.ui-note::before { content: "i"; position: absolute; left: 7px; top: 6px; width: 13px; height: 13px; font: bold 10px/13px "Ubuntu Mono", monospace; text-align: center; color: #0a0816; background: var(--ui-sub); }

/* ---- карточки выбора: одна система для всех сеток */
#editor .cards { gap: 6px; }
#editor .cards button, #ed-big .cards button { position: relative; border-radius: 0; border: 2px solid #342d5c; background: var(--ui-item); transition: border-color .1s, background .1s; }
#editor .cards button:hover:not(:disabled), #ed-big .cards button:hover:not(:disabled) { border-color: #7d70c8; background: var(--ui-item-h); }
#editor .cards button.on, #ed-big .cards button.on, #editor .cards.thumbs button.on { border-color: var(--ui-sel); background: var(--ui-item-on); box-shadow: 0 0 0 1px #000, 0 0 12px rgba(232,196,90,.28); }
#editor .cards button.on::before, #ed-big .cards button.on::before { content: "✓"; position: absolute; top: -2px; right: -2px; z-index: 1; width: 18px; height: 18px; font: bold 12px/18px "Ubuntu Mono", monospace; text-align: center; color: #120e04; background: var(--ui-sel); }
#editor .cards button:disabled { opacity: .38; filter: grayscale(.7); cursor: not-allowed; }
#editor .cards button.locked, #editor .cards.thumbs button.locked { opacity: .5; filter: grayscale(.5); }
#editor .cards button b { color: var(--text); }
#editor .cards button.on b { color: var(--gold); }
#editor .cards.thumbs button img.th, #editor .cards.thumbs button.nonecard .none { border-radius: 0; box-shadow: inset 0 0 0 1px #2a2450; }

/* ---- полоса категорий (модули, классы альтмодов) */
#editor .modcats { gap: 4px; margin: 0 0 8px; }
#editor .modcats button { border-radius: 0; background: var(--ui-item); border: 2px solid #342d5c; min-height: 32px; }
#editor .modcats button:hover { border-color: #7d70c8; }
#editor .modcats button.on { border-color: var(--ui-sel); background: var(--ui-item-on); color: var(--gold); }
#editor .modcats button.on small { color: var(--gold); }
#editor .modcats.grouped { display: flex; flex-wrap: wrap; gap: 6px; }
.mcg { flex: 1 1 auto; border: 1px solid var(--ui-line2); background: #120f24; padding: 4px; min-width: 0; }
.mcg-t { display: block; margin: 0 0 4px 2px; font-size: 11px; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; color: #8f88b8; }
.mcg.on { border-color: color-mix(in srgb, var(--ui-sel) 55%, var(--ui-line)); }
.mcg.on .mcg-t { color: var(--gold); }
.mcg-b { display: flex; flex-wrap: wrap; gap: 3px; }
.mcg-b button { flex: 1 1 auto; justify-content: flex-start; }

/* ---- поиск: заметный, с лупой */
#editor #ed-search, #editor #ed-asearch { margin: 2px 0 8px; min-height: 40px; padding-left: 36px; border: 2px solid #4a5f9a; border-radius: 0; background: #0c0a1a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Cpath fill='%236fdcff' d='M5 1h4v1h1v1h1v1h1v4h-1v1h-1v1H9v1H5v-1H4V9H3V8H2V4h1V3h1V2h1zm0 2v1H4v4h1v1h4V8h1V4H9V3zM11 10h1v1h1v1h1v1h1v2h-2v-1h-1v-1h-1v-1h-1v-1h1z'/%3E%3C/svg%3E") no-repeat 12px 50%; font-size: 14px; }
#editor #ed-search:focus, #editor #ed-asearch:focus { outline: none; border-color: var(--ui-sub); box-shadow: 0 0 0 2px rgba(111,220,255,.25); }
#editor #ed-search::placeholder, #editor #ed-asearch::placeholder { color: #8a9ac0; }

/* ---- ползунки: строка «подпись — дорожка — значение ↺» */
#editor .sline, #ed-big .sline { margin: 0 0 3px; padding: 2px 6px; background: #110e22; border: 1px solid #211c3c; }
#editor .sline:hover, #ed-big .sline:hover { border-color: #3a3266; }
#editor .sline > label, #ed-big .sline > label { color: #d6d1ee; font-size: 12.5px; text-transform: none; letter-spacing: 0; }
#editor .sline .sv, #ed-big .sline .sv { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--gold); font-variant-numeric: tabular-nums; }
#editor .sline .rst, #ed-big .sline .rst { margin: 0; padding: 0; width: 28px; height: 26px; min-width: 28px; border-radius: 0; opacity: .65; }
#editor .sline .rst:hover, #ed-big .sline .rst:hover { opacity: 1; border-color: var(--gold); }
#editor .props .pname { margin: 10px 0 4px; color: var(--ui-sub); font-weight: bold; }
#editor input[type=range], #ed-big input[type=range] { -webkit-appearance: none; appearance: none; height: 30px; background: transparent; border: 0; padding: 0 2px; cursor: pointer; touch-action: pan-y; }
#editor input[type=range]::-webkit-slider-runnable-track, #ed-big input[type=range]::-webkit-slider-runnable-track { height: 8px; background: linear-gradient(90deg, #3fa8d0 0, #6fdcff var(--p, 50%), #2a2450 var(--p, 50%)); box-shadow: 0 0 0 2px #07060e; }
#editor input[type=range]::-webkit-slider-thumb, #ed-big input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 22px; margin-top: -7px; background: var(--gold); border: 2px solid #120e04; box-shadow: inset -3px -3px 0 #a8862a, 0 0 0 1px #6a5a28; }
#editor input[type=range]::-moz-range-track, #ed-big input[type=range]::-moz-range-track { height: 8px; background: #2a2450; box-shadow: 0 0 0 2px #07060e; }
#editor input[type=range]::-moz-range-progress, #ed-big input[type=range]::-moz-range-progress { height: 8px; background: #6fdcff; }
#editor input[type=range]::-moz-range-thumb, #ed-big input[type=range]::-moz-range-thumb { width: 16px; height: 22px; border-radius: 0; background: var(--gold); border: 2px solid #120e04; }
#editor input[type=range]:focus-visible { outline: 1px dashed var(--ui-sub); outline-offset: 2px; }

/* ---- переключатели, списки, ряды */
#editor #ed-pane .seg button, #ed-big .eb-side .seg button { border-radius: 0; }
#editor #ed-pane .seg button.on, #ed-big .eb-side .seg button.on { border-color: var(--ui-sel); color: var(--gold); background: var(--ui-item-on); }
#editor #ed-pane .seg { flex-wrap: wrap; margin: 2px 0 6px; }
#editor .ptools .seg button { flex: 1 0 auto; min-width: 44px; }
#editor .ptools .ui-grp { margin: 6px 0 2px; }
#editor #ed-pane .actions button.on, #editor #ed-pane .ui-x button.on, #ed-big .eb-side .sec button.on, #ed-big .eb-side .ui-x button.on { border-color: var(--ui-sel); color: var(--gold); background: var(--ui-item-on); }
#editor .bones, #ed-big .bones { gap: 3px; padding: 4px; background: #0c0a1a; border: 1px solid var(--ui-line2); }
#editor .bones button, #ed-big .bones button { border-radius: 0; border-width: 1px; background: #19142f; }
#editor .bones button.on, #ed-big .bones button.on { border-color: var(--ui-sel); color: var(--gold); background: var(--ui-item-on); }
#editor .skrow { padding: 3px 6px; background: #110e22; border: 1px solid #211c3c; }
#editor .actions { gap: 6px; margin: 8px 0 4px; }
#editor #ed-pane .actions button, #editor #ed-pane .installed button { border-radius: 0; }
#editor .installed { padding: 4px; background: #0c0a1a; border: 1px dashed var(--ui-line2); margin: 4px 0 8px; }
#editor .installed::before { content: "Стоит:"; align-self: center; margin: 0 4px; color: var(--dim); font-size: 12px; }
#editor .installed span.on button { border-color: var(--ui-sel); color: var(--gold); }
#editor .card-stats { padding: 6px 8px; background: #0c0a1a; border: 1px solid var(--ui-line2); }
#editor .scheme .srow { padding: 2px 6px; background: #110e22; border: 1px solid #211c3c; }
#editor .tag { border-radius: 0; }
#editor .spark { border-radius: 0; background: #0c0a1a; }
#editor #ed-pane > .hint, #editor .ui-sb > .hint:not(.ui-note), #editor .ui-ssb > .hint:not(.ui-note) { padding-left: 2px; }
#editor .skin { border-radius: 0; background: var(--ui-item); border-color: #342d5c; }
#editor .pwrap { border-radius: 0; }

/* ---- «ещё N» в обзоре классов альтмодов, число в полосе классов, выбранная деталь */
#editor .cards.thumbs button.morecard { justify-content: center; border-style: dashed; background: #120f24; }
#editor .cards.thumbs button.morecard .more { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; font: 18px "Press Start 2P", monospace; color: var(--ui-sub); background: #0c0a1a; box-shadow: inset 0 0 0 1px #2a2450; }
#editor .modcats .mcn { display: inline-block; min-width: 18px; margin-left: 2px; padding: 0 3px; text-align: center; color: #8f88b8; background: #0a0816; }
#editor .modcats button.on .mcn { color: var(--gold); }
.ui-pick { margin: 6px 0 10px; padding: 6px 8px 4px; background: #1a1538; border: 2px solid color-mix(in srgb, var(--ui-sel) 60%, var(--ui-line)); box-shadow: 0 0 10px rgba(232,196,90,.15); }
.ui-pick > .ui-grp { margin-top: 0; color: var(--gold); }
/* «⇪ Код этого облика» во вкладке «Кто вы» — только на телефоне (на ПК код скина всегда под превью) */
.ui-codebtn { display: none; }
#ed-err:empty { display: none; }

/* ---- расширенный вид: те же заголовки, но компактнее (заголовки .sec в боковой панели) */
#ed-big .eb-side > .sec { display: flex; align-items: center; gap: 8px; margin: 12px -10px 8px; padding: 8px 10px; min-height: 38px; font-family: "Press Start 2P", monospace; font-size: 10px; line-height: 1.6; font-weight: normal; color: var(--gold); text-shadow: 2px 2px 0 #000;
  background: linear-gradient(90deg, color-mix(in srgb, var(--ui-acc) 24%, #1d1740) 0, #1d1740 50%, transparent); border-left: 4px solid var(--ui-acc); border-top: 1px solid var(--ui-line2); border-bottom: 1px solid var(--ui-line2); }
#ed-big .eb-side > .sec:first-child, #ed-big .eb-side > .eb-altsel + .sec { margin-top: 0; }
#ed-big .eb-side > .sec .tag, #ed-big .eb-side > .sec button { font-family: "Ubuntu Mono", ui-monospace, monospace; text-shadow: none; }
#ed-big .eb-side > .sec button { margin-left: auto; }
#ed-big .eb-side > label:not(.chk) { color: #a9a2cc; font-size: 12px; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 6px; }
#ed-big .eb-side .ui-sec { margin: 8px -4px 10px; }
#ed-big .eb-side .ui-sh .ui-t { font-size: 10px; }
#ed-big .eb-pats button, #ed-big .eb-side button { border-radius: 0; }
#ed-big .eb-pats button.on { border-color: var(--ui-sel); }
#ed-big .eb-det > summary { padding: 6px 8px; background: #1b1638; border-left: 3px solid var(--ui-sub); color: #c9f2ff; }

/* ---- телефон и планшет */
@media (max-width: 760px), (max-height: 520px) {
  #editor .ed-tabs { border-bottom-width: 2px; padding: 0; gap: 2px; }
  #editor .ed-tabs button { min-height: 44px; padding: 0 12px; font-size: 14px; }
  .ui-nav { flex: none; padding: 4px; gap: 4px; }
  .ui-nav { padding: 3px 4px; }
  .ui-nav button { min-height: 38px; padding: 0 10px; font-size: 13px; }
  #editor #ed-pane { padding: 4px 6px 12px; }
  .ui-sec { margin: 6px 0 10px; }
  .ui-sh { min-height: 50px; padding: 6px 8px 6px 6px; gap: 8px; }
  .ui-sh > .ui-t { font-size: 10px; }
  .ui-ico { width: 30px; height: 30px; }
  .ui-sb { padding: 6px 6px 8px; }
  .ui-ssh { min-height: 46px; }
  .ui-ssh > .ui-t { font-size: 15px; }
  .ui-ssb { padding-left: 8px; }
  .ui-x { max-width: 46%; }
  /* категории и классы — одна полоса, листается пальцем (не съедает высоту панели) */
  #editor .modcats, #editor .modcats.grouped { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; padding-bottom: 2px; }
  #editor .modcats::-webkit-scrollbar { display: none; }
  #editor .modcats > button { flex: none; }
  .mcg { flex: none; }
  .mcg-b { flex-wrap: nowrap; }
  .mcg-b button { flex: none; }
  #editor .modcats button { min-height: 44px; white-space: nowrap; }
  #editor .ed-tabs button:not(.on) { background: #15112a; border-color: #241e44; }
  .ui-ssh .ui-x .tag { display: none; }
  .ui-x .tag { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #editor #ed-search, #editor #ed-asearch { min-height: 46px; font-size: 15px; }
  #editor input[type=range]::-webkit-slider-thumb, #ed-big input[type=range]::-webkit-slider-thumb { width: 22px; height: 28px; margin-top: -10px; }
  #editor input[type=range]::-moz-range-thumb, #ed-big input[type=range]::-moz-range-thumb { width: 22px; height: 28px; }
  #editor input[type=range], #ed-big input[type=range] { height: 40px; }
  #editor .sline, #ed-big .sline { padding: 4px 6px; }
  #editor .sline .rst, #ed-big .sline .rst { width: 44px; min-width: 44px; height: 40px; }
  #ed-big .eb-side > .sec { margin-left: -10px; margin-right: -10px; }
}
/* телефон: код скина — не под превью (съедал место панели), а листом по кнопке из «Кто вы → Скины» */
@media (max-width: 760px), (max-height: 520px) {
  .ui-codebtn { display: inline-flex; align-items: center; }
  .ed-left > .ed-code { display: none; }
  body.ed-code-open .ed-left > .ed-code { display: block; position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 45; max-height: 70dvh; overflow-y: auto; padding: 10px 12px 12px; background: #15112a; border-top: 3px solid var(--ui-acc); box-shadow: 0 -10px 30px rgba(0,0,0,.6); }
  .ed-code .ed-codex { float: right; margin: 0 0 6px 8px; min-width: 44px; min-height: 44px; padding: 0; font-size: 18px; }
  .ed-code .ed-coderow { display: flex; gap: 6px; margin-top: 6px; }
  .ed-code .ed-coderow > * { flex: 1; min-width: 0; min-height: 44px; }
}
.ed-code .ed-codex { display: none; }
body.ed-code-open .ed-code .ed-codex { display: inline-block; }
@media (prefers-reduced-motion: reduce) { .ui-chev { transition: none; } }
/* планшет и любой сенсорный экран: цели касания не меньше 40 px (как в style.css) */
@media (pointer: coarse) {
  #editor .modcats button, .ui-nav button { min-height: 40px; }
  #editor .sline .rst, #ed-big .sline .rst { width: 40px; min-width: 40px; height: 40px; }
}
