/* Modestudio – Atelier-Oberfläche */
:root {
  --bg: #16141a; --bg2: #1e1b22; --bg3: #27232c; --linie: #3a3540; --text: #ece6dc; --text2: #a59d93; --text3: #7a736b;
  --gold: #d8b46a; --gold2: #b8924a; --rot: #c8475a; --gruen: #6fb68a; --blau: #6aa0d8;
  --radius: 10px; --schatten: 0 10px 30px rgba(0,0,0,.35);
  --leiste: 330px; --eigen: 300px; --kopf: 54px;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --titel: 'Playfair Display', Georgia, serif;
  color-scheme: dark;
}
:root[data-theme="light"] { --bg: #f4f0ea; --bg2: #fbf8f3; --bg3: #ede7de; --linie: #d9d0c3; --text: #2a2520; --text2: #6b6259; --text3: #8f867b; color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--ui); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h2, h3 { font-family: var(--titel); font-weight: 600; letter-spacing: .01em; }
a { color: var(--gold); }

/* Kopf */
.kopf { height: var(--kopf); display: flex; align-items: center; gap: 18px; padding: 0 14px; background: linear-gradient(180deg, #1c1920, #16141a); border-bottom: 1px solid var(--linie); position: relative; z-index: 20; }
.marke { display: flex; align-items: center; gap: 9px; font-family: var(--titel); font-size: 20px; color: var(--gold); white-space: nowrap; }
.marke svg { width: 26px; height: 26px; }
.ansichten { display: flex; gap: 4px; background: var(--bg3); padding: 4px; border-radius: 999px; margin: 0 auto; }
.ansichten button { border: 0; background: none; padding: 6px 16px; border-radius: 999px; color: var(--text2); font-weight: 500; white-space: nowrap; }
.ansichten button[aria-selected="true"] { background: var(--gold); color: #1a1612; }
.aktionen { display: flex; gap: 8px; align-items: center; }
.aktionen > button, .menue > button { display: flex; align-items: center; gap: 7px; border: 1px solid var(--linie); background: var(--bg2); padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.wuerfel-knopf { border-color: var(--gold2) !important; color: var(--gold); }
.wuerfel-knopf svg { width: 18px; height: 18px; }
.wuerfel-knopf:hover svg { transform: rotate(20deg); transition: transform .2s; }
.menue { position: relative; }
.menue-liste { position: absolute; right: 0; top: calc(100% + 6px); background: var(--bg2); border: 1px solid var(--linie); border-radius: 10px; padding: 6px; min-width: 230px; box-shadow: var(--schatten); display: flex; flex-direction: column; }
.menue-liste button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; }
.menue-liste button:hover { background: var(--bg3); }
.menue-liste hr { border: 0; border-top: 1px solid var(--linie); margin: 4px 0; width: 100%; }

/* Bühne */
.buehne { position: absolute; inset: var(--kopf) 0 22px 0; display: grid; grid-template-columns: var(--leiste) 1fr var(--eigen); }
.leiste { display: grid; grid-template-columns: 62px 1fr; border-right: 1px solid var(--linie); background: var(--bg2); min-height: 0; }
.reiter { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-right: 1px solid var(--linie); }
.reiter button { border: 0; background: none; color: var(--text3); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; border-radius: 8px; font-size: 10.5px; }
.reiter button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.reiter button.an { color: var(--gold); background: var(--bg3); }
.reiter button:hover { color: var(--text); }
.tafel { overflow-y: auto; padding: 14px 14px 40px; min-height: 0; }
.tafel h2 { font-size: 19px; margin: 2px 0 10px; }
.tafel h3, .eigenschaften h3 { font-family: var(--ui); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); margin: 16px 0 8px; font-weight: 600; }
.eigenschaften { border-left: 1px solid var(--linie); background: var(--bg2); overflow-y: auto; padding: 14px 14px 40px; min-height: 0; }
.eigenschaften h2 { font-size: 18px; margin: 2px 0 2px; }
.klein { font-size: 12px; color: var(--text2); }
.leer { color: var(--text3); font-size: 13px; padding: 18px 4px; text-align: center; }

/* Ansicht */
.ansicht { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 35%, #3a3538 0%, #221f24 55%, #18161b 100%); }
.ansicht.flach { background: var(--bg); overflow: auto; }
#leinwand { width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.werkzeuge { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 5px; background: rgba(22,20,26,.86); backdrop-filter: blur(8px); border: 1px solid var(--linie); border-radius: 12px; max-width: calc(100% - 20px); overflow-x: auto; }
.werkzeuge button { border: 0; background: none; padding: 6px 10px; border-radius: 7px; color: var(--text2); white-space: nowrap; font-size: 13px; }
.werkzeuge button:hover { background: var(--bg3); color: var(--text); }
.werkzeuge button[aria-pressed="true"] { background: var(--gold); color: #1a1612; }
.werkzeuge .trenner { width: 1px; height: 20px; background: var(--linie); margin: 0 4px; }
.wind { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; padding: 0 6px; }
.wind input { width: 80px; }
.legende { position: absolute; right: 14px; bottom: 70px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); background: rgba(22,20,26,.86); padding: 6px 10px; border-radius: 8px; }
.legende i { width: 120px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #2f6fd8, #5fc48a 35%, #f0e05a 60%, #e8823a 80%, #d8283a); }
.ladung { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: rgba(22,20,26,.9); border: 1px solid var(--linie); padding: 8px 14px; border-radius: 999px; font-size: 13px; color: var(--text2); pointer-events: none; transition: opacity .3s; }
.ladung.aus { opacity: 0; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--linie); border-top-color: var(--gold); border-radius: 50%; animation: dreh .8s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }
.hinweis { position: absolute; left: 50%; top: 62px; transform: translateX(-50%); background: var(--gold); color: #1a1612; padding: 8px 14px; border-radius: 8px; font-weight: 500; box-shadow: var(--schatten); z-index: 5; }
.etiketten { position: absolute; inset: 0; pointer-events: none; }
.etikett { position: absolute; transform: translate(8px, -50%); background: rgba(22,20,26,.85); border: 1px solid var(--gold2); color: var(--text); font-size: 11.5px; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.etikett b { color: var(--gold); font-weight: 600; }
.masskarte { position: absolute; z-index: 6; width: 260px; background: var(--bg2); border: 1px solid var(--gold2); border-radius: 12px; box-shadow: var(--schatten); padding: 12px 14px; }
.masskarte h4 { margin: 0 0 2px; font-family: var(--titel); font-size: 17px; }
.masskarte .zu { position: absolute; right: 8px; top: 6px; }

/* Bedienelemente */
.feld { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; margin: 8px 0; }
.feld > label { color: var(--text2); font-size: 13px; }
.feld .wert { display: flex; align-items: center; gap: 4px; }
.feld input[type=number] { width: 64px; background: var(--bg3); border: 1px solid var(--linie); border-radius: 6px; padding: 3px 6px; text-align: right; }
.feld input[type=range] { grid-column: 1 / -1; width: 100%; }
.feld select, .feld input[type=text], .feld textarea { grid-column: 1 / -1; width: 100%; background: var(--bg3); border: 1px solid var(--linie); border-radius: 7px; padding: 6px 8px; }
.feld.zeile select { grid-column: auto; width: auto; }
.feld .einheit { color: var(--text3); font-size: 12px; }
input[type=range] { accent-color: var(--gold); height: 18px; }
input[type=color] { width: 34px; height: 28px; border: 1px solid var(--linie); border-radius: 6px; background: none; padding: 1px; }
.knopf { border: 1px solid var(--linie); background: var(--bg3); padding: 7px 12px; border-radius: 8px; }
.knopf:hover { border-color: var(--gold2); }
.knopf.haupt, button.haupt { background: var(--gold); color: #1a1612; border: 0; font-weight: 600; padding: 8px 14px; border-radius: 8px; }
.knopf.gefahr { color: #ff9aa6; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.segment { display: flex; background: var(--bg3); border-radius: 8px; padding: 3px; gap: 2px; margin: 6px 0; }
.segment button { flex: 1; border: 0; background: none; padding: 6px 4px; border-radius: 6px; color: var(--text2); font-size: 13px; }
.segment button.an { background: var(--bg); color: var(--gold); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--linie); background: var(--bg3); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; color: var(--text2); }
.chip.an { border-color: var(--gold); color: var(--gold); }
.info-box { background: var(--bg3); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 13px; }
.info-box b { color: var(--gold); }
.zeilen { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 12.5px; }
.zeilen span:nth-child(odd) { color: var(--text2); }

/* Karten & Raster */
.karten { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.karte { border: 1px solid var(--linie); background: var(--bg3); border-radius: 10px; padding: 9px 10px; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.karte:hover { border-color: var(--gold2); }
.karte.an { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.karte b { font-weight: 600; font-size: 13px; }
.karte small { color: var(--text3); font-size: 11.5px; }
.karte canvas, .karte img { width: 100%; height: 56px; border-radius: 6px; display: block; object-fit: cover; margin-bottom: 5px; }
.raster-klein { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.raster-klein button { border: 1px solid var(--linie); border-radius: 8px; padding: 0; background: var(--bg3); overflow: hidden; display: flex; flex-direction: column; }
.raster-klein button canvas { width: 100%; aspect-ratio: 1; display: block; }
.raster-klein button span { font-size: 10.5px; color: var(--text2); padding: 3px 2px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.raster-klein button.an { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.paletten { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.palette { display: flex; align-items: center; gap: 6px; border: 1px solid var(--linie); background: var(--bg3); border-radius: 8px; padding: 5px 7px; font-size: 11.5px; color: var(--text2); }
.palette i { display: flex; border-radius: 4px; overflow: hidden; }
.palette i b { width: 12px; height: 18px; display: block; }
.farbreihe { display: flex; gap: 8px; align-items: center; }
.haut { display: flex; gap: 6px; flex-wrap: wrap; }
.haut button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; }
.haut button.an { border-color: var(--gold); }

/* Ebenenliste */
.ebenen { display: flex; flex-direction: column; gap: 5px; }
.ebene { display: grid; grid-template-columns: 18px 1fr auto auto; align-items: center; gap: 8px; border: 1px solid var(--linie); background: var(--bg3); border-radius: 9px; padding: 7px 9px; cursor: pointer; }
.ebene.an { border-color: var(--gold); }
.ebene i { width: 16px; height: 16px; border-radius: 4px; }
.ebene span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ebene small { color: var(--text3); }
.ebene button { border: 0; background: none; color: var(--text3); padding: 2px 4px; }
.ebene button:hover { color: var(--text); }
.gruppe-titel { display: flex; justify-content: space-between; align-items: baseline; }

/* Logos */
.logo-liste { display: flex; flex-direction: column; gap: 6px; }
.logo-eintrag { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--linie); border-radius: 9px; padding: 5px; background: var(--bg3); cursor: pointer; }
.logo-eintrag.an { border-color: var(--gold); }
.logo-eintrag canvas { width: 64px; height: 40px; border-radius: 5px; }
.embleme { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.embleme button { aspect-ratio: 1; border: 1px solid var(--linie); background: var(--bg3); border-radius: 7px; padding: 4px; }
.embleme button canvas { width: 100%; height: 100%; }
.embleme button.an { border-color: var(--gold); }

/* Dialoge */
.dialog { position: fixed; inset: 0; background: rgba(8,7,10,.62); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog-karte { background: var(--bg2); border: 1px solid var(--linie); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--schatten); }
.dialog-karte.breit { width: min(1100px, 100%); }
.dialog-karte.schmal { width: min(380px, 100%); }
.dialog-karte header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--linie); }
.dialog-karte header h2 { margin: 0; font-size: 21px; }
.dialog-karte footer { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--linie); }
.dialog-karte form { padding: 16px 18px 0; }
.dialog-karte form input { width: 100%; background: var(--bg3); border: 1px solid var(--linie); border-radius: 8px; padding: 9px 10px; }
.dialog-karte form footer { padding: 14px 0; border: 0; justify-content: flex-end; }
.zu { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--text2); }
.welten { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 0; }
.wurf-raster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px 18px; overflow-y: auto; }
.wurf { border: 1px solid var(--linie); background: var(--bg3); border-radius: 12px; overflow: hidden; text-align: left; padding: 0; display: flex; flex-direction: column; }
.wurf:hover { border-color: var(--gold); transform: translateY(-1px); }
.wurf .bild { aspect-ratio: 4/5; background: radial-gradient(ellipse at 50% 35%, #3a3538, #1c1a1f); display: flex; align-items: center; justify-content: center; color: var(--text3); }
.wurf .bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wurf .text { padding: 8px 10px 10px; }
.wurf .text b { display: block; font-family: var(--titel); font-size: 15px; }
.wurf .text small { color: var(--text2); font-size: 12px; }
.wurf .farben { display: flex; gap: 3px; margin-top: 5px; }
.wurf .farben i { width: 16px; height: 16px; border-radius: 4px; }
.projekt-liste { padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.projekt-zeile { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; border: 1px solid var(--linie); border-radius: 9px; padding: 8px 10px; background: var(--bg3); }

/* Schnittmuster / Zuschnitt */
.flach-kopf { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px; background: var(--bg2); border-bottom: 1px solid var(--linie); }
.flach-kopf h2 { margin: 0; font-size: 19px; }
.flach-kopf label { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.flach-kopf select, .flach-kopf input[type=number] { background: var(--bg3); border: 1px solid var(--linie); border-radius: 7px; padding: 5px 8px; }
.flach-kopf .rechts { margin-left: auto; display: flex; gap: 8px; }
.schnitt-flaeche { position: relative; }
.schnitt-svg { display: block; background: #f6f1e6; touch-action: none; cursor: grab; }
.schnitt-svg.zieht { cursor: grabbing; }
.schnitt-svg .teil-flaeche { fill: #fffdf7; stroke: #23201c; stroke-width: .12; }
.schnitt-svg .zugabe { fill: none; stroke: #6a625a; stroke-width: .08; stroke-dasharray: .6 .4; }
.schnitt-svg .loch { fill: #f6f1e6; stroke: #b8302c; stroke-width: .1; }
.schnitt-svg .abnaeher { fill: none; stroke: #b8302c; stroke-width: .1; }
.schnitt-svg .hilfslinie { fill: none; stroke: #2a6fb0; stroke-width: .07; stroke-dasharray: 1 .5; }
.schnitt-svg .fadenlauf { stroke: #23201c; stroke-width: .1; }
.schnitt-svg .knips { stroke: #23201c; stroke-width: .14; }
.schnitt-svg text { font-family: 'Inter', sans-serif; fill: #23201c; }
.schnitt-svg .grad { fill: none; stroke-width: .08; }
.schnitt-svg .teil-gruppe.an .teil-flaeche { fill: #fff6dc; stroke: #a06a10; }
.schnitt-svg .stoffbahn { fill: #ece3d2; stroke: #9a8f80; stroke-width: .2; }
.schnitt-svg .bruchkante { stroke: #2a6fb0; stroke-width: .3; stroke-dasharray: 2 1; }
.schnitt-svg .ueberlappt .teil-flaeche { fill: #ffd6d6; }
.schnitt-svg .seite-raster { fill: none; stroke: #2a6fb0; stroke-width: .12; stroke-dasharray: 1 1; }
.schnitt-svg .seite-name { fill: #2a6fb0; font-size: 2.4px; }
.zuschnitt-layout { display: grid; grid-template-columns: 1fr 320px; min-height: calc(100% - 56px); }
.zuschnitt-info { border-left: 1px solid var(--linie); padding: 14px 16px; background: var(--bg2); }
.messwert { font-family: var(--titel); font-size: 30px; color: var(--gold); line-height: 1.1; }
.liste-material { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.liste-material td { padding: 4px 0; border-bottom: 1px solid var(--linie); }
.liste-material td:last-child { text-align: right; color: var(--text2); }
.teile-tabelle { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.teile-tabelle td, .teile-tabelle th { padding: 4px 6px; border-bottom: 1px solid var(--linie); text-align: left; }
.teile-tabelle th { color: var(--text3); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.hinweis-liste { font-size: 12.5px; color: var(--text2); padding-left: 18px; }

.fuss { position: fixed; bottom: 0; left: 0; right: 0; height: 22px; font-size: 11px; color: var(--text3); background: var(--bg); border-top: 1px solid var(--linie); display: flex; align-items: center; justify-content: center; gap: 6px; }
.fuss a { color: var(--text2); text-decoration: none; }

#druckbereich { display: none; }

/* Mobil */
@media (max-width: 1100px) { :root { --leiste: 290px; --eigen: 260px; } }
@media (max-width: 900px) {
  :root { --kopf: 96px; }
  body { overflow: auto; }
  .kopf { flex-wrap: wrap; height: auto; min-height: var(--kopf); padding: 8px 16px; gap: 8px; }
  .ansichten { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .ansichten button { padding: 6px 10px; flex: 1; }
  .aktionen { margin-left: auto; }
  .wuerfel-knopf span { display: none; }
  .buehne { position: static; display: flex; flex-direction: column; height: auto; }
  .ansicht { order: 1; height: 62vh; min-height: 380px; }
  .ansicht.flach { height: auto; min-height: 70vh; }
  .leiste { order: 2; grid-template-columns: 1fr; border-right: 0; }
  .reiter { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--linie); position: sticky; top: 0; background: var(--bg2); z-index: 2; }
  .reiter button { flex: 1; min-width: 56px; }
  .tafel { padding: 14px 16px 30px; max-height: none; }
  .eigenschaften { order: 3; border-left: 0; border-top: 1px solid var(--linie); padding: 14px 16px 60px; }
  .werkzeuge { bottom: 8px; }
  .wind input { width: 60px; }
  .zuschnitt-layout { grid-template-columns: 1fr; }
  .zuschnitt-info { border-left: 0; border-top: 1px solid var(--linie); }
  .wurf-raster { grid-template-columns: repeat(2, 1fr); }
  .fuss { position: static; height: auto; padding: 8px 16px; flex-wrap: wrap; }
}

/* Druck (1:1) */
@media print {
  body { overflow: visible; background: #fff; color: #000; }
  body > *:not(#druckbereich) { display: none !important; }
  #druckbereich { display: block !important; }
  .druckseite { page-break-after: always; break-after: page; position: relative; }
  .druckseite:last-child { page-break-after: auto; break-after: auto; }
  .druckseite svg { display: block; }
}
