:root {
  --bg-outer: #0f0f0f;
  --bg: #0f0f0f;
  --canvas-top: #1c1c1c;
  --canvas-bottom: #1c1c1c;
  --loading-top: #1c1c1c;
  --loading-bottom: #1c1c1c;
  --modal-bg: #1c1c1c;
  --modal-focus: #292929;
  --modal-border: #292929;
  --modal-radius: 14px;
  --panel: #1c1c1c;
  --panel-2: #292929;
  --accent: #ffea00;
  --accent-2: #ffea00;
  --text: #e6edf3;
  --muted: #9aa4b5;
  --border: #233044;
  --error: #ff6b6b;
  --success: #6fffa1;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --panel-alpha: 1;
  --panel-radius: 14px;
  --toolbar-bg: #1c1c1c;
  --toolbar-bg-active: #ffea00;
  --toolbar-border: #233044;
  --template-fill: #1c1c1c;
  --template-outline: #233044;
  --template-outline-hover: rgba(255, 234, 0, 0.7);
  --template-glow-strength: 80%;
  --highlight-color: #ffea00;
  --cube-text: #242424;
  --cube-edges: #e0e7ff;
  --cube-base: #ffea00;
  --cube-hover: #ffffff;
  --cube-edge-color: #e0e7ff;
  --cube-edge-alpha: 0.6;
  --plus-color: #ffea00;
  --measure-line: #ffea00;
  --measure-label: #ffea00;
  --measure-label-text: #292929;
  --measure-dot: #ffea00;
  --tb-size: 25px;
  --tb-gap: 10px;
  --tb-radius: 7px;
  --tb-pad-y: 6px;
  --tb-icon-pad: 5px;
  --tb-icon-size: 13px;
  --settings-width: 350px;
  --templates-width: 350px;
  --templates-left: 72px;
  --templates-bottom: 12px;
  --settings-left: 72px;
  --settings-bottom: 12px;
  --measure-left: 72px;
  --measure-bottom: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(76, 224, 210, 0.08), transparent 28%),
              radial-gradient(circle at 82% 22%, rgba(116, 240, 229, 0.08), transparent 25%),
              var(--bg-outer);
  color: var(--text);
  overflow: hidden;
}

html,
body,
.viewer-wrapper,
#viewerCanvas {
  outline: none;
}

#viewerCanvas:focus,
#viewerCanvas:focus-visible,
.viewer-wrapper:focus,
.viewer-wrapper:focus-visible {
  outline: none;
  box-shadow: none;
}

header {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 20;
  pointer-events: none;
}

.ue-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-btn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 32px;
}


.main {
  position: relative;
  padding: 0;
  margin: 0;
  height: 100vh;
  width: 100vw;
}

.viewer-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--panel);
  height: 100vh;
  width: 100vw;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

#viewerCanvas {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--canvas-top), var(--canvas-bottom));
}

#navCube {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 100px;
  height: 100px;
  z-index: 5;
  display: none;
}

/* убираем штатный спиннер xeokit (sk-circle) */
.sk-circle,
[class*="sk-circle"] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.drop-hint {
  position: absolute;
  inset: 0;
  border: none;
  border-radius: 14px;
  margin: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--loading-top), var(--loading-bottom));
  color: var(--muted);
  text-align: center;
  pointer-events: none;
  z-index: 4;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.drop-hint.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(76, 224, 210, 0.06);
}

.drop-hint.hidden {
  display: none;
}

.drop-center {
  position: relative;
  width: 110px;
  height: 110px;
}

.drop-plus {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  border-radius: 12px;
  font-size: 44px;
  font-weight: 700;
  color: var(--plus-color);
  background: transparent;
  border: none;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  display: grid;
  place-items: center;
  line-height: 1;
}

.drop-formats {
  font-size: 9.6px;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 90px; /* ширина плюсика ~90px */
  pointer-events: none;
}

.drop-formats > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  white-space: nowrap;
  width: 140px;
}

.drop-formats > div:first-child {
  text-align: right;
}

.drop-formats > div:last-child {
  text-align: left;
}

.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  --loader-size: 32px;
  --loader-duration: 1.15s;
  width: var(--loader-size);
  height: 0;
  padding-top: var(--loader-size);
  overflow: visible;
  pointer-events: none;
  z-index: 7;
}

.loader.hidden {
  display: none;
}

