/* Шакалайзер — тёмная «аппаратная» тема: сетевой монитор, а не фоторедактор. */

:root {
  --bg: #0b0c0f;
  --bg-2: #101218;
  --panel: #14161d;
  --panel-2: #191c24;
  --line: #262a35;
  --line-2: #343949;
  --text: #e9ebf2;
  --muted: #868da0;
  --dim: #5c6478;
  --loss: #ff3d6e;
  --ok: #2fdfc4;
  --warn: #ffb347;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --r: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font-family: inherit; color: inherit; }

/* ------------------------------------------------------------------ шапка */

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
}

.mark { flex: none; }

.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .2px;
}

.brand p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
}

header .spacer { flex: 1; }

.ghlink {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: .15s;
}
.ghlink:hover { color: var(--text); border-color: var(--line-2); background: var(--panel); }

/* ------------------------------------------------------------------- сцена */

main {
  display: grid;
  grid-template-columns: 1fr 336px;
  min-height: 0;
}

.stage-wrap {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  gap: 12px;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background:
    linear-gradient(45deg, #0e1014 25%, transparent 25%, transparent 75%, #0e1014 75%),
    linear-gradient(45deg, #0e1014 25%, #0a0b0e 25%, #0a0b0e 75%, #0e1014 75%);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
  overflow: hidden;
}

/* Абсолют + object-fit, а не max-height: в грид-ячейке процентная высота
   у canvas не срабатывает и портретную картинку просто обрезает. */
#view {
  position: absolute;
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}
#view.hidden { display: none; }

.empty {
  text-align: center;
  padding: 30px;
  color: var(--dim);
  pointer-events: none;
}
.empty strong { display: block; color: var(--muted); font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty kbd {
  font: 11px var(--mono);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--muted);
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(8, 9, 12, .82);
  border: 1px solid var(--line-2);
  font: 11px var(--mono);
  letter-spacing: .4px;
  color: var(--warn);
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
}
.badge.on { opacity: 1; }

/* ------------------------------------------------ полоска пакетов и цифры */

.readout {
  display: grid;
  gap: 9px;
}

.packets {
  display: block;
  width: 100%;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font: 11.5px var(--mono);
  color: var(--dim);
  min-height: 17px;
}
.stats b { color: var(--muted); font-weight: 500; }
.stats .v { color: var(--text); }
.stats .v.loss { color: var(--loss); }
.stats .v.ok { color: var(--ok); }

/* ------------------------------------------------------------------ панель */

.panel {
  border-left: 1px solid var(--line);
  background: var(--bg-2);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 3px solid var(--bg-2); }

.block { padding: 14px 16px; border-bottom: 1px solid var(--line); }

.block > h2 {
  margin: 0 0 10px;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--dim);
}

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.btn {
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
  transition: .13s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: #454b60; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--loss); border-color: var(--loss); color: #16040c; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #ff5583; border-color: #ff5583; }

/* сегментированный переключатель движка */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.seg button {
  padding: 7px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  transition: .13s;
}
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button:disabled { opacity: .35; cursor: default; }
.engine-note { margin: 8px 0 0; font-size: 11.5px; color: var(--dim); line-height: 1.45; }

/* пресеты */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  transition: .13s;
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip[aria-pressed="true"] {
  background: rgba(255, 61, 110, .13);
  border-color: rgba(255, 61, 110, .55);
  color: #ff9ab5;
}

/* слайдеры */
.ctl { margin-bottom: 12px; }
.ctl:last-child { margin-bottom: 0; }

.ctl label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--muted);
}
.ctl label .num { font: 11.5px var(--mono); color: var(--text); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  display: block;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line-2);
}
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
  transition: box-shadow .13s;
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
}
input[type=range]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(255, 61, 110, .18); }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(255, 61, 110, .32); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--loss); width: 15px; height: 15px; cursor: pointer; }

/* ------------------------------------------------------------- нижняя строка */

footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  font: 12px var(--mono);
  color: var(--dim);
  min-height: 36px;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.busy { background: var(--warn); animation: pulse 1s infinite; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--loss); }
@keyframes pulse { 50% { opacity: .25; } }

footer .spacer { flex: 1; }
footer a { color: var(--dim); }

/* --------------------------------------------------------------- оверлеи */

.drop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(8, 9, 12, .86);
  backdrop-filter: blur(3px);
  z-index: 40;
  font-size: 17px;
  color: var(--text);
}
.drop.on { display: grid; }
.drop div {
  padding: 44px 68px;
  border: 2px dashed var(--loss);
  border-radius: 14px;
}

.loader {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(8, 9, 12, .9);
  backdrop-filter: blur(4px);
  z-index: 50;
}
.loader.on { display: grid; }
.loader .box { width: min(380px, 84vw); text-align: center; }
.loader h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.loader p { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--loss); transition: width .2s; }
.loader .pct { margin-top: 9px; font: 11.5px var(--mono); color: var(--dim); }

/* ------------------------------------------------------------- адаптив */

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  main { grid-template-columns: 1fr; }
  .stage-wrap { padding: 12px; }
  .stage { min-height: 46vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  header { flex-wrap: wrap; }
}
