/* 3D-Viewer – übernommen aus der Hauptseite, Farben lokal gesetzt (dunkles Carbon-Panel) */
.viewer { --carbon:#0b0c0e; --carbon-1:#121418; --carbon-2:#1a1d22; --line:#2a2e35; --line-soft:#1f2228; --text:#eceef1; --muted:#9aa0a9; --red:#e3262b; --f-mono:"IBM Plex Mono", ui-monospace, Consolas, monospace; --radius:6px; color: var(--text); }
/* ---------- 3D-Viewer ---------- */
.viewer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 42% 45%, #1b1e24 0%, #101216 55%, #0b0c0e 100%);
}
.viewer-stage { position: relative; height: clamp(440px, calc(100vh - 320px), 720px); min-width: 0; }
.viewer-canvas { position: absolute; inset: 0; }
.viewer-canvas canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; touch-action: pan-y; }
.viewer-canvas canvas:active { cursor: grabbing; }

/* technisches Raster im Hintergrund */
.viewer-stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 60% 60% at 45% 50%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 45% 50%, #000 20%, transparent 75%);
  opacity: .55;
}

.viewer-pins { position: absolute; inset: 0; pointer-events: none; }
.pin {
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 1.5px solid var(--text);
  background: rgba(11, 12, 14, .82);
  color: var(--text);
  font-family: var(--f-mono); font-size: 0.66rem; font-weight: 500;
  display: grid; place-items: center;
  pointer-events: auto; cursor: pointer;
  opacity: 0;
  transition: opacity .25s, background .15s, border-color .15s;
}
.viewer.is-ready .pin { opacity: 1; }
.viewer.is-ready .pin.is-behind { opacity: .28; }
.pin:hover, .pin.is-active { background: var(--red); border-color: var(--red); color: #fff; opacity: 1 !important; }
.viewer.has-selection .pin:not(.is-active) { opacity: .2; }

.viewer-toolbar {
  position: absolute; left: 16px; right: 16px; bottom: 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  pointer-events: none;
}
.viewer-toolbar > * { pointer-events: auto; }
.tool {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  background: rgba(18, 20, 24, .85); border: 1px solid var(--line);
  color: var(--text); font-family: var(--f-mono); font-size: 0.74rem; letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer; backdrop-filter: blur(6px);
}
.tool:hover { border-color: var(--muted); }
.tool[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.tool svg { width: 14px; height: 14px; }
.viewer-hint { margin-left: auto; font-family: var(--f-mono); font-size: 0.7rem; color: var(--muted); letter-spacing: .04em; pointer-events: none; }

.viewer-note {
  position: absolute; top: 16px; left: 16px;
  font-family: var(--f-mono); font-size: 0.68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.viewer-note::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

.viewer.no-webgl .viewer-stage { display: grid; place-items: center; }
.viewer.no-webgl .viewer-stage::after {
  content: "3D-Ansicht in diesem Browser nicht verfügbar – die Stückliste rechts zeigt alle Bauteile.";
  color: var(--muted); padding: 24px; text-align: center; max-width: 36ch; position: relative;
}
.viewer.no-webgl .viewer-toolbar { display: none; }

/* Ladezustand & Bauteile ohne 3D-Geometrie */
.viewer.is-loading .viewer-stage::after {
  content: "3D-Modell wird geladen …";
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 0.78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.bom-item.not-in-model .bom-name::after {
  content: "nicht im CAD";
  margin-left: 8px; padding: 1px 6px; border: 1px dashed var(--line); border-radius: 3px;
  font-family: var(--f-mono); font-size: 0.6rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  vertical-align: 2px; white-space: nowrap;
}

/* Stückliste */
.bom {
  border-left: 1px solid var(--line);
  background: rgba(14, 16, 19, .9);
  display: flex; flex-direction: column;
  max-height: clamp(440px, calc(100vh - 320px), 720px);
  min-height: 0;
}
.bom-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--line);
}
.bom-head h2 { font-size: 1.1rem; font-weight: 800; font-stretch: 112%; text-transform: uppercase; margin: 0; }
.bom-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.bom-list li { border-bottom: 1px solid var(--line-soft); }
.bom-item {
  width: 100%; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; row-gap: 1px;
  text-align: left; background: none; border: 0; color: var(--text);
  padding: 11px 20px; cursor: pointer; font: inherit;
}
.bom-item:hover { background: var(--carbon-2); }
.bom-pos { grid-row: span 2; font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); padding-top: 3px; }
.bom-name { font-weight: 600; font-size: 0.94rem; line-height: 1.3; }
.bom-spec { font-family: var(--f-mono); font-size: 0.72rem; color: var(--muted); line-height: 1.4; }
.bom-item[aria-expanded="true"] { background: var(--carbon-2); box-shadow: inset 3px 0 0 var(--red); }
.bom-item[aria-expanded="true"] .bom-pos { color: var(--red); }
.bom-text { padding: 0 20px 14px 62px; background: var(--carbon-2); font-size: 0.88rem; color: #c9cdd3; line-height: 1.5; }

@media (max-width: 980px) {
  .viewer { grid-template-columns: 1fr; }
  .viewer-stage { height: min(100vw, 560px); min-height: 380px; }
  .bom { border-left: 0; border-top: 1px solid var(--line); max-height: 330px; }
  .viewer-hint { display: none; }
  .viewer-toolbar { left: 10px; right: 10px; bottom: 10px; gap: 6px; }
  .tool { padding: 7px 10px; font-size: 0.66rem; }
  .pin { width: 22px; height: 22px; margin: -11px 0 0 -11px; font-size: 0.6rem; }
}