.loader__figure,
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.loader__figure {
  width: 0;
  height: 0;
  box-sizing: border-box;
  border: 0 solid var(--loader-color, var(--accent));
  border-radius: 50%;
  animation: loader-figure var(--loader-duration) infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

.loader__label {
  display: none;
}

@keyframes loader-figure {
  0% {
    width: 0;
    height: 0;
    background-color: var(--loader-color, var(--accent));
  }
  29% {
    background-color: var(--loader-color, var(--accent));
  }
  30% {
    width: var(--loader-size);
    height: var(--loader-size);
    background-color: transparent;
    border-width: calc(var(--loader-size) / 2);
    opacity: 1;
  }
  100% {
    width: var(--loader-size);
    height: var(--loader-size);
    border-width: 0;
    opacity: 0;
    background-color: transparent;
  }
}

@keyframes loader-label {
  0% { opacity: 0.25; }
  30% { opacity: 1; }
  100% { opacity: 0.25; }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status-bar {
  display: none;
}

.status-bar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(76, 224, 210, 0.18);
}

.side-panel {
  position: fixed;
  top: 170px;
  right: 12px;
  bottom: 12px;
  width: 320px;
  max-height: calc(100vh - 90px);
  overflow: auto;
  background: color-mix(in srgb, var(--modal-bg) var(--modal-bg-alpha, 100%), transparent);
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius, 16px);
  padding: 14px 14px 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 11;
  display: none;
}

.panel-section {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.panel-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.panel-section p,
.panel-section ul {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel-section ul {
  padding-left: 18px;
}

.project-name-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--modal-radius, 10px);
  border: 1px solid var(--modal-border);
  background: color-mix(in srgb, var(--modal-focus) var(--modal-focus-alpha, 100%), transparent);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.project-name-input:focus {
  border-color: var(--modal-element-outline);
  box-shadow: 0 0 0 2px rgba(255, 234, 0, 0.08);
}

.inline-error {
  min-height: 16px;
}

.primary-btn,
.secondary-btn {
  border-radius: var(--modal-radius, 12px);
  border: 1px solid var(--template-outline);
  font-weight: 700;
  padding: 12px;
  width: 100%;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s ease;
}

.danger-btn {
  background: var(--modal-element);
  color: var(--text);
  border-color: var(--modal-border);
}

.danger-btn:not(:disabled):hover {
  background: var(--modal-border);
}

.primary-btn {
  background: color-mix(in srgb, var(--modal-btn-primary, var(--accent)) 100%, transparent);
  color: #0f0f0f;
  box-shadow: 0 8px 24px rgba(255, 234, 0, 0.25);
}

.primary-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(255, 234, 0, 0.3);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-btn {
  background: color-mix(in srgb, var(--modal-btn-secondary, var(--modal-focus)) var(--modal-focus-alpha, 100%), transparent);
  color: var(--text);
  border-color: var(--modal-border);
}

.secondary-btn:not(:disabled):hover {
  background: var(--modal-border);
}

#saveProjectSection {
  margin-top: auto;
}

.log {
  background: var(--modal-focus);
  border-radius: var(--modal-radius, 12px);
  border: 1px solid var(--modal-border);
  min-height: 100px;
  max-height: 140px;
  overflow: auto;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  white-space: pre-line;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.switch input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* убираем браузерный фокусный пунктир на тулбаре */
.toolbar *:focus,
.toolbar *:focus-visible,
.switch:focus,
.switch:focus-visible {
  outline: none;
  box-shadow: none;
}

.tree {
  background: color-mix(in srgb, var(--modal-element) var(--modal-focus-alpha, 100%), transparent);
  border-radius: 10px;
  border: 1px solid var(--modal-element-outline, var(--modal-element));
  height: 260px;
  overflow: auto;
  padding: 8px;
  list-style: none;
}

.tree .highlighted-node {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 2px 4px;
}

.tree .highlighted-node > span {
  display: inline-flex;
  align-items: center;
  width: auto;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}

.tree li {
  position: relative;
  padding-left: 0;
  padding-right: 18px;
  cursor: pointer;
}

.tree li > span {
  display: inline-block;
  padding-right: 6px;
}

.tree li::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
}

.tree li > a.plus,
.tree li > a.minus {
  position: absolute;
  right: 4px;
  top: 6px; /* фиксированное позиционирование, чтобы не прыгало при раскрытии */
  width: 9px;
  height: 9px;
  text-indent: -9999px;
  overflow: visible;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-block;
}

.tree li > a.plus::after,
.tree li > a.minus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.tree li > a.plus::after {
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-left: 5px solid var(--text);
}

.tree li > a.minus::after {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text);
}

.tree li > input[type="checkbox"] {
  margin-right: 6px;
}

.display-mode-panel {
  margin-top: 10px;
}

.display-mode-title {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.display-mode-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.display-mode-buttons button {
  min-width: 0;
  border: 1px solid var(--modal-border);
  border-radius: 9px;
  background: var(--modal-focus);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  outline: none;
  padding: 8px 6px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.display-mode-buttons button:hover,
.display-mode-buttons button.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--modal-focus));
  color: var(--text);
}

