/* ==========================================================================
   Физлаб 3D · стили
   Концепция: холст во весь экран, поверх — «приборные» плашки:
   верхняя строка управления временем, слева — инструменты, справа — панель свойств.
   ========================================================================== */

:root {
  /* светлая тема */
  --ground: #eef2fb;
  --plate: #ffffff;
  --plate-2: #f2f5fb;
  --inset: #e8edf7;
  --line: rgba(24, 34, 64, 0.1);
  --ink: #1b2238;
  --ink-soft: #4a5370;
  --muted: #727b96;
  --signal: #c66a00;
  --signal-ink: #ffffff;
  --signal-soft: rgba(198, 106, 0, 0.12);
  --danger: #d6334a;
  --danger-soft: rgba(214, 51, 74, 0.1);
  --ok: #0ca678;
  --shadow: 0 6px 24px rgba(30, 40, 80, 0.12), 0 1px 2px rgba(30, 40, 80, 0.08);
  --font-ui: "Manrope", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-brand: "Unbounded", "Manrope", system-ui, sans-serif;
  --font-num: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --r: 12px;
  --r-sm: 8px;
  --panel-w: 328px;
  --gap: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0b1020; --plate: #141b2d; --plate-2: #1a2238; --inset: #0f1527;
    --line: rgba(190, 205, 255, 0.08); --ink: #e7ebf6; --ink-soft: #b8c0d8; --muted: #7f89a8;
    --signal: #f5a524; --signal-ink: #1a1203; --signal-soft: rgba(245, 165, 36, 0.14);
    --danger: #ff6b81; --danger-soft: rgba(255, 107, 129, 0.12); --ok: #3ddc97;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0b1020; --plate: #141b2d; --plate-2: #1a2238; --inset: #0f1527;
  --line: rgba(190, 205, 255, 0.08); --ink: #e7ebf6; --ink-soft: #b8c0d8; --muted: #7f89a8;
  --signal: #f5a524; --signal-ink: #1a1203; --signal-soft: rgba(245, 165, 36, 0.14);
  --danger: #ff6b81; --danger-soft: rgba(255, 107, 129, 0.12); --ok: #3ddc97;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 500 13px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
kbd {
  font: 600 10.5px/1 var(--font-num);
  padding: 3px 5px; border-radius: 5px;
  background: var(--inset); color: var(--ink-soft); border: 1px solid var(--line);
}
.ico { width: 18px; height: 18px; flex: none; display: block; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* плашки поверх холста — без backdrop-filter, чтобы не перерисовывать размытие каждый кадр */
.plate {
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ------------------------------ верхняя строка ------------------------------ */

#topbar {
  position: fixed;
  top: calc(var(--gap) + env(safe-area-inset-top, 0px));
  left: calc(var(--gap) + env(safe-area-inset-left, 0px));
  right: calc(var(--panel-w) + var(--gap) * 2 + env(safe-area-inset-right, 0px));
  height: 48px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 14px;
  z-index: 20;
}
.panel-closed #topbar { right: calc(var(--gap) + env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 9px; margin-right: 6px; }
.brand-mark { width: 22px; height: 22px; color: var(--signal); }
.brand b { font: 700 15px/1 var(--font-brand); letter-spacing: 0.01em; }
.scene-name {
  min-width: 0; max-width: 260px;
  padding: 6px 10px; border-radius: var(--r-sm);
  color: var(--ink-soft); background: transparent; border: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scene-name:hover { background: var(--inset); color: var(--ink); }
.vsep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex: none; }
.spacer { flex: 1; min-width: 8px; }
.ibtn {
  width: 36px; height: 36px; display: grid; place-items: center; flex: none;
  border-radius: var(--r-sm); border: 0; background: transparent; color: var(--ink-soft);
}
.ibtn:hover { background: var(--inset); color: var(--ink); }
.ibtn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.ibtn.play { width: 44px; background: var(--signal); color: var(--signal-ink); }
.ibtn.play:hover { filter: brightness(1.08); background: var(--signal); color: var(--signal-ink); }
.ibtn.play.paused { box-shadow: 0 0 0 4px var(--signal-soft); }
.speed {
  height: 32px; padding: 0 8px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--inset);
  font: 600 12px var(--font-num); color: var(--ink);
}
.state-pill {
  font: 700 10.5px/1 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 8px; border-radius: 999px; color: var(--signal); background: var(--signal-soft);
  display: none;
}
.is-paused .state-pill { display: inline-block; }

/* ------------------------------ инструменты ------------------------------ */

#toolbar {
  position: fixed;
  top: calc(48px + var(--gap) * 2 + env(safe-area-inset-top, 0px));
  left: calc(var(--gap) + env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 2px;
  padding: 5px; z-index: 20;
  max-height: calc(100% - 48px - var(--gap) * 4 - 40px);
  overflow-y: auto; scrollbar-width: none;
}
#toolbar::-webkit-scrollbar { display: none; }
.tool {
  position: relative; width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-soft);
}
.tool .ico { width: 20px; height: 20px; }
.tool:hover { background: var(--inset); color: var(--ink); }
.tool.active { background: var(--signal); color: var(--signal-ink); }
.tool .tip {
  position: fixed; left: 70px; transform: translateY(-50%); margin-top: 20px;
  display: none; align-items: center; gap: 8px; white-space: nowrap;
  padding: 6px 8px 6px 10px; border-radius: var(--r-sm);
  background: var(--plate); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-weight: 600; pointer-events: none;
}
@media (hover: hover) { .tool:hover .tip { display: flex; } }
.tb-sep { height: 1px; margin: 4px 6px; background: var(--line); flex: none; }

