:root {
  --papier: #f6f2ea;
  --tinte: #23201c;
  --rand: #d5cdbf;
  --flaeche: #fffdf8;
  --dunkel: #2c2925;
  --akzent: #8c3a1c;
  --akzent-hell: #b8552f;
  --grau: #6d675e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--tinte); background: var(--papier);
}

body { display: flex; flex-direction: column; }

/* --- Kopf --- */
.kopf {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--dunkel); color: #f4efe6;
  border-bottom: 3px solid var(--akzent);
}
.kopf h1 { font-size: 17px; margin: 0; letter-spacing: .5px; text-transform: uppercase; }
.kopf .untertitel { font-size: 12px; opacity: .7; text-transform: none; letter-spacing: 0; }
.kopf-knoepfe { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.trenner { width: 1px; height: 22px; background: #5c554b; margin: 0 4px; }

/* --- Knöpfe --- */
.knopf {
  font: inherit; font-size: 13px; padding: 6px 10px; cursor: pointer;
  background: var(--flaeche); color: var(--tinte);
  border: 1px solid var(--rand); border-radius: 4px;
}
.knopf:hover { background: #fff; border-color: var(--akzent-hell); }
.knopf.haupt { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.knopf.haupt:hover { background: var(--akzent-hell); }
.knopf.klein { padding: 4px 8px; font-size: 13px; }
.knopf.breit { width: 100%; margin-top: 8px; padding: 9px; font-size: 14px; }
.knopf:disabled { opacity: .45; cursor: default; }

/* --- Grundraster --- */
.haupt-bereich { flex: 1; display: flex; min-height: 0; }
.spalte {
  width: 272px; flex: 0 0 272px; overflow-y: auto; background: var(--papier);
  border-right: 1px solid var(--rand); padding: 10px;
}
.spalte.rechts { border-right: none; border-left: 1px solid var(--rand); }

.block { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 5px; padding: 10px; margin-bottom: 10px; }
.block h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; margin: 0 0 8px; color: var(--grau); }

.feld { display: block; margin-bottom: 8px; font-size: 13px; }
.feld > span { display: block; margin-bottom: 3px; color: var(--grau); font-size: 12px; }
.feld input[type=text], .feld input[type=number], .feld select, input[type=search] {
  width: 100%; font: inherit; padding: 5px 6px; border: 1px solid var(--rand);
  border-radius: 3px; background: #fff; color: var(--tinte);
}
input[type=search] { margin-bottom: 8px; }
.feld .reihe { display: flex; gap: 4px; }
.feld.reihe.zwei { display: flex; gap: 8px; }
.feld.reihe.zwei label { flex: 1; }
.klein-text { font-size: 12px; color: var(--grau); display: flex; align-items: center; gap: 5px; }

.optionen { border-top: 1px solid var(--rand); margin-top: 10px; padding-top: 8px; }
.optionen label { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 5px; font-size: 13px; line-height: 1.25; }
.optionen label input { margin-top: 2px; }
.optionen .gruppe-titel { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--grau); margin: 8px 0 4px; }

/* --- Kartenbereich --- */
.karten-bereich { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #46423c; }
.karten-leiste {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; background: var(--dunkel); color: #eee; border-bottom: 1px solid #1c1a17;
}
.karten-leiste-rechts { margin-left: auto; display: flex; align-items: center; gap: 8px; color: #ddd; }
.karten-leiste-rechts .klein-text { color: #cfc9be; }
.werkzeuge { display: flex; gap: 4px; flex-wrap: wrap; }
.wz {
  font: inherit; font-size: 12.5px; padding: 5px 9px; cursor: pointer;
  background: #3c3833; color: #e8e2d8; border: 1px solid #58524a; border-radius: 4px;
}
.wz:hover { background: #4a453e; }
.wz.aktiv { background: var(--akzent); border-color: var(--akzent); color: #fff; }

.szenen-leiste { display: flex; gap: 3px; align-items: stretch; flex-wrap: wrap;
  padding: 4px 8px; background: #3a3630; border-bottom: 1px solid #1c1a17; }
.szenen-leiste:empty { display: none; }
.szenen-reiter { font: inherit; font-size: 12px; padding: 3px 9px; cursor: pointer;
  background: #4a453e; color: #ddd6cb; border: 1px solid #58524a; border-radius: 4px 4px 0 0; }
.szenen-reiter:hover { background: #565049; }
.szenen-reiter.aktiv { background: var(--papier); color: var(--tinte); border-color: var(--papier); font-weight: 600; }

.leinwand-huelle { flex: 1; overflow: hidden; position: relative; }
#leinwand { display: block; width: 100%; height: 100%; cursor: crosshair; }
.statuszeile {
  display: flex; gap: 16px; padding: 4px 10px; font-size: 12px;
  background: var(--dunkel); color: #bdb6ab; border-top: 1px solid #1c1a17;
}
#status-info { margin-left: auto; }

/* --- Paletten --- */
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 4px;
  max-height: 320px; overflow-y: auto; overflow-x: hidden; }
.palette.terrain { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); max-height: none; }
.palette .eintrag {
  border: 1px solid var(--rand); border-radius: 4px; background: #fff; cursor: pointer;
  padding: 3px 2px 2px; text-align: center; font-size: 9.5px; line-height: 1.1; color: var(--grau);
}
.palette .eintrag:hover { border-color: var(--akzent-hell); }
.palette .eintrag.aktiv { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent); background: #fff6f0; }
.palette .eintrag canvas { display: block; margin: 0 auto 2px; }
.palette .eintrag .farbfeld { display: block; height: 26px; border: 1px solid var(--rand); margin-bottom: 2px; }
.palette-gruppe { grid-column: 1 / -1; font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--grau); margin: 6px 0 1px; border-bottom: 1px solid var(--rand); }

.wz-trenner { width: 1px; height: 20px; background: #58524a; margin: 0 2px; }
.bereich-knoepfe { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.bereich-knoepfe .knopf { font-size: 11.5px; padding: 3px 6px; }
.bereich-liste { max-height: 300px; overflow-y: auto; }
.bereich-eintrag { border: 1px solid var(--rand); border-radius: 4px; padding: 4px; margin-bottom: 4px; background: #fff; cursor: pointer; }
.bereich-eintrag.aktiv { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent); }
.bereich-kopf { display: flex; gap: 4px; align-items: center; }
.bereich-kopf input.nr { width: 42px; font: inherit; font-size: 12px; padding: 2px 3px; border: 1px solid var(--rand); border-radius: 3px; text-align: center; }
.bereich-kopf input.name { flex: 1; min-width: 0; font: inherit; font-size: 12.5px; padding: 2px 4px; border: 1px solid var(--rand); border-radius: 3px; }
.bereich-kopf button { border: none; background: none; cursor: pointer; color: var(--grau); font-size: 15px; line-height: 1; padding: 0 3px; }
.bereich-kopf button:hover { color: var(--akzent); }
.bereich-eintrag input.notiz { width: 100%; margin-top: 3px; font: inherit; font-size: 12px; padding: 2px 4px; border: 1px solid var(--rand); border-radius: 3px; color: var(--grau); }

.hinweis { font-size: 12px; color: var(--grau); line-height: 1.4; }
.hilfe { margin: 0; padding-left: 16px; font-size: 12px; color: var(--grau); line-height: 1.5; }
.hilfe b { color: var(--tinte); }

.auswahl-zeile { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.auswahl-zeile label { flex: 0 0 74px; font-size: 12px; color: var(--grau); }
.auswahl-zeile input, .auswahl-zeile select, .auswahl-zeile textarea {
  flex: 1; font: inherit; font-size: 13px; padding: 4px 5px; border: 1px solid var(--rand); border-radius: 3px;
}
.auswahl-zeile textarea { resize: vertical; min-height: 46px; }

@media (max-width: 1100px) {
  .haupt-bereich { flex-direction: column; }
  .spalte { width: auto; flex: none; max-height: 40vh; border: none; border-bottom: 1px solid var(--rand); }
  .karten-bereich { min-height: 60vh; }
}
