:root {
  --bg0: #0b1018;
  --bg1: #121a26;
  --panel: rgba(16, 23, 34, 0.86);
  --panel-border: rgba(140, 170, 210, 0.18);
  --text: #dbe4f0;
  --muted: #8a9ab0;
  --accent: #ff6a3d;
  --accent2: #b98bff;
  --ok: #4fd18b;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 40% 35%, #1a2536 0%, var(--bg0) 75%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }

/* ---------- Заголовок ---------- */
.title {
  position: fixed; left: 20px; top: 14px; z-index: 5;
  pointer-events: none;
}
.title h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: .3px; }
.title .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.title a { pointer-events: auto; color: var(--muted); text-decoration: none; font-size: 13px; }
.title a:hover { color: var(--text); }

/* ---------- Панели ---------- */
.panel {
  position: fixed; z-index: 5;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  padding: 12px 14px;
}
.panel h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

#info { right: 16px; top: 16px; width: 340px; max-height: calc(100vh - 32px); overflow-y: auto; line-height: 1.45; }
#info p { margin: 0 0 8px; }
#info .reaction {
  font-family: Consolas, "Cambria Math", monospace;
  background: rgba(255,255,255,.05); border-radius: 6px; padding: 6px 8px; margin: 6px 0 10px;
  font-size: 13px;
}
#info ol { padding-left: 20px; margin: 4px 0 8px; }
#info li { margin-bottom: 5px; }
#info li.active { color: #fff; }
#info li.active::marker { color: var(--accent); }
#info .note { color: var(--muted); font-size: 12px; }

