/* ===== Ветка editor-ux: удобство редактора (подключён последним — перекрывает style/edui.css) ===== */

/* вкладки: значок + полная подпись (ПК) / короткая (телефон) */
#editor .ed-tabs button .tico { font-style: normal; margin-right: 5px; opacity: .85; }
#editor .ed-tabs button .ts { display: none; }

/* виды одной кнопкой (расширенный вид) */
.eb-vviews { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 4px; z-index: 3; }
.eb-vviews button { margin: 0; min-width: 44px; min-height: 40px; padding: 0 8px; font-size: 13px; background: rgba(20,16,40,.82); }
/* подсказки поверх модели — полупрозрачные, не ловят касания (кроме кнопки «Понятно») */
.eb-status { pointer-events: none; }
.eb-hint { pointer-events: none; }
.eb-hint button { pointer-events: auto; }

/* ---------- телефон (портрет и узкий Android) ---------- */
@media (max-width: 760px) and (min-height: 521px) {
  /* шапка — тоньше, заголовок мелко */
  #editor > .card.ed { padding-top: 2px !important; row-gap: 2px !important; padding-bottom: calc(54px + env(safe-area-inset-bottom)) !important; }
  .ed-head { min-height: 40px !important; gap: 4px; margin-bottom: 2px; }
  #editor .ed-head h2 { font-size: 10px !important; letter-spacing: 0; }
  .ed-hbtns { gap: 3px; }
  .ed-hbtns button { min-width: 44px !important; min-height: 40px !important; height: 40px; font-size: 17px; }
  /* превью — крупнее: место взято у шапки, бюджета и нижней полосы */
  .ed-left #ed-pv, .ed-left > .pvbox > #ed-pv { height: 34vh !important; height: 34dvh !important; }
  .ed-left { gap: 2px !important; }
  .ed-left .budget { height: 18px !important; box-sizing: border-box; }
  .ed-left .budget span { display: block; font-size: 10px !important; line-height: 14px !important; }
  .ed-grid { margin-top: 2px !important; }
  /* вкладки: значок + короткая подпись, все 7 видны или листаются */
  #editor .ed-tabs { margin: 2px 0 0; gap: 2px; }
  #editor .ed-tabs button { min-height: 40px; padding: 0 9px; font-size: 12px; }
  #editor .ed-tabs button .tl { display: none; }
  #editor .ed-tabs button .ts { display: inline; }
  #editor .ed-tabs button .tico { margin-right: 3px; }
  /* полоса разделов — компактная */
  .ui-nav { padding: 2px 4px !important; gap: 3px !important; }
  .ui-nav button { min-height: 40px !important; padding: 0 8px !important; font-size: 12px !important; }
  /* шапки разделов/подразделов — ниже, шрифт мельче (цель пальцу ≥ 40 px) */
  .ui-sh { min-height: 42px !important; padding: 3px 6px 3px 4px !important; gap: 6px !important; }
  .ui-sh > .ui-t { font-size: 9px !important; }
  .ui-ico { width: 24px !important; height: 24px !important; font-size: 14px; }
  .ui-ssh { min-height: 40px !important; }
  .ui-ssh > .ui-t { font-size: 13px !important; }
  .ui-sec { margin: 4px 0 8px !important; }
  #editor .hint, #editor .ui-note { font-size: 12px; }
  /* нижняя полоса «Сохранить / Войти» — одна строка, 44 px */
  .ed-save { padding: 4px 6px calc(4px + env(safe-area-inset-bottom)) !important; }
  .ed-save button { min-height: 44px !important; height: 44px; font-size: 12px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
  .ed-save button.big { font-size: 10px !important; }

  /* расширенный вид: модель — большая часть экрана */
  .eb-head { padding: 3px 4px !important; }
  .eb-head .eb-modes button { min-height: 44px !important; font-size: 11px !important; }
  .eb-head .eb-modes button i { font-size: 15px !important; }
  .eb-view { height: 60dvh !important; }
  #ed-big.sheet-full .eb-view { height: 30dvh !important; }
  .eb-sheet { min-height: 40px !important; font-size: 12px !important; }
  /* строка состояния — одна-две строки мелко на полупрозрачной плашке */
  .eb-status { font-size: 11px !important; line-height: 1.3; top: 4px !important; left: 4px !important; right: 54px !important; padding: 2px 6px; background: rgba(11,9,24,.55); border-radius: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .eb-status:empty { display: none; }
  /* первая подсказка режима — внизу, мелко, не на модели */
  #ed-big .eb-hint { position: fixed; top: auto !important; bottom: 0; left: 0; right: 0; max-width: none !important; transform: none !important; font-size: 12px !important; line-height: 1.35; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important; border-radius: 10px 10px 0 0; background: rgba(16,13,34,.97) !important; max-height: 34dvh; overflow-y: auto; pointer-events: auto; z-index: 80; box-shadow: 0 -8px 24px rgba(0,0,0,.6); }
  .eb-hint button { min-height: 40px; font-size: 12px; margin: 4px 0 0; }
  .eb-vbtn { top: 50px !important; }
  .eb-vbtn button { height: 40px !important; min-height: 40px !important; font-size: 16px; }
  .eb-vviews { left: 4px; bottom: 4px; }
  .eb-vviews button { min-width: 44px; padding: 0 6px; font-size: 12px; }
}

/* ---------- телефон боком ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .ed-head { min-height: 36px !important; }
  .ed-head h2 { font-size: 10px !important; }
  #editor > .card.ed { padding-top: 2px !important; row-gap: 2px !important; }
  #editor .ed-head h2 { font-size: 10px !important; }
  .ed-hbtns button { min-width: 44px !important; min-height: 40px !important; height: 40px; font-size: 16px; }
  .ed-grid { margin-top: 2px !important; }
  .ed-left #ed-pv, .ed-left > .pvbox > #ed-pv { height: calc(100dvh - 124px) !important; }
  /* «во весь экран» — значок в углу, анимации — сеткой 2×2: модель свободна */
  .pvbox .ed-bigbtn { left: 6px !important; top: 6px !important; bottom: auto !important; transform: none !important; width: 44px; height: 44px; min-height: 44px; padding: 0 !important; border-radius: 10px; font-size: 20px; }
  .pvbox .ed-bigbtn .short { display: none !important; }
  .pvbox .ed-bigbtn .ico { display: inline !important; }
  .pvbox .pvanim { display: grid !important; grid-template-columns: 40px 40px; gap: 3px !important; left: 6px !important; top: auto !important; bottom: 6px !important; }
  .pvbox .pvanim button { width: 40px !important; min-width: 40px !important; height: 40px !important; min-height: 40px !important; }
  .pvbox .pvrot button { height: 40px !important; min-height: 40px !important; }
  .ed-save button { min-height: 40px !important; height: 40px; font-size: 11px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ed-save button.big { font-size: 10px !important; }
  #editor .ed-tabs button { min-height: 40px; padding: 0 8px; font-size: 12px; }
  #editor .ed-tabs button .tl { display: none; }
  #editor .ed-tabs button .ts { display: inline; }
  .ui-nav button { min-height: 40px !important; padding: 0 8px !important; font-size: 12px !important; }
  .ui-sh { min-height: 40px !important; padding: 2px 6px 2px 4px !important; }
  .ui-sh > .ui-t { font-size: 9px !important; }
  .ui-ico { width: 22px !important; height: 22px !important; }
  .ui-ssh { min-height: 40px !important; }
  .ui-ssh > .ui-t { font-size: 13px !important; }
  /* расширенный вид боком */
  .eb-head { padding: 2px 4px !important; }
  .eb-head .eb-modes button { min-height: 40px !important; flex-direction: row !important; gap: 4px !important; font-size: 11px !important; }
  .eb-head .eb-modes button i { font-size: 14px !important; }
  .eb-head .eb-close, .eb-head .eb-kind button { min-height: 40px !important; }
  .eb-status { font-size: 11px !important; line-height: 1.3; right: 52px !important; padding: 2px 6px; background: rgba(11,9,24,.55); border-radius: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .eb-status:empty { display: none; }
  /* первая подсказка режима — поверх панели настроек справа, не на модели */
  #ed-big .eb-hint { position: fixed; top: 46px !important; bottom: auto; left: auto; right: 0; width: 46vw; max-width: none !important; transform: none !important; font-size: 12px !important; line-height: 1.35; padding: 8px 10px !important; background: rgba(16,13,34,.97) !important; max-height: calc(100dvh - 52px); overflow-y: auto; pointer-events: auto; z-index: 80; box-shadow: -8px 0 24px rgba(0,0,0,.6); }
  /* кнопки вида — колонкой справа, виды — строкой слева внизу */
  .eb-vbtn { left: auto !important; right: 4px !important; top: 4px !important; bottom: auto !important; flex-direction: column; justify-content: flex-start !important; }
  .eb-vbtn button { width: 44px !important; max-width: 44px !important; height: 40px !important; min-height: 40px !important; flex: none !important; font-size: 15px; }
  .eb-vbtn button[data-act^="eb-turn"], .eb-vbtn button[data-act^="eb-tilt"] { display: none; }
  .eb-vviews { left: 4px; bottom: 4px; }
  .eb-vviews button { min-height: 40px; font-size: 12px; }
}

/* расширенный вид на телефоне: заголовок раздела панели — мельче */
@media (max-width: 760px), (max-height: 520px) {
  #ed-big .eb-side > .sec { font-size: 9px !important; min-height: 40px; padding-top: 4px !important; padding-bottom: 4px !important; }
}
/* ↶/↷: нечего отменять/повторять — тусклые (нажатие безвредно) */
#editor button.ux-off, #ed-big button.ux-off { opacity: .38; }

/* ---------- постоянная панель инструментов расширенного вида (#eb-tools) ---------- */
.eb-tools { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 3px; z-index: 3; padding: 3px; border-radius: 10px; background: rgba(11,9,24,.45); }
.eb-tools button { margin: 0; width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; font-size: 18px; line-height: 1; background: rgba(20,16,40,.85); border-radius: 8px; }
.eb-tools button.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 0 10px rgba(255,210,58,.35); }
.eb-tools button.tb-tog.on { border-color: #6ae8ff; box-shadow: 0 0 0 1px #6ae8ff inset; }
.eb-tools .tb-sep { height: 2px; margin: 2px 4px; background: rgba(255,255,255,.18); }
.eb-tools:empty { display: none; }
@media (max-width: 760px) and (min-height: 521px) {
  /* режимы уже в шапке — здесь только инструменты покраски и переключатели */
  .eb-tools { top: 42px; transform: none; left: 4px; padding: 2px; gap: 2px; }
  .eb-tools button.tb-mode { display: none; }
  .eb-tools button { width: 42px; height: 40px; font-size: 17px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .eb-tools { top: 40px; left: 4px; transform: none; flex-direction: row; padding: 2px; gap: 2px; }
  .eb-tools button.tb-mode { display: none; }
  .eb-tools .tb-sep { width: 2px; height: auto; margin: 4px 2px; }
}
/* свойства выбранной на превью детали — подсветка, когда панель прокрутилась к ним */
@keyframes ux-flash { 0% { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255,210,58,.55); } 100% { box-shadow: 0 0 0 0 transparent; } }
#editor .ux-flash { animation: ux-flash 1.4s ease-out 1; }
@media (prefers-reduced-motion: reduce) { #editor .ux-flash { animation: none; outline: 2px solid var(--gold); } }

/* ---------- поиск по разделам (edux.js) ---------- */
.ux-find { position: fixed; z-index: 90; left: 50%; top: 56px; transform: translateX(-50%); width: min(520px, calc(100vw - 16px)); box-sizing: border-box; display: grid; grid-template-columns: 1fr 44px; gap: 6px; padding: 8px; background: rgba(16,13,34,.98); border: 2px solid var(--gold); border-radius: 10px; box-shadow: 0 10px 40px #000c; }
.ux-find.hidden { display: none !important; }
.ux-find input { min-height: 44px; font-size: 16px; margin: 0; width: 100%; box-sizing: border-box; }
.ux-find > button { margin: 0; min-height: 44px; }
#ux-find-r { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 3px; max-height: min(60vh, 420px); max-height: min(60dvh, 420px); overflow-y: auto; }
#ux-find-r button { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0; min-height: 42px; padding: 4px 10px; text-align: left; }
#ux-find-r button small { color: var(--dim, #9a96c0); font-size: 12px; white-space: nowrap; }
#ux-find-r .ux-none { color: var(--dim, #9a96c0); font-size: 13px; padding: 6px 4px; }
#editor .ux-flash, #ed-big .ux-flash { animation: ux-flash 1.4s ease-out 1; }

/* ---------- недавние цвета и модули ---------- */
.ux-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 6px; }
.ux-recent .ux-rl { font-size: 11px; color: var(--dim, #9a96c0); text-transform: uppercase; letter-spacing: 1px; margin-right: 4px; }
.ux-rmods { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ux-rmods::-webkit-scrollbar { display: none; }
.ux-rmods button { flex: none; margin: 0; white-space: nowrap; }
.ux-rmods button.on { border-color: var(--gold); color: var(--gold); }
@media (max-width: 760px), (max-height: 520px) {
  .ux-find { top: 6px; }
  .ux-rmods button { min-height: 40px; }
}
/* день / ночь */
button.ux-night.on { border-color: #8aa0ff; color: #ffe08a; box-shadow: 0 0 10px rgba(138,160,255,.5); }
/* телефон: раздел и его первый подраздел («Основа» → «Пресет скелета») — без пустот между шапками */
@media (max-width: 760px) and (min-height: 521px), (max-height: 520px) and (orientation: landscape) {
  #editor .ui-sh .ui-ico { display: none; }
  #editor .ui-sh { padding-left: 8px !important; }
  #editor .ui-sb { padding: 2px 4px 6px !important; }
  #editor .ui-sb > .ui-sub:first-child { margin-top: 0 !important; }
  #editor .ui-ssh { min-height: 40px !important; padding-top: 0 !important; padding-bottom: 0 !important; }
  #editor .ui-ssb { padding-left: 4px !important; }
}

/* ---------- «Как в игре» (editor/gamepv.rs) ---------- */
.ed-gpv { position: fixed; inset: 0; z-index: 85; background: rgba(6,5,14,.78); display: flex; align-items: center; justify-content: center; padding: 12px; box-sizing: border-box; }
.ed-gpv.hidden { display: none !important; }
.gpv-box { width: min(900px, 100%); height: min(620px, 100%); display: flex; flex-direction: column; gap: 6px; background: #120f22; border: 2px solid var(--gold); border-radius: 12px; padding: 8px; box-sizing: border-box; box-shadow: 0 12px 50px #000c; }
.gpv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gpv-head > b { color: var(--gold); font-family: "Press Start 2P", monospace; font-size: 11px; font-weight: normal; }
.gpv-head .seg { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.gpv-head button { margin: 0; min-width: 44px; min-height: 40px; padding: 0 10px; }
.gpv-head .gpv-x { margin-left: auto; }
#ed-gpvcv { flex: 1; min-height: 0; width: 100%; border-radius: 8px; image-rendering: pixelated; }
.gpv-note { font-size: 12px; color: var(--dim, #9a96c0); }
@media (max-width: 760px), (max-height: 520px) {
  .ed-gpv { padding: 0; }
  .gpv-box { width: 100%; height: 100%; border-radius: 0; border-width: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .gpv-head > b { display: none; }
  .gpv-head .seg { flex-wrap: nowrap; gap: 3px; }
  .gpv-head button { padding: 0 6px; min-width: 40px; }
  .gpv-note { font-size: 11px; }
}
/* телефон-портрет: в колонке превью вместо ☾ — 🎮 (ночь есть внутри «Как в игре» и в расширенном виде) */
@media (max-width: 760px) and (min-height: 521px) {
  .pvbox .pvrot button.ux-night { display: none; }
}
/* телефон: «Основа › Пресет скелета» — одна шапка (edui.js: merge) */
.ui-sub > summary .ux-pre { display: none; }
@media (max-width: 760px) and (min-height: 521px), (max-height: 520px) and (orientation: landscape) {
  #editor .ui-sec.ux-merged > summary { display: none; }
  #editor .ui-sec.ux-merged > .ui-sb { padding-top: 0 !important; }
  #editor .ui-sub > summary .ux-pre { display: inline; flex: none; margin-right: 6px; color: var(--gold); font-size: 12px; font-weight: normal; opacity: .9; white-space: nowrap; }
}