/* ------------------------------ панель свойств ------------------------------ */

#panel {
  position: fixed;
  top: calc(var(--gap) + env(safe-area-inset-top, 0px));
  right: calc(var(--gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  width: var(--panel-w);
  display: flex; flex-direction: column; z-index: 25;
  overflow: hidden;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.panel-closed #panel { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
#tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px 6px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 700;
}
.tab:hover { color: var(--ink); background: var(--inset); }
.tab.active { color: var(--ink); background: var(--signal-soft); }
.tab.active .ico { color: var(--signal); }
#panelBody {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 14px 18px; user-select: text; -webkit-user-select: text;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}

.sec { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h3, .details > summary {
  margin: 0; font: 800 10.5px/1.2 var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.details { display: block; }
.details-body { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.details > summary::-webkit-details-marker { display: none; }
.details > summary::after { content: "+"; font: 600 14px var(--font-num); color: var(--muted); }
.details[open] > summary::after { content: "−"; }
.muted { color: var(--muted); margin: 0; font-size: 12px; }

.ctl { display: flex; flex-direction: column; gap: 6px; }
.ctl.disabled { opacity: 0.5; pointer-events: none; }
.ctl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ctl-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.ctl-label { color: var(--ink-soft); font-weight: 600; min-width: 0; }
.ctl-val { display: flex; align-items: baseline; gap: 4px; }
.unit { color: var(--muted); font: 500 11px var(--font-num); }
.num {
  width: 64px; padding: 3px 6px; text-align: right;
  font: 600 12px var(--font-num); font-variant-numeric: tabular-nums;
  background: var(--inset); border: 1px solid transparent; border-radius: 6px; color: var(--ink);
}
.num.wide { width: 70px; }
.num:hover { border-color: var(--line); }
.num:focus { outline: none; border-color: var(--signal); }
.vec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vcell { display: flex; align-items: center; gap: 4px; min-width: 0; }
.vcell i { font: 600 11px var(--font-num); font-style: normal; color: var(--muted); }
.num.v3 { width: 100%; min-width: 0; }

input[type="range"] {
  --p: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(to right, var(--signal) var(--p), var(--inset) var(--p));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--inset); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--signal); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: var(--plate); border: 2px solid var(--signal); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--plate); border: 2px solid var(--signal);
}

select {
  max-width: 170px; padding: 5px 8px; border-radius: 7px;
  background: var(--inset); border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 12.5px;
}
.txt {
  width: 100%; padding: 7px 9px; border-radius: 8px; resize: vertical;
  background: var(--inset); border: 1px solid var(--line); color: var(--ink);
}
.txt:focus { outline: none; border-color: var(--signal); }
input[type="color"] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

.tgl { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; color: var(--ink-soft); font-weight: 600; }
.tgl input { position: absolute; opacity: 0; pointer-events: none; }
.tgl i { position: relative; width: 32px; height: 18px; flex: none; border-radius: 999px; background: var(--inset); border: 1px solid var(--line); transition: background 0.15s; }
.tgl i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.tgl input:checked + i { background: var(--signal); border-color: var(--signal); }
.tgl input:checked + i::after { transform: translateX(14px); background: var(--signal-ink); }
.tgl input:focus-visible + i { outline: 2px solid var(--signal); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--plate); background: var(--c); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw:hover { transform: scale(1.12); }
.sw.none { background: repeating-linear-gradient(45deg, var(--inset) 0 3px, var(--plate-2) 3px 6px); }

.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--plate-2); color: var(--ink); font-weight: 650; font-size: 12.5px;
}
.btn .ico { width: 15px; height: 15px; }
.btn:hover { border-color: var(--signal); }
.btn.primary { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.armed { background: var(--danger); color: var(--plate); border-color: var(--danger); }

.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.readouts div { display: flex; flex-direction: column; gap: 2px; padding: 7px 9px; border-radius: 8px; background: var(--inset); min-width: 0; }
.readouts span { color: var(--muted); font-size: 11px; }
.readouts b { font: 600 13px var(--font-num); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

.insp-head { display: flex; align-items: center; gap: 10px; }
.insp-head b { display: block; font-size: 14px; }
.insp-head small { color: var(--muted); }
.dot { width: 28px; height: 28px; border-radius: 8px; background: var(--c); flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ico-dot { display: grid; place-items: center; background: var(--signal-soft); color: var(--signal); }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 8px 18px; border-bottom: 1px solid var(--line); }
.empty-state p { margin: 4px 0 0; font-weight: 700; }
.empty-state small { color: var(--muted); max-width: 30ch; }
.es-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--signal-soft); color: var(--signal); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; min-width: 0;
  padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--plate-2);
}
.card:hover { border-color: var(--signal); }
.card.current { border-color: var(--signal); background: var(--signal-soft); }
.card-ico { font-size: 18px; line-height: 1; }
.card b { font-size: 12.5px; }
.card small { color: var(--muted); font-size: 11px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px 6px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--plate-2); font-weight: 650; font-size: 12px;
}
.chip .ico { width: 14px; height: 14px; color: var(--signal); }
.chip:hover { border-color: var(--signal); }

