/* Библиотека игр — стили. Палитра совпадает с nevend.ru (тёмная тема). */

:root {
  color-scheme: dark;
  --bg: #12131a;
  --surface: #1b1d27;
  --surface-2: #232634;
  --surface-3: #2b2f40;
  --text: #e8e8ef;
  --text-dim: #9aa0b4;
  --text-muted: #747a90;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, 0.16);
  --border: #2c2f3d;
  --grid: #2a2d3b;
  --axis: #3a3e50;
  --danger: #e66767;
  --ok: #3cbf6a;
  --warn: #e0a020;
  --no-rating: #6b6f80;
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1120px;
  --tabbar-h: 0px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; margin-bottom: 12px; }
h3 { font-size: 15px; margin-bottom: 8px; color: var(--text-dim); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(18, 19, 26, 0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { color: var(--text-muted); font-weight: 500; font-size: 13px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 999px; color: var(--text-dim); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav svg { width: 18px; height: 18px; flex: none; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 48px; }
body.locked .nav, body.locked .tabbar { display: none; }

@media (max-width: 760px) {
  :root { --tabbar-h: 60px; font-size: 15px; }
  .topbar .nav { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(22, 23, 32, 0.96);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-muted); font-size: 11px; font-weight: 500;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .wrap { padding: 14px 12px 32px; }
  h1 { font-size: 21px; }
}
@media (min-width: 761px) { .tabbar { display: none; } }

/* ---------- элементы ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.panel + .panel, .section + .section { margin-top: 16px; }
.game-top > .panel, .predict-layout > .panel, .grid-2 > .panel { margin-top: 0; }
.section { margin-top: 22px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; border-color: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0d1424; }
.btn-primary:hover { background: #8bbaff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 13px; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 38px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); min-height: 28px; }
input[type=file] { padding: 6px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-dim); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; min-height: 30px; padding: 4px 12px; color: var(--text-dim); font-weight: 500; }
.seg button.on, .seg a.on { background: var(--surface-3); color: var(--text); }
.seg a { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 14px; border-radius: 999px; color: var(--text-dim); font-weight: 500; }
.seg a:hover { text-decoration: none; color: var(--text); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 26px; padding: 0 8px; border-radius: 999px;
  font-weight: 700; font-size: 14px; color: #10121a; font-variant-numeric: tabular-nums;
}
.badge.none { background: var(--surface-3); color: var(--text-muted); font-weight: 500; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  white-space: nowrap;
}
.warn-box {
  border: 1px solid rgba(224, 160, 32, .45); background: rgba(224, 160, 32, .08);
  color: #f0c46a; border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px;
}
.err-box {
  border: 1px solid rgba(230, 103, 103, .5); background: rgba(230, 103, 103, .08);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px;
}
.err-box ul { margin: 6px 0 0; padding-left: 18px; max-height: 320px; overflow: auto; }
.ok-box {
  border: 1px solid rgba(60, 191, 106, .45); background: rgba(60, 191, 106, .08);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px;
}
.empty { padding: 36px 16px; text-align: center; color: var(--text-dim); }
.loading { padding: 40px; text-align: center; color: var(--text-muted); }

/* ---------- фильтры ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; min-width: 160px; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  padding: 12px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.filters .range { display: flex; gap: 6px; }
.filters .range input { min-width: 0; }

/* ---------- таблица ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--text-dim); background: var(--surface-2); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted { color: var(--accent); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.name { white-space: normal; min-width: 160px; font-weight: 600; }
@media (max-width: 760px) { .hide-sm { display: none; } td.name { min-width: 130px; } }
.layer-cell { display: inline-flex; align-items: center; gap: 6px; }
.layer-cell svg { width: 34px; height: 6px; }

/* ---------- карточки ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.card {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; cursor: pointer; transition: border-color .12s, background .12s;
}
.card:hover { border-color: var(--accent); background: var(--surface-2); text-decoration: none; }
.card { flex-direction: column; align-items: stretch; gap: 10px; }
.card-top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.card .mini { flex: none; display: block; line-height: 0; }
.card .body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.card .title { display: block; font-weight: 650; font-size: 15px; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .meta { display: block; font-size: 12.5px; color: var(--text-dim); }
.card .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.card .chip { font-size: 11px; padding: 1px 7px; }
.card-scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cs { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.cs.main { border-color: var(--axis); }
.cs b { font-size: 17px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cs small { font-size: 10.5px; color: var(--text-muted); text-transform: lowercase; }

/* ---------- карточка игры ---------- */
.game-top { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.game-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.game-side .scores3 { margin-bottom: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px 14px; margin: 0 0 14px; }
.facts dt { font-size: 11.5px; color: var(--text-muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.pred-details { padding: 10px 12px; margin-bottom: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
/* две колонки шкал на широком экране: общая оценка | сложность, слои 2×2 */
.form-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; align-items: start; }
.form-cols .scale-hint, .form-cols .scale-tip { min-height: calc(2 * 1.35em); line-height: 1.35; }
@media (max-width: 760px) {
  .form-cols { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .form-cols .scale-hint, .form-cols .scale-tip { min-height: 0; }
}
@media (max-width: 760px) { .game-top { grid-template-columns: minmax(0, 1fr); } }
.diamond-box { display: flex; justify-content: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; }
.score-big { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.score-big .val { font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.score-big .lbl { font-size: 12px; color: var(--text-dim); }

.bars { display: grid; grid-template-columns: minmax(110px, auto) 1fr 42px; gap: 7px 10px; align-items: center; font-size: 13px; }
.bars .lab { color: var(--text-dim); }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bars svg { width: 100%; height: 12px; display: block; }
.bars .na { color: var(--text-muted); font-style: italic; font-size: 12px; }

/* шкала-кнопки: оценки 1–10, сложность, слои 0–10 */
.scale-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.scale-head { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.scale-label { font-size: 13px; font-weight: 600; color: var(--text); }
.scale-head .precise { width: 78px; min-height: 30px; padding: 4px 8px; text-align: right; margin-left: auto; }
.scale-hint { font-size: 12px; color: var(--text-muted); margin-top: -3px; }
.scale-tip { font-size: 12.5px; color: var(--text-dim); min-height: 18px; line-height: 1.35; }
.scale-tip.is-empty { color: var(--text-muted); }
.scale-tip.preview { color: var(--text-muted); font-style: italic; }
.scale { display: flex; gap: 3px; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: pointer; }
.scale button {
  flex: 1 1 0; min-width: 0; min-height: 34px; padding: 0;
  border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-muted);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background .1s, border-color .1s, color .1s;
}
.scale button:hover { border-color: var(--c, var(--text-muted)); color: var(--text); }
.scale button.on { background: var(--c); border-color: var(--c); color: var(--fg, #10121a); }
.scale button.part { background: linear-gradient(90deg, var(--c) var(--p), var(--bg) var(--p)); border-color: var(--c); color: var(--text); }
.scale .sc-na { flex: 0.8 1 0; }
.scale .sc-na.on { background: var(--surface-3); border-color: var(--text-muted); color: var(--text); }
.scale-layer button[data-v="0"].on { background: var(--surface-3); border-color: var(--text-muted); color: var(--text); }
@media (max-width: 420px) { .scale { gap: 2px; } .scale button { font-size: 12px; min-height: 36px; border-radius: 6px; } }
.scale-list { display: flex; flex-direction: column; gap: 14px; }
.aspect-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px 22px; }
@media (max-width: 760px) { .aspect-inputs { grid-template-columns: minmax(0, 1fr); } }

.items-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  cursor: pointer;
}
.item-row:hover { border-color: var(--accent); }
.item-row .nm { font-weight: 600; flex: 1; min-width: 0; }
.item-row .nm small { display: block; font-weight: 400; color: var(--text-dim); }
.item-editor { padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--bg); }

/* ---------- графики ---------- */
.chart { width: 100%; }
.chart svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.map-wrap { max-width: 760px; margin: 0 auto; }
.map-wrap svg .pt { cursor: pointer; }
.map-wrap svg .pt:hover circle { stroke: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: center; font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -2px; margin-right: 5px; }
.legend .grad { width: 120px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #d03b3b, #e0a020, #2fb35a); display: inline-block; vertical-align: -1px; margin: 0 6px; }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  max-width: 260px; padding: 8px 10px;
  background: #0c0d13; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; line-height: 1.4; white-space: pre-line;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

/* ---------- предсказатель ---------- */
.predict-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .predict-layout { grid-template-columns: minmax(0, 1fr); } }
.pred-result .val { font-size: 52px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.factor-list { display: grid; grid-template-columns: minmax(120px, auto) 1fr 52px; gap: 6px 10px; align-items: center; font-size: 13px; }
.factor-list svg { width: 100%; height: 12px; display: block; }
.neighbors { display: flex; flex-direction: column; gap: 6px; }
.neighbors a { display: flex; align-items: center; gap: 10px; color: var(--text); }
.neighbors a:hover { text-decoration: none; color: var(--accent); }
.next-list { display: flex; flex-direction: column; gap: 8px; }
.next-row {
  display: grid; grid-template-columns: 28px auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit; cursor: pointer;
}
.next-row:hover { border-color: var(--accent); text-decoration: none; }
.next-row .rank { color: var(--text-muted); font-weight: 700; text-align: center; }
.next-row .why { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- статистика ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.tile .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--text-dim); }
.mini-table { font-size: 13px; }
.mini-table th, .mini-table td { padding: 6px 8px; }
.mini-table tbody tr { cursor: default; }
.mini-table tbody tr:hover { background: none; }

/* ---------- вход ---------- */
.login { max-width: 360px; margin: 12vh auto 0; }
.login .panel { padding: 24px; }
.login h1 { margin-bottom: 6px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

/* ---------- всплывающие ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #0c0d13; border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  animation: toast-in .15s ease-out;
}
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; max-width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

pre.code {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12px; overflow-x: auto; color: var(--text-dim);
}
/* на широком экране шкалы слоёв и сложности не растягиваем на всю панель */

/* В сетке аспектов описание и подсказка занимают фиксированную высоту: шкалы в строке
   выровнены, и смена подсказки при наведении/перетаскивании не сдвигает кнопки под курсором. */
.aspect-inputs { align-items: start; }
.aspect-inputs .scale-hint { min-height: calc(3 * 1.35em); line-height: 1.35; }
.aspect-inputs .scale-tip { min-height: calc(3 * 1.35em); }
@media (max-width: 760px) { .aspect-inputs .scale-hint, .aspect-inputs .scale-tip { min-height: 0; } }


/* три главные оценки игры */
.scores3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.score-tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.score-tile { text-align: center; }
.score-tile .v { display: block; font-size: 32px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.score-tile .l { display: block; font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.score-tile .l small { color: var(--text-muted); font-size: 11px; }
.score-tile.main { border-color: var(--axis); }
@media (max-width: 420px) { .score-tile { padding: 8px; } .score-tile .v { font-size: 28px; } }
.tri { display: inline-flex; gap: 4px; align-items: center; }
.tri .badge { min-width: 30px; height: 22px; font-size: 12px; padding: 0 6px; }
.tri .badge.ghost { background: transparent; border: 1.5px solid currentColor; }
.tri-legend { font-size: 11px; color: var(--text-muted); }
/* панель библиотеки на телефоне: поиск + фильтры, затем сортировка и вид в одну строку */
@media (max-width: 760px) {
  .toolbar #sort { flex: 1 1 0; min-width: 0; max-width: none !important; }
  .toolbar .seg button { padding: 4px 10px; }
}
@media (max-width: 760px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* полосы растягиваются по ширине (preserveAspectRatio=none), поэтому скругляем рамку SVG,
   а не сами прямоугольники — иначе края выглядят обрезанными */
svg.hbar { border-radius: 4px; overflow: hidden; }

/* ---------- быстрая форма (v5) ---------- */
.scale-head .scale-tip { margin-left: 6px; min-height: 0; flex: 1; min-width: 0; }
.scale-hint { display: none; }
.show-hints .scale-hint { display: block; }
.form-cols .scale-hint, .form-cols .scale-tip, .aspect-inputs .scale-hint, .aspect-inputs .scale-tip { min-height: 0; }
.scale-words button { font-size: 12.5px; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scale button.sel { box-shadow: 0 0 0 2px var(--text) inset; }
.scale button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 420px) { .scale-words button { font-size: 11px; } }

.quick { display: flex; flex-direction: column; gap: 12px; }
.name-row { align-items: flex-end; gap: 10px; }
.genre-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: -6px; }
.genre-chips .chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); min-height: 0; padding: 2px 9px; font-size: 12px; }
.genre-chips .chip:hover { border-color: var(--accent); color: var(--text); }
.seg-row { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.seg-row .field > span:first-child, .item-editor .field > span:first-child { font-size: 13px; color: var(--text-dim); }
.seg-input { flex-wrap: wrap; border-radius: 12px; }
.seg-input button { border-radius: 9px; }

.fav-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; color: var(--text-dim); }
.fav-toggle .heart { font-size: 16px; color: var(--text-muted); }
.fav-toggle[aria-pressed="true"] { border-color: #e2557a; color: var(--text); background: rgba(226, 85, 122, 0.14); }
.fav-toggle[aria-pressed="true"] .heart, .heart.on { color: #e2557a; }

details.more { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
details.more > summary { cursor: pointer; font-weight: 600; padding: 4px 0; list-style-position: outside; }
details.more[open] > summary { margin-bottom: 10px; }
.form-foot { margin-top: 14px; }
.save-status.ok { color: var(--ok); }
.save-status.err { color: var(--danger); }

.fill-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 14px; padding: 10px 14px; border-color: var(--accent); }
.game-top .game-side .pred-details { margin: 12px 0 0; }

.item-row.is-part { border-left: 3px solid var(--accent); }
.item-row .kind { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--accent); letter-spacing: .03em; }

/* ---------- быстрое редактирование в таблице ---------- */
.fav-col { width: 30px; padding-right: 0 !important; text-align: center; }
.heart-btn { border: 0; background: transparent; min-height: 0; padding: 2px 4px; font-size: 16px; color: var(--surface-3); line-height: 1; }
.heart-btn:hover { color: #e2557a; background: transparent; }
.heart-btn.on { color: #e2557a; }
.cell-btn { border: 0; background: transparent; padding: 0; min-height: 0; font: inherit; color: inherit; cursor: pointer; }
.cell-btn:hover { background: transparent; }
.status-btn { border-bottom: 1px dashed var(--text-muted); border-radius: 0; }
.popover { position: absolute; z-index: 50; display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; max-width: 320px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.popover button { min-height: 34px; padding: 4px 10px; }
.pop-rating button[style] { min-width: 34px; padding: 0; border-color: var(--c); }
.pop-rating button[style]:hover, .pop-rating button.on { background: var(--c); color: #10121a; }
.pop-list { flex-direction: column; }
.pop-list button { text-align: left; }
.popover button.on { border-color: var(--accent); }

/* ---------- статистика: гистограмма ---------- */
.histo { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; height: 140px; align-items: end; }
.hcol { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.hb { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; }
.hn { font-size: 11px; color: var(--text-dim); }
.hl { font-size: 12px; color: var(--text-muted); }
.aspect-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .aspect-inputs { grid-template-columns: minmax(0, 1fr); } }
.pop-rating { max-width: 440px; flex-wrap: nowrap; }
@media (max-width: 460px) { .pop-rating { flex-wrap: wrap; max-width: 260px; } }
@media (max-width: 420px) { .scale-words button { font-size: 10.5px; letter-spacing: -0.02em; } }

/* ---------- шлифовка (v6) ---------- */
/* подписи к переключателям — всегда над ними */
.seg-row .field, .predict-layout .field:has(> .seg-input), .item-editor .field:has(> .seg-input) { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.name-row { flex-wrap: nowrap; }
/* в таблице библиотеки полоски слоёв — только на широком экране, иначе столбцы не влезают */
@media (max-width: 1380px) { .layer-cell svg { display: none; } }
@media (max-width: 760px) {
  .fav-toggle { padding: 0 12px; }
  .fav-toggle .fav-label { display: none; }
  .fav-toggle .heart { font-size: 18px; }
  /* чипы жанров — одной прокручиваемой строкой */
  .genre-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .genre-chips::-webkit-scrollbar { display: none; }
  .genre-chips .chip { flex: 0 0 auto; }
  .diamond-box svg { width: 190px; height: auto; }
  .diamond-box { padding: 6px; }
  .item-diamond { display: none; }
}
.predict-layout .field > span:first-child { font-size: 13px; color: var(--text-dim); }