#controls { left: 16px; bottom: 16px; width: 330px; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row label { flex: 1; }
.row output { width: 70px; text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
button, .toggle {
  background: rgba(255,255,255,.07); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 6px;
  padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
button:hover, .toggle:hover { background: rgba(255,255,255,.13); }
.toggle.on, button[data-view].on { background: rgba(255,106,61,.22); border-color: rgba(255,106,61,.6); color: #fff; }

#readout { left: 362px; bottom: 16px; width: 360px; }
#readout .big { font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
#readout .big small { font-size: 15px; color: var(--muted); font-weight: 400; }
#readout canvas { width: 100%; height: 110px; display: block; margin-top: 6px; }
#readout .legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
#readout .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* ---------- Подписи в 3D (вынесены за контур объекта, с выносками) ---------- */
#labels .lbl-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#labels .lbl-lines line { stroke: rgba(200,220,255,.55); stroke-width: 1; }
#labels .lbl-lines circle { fill: #e9eef6; }
#labels .lbl-lines .pop { stroke: rgba(255,130,80,.9); fill: #ff8250; }
.lbl {
  position: absolute; left: 0; top: 0;
  white-space: nowrap; font-size: 12.5px; color: #e9eef6;
  padding: 2px 7px; border-radius: 4px;
  background: rgba(10, 15, 24, .78); border: 1px solid rgba(160,190,230,.25);
}
.lbl.pop { font-size: 12px; background: rgba(200,70,30,.9); border-color: transparent; }

/* ---------- Легенда молекул ---------- */
#mols { left: 16px; top: 96px; width: 210px; font-size: 12.5px; }
#mols .m { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
#mols .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset -2px -2px 3px rgba(0,0,0,.4); filter: saturate(1.6); }  /* = GA.molSat */

@media (max-width: 1400px) {
  .lbl { font-size: 11px; padding: 1px 5px; }
}
@media (max-width: 1100px) {
  #info { width: 280px; font-size: 13px; }
  #readout { left: 16px; bottom: 260px; }
}

/* ---------- Компоновка страницы (расставляет GA.layoutUI) ---------- */
.title { text-align: center; white-space: nowrap; }
.home-btn {
  display: block; flex: none; text-align: center; text-decoration: none;
  padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; letter-spacing: .8px;
  color: #fff; background: #3a2722; border: 1px solid rgba(255,106,61,.7);
}
.home-btn:hover { background: #57302499; background: #573024; }
#leftcol {
  position: fixed; left: 16px; top: 160px; bottom: 90px; width: 450px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin;
}
#leftcol > .panel { position: static; width: auto !important; flex: none; }
#leftcol #readout canvas { height: 90px; }
#mols {
  top: auto; width: auto;
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 18px; row-gap: 3px;
  padding: 8px 14px;
}
#mols h3 { margin: 0 6px 0 0; }
#mols .m { margin: 0; }
/* компактные панели в левой колонке */
#leftcol > .panel { padding: 9px 12px; }
#leftcol .panel h3 { margin-bottom: 5px; }
#leftcol .row { margin: 2px 0; }
#leftcol input[type=range] { margin: 1px 0 3px; height: 14px; }
#leftcol .btns { margin-top: 5px; gap: 5px; }
#leftcol button, #leftcol .toggle { padding: 3px 8px; font-size: 12.5px; }
#leftcol #readout .big { font-size: 30px; }
#leftcol #readout canvas { height: 56px; }
/* строка «Пауза · Подписи · Молекулы воздуха»: равные ширины, надпись не сдвигает кнопки */
.btns.sys { display: grid; grid-template-columns: repeat(3, 1fr); }
.btns.sys button { width: 100%; text-align: center; white-space: nowrap; padding-left: 4px; padding-right: 4px; }
/* подписи самописцев в «Показании» */
#readout .chart-t { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
#readout .chart-t b { color: #fff; font-weight: 500; }
/* ---------- Фиксированные размеры панелей: содержимое не меняет их высоту и ширину ---------- */
#readout, #controls { font-variant-numeric: tabular-nums; }
#readout .vals { min-width: 0; }
/* предупреждение: место всегда зарезервировано на две строки */
#readout .warn {
  height: 34px; min-height: 34px; line-height: 17px; margin: 2px 0; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
/* строки значений и подписи — без переносов */
#readout .small, #readout .unit, #readout .chart-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#readout > .note { height: 34px; line-height: 17px; overflow: hidden; }
#controls .row label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#controls .row output { flex: none; width: auto; min-width: 70px; white-space: nowrap; }

/* два самописца в «Показании»: измеряемая величина и пересчитанная концентрация */
#readout .chart-t { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; font-size: 11.5px; }
#readout .chart-t .nm { overflow: hidden; text-overflow: ellipsis; }
#readout .chart-t .lg { margin-left: auto; display: flex; gap: 9px; font-size: 11px; flex: none; }
#readout .chart-t .lg i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }
#leftcol #readout canvas.ch { height: 44px; margin-top: 2px; }

/* самописцы рядом: слева измеряемая величина, справа пересчитанная концентрация */
#readout .charts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
#readout .chb { min-width: 0; }
#readout .chb .chart-t { display: block; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#leftcol #readout .chb canvas.ch { height: 52px; margin-top: 2px; }
#readout .lgl { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; margin-top: 2px; }
#readout .lgl .lg { display: flex; gap: 8px; }
#readout .lgl .lg i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }

/* «Принцип работы»: заголовок закреплён, прокручивается только текст; стрелки прокрутки */
#info { display: flex; flex-direction: column; overflow: hidden; }
#info > h3 { flex: none; }
#info .info-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: none; }
#info .info-body::-webkit-scrollbar { display: none; }
#info .scr { flex: none; height: 20px; margin: 0 0 6px; padding: 0; font-size: 10px; line-height: 18px; cursor: pointer;
  color: var(--text); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-border); border-radius: 5px; }
#info .scr.dn { margin: 6px 0 0; }
#info .scr:hover:not(:disabled) { background: rgba(255, 106, 61, 0.2); color: #fff; }
#info .scr:disabled { opacity: 0.25; cursor: default; }
