:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #dedbd4;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --stage: #1f2125;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141518;
    --panel: #1c1d21;
    --ink: #ecebe8;
    --muted: #9a9aa2;
    --line: #2e3036;
    --accent: #ff7a3d;
    --accent-ink: #141518;
    --stage: #0c0d0f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
h2 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
a { color: var(--accent); }

.top { padding: 24px 16px 8px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 52px; height: 52px; flex: none; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .25)); }
.top h1 { font-size: 26px; letter-spacing: -.01em; line-height: 1.15; }
.beta {
  display: inline-block; vertical-align: top; margin-left: 2px; padding: 1px 5px; border-radius: 4px;
  font: 700 10px/1.3 "DM Mono", ui-monospace, Consolas, monospace; letter-spacing: 1px;
  color: #fff; background: #d32f2f;
}
.top p { margin: 2px 0 0; color: var(--muted); }
.top { position: relative; }
.install {
  position: absolute; top: 28px; right: 16px; width: auto; margin: 0;
  padding: 8px 14px; font-size: 14px;
}
@media (max-width: 540px) { .install { position: static; margin-top: 10px; } }
/* Versionszeile unter Logo + Name (Baustein landing-dark-neon-matrix) */
.version-line {
  font: 11px/1.4 "DM Mono", ui-monospace, Consolas, monospace;
  letter-spacing: 1px; color: #888; margin-top: 8px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: stretch;   /* rechte Spalte so hoch wie die Einstellungen */
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.controls { counter-reset: step; }
.controls section:not(:first-of-type) { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
/* Abschnittsnummern automatisch – ausgeblendete Abschnitte zählen nicht mit */
.controls section > h2::before { counter-increment: step; content: counter(step) " · "; }
.section-intro { margin: -4px 0 10px; font-size: 13px; color: var(--muted); }

.drop {
  display: grid; place-items: center; text-align: center; gap: 8px;
  min-height: 120px; padding: 12px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  cursor: pointer; color: var(--muted);
}
.cropper.over .crop-wrap { outline: 2px dashed var(--accent); outline-offset: 2px; }
.drop.over, .drop:focus-visible { border-color: var(--accent); outline: none; }
.drop img { max-width: 100%; max-height: 160px; border-radius: 6px; }

/* Ausschnitt wählen */
.cropper { display: grid; gap: 8px; }
.cropper small { color: var(--muted); font-size: 12px; }
.crop-wrap {
  position: relative; width: fit-content; margin: 0 auto; overflow: hidden; border-radius: 6px;
  cursor: crosshair; touch-action: none; user-select: none; line-height: 0;
}
.crop-wrap img { display: block; max-width: 100%; max-height: 340px; }
.crop-box {
  position: absolute; border: 2px solid var(--accent); pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5);
}
.crop-actions { display: flex; gap: 8px; }
button.ghost {
  width: auto; margin: 0; padding: 6px 12px; font-size: 13px; font-weight: 500;
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
button.ghost:disabled { opacity: .4; }
/* Zurücksetzen: ↺ je Regler + alle */
button.reset-one {
  width: auto; margin: 0 0 0 6px; padding: 0 6px; vertical-align: 1px;
  font-size: 12px; line-height: 1.5; font-family: inherit; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px;
}
button.reset-one:hover { color: var(--accent); border-color: var(--accent); }
button.reset-all { width: 100%; margin-top: 4px; }
button.hint-action { margin-top: 6px; display: block; }
.hint-box {
  margin: 8px 0; padding: 8px 10px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent);
}
/* Formwahl als Kacheln */
.shape-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
button.shape-tile {
  width: auto; margin: 0; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink);
  font-weight: 500; font-size: 11.5px; line-height: 1.2; font-family: inherit; text-align: center; cursor: pointer;
}
button.shape-tile svg { width: 34px; height: 34px; }
button.shape-tile:hover { border-color: var(--accent); }
button.shape-tile[aria-pressed="true"] {
  border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.modes { display: grid; gap: 8px; }
.mode { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.mode:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mode input { margin-top: 4px; accent-color: var(--accent); }
.mode b { display: block; }
.mode span { font-size: 13px; color: var(--muted); }
.mode b { color: var(--ink); font-size: 15px; }
.badge { display: inline-block; margin-top: 4px; font-style: normal; font-size: 12px; color: var(--accent); }

.field { margin: 10px 0; }
.field label { display: block; font-size: 14px; margin-bottom: 2px; }
.field small { color: var(--muted); font-size: 12px; }
.field output { font-variant-numeric: tabular-nums; font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 8px 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=range]:disabled { opacity: .4; }
input[type=text] { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
select { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
.field[hidden] { display: none; }

button, .button {
  display: inline-block; width: 100%; margin-top: 8px; padding: 11px 16px;
  border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 15px; line-height: 1.2; font-family: inherit; text-align: center; text-decoration: none; cursor: pointer;
}
button:disabled { opacity: .45; cursor: not-allowed; }

/* Rechte Spalte: 2D-Vorschau, darunter direkt die 3D-Vorschau; nicht auf die Höhe der Einstellungen strecken */
.results {
  align-self: start;
  display: flex; flex-direction: column; gap: 14px;
}
/* Raster statt Flex, damit die Werkzeugleiste über Vorschau und Infospalte reicht (eine Zeile).
   .view-2d löst sich dafür auf (display: contents), in der Großansicht ist sie wieder ein Block. */
.top-row { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; align-items: start; }
.view-2d:not(.expanded) { display: contents; }
.view-2d:not(.expanded) > h2 { grid-area: 1 / 1 / 2 / -1; }
.view-2d:not(.expanded) > .toolbar { grid-area: 2 / 1 / 3 / -1; }
.view-2d:not(.expanded) > .tools-hint { grid-area: 3 / 1 / 4 / -1; }
.view-2d:not(.expanded) > .stage { grid-area: 4 / 1; }
.top-row > .side { grid-area: 4 / 2 / 5 / 3; }
.view-2d .stage { width: clamp(220px, 38vh, 380px); aspect-ratio: 1; cursor: crosshair; touch-action: none; user-select: none; }
/* Werkzeugleiste der 2D-Vorschau */
.toolbar { display: grid; gap: 6px; margin-bottom: 8px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* Werkzeuge nur als Symbol (Name im Tooltip), in der Großansicht mit Beschriftung */
.view-2d:not(.expanded) .tool span { display: none; }
/* Normalansicht kompakt, damit die Leiste auch bei ~1100 px Fensterbreite in eine Zeile passt */
.view-2d:not(.expanded) .tool-row { gap: 4px; }
.view-2d:not(.expanded) .toolbar button { min-width: 28px; width: 28px; height: 28px; padding: 0; }
.view-2d:not(.expanded) .toolbar .sizes .size { width: 26px; min-width: 26px; }
.view-2d:not(.expanded) .toolbar .zoom-level { width: auto; min-width: 46px; }
.tool-group {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px;
  background: color-mix(in srgb, var(--ink) 6%, transparent); border: 1px solid var(--line);
}
.toolbar button {
  width: auto; margin: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink); font-weight: 500; font-size: 12.5px; line-height: 1; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s;
}
.toolbar button:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.toolbar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.toolbar button:disabled { opacity: .35; cursor: default; }
.toolbar .icon-btn { padding: 0; width: 32px; }
.ico { width: 18px; height: 18px; flex: none; }
.sizes .size { width: 30px; padding: 0; }
.dot { display: block; border-radius: 50%; background: currentColor; }
.dot.d1 { width: 4px; height: 4px; } .dot.d2 { width: 7px; height: 7px; }
.dot.d3 { width: 11px; height: 11px; } .dot.d4 { width: 16px; height: 16px; }
.sizes.inactive { opacity: .35; pointer-events: none; }
/* Hinweis zum Werkzeug: unter der Leiste, eine Zeile (zu lang -> „…“, voller Text im Tooltip) */
.tools-hint {
  display: block; margin: -2px 0 8px; color: var(--muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Motivgröße: rechts neben der 2D-Vorschau (oben in .side), damit die 3D-Vorschau direkt darunter folgt.
   In der Großansicht hängt app.js (setExpanded) den Regler unter das Bild. */
.preview-slider {
  margin: 0 0 10px; padding: 8px 10px; max-width: 380px;
  border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--ink) 4%, transparent);
}
.preview-slider label { display: block; font-size: 13px; margin-bottom: 2px; }
.preview-slider output { font-weight: 600; font-variant-numeric: tabular-nums; }
.view-2d.expanded .preview-slider { max-width: min(96vw, 1400px); width: 100%; background: var(--panel); }
.draw-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.brush-cursor {
  position: absolute; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%);
  border: 1.5px solid var(--accent); box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}
#mask-stage[data-tool="pen"], #mask-stage[data-tool="eraser"] { cursor: none; }
#mask-stage[data-tool="hand"] { cursor: grab; }
#mask-stage.panning { cursor: grabbing; }
.stage-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; margin: 0; padding: 0;
  display: grid; place-items: center; border-radius: 8px; border: 0; cursor: pointer;
  background: rgba(20, 21, 24, .72); color: #fff;
}
.stage-btn:hover { background: var(--accent); }
.stage-btn .when-big, .view-2d.expanded .stage-btn .when-small { display: none; }
.view-2d.expanded .stage-btn .when-big { display: inline; }
.zoom-level { min-width: 52px; font-variant-numeric: tabular-nums; }
/* Großansicht zum Zeichnen */
.view-2d.expanded {
  position: fixed; inset: 0; z-index: 100; padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(8, 9, 11, .88);
}
.view-2d.expanded h2 { color: #ddd; align-self: stretch; max-width: 1400px; margin: 0 auto; }
.view-2d.expanded .stage { width: min(96vw, 1400px); height: calc(100vh - 200px); aspect-ratio: auto; }
.view-2d.expanded .toolbar {
  max-width: min(96vw, 1400px); width: 100%; margin-bottom: 0; justify-content: center;
  padding: 8px; border-radius: 12px; background: var(--panel);
}
.view-2d.expanded .tool-row { justify-content: center; }
.view-2d.expanded .tools-hint { margin: 0; color: #bbb; }
body.editor-open { overflow: hidden; }
.side { min-width: 0; }
.side .legend { margin: 0 0 4px; }
.material { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.material b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.material table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.material td { padding: 1px 0; }
.material td + td { text-align: right; padding-left: 12px; }
.material tr.sum td { border-top: 1px solid var(--line); font-weight: 600; padding-top: 3px; }
.material small { color: var(--muted); font-size: 12px; }
/* 3D-Vorschau so hoch wie das Fenster erlaubt, nicht so hoch wie die Einstellungsspalte –
   sonst steht das Modell weit unten außerhalb des sichtbaren Bereichs */
.view-3d { display: flex; flex-direction: column; }
.view-3d .stage { height: clamp(320px, 65vh, 640px); }
@media (max-width: 860px) {

  .view-3d .stage { flex: none; height: 70vh; }
}
@media (max-width: 540px) {
  .top-row { grid-template-columns: minmax(0, 1fr); }
  .top-row > .side { grid-area: 5 / 1; margin-top: 8px; }
  .tools-hint { white-space: normal; }
  .view-2d .stage { width: 100%; }
  .side { padding-top: 0; }
}
.stage {
  position: relative; background: var(--stage); border-radius: 8px;
  display: grid; place-items: center; overflow: hidden;
}
/* Ganzes Bild einpassen – Hoch- wie Querformat, nichts abschneiden */
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
/* 2D-Vorschau: Größe und Lage setzt app.js (Zoom/Verschieben) */
#mask { inset: auto; max-width: none; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.busy::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  animation: sweep 1s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.empty { color: #8a8a90; font-size: 14px; }
.legend { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
#status { margin: 0; min-height: 1.4em; color: var(--muted); }
#status.error { color: #d6336c; }
#download .button { width: 100%; }
#download .button::before { content: "⬇ "; }
#inlay-hint { font-size: 14px; color: var(--muted); }

/* Footer: ProLogixx-Logo links, Copyright rechts daneben (Stil aus Baustein landing-dark-neon-matrix) */
.footer-logo { display: block; width: 150px; height: auto; border-radius: 8px; }
.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px;
  text-align: center; padding: 24px 16px 40px;
  font: 12px/1.8 "DM Mono", ui-monospace, Consolas, monospace; color: #888;
}
.foot a { color: #aaa; text-decoration: none; transition: color .2s ease, border-color .2s ease, background .2s ease; }
@media (prefers-color-scheme: light) { .foot a { color: #6b6b70; } }
.foot a.footer-prologixx { color: inherit; border: 1px solid transparent; padding: .1em .35em; border-radius: 3px; }
.foot a.footer-prologixx:hover { color: #ff6b6b; border-color: #ff6b6b; background: rgba(255, 107, 107, .08); }
.foot a.footer-legal:hover { color: var(--accent); }
