:root {
  --bg: #161412;
  --panel: #1f1c19;
  --panel2: #282420;
  --line: #3a342e;
  --text: #f3e9d8;
  --muted: #a99d8b;
  --accent: #ff5d3a;
  --accent2: #ffb347;
  --sel: #3ab8ff;
  --danger: #ff4d6a;
  --radius: 7px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 "Inter", system-ui, sans-serif;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 11px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #5a5047; background: #322d28; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a0f0a; font-weight: 700; }
button.primary:hover { background: #ff7656; }
button.danger { color: var(--danger); }
button.mini { padding: 3px 8px; font-size: 12px; }
button.icon { width: 32px; padding: 6px 0; font-size: 16px; line-height: 1; }
button.active { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
input[type=text], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent2); }
textarea { resize: vertical; min-height: 80px; font-family: "IBM Plex Mono", monospace; font-size: 12px; }
input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
label { color: var(--muted); font-size: 12px; }

#app {
  display: grid; height: 100vh;
  grid-template-columns: 230px 1fr 270px;
  grid-template-rows: 52px 1fr;
  grid-template-areas: "top top top" "left center right";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .02em; font-size: 15px; }
.brand svg { width: 28px; height: 28px; fill: var(--accent); }
.brand svg .w { fill: var(--bg); }
.brand svg circle { fill: var(--text); }
.name-input { max-width: 260px; font-weight: 600; background: transparent !important; border-color: transparent !important; }
.name-input:hover, .name-input:focus { border-color: var(--line) !important; }
.tb-group { display: flex; gap: 3px; }
.zoomlabel { min-width: 60px; }
.spacer { flex: 1; }
.save-state { color: var(--muted); font-size: 12px; }

