:root {
  --grund: #f4f5f7;
  --flaeche: #fff;
  --text: #1d232b;
  --leise: #66707c;
  --rand: #d6dae0;
  --akzent: #2f6f4f;
  --fehler: #b3261e;
  --ok: #2e7d32;
  --hinweis: #8a6a1f;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--grund);
}

* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3 { margin: 0 0 .6em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--rand); background: var(--flaeche); border-radius: 6px;
  padding: .35em .8em; cursor: pointer;
}
button:hover { border-color: var(--leise); }
button.haupt { background: var(--akzent); border-color: var(--akzent); color: #fff; }
button.gefahr { color: var(--fehler); }
button:disabled { opacity: .5; cursor: default; }
button.klein { padding: .1em .5em; }
input, select, textarea { border: 1px solid var(--rand); border-radius: 6px; padding: .3em .5em; background: #fff; }

.klein { font-size: .85em; color: var(--leise); }
.fehler { color: var(--fehler); }
.ok { color: var(--ok); }
.hinweis { color: var(--hinweis); }
.mitte { max-width: 360px; margin: 15vh auto; text-align: center; }
.rechts { margin-left: auto; display: flex; gap: .5em; align-items: center; }

header {
  display: flex; align-items: center; gap: 1.5em; padding: .6em 1em;
  background: var(--flaeche); border-bottom: 1px solid var(--rand);
}
nav { display: flex; gap: .3em; }
nav button { border-color: transparent; }
nav button.aktiv { background: var(--grund); border-color: var(--rand); }

#meldung { margin: .5em 1em; padding: .5em .8em; border-radius: 6px; background: #eef4ef; }
#meldung.fehler { background: #fbeceb; }
#meldung.hinweis { background: #fbf4e4; color: var(--text); }

section.reiter { padding: 1em; }
#reiter-flow { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 50px); }
.leiste { display: flex; align-items: center; gap: 1em; padding: .5em 1em; background: var(--flaeche); border-bottom: 1px solid var(--rand); }
.arbeitsflaeche { flex: 1; display: grid; grid-template-columns: 170px 1fr 300px; min-height: 0; }
aside { background: var(--flaeche); padding: .8em; overflow: auto; }
#palette { border-right: 1px solid var(--rand); display: flex; flex-direction: column; gap: .4em; }
#eigenschaften { border-left: 1px solid var(--rand); }

.palettenkarte { text-align: left; border-left: 5px solid var(--farbe); }

/* --- Editor --- */
.editor {
  position: relative; overflow: hidden; outline: none; cursor: grab;
  background-color: #eef0f3;
  background-image: radial-gradient(#cfd4da 1px, transparent 1px);
  background-size: 20px 20px;
  touch-action: none; user-select: none;
}
.editor:active { cursor: grabbing; }
.flaeche { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
svg.linien { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
svg .linie { fill: none; stroke: #7d8794; stroke-width: 2; }
svg .linie.gewaehlt { stroke: var(--fehler); stroke-width: 3; }
svg .linie.neu { stroke-dasharray: 6 4; }
svg .treffer { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }

.karte {
  position: absolute; width: 220px; background: var(--flaeche);
  border: 1px solid var(--rand); border-top: 4px solid var(--farbe); border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); cursor: move;
}
.karte.gewaehlt { box-shadow: 0 0 0 2px var(--farbe), 0 2px 8px rgba(0,0,0,.15); }
.karte .kopf { position: relative; padding: .45em .7em; font-weight: 600; display: flex; justify-content: space-between; }
.kid { font-weight: 400; font-size: .8em; color: var(--leise); }
.karte .kurz { padding: 0 .7em .45em; font-size: .85em; color: var(--leise); overflow-wrap: anywhere; }
.karte .ausgaenge { border-top: 1px solid var(--grund); padding: .25em 0; }
.karte .ausgang { position: relative; text-align: right; padding: .15em 1.1em .15em .7em; font-size: .85em; }
.port {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--farbe);
}
.port.ein { left: -8px; top: 50%; margin-top: -6px; }
.port.aus { right: -8px; top: 50%; margin-top: -6px; cursor: crosshair; }
.port.aus:hover { background: var(--farbe); }

/* --- Eigenschaften --- */
.feld { display: flex; flex-direction: column; gap: .25em; margin-bottom: .8em; }
.feld > span { font-size: .85em; color: var(--leise); }
.feld.waagerecht { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: .5em; }
#eigenschaften button { margin-top: .4em; }
.zeitregel { border: 1px solid var(--rand); border-radius: 6px; padding: .4em; margin-bottom: .4em; }
.tage { display: flex; flex-wrap: wrap; gap: .3em; margin-bottom: .3em; }
.tage label { font-size: .85em; }

/* --- Tabellen --- */
table { border-collapse: collapse; background: var(--flaeche); width: 100%; }
table.schmal { width: auto; }
th, td { text-align: left; padding: .45em .7em; border-bottom: 1px solid var(--rand); vertical-align: middle; }
th { font-weight: 600; }
td audio { height: 30px; vertical-align: middle; }
form.zeile { display: flex; gap: .6em; align-items: center; margin-bottom: 1em; flex-wrap: wrap; }

/* --- Vorschau --- */
dialog { width: min(900px, 95vw); max-height: 90vh; border: 1px solid var(--rand); border-radius: 10px; }
dialog::backdrop { background: rgba(0,0,0,.3); }
pre.diff { max-height: 50vh; overflow: auto; background: #fafbfc; border: 1px solid var(--rand); padding: .6em; font-size: 12px; }
pre.diff .neu { background: #e6f4ea; }
pre.diff .weg { background: #fbeceb; text-decoration: line-through; }
.knoepfe { display: flex; justify-content: flex-end; gap: .6em; }
