:root {
  --bg: #ffffff;
  --bg-panel: #e2e2e2;
  --bg-panel-header: #cfcfcf;
  --bg-hover: #cecece;
  --bg-selected: #929292;
  --border: #3c3c3c;
  --text: #000000;
  --text-muted: #555555;
  --accent: #ffb400;
  --accent-hover: #ffd500;
  --danger: #f06a6a;

  --kind-mesh: #d19a66;
  --kind-transform: #61afef;
  --kind-light: #e5c07b;
  --kind-camera: #98c379;
  --kind-node: #9a9a9a;

  --row-height: 24px;
  --indent: 16px;

  --red: #cc0000;
  --yellow: #ffb400;
  --light-gray: #f4f4f4;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 13px;
}

[hidden] {
  display: none !important;
}

/* ---------- Buttons ---------- */

.button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 8px 16px;
  cursor: pointer;
}

.button:hover {
  background: var(--bg-hover);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button--small {
  padding: 3px 10px;
  font-size: 12px;
}

/* ---------- Startbildschirm ---------- */

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.start-card {
  width: min(480px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  border: 1px solid var(--border);
  padding: 20px;
  row-gap: 20px;
}

.start-logos {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
}

.start-logo {
  height: 24px;
}

.start-dec3-logo {
  margin-left: auto;
  height: 24px;
}

.start-title {
  font-size: 28px;
  margin: 0;
  margin-top: 20px;
  font-weight: 600;
  color: var(--red);
}

.start-block {
  display: flex;
  flex-direction: column;
  row-gap: 20px;
  padding: 0 20px;
}

.start-hr {
  width: calc(100% + 40px);
  height: 1px;
  margin-left: -20px;
  margin-right: -20px;
  border: none;
  border-bottom: 1px solid var(--border);
}

.start-block-headline {
  text-align: left;
  font-weight: 400;
  font-size: 18px;
  margin: 0;
  margin-left: -20px;
}

.start-button {
  font: inherit;
  cursor: pointer;
  background: var(--yellow);
  border: 1px solid var(--yellow);
  padding: 20px 40px;
  font-weight: 600;
  font-size: 20px;
  display: flex;
  flex-direction: column;
}

.start-button:hover {
  background: var(--accent-hover);
}

.start-info {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  min-height: 1em;
}

.start-comment {
  margin: 0;
  color: var(--text-muted);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px dashed var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-hover);
}

.drop-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-text {
  font-size: 15px;
}

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

.start-error {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--danger);
  border-radius: 4px;
  color: var(--danger);
  background: rgba(240, 106, 106, 0.08);
}

/* ---------- Layout: Viewport 2/3, Panel 1/3 ---------- */

.app {
  display: grid;
  grid-template-columns: 2fr 1fr;
}

.viewport {
  position: relative;
  min-width: 0;
  overflow: hidden;

}

.render-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

.viewport-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(30, 30, 30, 0.7);
  color: var(--light-gray);
  font-size: 12px;
  pointer-events: none;
}

.viewport-status:empty {
  display: none;
}

/* Achsenanzeige unten rechts */
.axes-indicator {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(30, 30, 30, 0.45);
  pointer-events: none;
}

