/* Магазин, версии и каталог лаунчера.
   Самодостаточно: опирается только на переменные админки (--bg, --card, --border …),
   а не на её классы раскладки, которые переделываются. Все имена с префиксом stx-. */

.stx-view { min-height: 0; flex-direction: column; gap: 12px; }
.stx-view:not(.hidden) { display: flex; flex: 1; }
.stx-dock { overflow: hidden; }
.stx-page { overflow: auto; padding-bottom: 32px; }
.stx-page > * { flex-shrink: 0; }

/* ---- primitives --------------------------------------------------------- */
.stx-view button, .stx-modal button { font: inherit; }
.stx-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border, #1e293b); background: transparent; color: var(--text, #f4f7fb);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.stx-btn:hover:not(:disabled) { background: var(--card-hover, #1b2230); }
.stx-btn:disabled { opacity: .45; cursor: not-allowed; }
.stx-btn.pri { background: var(--accent, #3b82f6); border-color: transparent; color: #fff; }
.stx-btn.pri:hover:not(:disabled) { background: var(--accent-2, #2563eb); }
.stx-btn.dng { color: var(--danger, #f87171); border-color: rgba(248, 113, 113, .4); }
.stx-btn.dng:hover:not(:disabled) { background: rgba(248, 113, 113, .14); }
.stx-btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.stx-btn.lnk { border: 0; height: auto; padding: 0; color: var(--action-fg, #93c5fd); font-weight: 600; }
.stx-btn.lnk:hover:not(:disabled) { background: none; text-decoration: underline; }

.stx-in {
  width: 100%; height: 36px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--border, #1e293b); background: var(--bg, #07080c); color: var(--text, #f4f7fb);
  font: inherit; font-size: 13px;
}
textarea.stx-in { height: auto; min-height: 64px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.stx-in:focus { outline: 2px solid rgba(59, 130, 246, .45); outline-offset: 0; }
.stx-in:disabled, .stx-in[readonly] { opacity: .65; }
select.stx-in { padding-right: 6px; }
input[type="color"].stx-in { padding: 2px 4px; width: 48px; }
.stx-check { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; line-height: 1.4; cursor: pointer; }
.stx-check input { margin-top: 2px; flex: none; }

.stx-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.stx-chip {
  appearance: none; height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border, #1e293b); background: transparent; color: var(--muted, #93a4bb);
  font-size: 12px; font-weight: 600;
}
.stx-chip:hover { color: var(--text, #f4f7fb); }
.stx-chip.on { background: var(--accent, #3b82f6); border-color: transparent; color: #fff; }
.stx-chip .n { margin-left: 5px; opacity: .75; font-weight: 500; }

.stx-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  background: var(--pill, rgba(255, 255, 255, .12)); color: var(--muted, #93a4bb);
}
.stx-badge.ok { background: rgba(52, 211, 153, .14); color: var(--ok, #34d399); }
.stx-badge.warn { background: rgba(251, 191, 36, .14); color: var(--warn, #fbbf24); }
.stx-badge.err { background: rgba(248, 113, 113, .14); color: var(--danger, #f87171); }
.stx-badge.info { background: var(--action, rgba(59, 130, 246, .13)); color: var(--action-fg, #93c5fd); }

.stx-muted { color: var(--muted, #93a4bb); }
.stx-mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.stx-small { font-size: 12px; }
.stx-empty { padding: 28px 16px; text-align: center; color: var(--muted, #93a4bb); font-size: 13px; }
.stx-err { color: var(--danger, #f87171); font-size: 13px; }

/* ---- toolbar and stats -------------------------------------------------- */
.stx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: none; }
.stx-bar .grow { flex: 1; min-width: 160px; }
.stx-bar .stx-in { width: auto; }
.stx-bar input[type="search"] { max-width: 320px; }
.stx-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); flex: none;
  border: 1px solid var(--border, #1e293b); border-radius: 9px; overflow: hidden; background: var(--card, #161b27);
}
.stx-stat { padding: 11px 16px; border-right: 1px solid var(--border, #1e293b); min-width: 0; }
.stx-stat:last-child { border-right: 0; }
.stx-stat .k { font-size: 11px; color: var(--muted, #93a4bb); letter-spacing: .05em; text-transform: uppercase; }
.stx-stat .v { margin-top: 4px; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.stx-stat .s { margin-top: 2px; font-size: 11px; color: var(--muted, #93a4bb); }
.stx-meter { height: 5px; border-radius: 3px; background: var(--pill, rgba(255, 255, 255, .12)); margin-top: 7px; overflow: hidden; }
.stx-meter > span { display: block; height: 100%; background: var(--accent, #3b82f6); }
.stx-meter.warn > span { background: var(--warn, #fbbf24); }

/* ---- two-pane layout ---------------------------------------------------- */
.stx-split {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 540px);
  border: 1px solid var(--border, #1e293b); border-radius: 9px; background: var(--card, #161b27); overflow: hidden;
}
.stx-split.cat { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
.stx-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.stx-pane + .stx-pane { border-left: 1px solid var(--border, #1e293b); }
.stx-pane-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none;
  padding: 10px 15px; min-height: 45px; border-bottom: 1px solid var(--border, #1e293b);
  font-size: 12px; color: var(--muted, #93a4bb);
}
.stx-pane-h b { color: var(--text, #f4f7fb); font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stx-scroll { flex: 1; min-height: 0; overflow: auto; }

/* ---- list rows ---------------------------------------------------------- */
.stx-row {
  appearance: none; width: 100%; text-align: left; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px; align-items: center; padding: 11px 15px; border: 0; border-bottom: 1px solid var(--border, #1e293b);
  background: transparent; color: inherit; cursor: pointer; min-height: 66px; font: inherit;
}
.stx-row:hover { background: var(--card-hover, #1b2230); }
.stx-row.on { background: var(--action, rgba(59, 130, 246, .13)); box-shadow: inset 3px 0 #72a5ff; }
.stx-row .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stx-row .s { margin-top: 3px; font-size: 12px; color: var(--muted, #93a4bb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stx-row .b { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.stx-row.plain { grid-template-columns: minmax(0, 1fr) auto; min-height: 52px; }
.stx-group-h {
  padding: 8px 15px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #93a4bb);
  background: rgba(255, 255, 255, .03); border-bottom: 1px solid var(--border, #1e293b);
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;
}
.stx-ico {
  width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex: none; display: grid; place-items: center;
  background: var(--deep, #0b1018); border: 1px solid var(--border, #1e293b); color: #fff; font-weight: 800; font-size: 18px;
}
.stx-ico img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stx-ico.big { width: 88px; height: 88px; border-radius: 18px; font-size: 36px; }
.stx-ico.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 13px; }

/* ---- inspector ---------------------------------------------------------- */
.stx-tabs { display: flex; gap: 16px; padding: 0 15px; border-bottom: 1px solid var(--border, #1e293b); flex: none; overflow-x: auto; }
.stx-tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 0; cursor: pointer;
  color: var(--muted, #93a4bb); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.stx-tab.on { color: #72a5ff; border-bottom-color: #72a5ff; }
.stx-body { padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.stx-sec h4 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #93a4bb); }
.stx-hero { display: flex; gap: 14px; align-items: center; }
.stx-hero h3 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.stx-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.stx-kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13px; }
.stx-kv dt { color: var(--muted, #93a4bb); font-size: 12px; }
.stx-kv dd { margin: 0; min-width: 0; word-break: break-word; }
.stx-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stx-form .full { grid-column: 1 / -1; }
.stx-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.stx-field > span { font-size: 11px; font-weight: 700; color: var(--muted, #93a4bb); }
.stx-field > small { font-size: 11px; color: var(--muted, #93a4bb); line-height: 1.35; }
.stx-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stx-foot {
  flex: none; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 11px 15px; border-top: 1px solid var(--border, #1e293b); background: var(--card, #161b27);
}
.stx-danger { padding-top: 14px; border-top: 1px solid var(--border, #1e293b); }

.stx-issues { display: flex; flex-direction: column; gap: 6px; }
.stx-issue {
  display: flex; gap: 9px; padding: 8px 11px; border-radius: 8px; font-size: 12.5px; line-height: 1.4;
  background: rgba(255, 255, 255, .04); border-left: 3px solid var(--muted, #93a4bb);
}
.stx-issue.error, .stx-issue.block { border-left-color: var(--danger, #f87171); background: rgba(248, 113, 113, .08); }
.stx-issue.warn { border-left-color: var(--warn, #fbbf24); background: rgba(251, 191, 36, .07); }
.stx-issue.info { border-left-color: #72a5ff; }
.stx-issue.accepted { border-left-color: var(--ok, #34d399); background: rgba(52, 211, 153, .07); }
.stx-issue .x { flex: 1; min-width: 0; }

/* ---- tables ------------------------------------------------------------- */
.stx-tw { border: 1px solid var(--border, #1e293b); border-radius: 9px; overflow: auto; }
.stx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stx-table th, .stx-table td { padding: 9px 12px; border-bottom: 1px solid var(--border, #1e293b); text-align: left; vertical-align: middle; }
.stx-table th { font-size: 11px; color: var(--muted, #93a4bb); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; background: rgba(255, 255, 255, .03); white-space: nowrap; }
.stx-table tr:last-child td { border-bottom: 0; }
.stx-table td.r, .stx-table th.r { text-align: right; }
.stx-table .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.stx-table input.stx-in, .stx-table select.stx-in { height: 30px; font-size: 12px; min-width: 62px; }

/* ---- icon picker -------------------------------------------------------- */
.stx-src { display: flex; flex-wrap: wrap; gap: 6px; }
.stx-src .stx-chip.busy { opacity: .6; pointer-events: none; }
.stx-src .stx-chip.err { border-color: rgba(248, 113, 113, .5); }
.stx-cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.stx-cand {
  appearance: none; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 6px 8px; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--border, #1e293b); background: var(--deep, #0b1018); color: inherit; font: inherit; text-align: center;
}
.stx-cand:hover { border-color: #4b5d78; }
.stx-cand.sel { border-color: #72a5ff; box-shadow: 0 0 0 2px rgba(114, 165, 255, .35); }
.stx-cand .pv {
  width: 72px; height: 72px; border-radius: 14px; display: grid; place-items: center; overflow: hidden;
  background-image: linear-gradient(45deg, #1b2230 25%, transparent 25%, transparent 75%, #1b2230 75%), linear-gradient(45deg, #1b2230 25%, #121826 25%, #121826 75%, #1b2230 75%);
  background-size: 14px 14px; background-position: 0 0, 7px 7px;
}
.stx-cand .pv img { max-width: 100%; max-height: 100%; display: block; }
.stx-cand .l { font-size: 11px; font-weight: 600; line-height: 1.25; }
.stx-cand .m { font-size: 10.5px; color: var(--muted, #93a4bb); }
.stx-srcblock { margin-top: 12px; }
.stx-srcblock > h5 { margin: 0 0 6px; font-size: 12px; color: var(--muted, #93a4bb); display: flex; gap: 8px; align-items: center; }

/* ---- modal -------------------------------------------------------------- */
.stx-modal {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(3, 6, 12, .72);
}
.stx-modal.hidden { display: none; }
.stx-modal-card {
  width: min(880px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--card, #161b27); border: 1px solid var(--border, #1e293b); border-radius: 14px; box-shadow: var(--shadow, 0 24px 80px rgba(0, 0, 0, .45));
}
.stx-modal-card.narrow { width: min(520px, 100%); }
.stx-modal-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 12px; flex: none; }
.stx-modal-h h2 { margin: 0; font-size: 18px; font-weight: 700; }
.stx-modal-h p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted, #93a4bb); }
.stx-modal-b { padding: 4px 20px 18px; overflow: auto; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.stx-modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border, #1e293b); flex: none; flex-wrap: wrap; }
.stx-progress { height: 8px; border-radius: 4px; background: var(--pill, rgba(255, 255, 255, .12)); overflow: hidden; }
.stx-progress > span { display: block; height: 100%; width: 0; background: var(--accent, #3b82f6); transition: width .2s; }
.stx-opt { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--border, #1e293b); border-radius: 10px; }
.stx-opt.on { border-color: #72a5ff; }
.stx-opt > label.head { display: flex; gap: 9px; align-items: center; font-weight: 650; font-size: 14px; cursor: pointer; }
.stx-drop {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; border: 2px dashed #72a5ff; border-radius: 9px;
  background: rgba(7, 8, 12, .86); font-size: 17px; font-weight: 650; color: #cfe1ff;
}
.stx-drop.hidden { display: none; }
.stx-rel { position: relative; }
.stx-dz {
  padding: 18px; text-align: center; border: 1px dashed var(--border, #1e293b); border-radius: 10px; cursor: pointer;
  color: var(--muted, #93a4bb); font-size: 13px;
}
.stx-dz:hover, .stx-dz.over { border-color: #72a5ff; color: var(--text, #f4f7fb); }

/* ---- journal ------------------------------------------------------------ */
.stx-log { border: 1px solid var(--border, #1e293b); border-radius: 9px; background: var(--card, #161b27); overflow: hidden; }
.stx-ev { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; padding: 10px 15px; border-bottom: 1px solid var(--border, #1e293b); align-items: start; font-size: 13px; }
.stx-ev:last-child { border-bottom: 0; }
.stx-ev .when { color: var(--muted, #93a4bb); font-size: 12px; line-height: 1.4; }
.stx-ev .what { min-width: 0; }
.stx-ev .what .sm { margin-top: 3px; font-size: 12px; color: var(--muted, #93a4bb); word-break: break-word; }
.stx-ev .diff { margin: 6px 0 0; padding: 7px 10px; border-radius: 7px; background: rgba(255, 255, 255, .04); font-size: 12px; line-height: 1.5; font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.stx-h2 { margin: 6px 0 0; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #93a4bb); font-weight: 600; flex: none; }

/* ---- catalog ------------------------------------------------------------ */
.stx-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: -2px; margin-right: 7px; border: 1px solid rgba(255, 255, 255, .25); }
.stx-models { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow: auto; }

@media (max-width: 1100px) {
  .stx-split, .stx-split.cat { grid-template-columns: 1fr; grid-template-rows: minmax(160px, 38%) minmax(0, 1fr); }
  .stx-pane + .stx-pane { border-left: 0; border-top: 1px solid var(--border, #1e293b); }
  .stx-ev { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 640px) {
  .stx-form { grid-template-columns: 1fr; }
  .stx-kv { grid-template-columns: 1fr; }
  .stx-kv dt { margin-top: 6px; }
}
body.role-viewer .stx-write { display: none !important; }

/* ---- slot cards in the inspector ---------------------------------------- */
.stx-slot { display: flex; flex-direction: column; gap: 8px; padding: 11px 13px; border: 1px solid var(--border, #1e293b); border-radius: 10px; background: var(--deep, #0b1018); }
.stx-slot-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stx-slot .stx-kv { grid-template-columns: 96px minmax(0, 1fr); }
.stx-ico { position: relative; }
.stx-ico img { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--deep, #0b1018); }

/* radios and checkboxes must not inherit the width of text inputs */
.stx-view input[type="checkbox"], .stx-view input[type="radio"],
.stx-modal input[type="checkbox"], .stx-modal input[type="radio"] {
  width: 16px; height: 16px; min-width: 16px; padding: 0; margin: 0; flex: none; accent-color: var(--accent, #3b82f6);
}
.stx-opt > label.head { cursor: pointer; }
.stx-opt .stx-form { margin-top: 2px; }