.saves { display: flex; flex-direction: column; gap: 6px; }
.save { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 10px; background: var(--inset); }
.save-main { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 4px 6px; display: flex; flex-direction: column; }
.save-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-main small { color: var(--muted); font: 500 11px var(--font-num); }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--ink-soft); flex: none; }
.icon-btn .ico { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--plate); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.armed { background: var(--danger); color: var(--plate); }

/* ------------------------------ нижние плашки ------------------------------ */

#stats {
  position: fixed;
  left: calc(var(--gap) + env(safe-area-inset-left, 0px));
  bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  padding: 6px 10px; z-index: 15; border-radius: 8px;
  font: 500 11.5px var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-soft);
  pointer-events: none;
}
#stats b { color: var(--signal); }
#stats span { color: var(--muted); }
.no-stats #stats { display: none; }

#hint {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  max-width: min(560px, calc(100% - 520px)); padding: 7px 14px; border-radius: 999px; z-index: 15;
  font-size: 12px; color: var(--ink-soft); text-align: center; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#hint.empty { display: none; }

#graph {
  position: fixed; width: 260px; height: 116px; z-index: 15;
  right: calc(var(--panel-w) + var(--gap) * 2 + env(safe-area-inset-right, 0px));
  bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.panel-closed #graph { right: calc(var(--gap) + env(safe-area-inset-right, 0px)); }
