/* ============================================================================
 * lyss/ux.css — общий UX-набор кастомайзеров (см. lyss/ux.js)
 * Иерархия: Preview — главный холст; навигация и настройки вторичны, спокойные
 * тона, один акцент (--acc) только для активного и главного действия.
 * ========================================================================== */

:root {
  --ux-top: 52px;
  --ux-rail: 76px;
  --ux-panel: 360px;
  --ux-r: 10px;
  --ux-focus: #b9c1ff;
}

/* ---- фокус с клавиатуры: виден всегда, мышью не мешает ---- */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ux-focus); outline-offset: 2px; border-radius: 8px; }
.ux-card:focus-visible { outline-offset: -2px; }

/* ---- общая раскладка ---- */
.ux-shell { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.ux-top { height: var(--ux-top); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--bg2); border-bottom: 1px solid var(--line); position: relative; z-index: 30; }
.ux-top__brand { display: flex; flex-direction: column; line-height: 1.1; margin-right: 6px; min-width: 0; }
.ux-top__brand b { font: 700 15px 'Comfortaa', sans-serif; white-space: nowrap; }
.ux-top__brand small { color: var(--mute); font-size: 10.5px; white-space: nowrap; }
.ux-top__sp { flex: 1; min-width: 8px; }
.ux-group { display: inline-flex; align-items: center; gap: 2px; }
.ux-top button, .ux-qe button, .ux-tr button { padding: 6px 10px; font-size: 12px; }
.ux-top button.ghost, .ux-qe button.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line2); color: var(--ink2); }
.ux-top button.ghost:hover, .ux-qe button.ghost:hover { background: #232a55; }
.ux-top button[disabled] { opacity: .35; cursor: default; }
.ux-icon-btn { width: 30px; height: 30px; padding: 0 !important; display: inline-grid; place-items: center; font-size: 15px !important;
  background: transparent; color: var(--ink2); border-radius: 8px; }
.ux-icon-btn:hover { background: #232a55; color: #fff; }
.ux-find { min-width: 190px; text-align: left; display: inline-flex; gap: 8px; align-items: center; color: var(--mute) !important; }
.ux-find kbd { margin-left: auto; font: 600 10.5px ui-monospace, Consolas, monospace; padding: 1px 5px; border-radius: 5px; background: #0f1330; color: var(--ink2); }
.ux-split { display: inline-flex; }
.ux-split > button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ux-split > button:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 6px 7px; margin-left: 1px; }

.ux-app { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--ux-rail) var(--ux-panel) minmax(0, 1fr); }
#railHost { display: contents; }
body.ux-panel-hidden .ux-app { grid-template-columns: var(--ux-rail) minmax(0, 1fr); }
body.ux-panel-hidden .ux-panel { display: none; }
body.ux-focus .ux-app { grid-template-columns: minmax(0, 1fr); }
body.ux-focus .ux-rail, body.ux-focus .ux-panel, body.ux-focus .ux-qe, body.ux-focus .ux-top > :not(.ux-keep) { display: none !important; }
body.ux-focus .ux-top { background: transparent; border: 0; position: absolute; right: 8px; top: 8px; width: auto; height: auto; z-index: 60; }
body.ux-focus .ux-top__brand { display: none; }
body.ux-focus .ux-top .ux-keep { display: inline-flex !important; }

/* ---- рейка ---- */
.ux-rail { display: flex; flex-direction: column; gap: 4px; padding: 10px 6px; background: var(--bg2); border-right: 1px solid var(--line); overflow-y: auto; }
.ux-rail__b { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%; padding: 9px 2px; background: transparent !important;
  color: var(--mute); border-radius: 12px; font-size: 10.5px; font-weight: 700; letter-spacing: .01em; }
.ux-rail__b:hover { background: #1c2248 !important; color: var(--ink2); }
.ux-rail__b.on { background: #262e66 !important; color: #fff; box-shadow: inset 0 0 0 1px #4b58c8; }
.ux-rail__i { font-size: 20px; line-height: 1; }
.ux-rail__t { line-height: 1.1; text-align: center; }
.ux-rail__sp { flex: 1; }

/* ---- панель ---- */
.ux-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #10132b; border-right: 1px solid var(--line); }
.ux-panel__h { flex: none; padding: 12px 14px 0; background: #10132b; }
.ux-panel__t { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ux-panel__t h2 { font: 700 15px 'Comfortaa', sans-serif; flex: 1; }
.ux-panel__b { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 90px; scroll-behavior: smooth; }
.ux-panel__b::-webkit-scrollbar { width: 9px; } .ux-panel__b::-webkit-scrollbar-thumb { background: #2c3260; border-radius: 6px; }
.ux-panel__f { flex: none; padding: 8px 14px; border-top: 1px solid var(--line); display: flex; gap: 6px; background: #10132b; }
.ux-panel__f button { flex: 1; }

.ux-tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.ux-tabs::-webkit-scrollbar { display: none; }
.ux-tab { background: transparent !important; color: var(--mute); padding: 8px 11px !important; border-radius: 8px 8px 0 0; font-weight: 700; position: relative; }
.ux-tab:hover { color: var(--ink2); }
.ux-tab.on { color: #fff; box-shadow: inset 0 -2px 0 var(--acc); }

/* ---- сцена ---- */
.ux-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0b0d1e; position: relative; }
.ux-stage .pv-stage { flex: 1; min-height: 160px; }
.ux-qe { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.ux-qe__sp { flex: 1; }
.ux-pvbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #0f1229; border-bottom: 1px solid var(--line); }
.ux-pvbar select { padding: 5px 8px; border-radius: 8px; background: #0b0e24; border: 1px solid var(--line2); font-size: 12px; }
.ux-pvbar button { padding: 5px 10px; font-size: 12px; }
.ux-pvbar .ghost, .ux-tr .ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line2); color: var(--ink2); }
.ux-pvbar .ghost:hover, .ux-tr .ghost:hover { background: #232a55; }
.ux-tr__r select { padding: 4px 6px; border-radius: 8px; background: #0b0e24; border: 1px solid var(--line2); font-size: 12px; }
.ux-focus-exit { display: none; }
body.ux-focus .ux-focus-exit { display: inline-flex !important; }
body.ux-focus .ux-pvbar { display: none; }
body.ux-focus .ux-tr { background: transparent; border: 0; }
.ux-flash { animation: ux-flash 1.6s ease; border-radius: 8px; }
@keyframes ux-flash { 0%,60% { background: rgba(123,134,255,.35); box-shadow: 0 0 0 4px rgba(123,134,255,.35); } 100% { background: transparent; box-shadow: none; } }
.ux-qe__l { color: var(--mute); font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-right: 2px; }
.ux-qe__g { display: inline-flex; align-items: center; gap: 6px; }
.ux-qe__g > span { color: var(--mute); font-size: 11.5px; }
.ux-qe .seg button { padding: 4px 8px; font-size: 11.5px; }
.ux-qe__sw { display: inline-flex; gap: 2px; margin-right: 2px; }
.ux-qe__sw i { width: 9px; height: 14px; border-radius: 3px; }
.ux-tr { flex: none; background: var(--bg2); border-top: 1px solid var(--line); padding: 6px 12px 8px; }
.ux-tr__r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ux-tr .tm { font-variant-numeric: tabular-nums; color: #fff; font-size: 12px; min-width: 120px; }
.ux-tr canvas { display: block; width: 100%; height: 96px; border-radius: 8px; background: #0c0f26; cursor: ew-resize; touch-action: none; }
.ux-tr .tl__sw { margin-left: auto; font-size: 11.5px; }
.ux-ov { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: auto; cursor: default; touch-action: none; }
.ux-ov.is-hit { cursor: pointer; } .ux-ov.is-drag { cursor: grabbing; }

/* плашка «результат Random» поверх превью (только в редакторе) */
.ux-result { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 12px; border-radius: 12px; background: rgba(22,26,60,.94); border: 1px solid #3d4794; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 92%; }
.ux-result b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-result small { color: var(--mute); }
.ux-result[hidden] { display: none; }

/* ---- popover ---- */
.ux-pop { position: fixed; z-index: 80; min-width: 220px; max-width: min(92vw, 520px); overflow: auto; padding: 10px; border-radius: 14px;
  background: #181d44; border: 1px solid var(--line2); box-shadow: 0 18px 50px rgba(0,0,0,.6); }
.ux-pop h4 { font: 700 12px 'Comfortaa', sans-serif; margin: 2px 0 8px; color: #fff; }
.ux-pop .f-row { margin-bottom: 8px; }
.ux-menu { display: flex; flex-direction: column; min-width: 250px; }
.ux-menu button { text-align: left; background: transparent; padding: 8px 10px; font-weight: 600; display: flex; flex-direction: column; gap: 1px; border-radius: 8px; }
.ux-menu button:hover { background: #262d63; }
.ux-menu button small { font-weight: 400; color: var(--mute); font-size: 11px; }
.ux-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.ux-tip { font-size: 12px; line-height: 1.5; color: var(--ink2); }
.ux-locks { display: flex; flex-wrap: wrap; gap: 5px; max-width: 320px; }

/* ---- галерея ---- */
.ux-gal__bar { display: flex; flex-direction: column; gap: 7px; margin-bottom: 9px; }
.ux-search { width: 100%; padding: 8px 10px; border-radius: 10px; background: #0b0e24; border: 1px solid var(--line2); font-size: 12.5px; }
.ux-search:focus { border-color: #6b78e6; }
.ux-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ux-chip { background: transparent !important; box-shadow: inset 0 0 0 1px var(--line2); color: var(--ink2); padding: 4px 10px !important; font-size: 11.5px !important; border-radius: 99px !important; }
.ux-chip:hover { background: #202755 !important; }
.ux-chip.on { background: #2b3370 !important; box-shadow: inset 0 0 0 1px #6b78e6; color: #fff; }
.ux-gal__grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 8px; }
.ux-card { position: relative; display: flex; flex-direction: column; gap: 5px; padding: 6px; border-radius: 12px; background: #151a3c;
  border: 1px solid transparent; cursor: pointer; text-align: left; min-width: 0; transition: background .12s, border-color .12s; }
.ux-card:hover { background: #1d2354; }
.ux-card.on { background: #232b66; border-color: #6b78e6; }
.ux-card__thumb { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #0b0d1e; }
.ux-card__thumb canvas, .ux-card__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ux-card__t { font-size: 12px; color: #fff; line-height: 1.2; }
.ux-card__n { font-size: 10.5px; color: var(--mute); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ux-star { position: absolute; right: 8px; top: 8px; width: 24px; height: 24px; padding: 0 !important; border-radius: 99px !important; background: rgba(8,10,24,.6) !important;
  color: #7a82b4; font-size: 12px !important; line-height: 24px; opacity: 0; transition: opacity .12s; }
.ux-card:hover .ux-star, .ux-card:focus-within .ux-star, .ux-star.on { opacity: 1; }
.ux-star.on { color: #ffd45e; }
.ux-empty { grid-column: 1 / -1; padding: 22px 8px; text-align: center; color: var(--mute); font-size: 12.5px; }

/* ---- аккордеон / Advanced ---- */
.ux-coll { margin: 0 0 8px; border-radius: 12px; background: #131736; border: 1px solid var(--line); }
.ux-coll__h { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 700; color: var(--ink2); border-radius: 12px; }
.ux-coll__h::-webkit-details-marker { display: none; }
.ux-coll__h::before { content: "▸"; color: var(--mute); transition: transform .15s; font-size: 11px; }
.ux-coll[open] > .ux-coll__h::before { transform: rotate(90deg); }
.ux-coll[open] > .ux-coll__h { color: #fff; }
.ux-coll__b { padding: 2px 12px 10px; }
.ux-coll--adv { background: transparent; border: 0; border-top: 1px dashed var(--line2); border-radius: 0; margin-top: 12px; }
.ux-coll--adv > .ux-coll__h { padding: 10px 2px; font-size: 12px; color: var(--mute); }
.ux-coll--adv .ux-coll__b { padding: 2px 0 8px; }
.ux-coll__b b { color: inherit; }
.ux-coll__b > .f-head:first-child { margin-top: 4px; border-top: 0; padding-top: 0; }

/* ---- ⓘ ---- */
.ux-info { padding: 0 !important; width: 18px; height: 18px; border-radius: 50% !important; background: transparent !important; color: var(--mute); font-size: 12px !important; line-height: 18px; flex: none; }
.ux-info:hover { color: #fff; background: #262d63 !important; }
.f-row.has-hint > .f-hint { display: none; }
.f-row.has-hint.show-hint > .f-hint { display: block; }
.f-reset { padding: 0 !important; width: 18px; height: 18px; border-radius: 50% !important; background: transparent !important; color: #8a92c8; font-size: 12px !important; line-height: 18px; opacity: 0; transition: opacity .12s; }
.f-row:hover .f-reset, .f-row:focus-within .f-reset { opacity: 1; }
.f-reset:hover { color: #fff; background: #262d63 !important; }

/* ---- Inspector ---- */
.ux-insp__h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ux-insp__t { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.ux-insp__t small { color: var(--mute); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 800; }
.ux-insp__t b { font: 700 15px 'Comfortaa', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ux-insp__a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---- Status ---- */
.ux-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--mute); white-space: nowrap; }
.ux-status__dot { width: 7px; height: 7px; border-radius: 50%; background: #5a6290; }
.ux-status[data-state="saved"] .ux-status__dot { background: var(--ok); }
.ux-status[data-state="saving"] .ux-status__dot { background: #ffcf8a; animation: ux-pulse 1s infinite; }
.ux-status[data-state="error"] { color: var(--err); } .ux-status[data-state="error"] .ux-status__dot { background: var(--err); }
.ux-status__n { color: var(--ink2); }
@keyframes ux-pulse { 50% { opacity: .35; } }

/* ---- Command palette ---- */
.ux-pal { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; background: rgba(5,6,16,.55); backdrop-filter: blur(3px); }
.ux-pal__box { width: min(620px, 92vw); max-height: 70vh; display: flex; flex-direction: column; border-radius: 16px; background: #171b40; border: 1px solid #3d4794; box-shadow: 0 30px 80px rgba(0,0,0,.6); overflow: hidden; }
.ux-pal__in { width: 100%; padding: 15px 18px; font-size: 15px; background: transparent; border: 0; border-bottom: 1px solid var(--line2); }
.ux-pal__list { overflow-y: auto; padding: 6px; }
.ux-pal__g { padding: 8px 10px 3px; font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.ux-pal__r { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.ux-pal__r.on { background: #2b3370; }
.ux-pal__ic { width: 24px; text-align: center; font-size: 15px; flex: none; }
.ux-pal__tt { display: flex; flex-direction: column; min-width: 0; }
.ux-pal__tt b { font-size: 13px; color: #fff; }
.ux-pal__tt small { font-size: 11px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ux-pal__foot { padding: 7px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--mute); }
.ux-pal__foot kbd { font: 600 10.5px ui-monospace, Consolas, monospace; padding: 1px 5px; margin: 0 2px; border-radius: 5px; background: #0f1330; color: var(--ink2); }

/* ---- first run ---- */
.ux-first { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(135deg, #1b2154, #171b40); border: 1px solid #3d4794; }
.ux-first__h { display: flex; align-items: center; margin-bottom: 4px; }
.ux-first__h b { flex: 1; font-size: 12.5px; }
.ux-first__s { padding-left: 18px; font-size: 12px; color: var(--ink2); line-height: 1.55; margin-bottom: 4px; }
.ux-link { background: transparent !important; padding: 2px 0 !important; color: #a9b4ff !important; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---- мелкая чистка визуального шума (вместо кучи рамок и одинаково ярких акцентов) ---- */
.ux-panel .f-row select, .ux-panel .f-row input[type="text"], .ux-panel .f-row input[type="number"] { background: #0b0e24; }
.ux-panel .f-head { border-top: 0; margin-top: 16px; padding-top: 0; color: var(--ink2); font-size: 12px; letter-spacing: .02em; }
.ux-panel .f-note { background: transparent; border-color: var(--line); }
.ux-panel .seg { background: #0b0e24; border-color: var(--line); }
.ux-panel .chip { background: #151a3c; border-color: transparent; }
.ux-panel .chip:hover { background: #1d2354; }
.ux-panel .chip.on { border-color: #6b78e6; background: #232b66; }
.ux-panel .fam, .ux-panel .mask, .ux-panel .theme, .ux-panel .mech, .ux-panel .dir { border-color: transparent; background: #151a3c; }
.ux-panel .fam.on, .ux-panel .mask.on, .ux-panel .theme.on, .ux-panel .mech.on, .ux-panel .dir.on { border-color: #6b78e6; background: #232b66; }
.ux-panel .layer-card, .ux-panel .exp-box, .ux-panel .saved-row { border-color: transparent; background: #131736; }

/* ---- адаптив: планшет — панель поверх превью, телефон — Preview + Basic ---- */
@media (max-width: 1280px) { :root { --ux-panel: 330px; --ux-rail: 64px; } .ux-find { min-width: 0; } .ux-find span { display: none; } }
@media (max-width: 980px) {
  .ux-top__brand small, .ux-status__n { display: none; }
  .ux-app { grid-template-columns: var(--ux-rail) minmax(0, 1fr); position: relative; }
  .ux-panel { position: absolute; left: var(--ux-rail); top: 0; bottom: 0; width: min(380px, calc(100vw - var(--ux-rail))); z-index: 25; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
  body.ux-panel-hidden .ux-app { grid-template-columns: var(--ux-rail) minmax(0, 1fr); }
  body.ux-panel-hidden .ux-panel { display: none; }
}
@media (max-width: 640px) {
  :root { --ux-rail: 0px; }
  .ux-rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: 58px; flex-direction: row; z-index: 40; border-right: 0; border-top: 1px solid var(--line); padding: 4px; }
  .ux-rail__b { flex: 1; }
  .ux-app, body.ux-panel-hidden .ux-app, body.ux-focus .ux-app { grid-template-columns: minmax(0, 1fr); padding-bottom: 58px; }
  body.ux-focus .ux-app { padding-bottom: 0; }
  .ux-panel { left: 0; width: 100vw; bottom: 58px; }
  .ux-top { flex-wrap: wrap; height: auto; padding: 6px 8px; row-gap: 4px; }
  .ux-qe { display: none; }
  .ux-hide-sm { display: none !important; }
  .ux-gal__grid { --cols: 2; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

.mode .seg { flex-wrap: nowrap; }
.ux-top { flex-wrap: nowrap; overflow: visible; }
@media (max-width: 1100px) { .ux-top { flex-wrap: wrap; height: auto; padding: 6px 10px; row-gap: 6px; } .ux-status__t { display: none; } .ux-hide-sm { display: none; } }
@media (max-width: 640px) {
  .ux-top__brand, .ux-find kbd, #locks { display: none; }
  .ux-find { min-width: 0; } .ux-find span { display: inline; }
  .ux-pvbar #showPanel { display: none; }
  .ux-tr__r { gap: 5px; } .ux-tr .tl__sw { margin-left: 0; width: 100%; }
}