.display-mode-buttons button:focus,
.display-mode-buttons button:focus-visible {
  outline: none;
  box-shadow: none;
}

.examples-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px;
  background: rgba(12, 17, 24, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(5px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  z-index: 10;
  pointer-events: auto;
}
.templates-panel {
  position: fixed;
  left: var(--templates-left, 72px);
  bottom: var(--templates-bottom, 12px);
  background: color-mix(in srgb, var(--modal-bg) var(--modal-bg-alpha, 100%), transparent);
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius, 14px);
  padding: 10px;
  display: grid;
  gap: 10px;
  width: var(--templates-width, 280px);
  min-height: 200px;
  max-height: 420px;
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  z-index: 20;
  backdrop-filter: blur(5px);
}

.templates-panel.hidden {
  display: none;
}

.templates-panel .templates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 0 6px;
  color: var(--text);
  font-weight: 700;
}

.templates-panel .templates-title {
  font-size: 14px;
}

.templates-panel .templates-close {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--template-outline);
  background: color-mix(in srgb, var(--template-fill) var(--modal-focus-alpha, 100%), transparent);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.templates-panel .template-list {
  display: contents;
}

.templates-panel .example-card {
  background: color-mix(in srgb, var(--project-btn-fill) var(--modal-focus-alpha, 100%), transparent);
  border: 1px solid var(--project-btn-border);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  position: relative;
}

.templates-panel .example-card span {
  display: none;
}

.templates-panel .templates-section {
  display: grid;
  gap: 6px;
}

.templates-panel .templates-subtitle {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0 6px;
}

.templates-panel .templates-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 6px;
}

.template-card {
  display: grid;
  gap: 4px;
  align-items: flex-start;
}

.template-card .card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.template-card .card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.template-card .card-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--modal-focus);
  border: 1px solid var(--modal-border);
  color: var(--text);
  font-size: 12px;
}

.template-card .card-pill[data-kind="template"] {
  background: rgba(255, 234, 0, 0.12);
  color: var(--accent);
  border-color: rgba(255, 234, 0, 0.3);
}

.template-card .card-pill[data-kind="project"] {
  background: rgba(49, 178, 255, 0.12);
  color: #9ad8ff;
  border-color: rgba(49, 178, 255, 0.35);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 17, 24, 0.6);
  backdrop-filter: blur(2px);
  z-index: 35;
}

.modal-backdrop.hidden {
  display: none;
}

.templates-panel.measurement-modal {
  left: var(--measure-left, var(--templates-left, 72px));
  bottom: var(--measure-bottom, var(--templates-bottom, 12px));
  top: auto;
  transform: none;
  max-height: min(70vh, 420px);
  width: var(--templates-width, 280px);
  max-width: min(var(--templates-width, 350px), calc(100vw - 32px));
  padding: 12px;
  z-index: 40;
}

.measurement-modal .template-list {
  grid-template-columns: 1fr;
}

.measurement-modal .example-card {
  width: 100%;
}

.save-project-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 40px));
  background: color-mix(in srgb, var(--modal-bg) var(--modal-bg-alpha, 1), transparent);
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius, 14px);
  padding: 16px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
  z-index: 45;
  display: grid;
  gap: 10px;
}

.save-project-modal.hidden {
  display: none;
}

.save-project-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.save-project-modal .modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.save-project-modal .modal-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--modal-border);
  background: var(--modal-focus);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.save-project-modal .modal-close:hover {
  background: var(--modal-border);
}

.save-project-modal .input-label {
  font-size: 13px;
  color: var(--text);
}

.save-project-modal input[type="text"] {
  width: 100%;
  padding: 12px;
  border-radius: var(--modal-radius, 10px);
  border: 1px solid var(--modal-border);
  background: color-mix(in srgb, var(--modal-focus) var(--modal-focus-alpha, 1), transparent);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.save-project-modal input[type="text"]:focus {
  border-color: var(--modal-element-outline);
  box-shadow: 0 0 0 2px rgba(255, 234, 0, 0.08);
}

.save-project-modal .input-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: -6px;
}

.save-project-modal .modal-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.save-project-modal .modal-actions .primary-btn,
.save-project-modal .modal-actions .secondary-btn {
  width: auto;
  min-width: 140px;
  flex: 1;
  text-align: center;
}

.save-project-modal .error-text {
  min-height: 18px;
  color: var(--error);
  font-size: 12px;
}

.settings-panel {
  position: fixed;
  left: var(--settings-left, 72px);
  bottom: var(--settings-bottom, 12px);
  background: color-mix(in srgb, var(--modal-bg) var(--modal-bg-alpha, 100%), transparent);
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius, 14px);
  padding: 8px;
  display: grid;
  gap: 6px;
  width: var(--settings-width, 320px);
  min-height: 300px;
  max-height: 520px;
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  z-index: 22;
  font-size: 12px;
}