.no-graph #graph { display: none; }

#toasts {
  position: fixed; top: calc(48px + var(--gap) * 2 + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 40; pointer-events: none;
}
.toast {
  padding: 8px 14px; border-radius: 10px; font-weight: 650; max-width: min(460px, 90vw);
  background: var(--ink); color: var(--ground); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); color: var(--plate); }

#ctxmenu {
  position: fixed; z-index: 50; min-width: 210px; padding: 5px; display: none; flex-direction: column;
}
#ctxmenu.open { display: flex; }
.mi { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-weight: 600; }
.mi .ico { width: 16px; height: 16px; color: var(--ink-soft); }
.mi span { flex: 1; }
.mi:hover { background: var(--inset); }
.mi.danger, .mi.danger .ico { color: var(--danger); }
.mi-sep { height: 1px; background: var(--line); margin: 4px 6px; }

#modal {
  position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(5, 8, 18, 0.5);
}
#modal.open { display: grid; }
.modal-card { position: relative; width: min(760px, 100%); max-height: 100%; overflow-y: auto; padding: 22px 24px; user-select: text; }
.modal-card h2 { margin: 0 0 6px; font: 700 20px/1.25 var(--font-brand); text-wrap: balance; }
.modal-card h4 { margin: 18px 0 8px; font: 800 10.5px var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.modal-card ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; color: var(--ink-soft); max-width: 70ch; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.keys { display: flex; flex-direction: column; gap: 6px; }
.keys div { display: flex; align-items: center; gap: 10px; }
.keys kbd { min-width: 34px; text-align: center; }
.keys span { color: var(--ink-soft); }
.share-box { display: flex; flex-direction: column; gap: 8px; }
.share-box textarea { font: 500 11px var(--font-num); min-height: 90px; }

/* ------------------------------ узкие экраны ------------------------------ */

@media (max-width: 760px) {
  :root { --panel-w: min(360px, calc(100vw - 24px)); --gap: 8px; }
  #topbar, .panel-closed #topbar { right: calc(var(--gap) + env(safe-area-inset-right, 0px)); padding-left: 8px; gap: 2px; }
  .brand b, .scene-name, .hide-sm, .state-pill { display: none !important; }
  .brand { margin-right: 0; }
  .vsep { margin: 0 2px; }
  #toolbar {
    top: auto; flex-direction: row; max-height: none;
    left: calc(var(--gap) + env(safe-area-inset-left, 0px));
    right: calc(var(--gap) + env(safe-area-inset-right, 0px));
    bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
    overflow-x: auto; overflow-y: hidden;
  }
  .tb-sep { width: 1px; height: auto; margin: 6px 3px; }
  .tool .tip { display: none !important; }
  #panel { top: calc(48px + var(--gap) * 2 + env(safe-area-inset-top, 0px)); bottom: calc(62px + var(--gap) * 2 + env(safe-area-inset-bottom, 0px)); }
  #hint { display: none; }
  #stats { bottom: auto; top: calc(48px + var(--gap) * 2 + env(safe-area-inset-top, 0px)); }
  #graph, .panel-closed #graph { right: calc(var(--gap) + env(safe-area-inset-right, 0px)); bottom: calc(62px + var(--gap) * 2 + env(safe-area-inset-bottom, 0px)); width: 220px; }
  .help-cols { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) { #hint { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------ 3D: загрузка, подписи ------------------------------ */

#loading {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: var(--ground); color: var(--ink);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#loading[hidden] { display: none; }
.load-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; max-width: 42ch; }
.load-card b { font: 700 22px var(--font-brand); }
.load-card p { margin: 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--inset); border-top-color: var(--signal); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--plate); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.link-2d { color: var(--signal); font-weight: 700; text-decoration: none; }
.link-2d:hover { text-decoration: underline; }

/* невысокие экраны: 17 инструментов должны помещаться без прокрутки */
@media (max-height: 860px) and (min-width: 761px) {
  .tool { width: 36px; height: 34px; }
  .tool .ico { width: 18px; height: 18px; }
  .tb-sep { margin: 3px 6px; }
}