.axes-indicator svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis--x { --axis-color: #e5484d; }
.axis--y { --axis-color: #46a758; }
.axis--z { --axis-color: #3e8ef7; }

.axis-line {
  stroke: var(--axis-color);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.axis-head {
  fill: var(--axis-color);
}

.axis-negative {
  fill: var(--axis-color);
  opacity: 0.45;
}

.axis-label {
  fill: #ffffff;
  font-size: 9px;
  font-weight: 700;
}

/* Feste Ansichten: über der Achsenanzeige am rechten Rand */
.view-buttons {
  position: absolute;
  right: 12px;
  bottom: calc(12px + 84px + 8px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 84px;
}

.view-button {
  padding: 4px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  color: #000000;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.view-button:hover {
  background: var(--light-gray);
}

/* ---------- Ladeanzeige ---------- */

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(200, 200, 200, 0.85);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 14px;

}

.progress {
  width: 240px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* ---------- Seitenpanel ---------- */

.side-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  height: 100vh;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-header);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-file-name {
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-filter {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.tree-filter:focus {
  outline: none;
  border-color: var(--accent);
}

.panel-actions {
  display: flex;
  gap: 6px;
}

.panel-footer {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
}

.panel-move {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.panel-directions {
  height: 60px;
  width: 60px;
  position: relative;
}

.panel-direction {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  position: absolute;
}

.panel-direction:hover:not(:disabled) {
  background: var(--bg-hover);
}

.panel-direction:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.panel-direction--top {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.panel-direction--left {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.panel-direction--right {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.panel-direction--bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.panel-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

.panel-option-label {
  color: var(--text-muted);
  font-size: 12px;
}

/* Umschalter aus zwei oder mehr Buttons, der aktive ist hervorgehoben */
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.segmented-button {
  padding: 3px 10px;
  border: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.segmented-button + .segmented-button {
  border-left: 1px solid var(--border);
}

.segmented-button:hover {
  background: var(--bg-hover);
}

.segmented-button[aria-pressed="true"] {
  background: var(--accent);
}

/* Kameraauswahl: Menü öffnet sich nach oben, da der Button unten im Panel sitzt */
.camera-select {
  position: relative;
}

.camera-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  max-width: 280px;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.camera-menu-item {
  padding: 5px 10px;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.camera-menu-item:hover {
  background: var(--bg-hover);
}

.camera-menu-item[aria-checked="true"] {
  background: var(--accent);
}

/* Animationen: aufklappbare Liste mit Abspielen/Pausieren je Animation */
.panel-option-buttons {
  display: flex;
  gap: 6px;
}

.animation-toggle::after {
  content: "▸";
  display: inline-block;
  margin-left: 6px;
  transition: transform 0.15s;
}

.animation-toggle[aria-expanded="true"]::after {
  transform: rotate(90deg);
}

.animation-list {
  max-height: 160px;
  margin: 0 0 4px;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  background: var(--bg);
}

.animation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--row-height);
  padding: 0 8px 0 4px;
}

.animation-item + .animation-item {
  border-top: 1px solid var(--bg-panel);
}

.animation-play {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.animation-play:hover {
  background: var(--bg-hover);
}

.animation-play svg {
  width: 12px;
  height: 12px;
  fill: var(--text);
}

.animation-play[aria-pressed="true"] .icon-play,
.animation-play[aria-pressed="false"] .icon-pause {
  display: none;
}

.animation-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.animation-time {
  flex: none;
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.panel-footer-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
}

/* ---------- Szenenbaum ---------- */

.scene-tree {
  flex: 1;
  overflow: auto;
  padding: 4px 0;
  user-select: none;
}

.tree-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--row-height);
  padding-right: 8px;
  padding-left: calc(4px + var(--depth, 0) * var(--indent));
  white-space: nowrap;
  cursor: default;
}

.tree-row:hover {
  background: var(--bg-hover);
}

.tree-row.is-selected {
  background: var(--bg-selected);
}

/* Gruppe unter der Maus in der 3D-Szene */
.tree-row.is-hovered {
  box-shadow: inset 3px 0 0 var(--accent);
  background: var(--accent-hover);
}

.tree-expander,
.tree-expander-spacer {
  flex: none;
  width: 16px;
  height: 16px;
}

.tree-expander {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.tree-expander::before {
  content: "";
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.1s;
}

.tree-expander[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.node-kind {
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 4px 0 2px;
  border-radius: 2px;
  background: var(--kind-node);
}

.node-kind--mesh { background: var(--kind-mesh); }
.node-kind--transform { background: var(--kind-transform); border-radius: 50%; }
.node-kind--light { background: var(--kind-light); border-radius: 50%; }
.node-kind--camera { background: var(--kind-camera); }

.tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-path {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 6px;
}

.tree-count {
  flex: none;
  color: var(--text-muted);
  font-size: 11px;
}

/* Sichtbarkeits-Toggle */

.visibility-toggle {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.visibility-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.visibility-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visibility-toggle .icon-hidden,
.visibility-toggle[aria-pressed="false"] .icon-visible {
  display: none;
}

.visibility-toggle[aria-pressed="false"] .icon-hidden {
  display: block;
}

.visibility-toggle[aria-pressed="false"] {
  color: var(--text-muted);
}

/* Ausgeblendet (selbst) bzw. durch einen Eltern-Node ausgeblendet */
.tree-row.is-hidden .tree-label,
.tree-row.is-hidden .node-kind {
  opacity: 0.4;
}

.tree-row.is-parent-hidden .tree-label,
.tree-row.is-parent-hidden .node-kind,
.tree-row.is-parent-hidden .visibility-toggle {
  opacity: 0.45;
}

.tree-message {
  padding: 12px;
  color: var(--text-muted);
}