.settings-panel .settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-weight: 700;
  padding-bottom: 2px;
}

.settings-panel .settings-title {
  font-size: 12px;
}

.settings-panel .settings-close {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  border: 1px solid var(--modal-border);
  background: color-mix(in srgb, var(--modal-focus) var(--modal-focus-alpha, 100%), transparent);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.settings-panel .settings-section {
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius, 10px);
  padding: 6px;
  background: color-mix(in srgb, var(--modal-focus) var(--modal-focus-alpha, 100%), transparent);
  display: grid;
  gap: 4px;
}

.settings-panel .section-title {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 2px;
}

.settings-panel .color-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 4px 6px 4px 6px;
}

.slider-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
  padding: 4px 6px 4px 6px;
}

.slider-label {
  color: var(--text);
  font-size: 13px;
}

.slider-input {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--slider-fill-color, #ffffff) var(--slider-percent, 0%), #2f3544 var(--slider-percent, 0%));
  outline: none;
  cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--slider-thumb-color, #ffffff);
  border: 2px solid var(--modal-border);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
}

.slider-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--slider-thumb-color, #ffffff);
  border: 2px solid var(--modal-border);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
}

.settings-panel input[type="color"] {
  width: 100%;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: currentColor;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}

.settings-panel input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.settings-panel input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

.settings-panel input[type="text"],
.settings-panel input[type="number"] {
  width: 100%;
  max-width: 86px;
  background: color-mix(in srgb, var(--modal-element) var(--modal-focus-alpha, 100%), transparent);
  border: 1px solid var(--modal-element-outline, var(--modal-element));
  border-radius: 8px;
  color: var(--text);
  padding: 5px 6px;
}

.log {
  background: color-mix(in srgb, var(--modal-element) var(--modal-focus-alpha, 100%), transparent);
  border: 1px solid var(--modal-element-outline, var(--modal-element));
}


.bottom-toolbar {
  position: fixed;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--tb-gap, 8px);
  padding: var(--tb-pad-y, 8px) 0;
  z-index: 15;
}

.tb-btn {
  width: var(--tb-size, 52px);
  height: var(--tb-size, 52px);
  border-radius: var(--tb-radius, 12px);
  background: var(--toolbar-bg);
  border: 1px solid var(--toolbar-border);
  color: var(--text);
  font-size: var(--tb-icon-size, 22px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--tb-icon-pad, 10px);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.tb-btn:hover {
  transform: translateY(-1px);
  border-color: var(--toolbar-outline, rgba(76, 224, 210, 0.7));
  box-shadow: 0 10px 20px color-mix(in srgb, var(--toolbar-outline, rgba(76, 224, 210, 0.7)) 30%, transparent);
}

.tb-btn.active {
  background: var(--toolbar-bg-active);
}

.templates-panel {
  position: fixed;
  left: var(--templates-left, 72px);
  bottom: var(--templates-bottom, 12px);
  background: color-mix(in srgb, var(--modal-bg) var(--modal-bg-alpha, 100%), transparent);
  border: 1px solid var(--modal-border);
  border-radius: var(--modal-radius, 14px);
  padding: 10px;
  display: grid;
  gap: 10px;
  width: var(--templates-width, 280px);
  min-height: 200px;
  max-height: 420px;
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  z-index: 20;
  backdrop-filter: blur(5px);
}

.example-card {
  background: color-mix(in srgb, var(--project-btn-fill) var(--modal-focus-alpha, 100%), transparent);
  border: 1px solid var(--project-btn-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  color: #fff;
}

.example-card:hover {
  transform: translateY(-2px);
  border-color: var(--project-btn-hover, rgba(76, 224, 210, 0.7));
  box-shadow: 0 12px 26px color-mix(in srgb, var(--project-btn-hover, rgba(76, 224, 210, 0.7)) var(--template-glow-strength, 80%), transparent);
}

.example-card strong {
  display: block;
  margin-bottom: 6px;
}

.example-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.transform-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.btn.tiny {
  padding: 6px 8px;
  font-size: 12px;
}

.transform-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.transform-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.transform-grid input {
  flex: 1;
  background: color-mix(in srgb, var(--modal-element) var(--modal-focus-alpha, 100%), transparent);
  border: 1px solid var(--modal-element-outline, var(--modal-element));
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.panel-section .transform-grid input {
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1100px) {
  .main {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .side-panel {
    order: -1;
  }
}

@media (max-width: 720px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    width: 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .examples-bar {
    grid-template-columns: 1fr;
  }
}