.left, .right { background: var(--panel); overflow-y: auto; }
.left { grid-area: left; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.right { grid-area: right; border-left: 1px solid var(--line); padding-bottom: 30px; }
section { padding: 12px; border-bottom: 1px solid var(--line); }
section.grow { flex: 1; border-bottom: none; }
h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.row { display: flex; gap: 6px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.project-list, .layer-list { list-style: none; margin: 0 0 8px; padding: 0; }
.project-list { max-height: 190px; overflow-y: auto; }
.project-list li, .layer-list li {
  padding: 5px 8px; border-radius: 5px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-list li:hover, .layer-list li:hover { background: var(--panel2); }
.project-list li.active { background: var(--panel2); color: var(--accent2); }
.project-list li small { color: var(--muted); margin-left: auto; font-size: 11px; }
.layer-list li.active { background: #23384a; }
.layer-list li .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.layer-list li .ltype { width: 16px; text-align: center; color: var(--muted); }
.layer-list li button { padding: 0 4px; border: none; background: none; color: var(--muted); font-size: 12px; }
.layer-list li button:hover { color: var(--text); }
.layer-list li.hiddenel .lname { opacity: .4; text-decoration: line-through; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.add-grid button { text-align: left; font-size: 12px; padding: 6px 8px; }

.center { grid-area: center; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; background: var(--bg); }
.tabs button { border-radius: 7px 7px 0 0; border-bottom: none; background: var(--panel); color: var(--muted); }
.tabs button.active { background: #2b2622; color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tabs .tabinfo { color: var(--muted); font-size: 11px; margin-left: 6px; }
.viewport {
  flex: 1; overflow: auto; position: relative;
  background: #2b2622 radial-gradient(circle, #3a332d 1px, transparent 1px) 0 0/18px 18px;
}
.stage-wrap { position: relative; margin: 60px auto; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.statusbar { display: flex; justify-content: space-between; gap: 12px; padding: 5px 12px; background: var(--panel); border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.statusbar .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Surface rendering (shared editor/print) ---------- */
.surface {
  position: relative; overflow: hidden; background: #fff;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.el { position: absolute; transform-origin: 50% 50%; }
.el.text { white-space: pre-wrap; overflow-wrap: break-word; display: flex; flex-direction: column; }
.el.text .tx { width: 100%; }
.el.image { overflow: hidden; }
.el.image img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.el.line .ln { position: absolute; left: 0; top: 50%; width: 100%; transform: translateY(-50%); }

/* ---------- Editor overlays ---------- */
.stage .surface { box-shadow: 0 6px 30px rgba(0,0,0,.45); }
.guides, .overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
.guide-fold { position: absolute; top: 0; bottom: 0; border-left: calc(1px * var(--inv)) dashed rgba(58,184,255,.85); }
.guide-fold.hz { bottom: auto; left: 0; right: 0; border-left: none; border-top: calc(1px * var(--inv)) dashed rgba(58,184,255,.85); }
.guide-label { position: absolute; top: calc(-18px * var(--inv)); font-size: calc(11px * var(--inv)); color: var(--muted); white-space: nowrap; transform: translateX(-50%); }
.guide-label.side { left: calc(-8px * var(--inv)); transform: translate(-100%, -50%); }
.guide-window { position: absolute; border: calc(1px * var(--inv)) dashed rgba(255,93,58,.9); border-radius: 7.5mm; background: rgba(255,93,58,.06); }
.guide-safe { position: absolute; border: calc(1px * var(--inv)) dotted rgba(0,0,0,.25); }
.surface-dim { position: absolute; font-size: calc(11px * var(--inv)); color: var(--muted); white-space: nowrap; }
.snapline { position: absolute; background: #ff3ad1; }
.snapline.v { width: calc(1px * var(--inv)); top: -2000mm; bottom: -2000mm; }
.snapline.h { height: calc(1px * var(--inv)); left: -2000mm; right: -2000mm; }
.selbox { position: absolute; outline: calc(1.5px * var(--inv)) solid var(--sel); transform-origin: 50% 50%; pointer-events: none; }
.selbox.locked { outline-style: dashed; outline-color: var(--accent2); }
.handle {
  position: absolute; width: calc(10px * var(--inv)); height: calc(10px * var(--inv));
  margin: calc(-5px * var(--inv)) 0 0 calc(-5px * var(--inv));
  background: #fff; border: calc(1.5px * var(--inv)) solid var(--sel); border-radius: 2px; pointer-events: auto;
}
.handle.rot { border-radius: 50%; background: var(--sel); cursor: grab; }
.rot-stem { position: absolute; left: 50%; top: calc(-22px * var(--inv)); height: calc(22px * var(--inv)); border-left: calc(1px * var(--inv)) solid var(--sel); }
.text-editing { outline: calc(1.5px * var(--inv)) solid var(--accent2) !important; cursor: text; }
.text-editing .tx { outline: none; }

/* ---------- Properties panel ---------- */
.props-section { padding: 12px; border-bottom: 1px solid var(--line); }
.props-section h3 { margin-bottom: 10px; }
.field { margin-bottom: 8px; }
.field > label { display: block; margin-bottom: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.unit { position: relative; }
.unit input { padding-right: 26px; }
.unit::after { content: attr(data-u); position: absolute; right: 7px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; pointer-events: none; }
.mini-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.colorrow { display: flex; gap: 6px; align-items: center; }
.colorrow input[type=text] { flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; border: none; border-radius: 0; padding: 5px 0; background: var(--bg); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--panel2); color: var(--accent2); }
.btnrow { display: flex; flex-wrap: wrap; gap: 5px; }
.btnrow button { flex: 1 1 auto; font-size: 12px; padding: 5px 7px; }
.empty-note { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 12px; margin: 4px 0; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.swatches span { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; }

/* ---------- Dialogs ---------- */
.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(640px, 94vw); max-height: 92vh; }
.dlg.wide { width: min(1150px, 96vw); }
.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg form { padding: 18px 20px; display: flex; flex-direction: column; max-height: 92vh; }
.dlg h2 { margin: 0 0 14px; font-size: 18px; }
.dlg h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent2); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.dlg-actions .note { margin-right: auto; color: var(--muted); font-size: 12px; }
#formatBody { overflow-y: auto; }
.panel-table { width: 100%; border-collapse: collapse; }
.panel-table td { padding: 3px 4px; }
.panel-table td:first-child { width: 50%; }
.help { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.print-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; min-height: 0; flex: 1; overflow: hidden; }
.print-opts { overflow-y: auto; padding-right: 6px; }
.print-opts .card { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 10px; }
.print-opts .card h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.print-opts .card.off > *:not(h4) { opacity: .4; pointer-events: none; }
.print-preview-wrap { display: flex; flex-direction: column; min-height: 0; }
.pp-head { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.print-preview { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; gap: 16px; align-content: flex-start; background: #2b2622; border-radius: 9px; padding: 16px; min-height: 300px; }
.pp-page { position: relative; flex: none; }
.pp-page .pp-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
.pp-cap { position: absolute; bottom: -18px; left: 0; font-size: 11px; color: var(--muted); }

/* ---------- 3D-Ansicht ---------- */
.v3-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; min-height: 0; flex: 1; overflow: hidden; }
.v3-scene {
  position: relative; height: 64vh; min-height: 420px; border-radius: 9px; overflow: hidden;
  perspective: 1800px; cursor: grab; touch-action: none; user-select: none;
  background: radial-gradient(ellipse at 50% 38%, #514840 0%, #2b2622 58%, #1a1715 100%);
  --cass: #ff7a1a; --case: rgba(223,232,239,.25);
}
.v3-scene.dragging { cursor: grabbing; }
.v3-world, .obj3d { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.obj3d { left: 0; top: 0; }
.f3d { position: absolute; left: 0; top: 0; backface-visibility: hidden; overflow: hidden; }
.f3d svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.f3d.cass-front { border-radius: 3.5mm 3.5mm 2mm 2mm; }
.f3d.cass-edge { background: var(--cass); }
.f3d.cass-inner { overflow: visible; }
.f3d.part3d { overflow: visible; }
.label-back { position: absolute; background: #f2eee6; }
.obj3d.clear .f3d.cass-front .shade3d, .obj3d.clear .f3d.cass-edge .shade3d { background: rgba(0,0,0,.45); }
.obj3d.clear .f3d.cass-front { box-shadow: inset 0 0 0 .3mm rgba(255,255,255,.35); }
.f3d.plastic {
  backface-visibility: visible; overflow: visible; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,0) 45%), var(--case);
  box-shadow: inset 0 0 0 .35mm rgba(255,255,255,.4);
}
.mini3d-sec { flex: none; border-top: 1px solid var(--line); border-bottom: none; }
.mini3d-sec h3 { justify-content: flex-start; gap: 4px; }
.mini3d-sec .h-actions { margin-left: auto; }
.mini3d-title { color: var(--text); }
.mini3d-hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.v3-scene.mini { height: 150px; min-height: 0; perspective: 800px; cursor: pointer; border-radius: 7px; }
.v3-scene.mini .f3d { pointer-events: none; }
.shade3d { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.jpanel3d { position: relative; overflow: hidden; }

.drop-hint { position: fixed; inset: 0; display: none; place-items: center; font-size: 28px; font-weight: 800; color: var(--accent); background: rgba(22,20,18,.8); border: 4px dashed var(--accent); z-index: 50; pointer-events: none; }
.drop-hint.show { display: grid; }

/* ---------- Print ---------- */
.sheet-map { display: grid; gap: 3px; width: 96px; aspect-ratio: 210 / 297; padding: 3px; background: #fff; border-radius: 3px; }
.sheet-map button { min-height: 0; padding: 0; font-size: 12px; font-weight: 600; color: #333; background: #f1eee8; border: 1px dashed #3b8bd9; border-radius: 2px; }
.sheet-map button.used { color: #999; background: repeating-linear-gradient(45deg, #ddd 0 4px, #eee 4px 8px); border-style: solid; border-color: #bbb; }
#print-root { display: none; }
.print-page { position: relative; width: 210mm; height: 297mm; overflow: hidden; background: #fff; }
.print-page .pp-content { position: absolute; left: 0; top: 0; width: 210mm; height: 297mm; transform-origin: 0 0; }
.pitem { position: absolute; }
.pitem .surface-holder { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cutline { position: absolute; pointer-events: none; }
.foldmark { position: absolute; background: #000; }
.ptitle { position: absolute; font: 7pt "Inter", sans-serif; color: #999; }

@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { height: auto; overflow: visible; background: #fff; }
  #app, #home, .mx-toast, dialog, .drop-hint { display: none !important; }
  #print-root { display: block; }
  .print-page { page-break-after: always; break-after: page; height: 296.8mm; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
}

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto auto; grid-template-areas: "top" "center" "right" "left"; height: auto; min-height: 100vh; }
  body { overflow: auto; }
  .center { min-height: 60vh; }
  .topbar { flex-wrap: wrap; padding: 8px; }
  .print-layout, .v3-layout { grid-template-columns: 1fr; overflow: auto; }
  .v3-scene { height: 55vh; min-height: 320px; }
}

/* ---------- Startseite ---------- */
body[data-mode=home] #app { display: none; }
body:not([data-mode=home]) #home { display: none; }
.home { height: 100vh; overflow-y: auto; }
.home-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.home-main { max-width: 1180px; margin: 0 auto; padding: 26px 20px 40px; }
.home-main h1 { margin: 0 0 4px; font-size: 26px; }
.home-sub { margin: 0 0 22px; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.home-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.home-card.fresh { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(255,179,71,.25); }
.home-thumbwrap { display: grid; place-items: center; height: 150px; cursor: pointer; background: #2b2622 radial-gradient(circle, #3a332d 1px, transparent 1px) 0 0/18px 18px; }
.home-thumb .surface { box-shadow: 0 4px 16px rgba(0,0,0,.45); pointer-events: none; }
.home-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.home-name { margin: 0 0 2px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.home-meta { color: var(--muted); font-size: 12px; }
.home-go { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 8px; }
.home-go button { padding: 9px 0; font-size: 14px; }
button.primary.alt { background: var(--accent2); border-color: var(--accent2); }
button.primary.alt:hover { background: #ffc46e; }
.home-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.home-empty { grid-column: 1 / -1; text-align: center; padding: 50px 0; color: var(--muted); }
.home-storage { margin-top: 26px; color: var(--muted); font-size: 12px; }
.home-btn { display: flex; align-items: center; gap: 7px; font-weight: 800; background: none; border-color: transparent; padding: 5px 8px; }
.home-btn svg { width: 24px; height: 24px; fill: var(--accent); }
.home-btn svg .w { fill: var(--bg); }
.home-btn svg circle { fill: var(--text); }
.mode-seg { flex: none; }
.mode-seg button { padding: 5px 14px; }
body[data-mode=mix] .design-only { display: none !important; }

/* ---------- Mixer ---------- */
.mixer { display: none; grid-area: mix; min-height: 0; flex-direction: column; background: var(--bg); }
body[data-mode=mix] #app { grid-template-columns: 1fr; grid-template-areas: "top" "mix"; }
body[data-mode=mix] .left, body[data-mode=mix] .center, body[data-mode=mix] .right { display: none; }
body[data-mode=mix] .mixer { display: flex; }
.mx-loading { padding: 30px; color: var(--muted); }
.mx-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.mx-toolbar select { width: auto; }
.mx-toolbar .unit input { width: 70px; }
.mx-f { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.mx-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.mx-hint { color: var(--muted); font-size: 11px; align-self: center; }
.mx-head { display: flex; flex-wrap: wrap; align-items: stretch; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.v3-scene.mx3 { width: 100%; height: 100%; min-height: 0; perspective: 700px; cursor: pointer; background: none; border-radius: 0; overflow: visible; }
.v3-scene.mx3 .f3d { pointer-events: none; }
.v3-scene.mx3.spinning .hub-spin { animation: hubspin 2.4s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes hubspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .v3-scene.mx3.spinning .hub-spin { animation: none; } }
.mx-tabs { flex: 1 1 380px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mx-tab { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 6px; padding: 14px 18px; text-align: left; border-radius: 11px; background: var(--panel); white-space: normal; }
.mx-tab.active { border-color: var(--accent); background: var(--panel2); box-shadow: inset 0 3px 0 var(--accent); }
.mx-tab.drop { border-color: #3ab8ff; border-style: dashed; }
.mx-tab-t { font-size: 22px; font-weight: 800; }
.mx-tab:not(.active) .mx-tab-t { color: var(--muted); }
.mx-tab-play { display: none; font-size: 14px; color: #3ab8ff; }
.mx-tab.playing .mx-tab-play { display: inline; }
.mx-tab-i { color: var(--muted); font-variant-numeric: tabular-nums; }
.mx-tab.over .mx-tab-i { color: var(--danger); }
.mx-tab-bar { display: block; width: 100%; height: 5px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.mx-tab-bar span { display: block; height: 100%; background: var(--accent2); }
.mx-tab.over .mx-tab-bar span { background: var(--danger); }
.mx-main { flex: 1; min-height: 0; display: flex; }
.mx-side { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; border-bottom: none; }
.mx-side-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 12px 14px 8px; }
.mx-side-head h2 { margin: 0 6px 0 0; font-size: 18px; }
.mx-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.mx-time small { color: var(--muted); font-weight: 400; }
.mx-time.over, .mx-time.over small { color: var(--danger); }
.mx-pos { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; min-width: 92px; text-align: right; }
.mx-bar { position: relative; height: 22px; margin: 0 14px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; cursor: pointer; }
.mx-seg { position: absolute; top: 0; bottom: 0; background: rgba(255,179,71,.55); border-right: 1px solid var(--bg); }
.mx-seg.alt { background: rgba(255,93,58,.55); }
.mx-over { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(255,77,106,.55) 0 5px, rgba(255,77,106,.25) 5px 10px); }
.mx-cap { position: absolute; top: -2px; bottom: -2px; border-left: 2px solid var(--text); }
.mx-bar-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #3ab8ff; pointer-events: none; }
.mx-list { flex: 1; overflow-y: auto; padding: 0 14px 30px; position: relative; }
.mx-empty { border: 2px dashed var(--line); border-radius: 10px; padding: 30px 14px; text-align: center; color: var(--muted); }
.mx-track { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px 8px; }
.mx-track.playing { border-color: #3ab8ff; }
.mx-track.dragging { opacity: .4; }
.mx-track.missing { border-color: var(--danger); }
.mx-row1 { display: flex; align-items: center; gap: 5px; }
.mx-row1 input { padding: 3px 6px; min-width: 0; }
.mx-row1 input:first-of-type { flex: 2; } .mx-row1 input:last-of-type { flex: 3; }
.mx-handle { cursor: grab; color: var(--muted); padding: 0 2px; user-select: none; letter-spacing: -2px; }
.mx-num { font-weight: 700; color: var(--accent2); min-width: 24px; font-variant-numeric: tabular-nums; }
.mx-len { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 38px; text-align: right; }
.mx-wave-box { position: relative; margin: 7px 0 5px; height: 52px; background: #191614; border-radius: 5px; overflow: hidden; touch-action: none; }
.mx-wave { display: block; width: 100%; height: 100%; }
.mx-wave-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.55), 0 0 6px rgba(255,255,255,.8); pointer-events: none; display: none; z-index: 1; }
.mx-wave-head::before { content: ""; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top-color: #fff; }
.mx-wave-head.paused { background: #3ab8ff; box-shadow: 0 0 0 1px rgba(0,0,0,.55); }
.mx-wave-head.paused::before { border-top-color: #3ab8ff; }
.mx-wave-tip { position: absolute; left: 6px; top: 4px; display: none; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.75); font-size: 11px; pointer-events: none; }
.mx-row2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.mx-row2 .mx-f { flex-direction: row; align-items: center; gap: 6px; }
.mx-row2 .unit input { width: 62px; padding: 2px 22px 2px 5px; }
.mx-volwrap { position: relative; display: inline-flex; }
.mx-vol { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; }
.mx-vol.changed { color: var(--accent2); border-color: #6b5a3a; }
.mx-vol.changed .mx-db { color: var(--accent2); }
.mx-vol-ic { display: inline-flex; }
.mx-vol-ic svg { width: 15px; height: 15px; fill: currentColor; }
.mx-pop { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: 300px; align-items: center; gap: 8px; padding: 9px 10px;
  background: var(--panel2); border: 1px solid #5a5047; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.55); }
.mx-pop.open { display: flex; }
.mx-pop input[type=range] { flex: 1; min-width: 0; }
.mx-pop-t { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mx-db { font-variant-numeric: tabular-nums; color: var(--text); }
.mx-lufs { font-size: 11px; padding: 1px 6px; border-radius: 9px; font-variant-numeric: tabular-nums; }
.mx-lufs.ok { background: rgba(80,200,120,.18); color: #7fdc9c; }
.mx-lufs.off { background: rgba(255,179,71,.18); color: var(--accent2); }
.mx-lufs.clip { background: rgba(255,77,106,.2); color: var(--danger); }
.mx-trim { color: var(--muted); font-size: 11px; margin-left: auto; font-variant-numeric: tabular-nums; }
.mx-missing { margin-top: 6px; color: var(--danger); font-size: 12px; }
.mx-trans { display: flex; align-items: center; gap: 6px; padding: 5px 0; font-size: 12px; color: var(--muted); }
.mx-trans-line { flex: 1; border-top: 1px dashed var(--line); }
.mx-trans .unit input { width: 62px; padding: 2px 22px 2px 5px; }
.mx-mini-seg button { padding: 2px 9px; font-size: 12px; }
.mx-drop { height: 3px; margin: 2px 0; border-radius: 2px; background: #3ab8ff; }
.mx-toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 60;
  display: flex; align-items: center; gap: 12px; max-width: min(720px, 92vw); padding: 10px 14px; border-radius: 9px;
  background: #2f2a25; border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.5); transition: .18s; }
.mx-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* ---------- Boombox ---------- */
.bb { flex: none; width: 540px; max-width: 100%; position: relative; padding-top: 16px; user-select: none; --lvl: 0; }
.bb-handle { position: absolute; top: 0; left: 84px; right: 84px; height: 26px; border: 6px solid #8f8b84; border-bottom: none; border-radius: 14px 14px 0 0; box-shadow: inset 0 2px 0 rgba(255,255,255,.35); }
.bb-body { position: relative; display: grid; grid-template-columns: 136px 1fr 136px; gap: 8px; align-items: center; height: 228px; padding: 9px 10px;
  border-radius: 13px; border: 1px solid #6e6a63; color: #1c1a18;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, rgba(0,0,0,.03) 1px 3px), linear-gradient(180deg, #dedbd4, #bcb8b0 55%, #9d9991);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -3px 0 rgba(0,0,0,.18), 0 8px 20px rgba(0,0,0,.5); }
.bb-spk { position: relative; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; justify-self: center;
  background: radial-gradient(circle, #171513 0 66%, #0b0a09 67% 72%, #d4d0c8 73% 77%, #6a665f 78% 100%); box-shadow: 0 2px 3px rgba(0,0,0,.4), inset 0 0 0 1px #3a3632; }
.bb-spk::after { content: ""; position: absolute; inset: 14%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.2) .9px, transparent 1.3px) 0 0 / 6px 6px; }
.bb-cone { width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, #2f2b27 0 30%, #201d1a 31% 78%, #34302b 79% 100%); box-shadow: inset 0 0 14px #000;
  transform: scale(calc(1 + var(--lvl) * .07)); }
.bb-dome { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 38% 34%, #6a655e, #24211e 70%); }
.bb-center { display: flex; flex-direction: column; gap: 5px; height: 100%; min-width: 0; }
.bb-top { display: flex; align-items: center; gap: 6px; font-size: 9px; letter-spacing: .14em; font-weight: 800; white-space: nowrap; }
.bb-sub { font-weight: 500; opacity: .65; }
.bb-pl { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: #5a1a1a; box-shadow: inset 0 0 2px #000; }
.bb.on .bb-pl { background: #ff3b30; box-shadow: 0 0 7px #ff3b30; }
.bb-counter { font: 600 11px "IBM Plex Mono", monospace; letter-spacing: 0; color: #ffb347; background: #141210; padding: 1px 6px; border-radius: 3px; box-shadow: inset 0 0 4px #000; font-variant-numeric: tabular-nums; }
.bb-meter { display: flex; flex-direction: column; gap: 3px; padding: 6px 8px 3px; border-radius: 5px; background: #12100e; box-shadow: inset 0 1px 5px #000, 0 1px 0 rgba(255,255,255,.5); }
.bb-row { display: grid; grid-template-columns: 15px repeat(14, 1fr); gap: 2px; align-items: center; }
.bb-ch { color: #a99d8b; font-size: 8px; font-weight: 700; }
.bb-row i { height: 8px; border-radius: 1.5px; }
.bb-row i.g { background: #173a1e; } .bb-row i.y { background: #3e3510; } .bb-row i.r { background: #441414; }
.bb-row i.g.on { background: #45ff6c; box-shadow: 0 0 6px rgba(69,255,108,.9); }
.bb-row i.y.on { background: #ffd83a; box-shadow: 0 0 6px rgba(255,216,58,.9); }
.bb-row i.r.on { background: #ff3b30; box-shadow: 0 0 7px rgba(255,59,48,.95); }
.bb-scale b { font-size: 6.5px; font-weight: 400; color: #8d8274; text-align: center; white-space: nowrap; line-height: 1; }
.bb-deck { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; gap: 8px; }
.bb-door { position: relative; height: 100%; aspect-ratio: 1.54 / 1; flex: none; border-radius: 6px; cursor: pointer; background: linear-gradient(180deg, #040404, #151311); box-shadow: inset 0 4px 10px #000, 0 1px 0 rgba(255,255,255,.55); }
/* Kassette liegt im Fach hinter der Scheibe. Beim Auswerfen kommt sie erst nach vorn, wenn die Scheibe offen ist. */
.bb-cass { position: absolute; inset: 5px 6px; z-index: 2; filter: brightness(.86) saturate(.92); transition: transform .38s cubic-bezier(.3, 1.25, .5, 1), filter .3s, z-index 0s .38s; }
.bb.eject .bb-cass { transform: translateY(-64px) scale(1.22); z-index: 4; filter: none; transition: transform .38s cubic-bezier(.3, 1.25, .5, 1) .14s, filter .3s .14s, z-index 0s .14s; }
.bb-glass { position: absolute; inset: 0; z-index: 3; border-radius: 6px; pointer-events: none; border: 2px solid #8a867e; transform-origin: 50% 100%; transition: transform .3s .32s, opacity .3s .32s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.6), inset 0 7px 12px rgba(0,0,0,.6), inset 0 -4px 8px rgba(0,0,0,.45), inset 7px 0 10px rgba(0,0,0,.4), inset -7px 0 10px rgba(0,0,0,.4);
  background:
    linear-gradient(112deg, rgba(255,255,255,0) 0 8%, rgba(255,255,255,.34) 9% 20%, rgba(255,255,255,.08) 21% 24%, rgba(255,255,255,.22) 25% 29%, rgba(255,255,255,0) 30% 62%, rgba(255,255,255,.13) 63% 72%, rgba(255,255,255,0) 73%),
    linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,0) 30%),
    rgba(150,185,195,.13); }
.bb.eject .bb-glass { transform: perspective(900px) rotateX(-52deg); opacity: .55; transition: transform .26s, opacity .26s; }
.bb-side { flex: 1; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 6.5px; font-weight: 700; letter-spacing: .1em; color: #55514a; }
.bb-screw { width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f1eee7, #8e8a82); box-shadow: 0 1px 1px rgba(0,0,0,.5); }
.bb-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; height: 31px; padding: 3px 3px 7px; border-radius: 0 0 6px 6px; background: #12100e; }
.bb-key { padding: 0; border: none; border-radius: 2px 2px 4px 4px; font-size: 11px; line-height: 1; color: #2a2622;
  background: linear-gradient(180deg, #f4f1ea, #c2beb5); box-shadow: 0 4px 0 #76726b; transition: transform .07s, box-shadow .07s; }
.bb-key:hover { background: linear-gradient(180deg, #fff, #d0ccc3); border: none; }
.bb-key:active, .bb-key.down { transform: translateY(4px); box-shadow: 0 0 0 #76726b; background: linear-gradient(180deg, #cfcbc2, #a9a59c); }
.bb-key.play.down { color: #0b8a2c; }
.bb-key.pause.down { color: #b86a00; }
.bb-key.stop { color: #a32018; }
@media (prefers-reduced-motion: reduce) { .bb-cass, .bb-glass, .bb-key { transition: none; } .bb-cone { transform: none; } }


/* ---------- Hinweisbalken ---------- */
.notice { position: fixed; left: 50%; top: 12px; z-index: 80; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; transition: .18s;
  display: flex; align-items: center; gap: 12px; max-width: min(760px, 94vw); padding: 10px 12px 10px 16px; border-radius: 9px;
  background: #4a1d24; border: 1px solid var(--danger); color: #ffdfe4; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.notice.warn { background: #4a3a1a; border-color: var(--accent2); color: #ffeccc; }
.notice.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
@media print { .notice { display: none !important; } }

/* Wizard «Neues Tape» */
.wiz form { height: min(780px, 92vh); }
.wiz-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; }
.wiz-steps li { display: flex; align-items: center; gap: 7px; padding: 4px 11px 4px 5px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.wiz-steps li b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--panel2); font-size: 11px; }
.wiz-steps li.done { color: var(--text); }
.wiz-steps li.done b { background: var(--accent2); color: #1a0f0a; }
.wiz-steps li.active { border-color: var(--accent); color: var(--text); }
.wiz-steps li.active b { background: var(--accent); color: #1a0f0a; }
.wiz-layout { display: grid; grid-template-columns: minmax(320px, 430px) 1fr; gap: 18px; flex: 1; min-height: 0; }
.wiz-body { overflow-y: auto; padding-right: 6px; }
.wiz-body .card { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 10px; }
.wiz-body .card h4 { margin: 0 0 8px; }
.wiz-name { font-size: 16px; padding: 8px 10px; }
.wiz-prev { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.v3-scene.wiz3d { flex: 1; height: auto; min-height: 200px; perspective: 1400px; }
.v3-scene.wiz3d .f3d { pointer-events: none; }
.wiz-flat { display: grid; place-items: center; padding: 12px; border-radius: 9px; background: #2b2622 radial-gradient(circle, #3a332d 1px, transparent 1px) 0 0/18px 18px; }
.wiz-flat:empty { display: none; }
.wiz-thumb { position: relative; flex: none; overflow: hidden; }
.wiz-thumb .surface { pointer-events: none; }
.wiz-fold { position: absolute; border: 0 dashed rgba(0,0,0,.45); border-top-width: .3mm; border-left-width: .3mm; mix-blend-mode: difference; border-color: rgba(255,255,255,.55); }
.wiz-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.wiz-tiles.small { grid-template-columns: repeat(4, 1fr); }
.wiz-tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 5px; padding: 10px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; text-align: center; font-size: 12px; min-width: 0; }
.wiz-tile:hover { border-color: var(--muted); }
.wiz-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--text); }
.wiz-tile b { font-size: 13px; }
.wiz-tile small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.wiz-scheme { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 42px; border-radius: 5px; font: 700 18px/1 "Bebas Neue", sans-serif; letter-spacing: .04em; }
.wiz-scheme i { width: 16px; height: 16px; border-radius: 50%; }
.wiz-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.wiz-chip { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px; border-radius: 99px; font-size: 12px; background: var(--bg); }
.wiz-chip i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); }
.wiz-chip.active { border-color: var(--accent); color: var(--accent2); }
.wiz-pick { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); cursor: pointer; }
.wiz-pick input[type=color] { width: 30px; height: 26px; }
@media (max-width: 900px) {
  .wiz form { height: auto; }
  .wiz-layout { grid-template-columns: 1fr; overflow: auto; }
  .v3-scene.wiz3d { flex: none; height: 240px; }
}
