/* Rot/Blau: neutrale Graustufen; Farbe nur fuer die Container rot und blau der Demo */
@font-face { font-family: "Bricolage"; font-weight: 400; font-display: swap; src: url(fonts/bricolage-400.woff2) format("woff2"); }
@font-face { font-family: "Bricolage"; font-weight: 600; font-display: swap; src: url(fonts/bricolage-600.woff2) format("woff2"); }
@font-face { font-family: "Bricolage"; font-weight: 800; font-display: swap; src: url(fonts/bricolage-800.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-400.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 700; font-display: swap; src: url(fonts/jetbrains-700.woff2) format("woff2"); }

:root {
  --papier: #f4f5f7;
  --papier-tief: #e9ebef;
  --tinte: #14161c;
  --tinte-leise: #626775;
  --linie: #d9dce3;
  --signal: #14161c;      /* Hervorhebung auf hellem Grund */
  --signal-hell: #e9ebef;
  --hell: #e1e4ea;        /* Hervorhebung auf dunklem Grund */
  --leise-nacht: #8b91a0;
  --nacht: #0c0d11;
  --nacht-hoch: #101218;
  --nacht-linie: #23262f;
  --rot: #d7263d;
  --blau: #1e6bd6;
  --rot-hell: #ff5a6e;
  --blau-hell: #5b9bff;
  --sans: "Bricolage", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans); color: var(--tinte); background: var(--nacht);
  display: grid; grid-template-rows: auto 1fr; overflow: hidden;
}
button { font: inherit; cursor: pointer; }

/* --- Kopf -------------------------------------------------------------- */
.kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; background: var(--tinte); color: var(--papier);
  border-bottom: 3px solid; border-image: linear-gradient(90deg, var(--rot) 50%, var(--blau) 50%) 1;
}
.marke { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.marke-titel { font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.marke-unter { font-size: 13px; color: var(--leise-nacht); }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hell); white-space: nowrap; }
.status .punkt { width: 9px; height: 9px; border-radius: 50%; background: var(--leise-nacht); }
.status[data-zustand="laedt"] .punkt,
.status[data-zustand="arbeitet"] .punkt { background: var(--hell); animation: puls 1.1s ease-in-out infinite; }
.status[data-zustand="bereit"] .punkt { background: #5fbf6a; }
.status[data-zustand="fehler"] .punkt { background: #e03131; }
@keyframes puls { 50% { opacity: .3; } }

/* --- Raum: Blatt + Werkbank ------------------------------------------- */
.raum { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; min-height: 0; }

.blatt {
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; min-height: 0;
  background: var(--papier);
  border-right: 1px solid #000;
}

/* Stufen-Navigation: nummerierte Leiste */
.stufen { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--linie); }
.stufen button {
  border: 0; background: transparent; padding: 10px 2px 9px; color: var(--tinte-leise);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-bottom: 3px solid transparent; transition: color .15s, border-color .15s, background .15s;
}
.stufen button:hover { color: var(--tinte); background: var(--papier-tief); }
.stufen .nr { font-family: var(--mono); font-weight: 700; font-size: 17px; }
.stufen .name { font-size: 11px; letter-spacing: .01em; }
.stufen button[aria-current="step"] { color: var(--tinte); border-bottom-color: var(--signal); }
.stufen button.erledigt .nr::after { content: "✓"; color: var(--signal); font-size: 11px; margin-left: 2px; vertical-align: super; }

/* Inhalt einer Stufe */
.stufe { overflow-y: auto; padding: 22px 22px 30px; scroll-behavior: smooth; }
.stufe-kopf { margin-bottom: 18px; }
.stufe-nr { font-family: var(--mono); font-size: 12px; color: var(--signal); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.stufe-titel { font-size: 25px; line-height: 1.12; font-weight: 800; letter-spacing: -0.015em; margin: 4px 0 6px; }
.stufe-beschr { color: var(--tinte-leise); font-size: 14px; margin: 0; }

.schritt { margin: 0 0 12px; }
.hinweis { font-size: 14.5px; line-height: 1.45; margin: 18px 0 8px; }
.hinweis .schicht {
  display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 2px 6px; margin-right: 6px; border: 1px solid var(--tinte); border-radius: 3px; vertical-align: 1px;
}
.gegenueber { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 18px 0 8px; font-size: 14px; }
.gegenueber dt { font-family: var(--mono); font-size: 11px; color: var(--tinte-leise); text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.gegenueber dd { margin: 0; font-weight: 600; }

.frage {
  margin: 20px 0 10px; padding: 12px 14px 12px 16px; background: var(--signal-hell);
  border-left: 4px solid var(--signal); font-size: 15px; line-height: 1.4;
}
.frage .etikett { display: block; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--signal); letter-spacing: .08em; margin-bottom: 3px; }
.frage .klein { display: block; font-size: 12.5px; color: var(--tinte-leise); margin-top: 4px; }
.frage.zuruf { background: transparent; border-left-style: dashed; }   /* nur muendlich, ohne Abstimmung */

.befehl { position: relative; }
.befehl pre {
  margin: 0; padding: 10px 12px 10px 28px; background: var(--tinte); color: var(--hell);
  font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; border-radius: 4px 4px 0 0;
}
.befehl pre::before { content: "$"; position: absolute; left: 12px; color: var(--leise-nacht); font-weight: 700; }
.befehl .ms { font: 12px var(--mono); background: var(--nacht-hoch); color: var(--leise-nacht); padding: 5px 12px; }
.befehl .ms b { color: var(--hell); font-weight: 700; }
.befehl .leiste { display: flex; gap: 0; }
.befehl .leiste button {
  flex: 1; border: 1px solid var(--tinte); border-top: 0; background: transparent; color: var(--tinte);
  padding: 6px 8px; font-size: 13px; font-weight: 600; transition: background .12s, color .12s;
}
.befehl .leiste button + button { border-left: 0; }
.befehl .leiste button:first-child { border-radius: 0 0 0 4px; }
.befehl .leiste button:last-child { border-radius: 0 0 4px 0; }
.befehl .leiste button:hover:not(:disabled) { background: var(--tinte); color: var(--papier); }
.befehl .leiste button.los:hover:not(:disabled) { background: var(--blau); border-color: var(--blau); color: #fff; }
.befehl .leiste button:disabled { opacity: .45; cursor: not-allowed; }
.befehl.erledigt pre::before { content: "✓"; }
.befehl.erledigt.frisch pre::before { animation: haken .6s ease-out; }
@keyframes haken { 0% { transform: scale(2.2); } 100% { transform: scale(1); } }
.befehl.arbeitet .leiste button.los { background: var(--blau); color: #fff; border-color: var(--blau); }

.blatt-fuss {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 12px 22px;
  border-top: 1px solid var(--linie); background: var(--papier-tief);
}
.knopf { border: 1px solid var(--tinte); background: transparent; color: var(--tinte); padding: 7px 12px; border-radius: 4px; font-size: 13.5px; font-weight: 600; }
.knopf:hover:not(:disabled) { background: var(--tinte); color: var(--papier); }
.knopf:disabled { opacity: .4; cursor: not-allowed; }
#vorbauen { justify-self: center; }

/* --- Werkbank (Terminals) -------------------------------------------- */
.werkbank { display: grid; grid-template-rows: auto 1fr; min-height: 0; min-width: 0; background: var(--nacht); }
.reiter { display: flex; align-items: center; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--nacht-linie); }
.reiter-knopf {
  border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--leise-nacht);
  padding: 7px 14px; border-radius: 5px 5px 0 0; font-size: 13.5px; font-weight: 600;
}
.reiter-knopf.aktiv { background: var(--nacht-hoch); color: var(--hell); border-color: var(--nacht-linie); box-shadow: inset 0 2px 0 var(--hell); }
.reiter-rest { flex: 1; }
.knopf-mini { border-color: #3a3e4a; color: var(--hell); padding: 4px 10px; font-size: 12.5px; margin: 0 0 6px 6px; }
.knopf-mini:hover:not(:disabled) { background: var(--hell); color: var(--nacht); }

.terminals { position: relative; min-height: 0; overflow: hidden; background: var(--nacht-hoch); }
/* content-box: FitAddon misst die Hoehe des Rahmens und zieht dessen Padding nicht ab -- sonst eine Zeile zu viel, die unterste abgeschnitten */
.term { position: absolute; inset: 0; box-sizing: content-box; padding: 10px 6px 6px 12px; visibility: hidden; }
.term.aktiv { visibility: visible; }
/* Reiter Skript: liegt ueber den Terminals, die darunter weiterlaufen */
.skript { position: absolute; inset: 0; z-index: 5; display: none; background: #f7f6f2; }
body.skript-an .skript { display: block; }
.skript iframe { width: 100%; height: 100%; border: 0; display: block; }
body.skript-an #mitschnitt-start, body.skript-an .tastenleiste { display: none; }
.term .xterm-viewport { scrollbar-color: #2f333d transparent; }

.boot {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(12, 13, 17, .94);
  transition: opacity .5s ease, visibility .5s;
}
.boot.weg { opacity: 0; visibility: hidden; }
.boot-innen { width: min(440px, 86%); color: var(--hell); }
.boot-titel { font-weight: 800; font-size: 28px; letter-spacing: -0.01em; margin-bottom: 14px; }
.boot-balken { height: 6px; background: var(--nacht-linie); border-radius: 3px; overflow: hidden; }
.boot-balken span { display: block; height: 100%; width: 0; background: var(--hell); transition: width .4s ease; }
.boot-text { font-family: var(--mono); font-size: 12.5px; color: var(--leise-nacht); margin-top: 10px; min-height: 1.4em; }
.boot-hinweis { font-size: 13px; color: var(--leise-nacht); margin-top: 18px; line-height: 1.45; }
.boot.fehler .boot-balken span { background: #e03131; }

/* --- Bewegung -------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .stufe.neu .stufe-kopf, .stufe.neu .schritt { animation: auftauchen .38s cubic-bezier(.2, .7, .2, 1) both; }
  .stufe.neu .schritt { animation-delay: calc(var(--i, 0) * 28ms + 60ms); }
  @keyframes auftauchen { from { opacity: 0; transform: translateY(8px); } }
}

/* --- Schmale Bildschirme: untereinander ------------------------------ */
@media (max-width: 900px) {
  .raum { grid-template-columns: 1fr; grid-template-rows: minmax(0, 46%) minmax(0, 1fr); }
  .blatt { border-right: 0; border-bottom: 1px solid #000; }
  .stufe { padding: 16px; }
  .stufen .name { display: none; }
  .marke-unter { display: none; }
  .marke-titel { font-size: 16px; }
}

/* --- Handy: Anleitung und Terminal abwechselnd, Sondertasten ------------ */
.umschalter, .tastenleiste { display: none; }
@media (max-width: 699px) {
  body { height: var(--hoehe, 100%); grid-template-rows: auto auto 1fr; }
  .kopf { padding: 10px 14px; }
  .umschalter { display: grid; grid-template-columns: 1fr 1fr 1fr; background: var(--tinte); border-bottom: 1px solid var(--nacht-linie); }
  .umschalter button {
    border: 0; background: transparent; color: var(--leise-nacht); padding: 9px 0 8px;
    font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent;
  }
  .umschalter button.aktiv { color: var(--hell); border-bottom-color: var(--hell); }
  .raum { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .blatt { border-bottom: 0; }
  body.ansicht-terminal .blatt, body:not(.ansicht-terminal) .werkbank { display: none; }
  .blatt-fuss { padding: 10px 14px; }
  .knopf { padding: 7px 10px; }
  .werkbank { grid-template-rows: auto 1fr auto; }
  .term { padding: 6px 2px 4px 6px; }
  .tastenleiste { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px 8px; border-top: 1px solid var(--nacht-linie); }
  .tastenleiste button {
    border: 1px solid #3a3e4a; background: var(--nacht-hoch); color: var(--hell); border-radius: 5px;
    padding: 9px 0; font: 600 13px var(--mono); touch-action: manipulation;
  }
  .tastenleiste button:active { background: var(--hell); color: var(--nacht); }
}

/* --- Live-Abstimmung (live.js) ------------------------------------------ */
.stufen { grid-row: 1; } .live { grid-row: 2; } .stufe { grid-row: 3; } .blatt-fuss { grid-row: 4; }
.live { background: var(--tinte); color: var(--hell); padding: 10px 22px 14px; border-bottom: 1px solid #000; max-height: 62vh; overflow-y: auto; }
.live[hidden], .reiter-knopf[hidden] { display: none; }
.live-kopf { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--leise-nacht); }
.live-marke { display: inline-flex; align-items: center; gap: 6px; font: 700 11px var(--mono); letter-spacing: .1em; color: var(--hell); }
.live-punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--rot-hell); animation: puls 1.6s ease-in-out infinite; }
.live-name { color: var(--hell); font-weight: 600; }
.live-stand { margin-left: auto; font-family: var(--mono); font-size: 12px; }
.live-sync { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13.5px; }
.live-sync span { flex: 1; }
.live-knopf { border: 1px solid var(--hell); background: transparent; color: var(--hell); border-radius: 4px; padding: 5px 10px; font-size: 13px; font-weight: 600; }
.live-knopf:hover { background: var(--hell); color: var(--tinte); }
.live-weg { border: 0; background: transparent; color: var(--leise-nacht); font-size: 18px; line-height: 1; padding: 2px 4px; }
.live-weg:hover { color: var(--hell); }
.live-frage { position: relative; margin-top: 12px; }
.live-etikett { font: 700 11px var(--mono); letter-spacing: .08em; color: var(--leise-nacht); }
.live-frage.offen .live-etikett { color: var(--hell); }
.live-text { font-size: 17px; font-weight: 700; line-height: 1.3; margin: 3px 28px 10px 0; }
.live-optionen { display: grid; gap: 6px; }
.live-option {
  text-align: left; border: 1px solid #3a3e4a; background: var(--nacht-hoch); color: var(--hell);
  border-radius: 5px; padding: 10px 12px; font-size: 15px; font-weight: 600; transition: background .12s, border-color .12s;
}
.live-option:hover { border-color: var(--hell); }
.live-option:active { background: var(--hell); color: var(--tinte); }
.live-wolke-eingabe { display: flex; gap: 6px; }
.live-wolke-eingabe input {
  flex: 1; min-width: 0; border: 1px solid #3a3e4a; background: var(--nacht-hoch); color: var(--hell);
  border-radius: 5px; padding: 9px 10px; font: 15px var(--sans);
}
.live-wolke-eingabe input:focus { outline: none; border-color: var(--hell); }
.live-info { font-size: 14px; margin-top: 8px; color: var(--hell); }
.live-fehler { font-size: 13.5px; margin-top: 8px; color: var(--rot-hell); }
.live-balken { display: grid; gap: 5px; }
.live-zeile { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr 44px; align-items: center; gap: 8px; font-size: 13.5px; color: var(--leise-nacht); }
.live-zeile.richtig { color: #9bd8a7; font-weight: 700; }
.live-zeile.meine .live-opt::before { content: "▸ "; }
.live-spur { height: 8px; background: var(--nacht-linie); border-radius: 4px; overflow: hidden; }
.live-spur span { display: block; height: 100%; background: var(--leise-nacht); }
.live-zeile.richtig .live-spur span { background: #7cc48a; }
.live-zahl { text-align: right; font-family: var(--mono); font-size: 12px; }
.live-woerter { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-weight: 700; }
.live-zu { position: absolute; top: -2px; right: -4px; }
@media (max-width: 699px) { .live { padding: 10px 14px 12px; max-height: 55vh; } }

/* --- Container-Farben: rot und blau ---------------------------------- */
.fa { font-weight: 700; }
/* Geraetefarben (Tabelle FARBEN in demo/lib.sh): auf hellem Grund dunkle Varianten,
   auf dunklem Grund (Befehl, Mitschnitt) die Tafelfarben aus der Tabelle (--fa-*, von app.js gesetzt) */
.fa-rot { color: var(--rot); } .fa-blau { color: var(--blau); } .fa-gruen { color: #1e8449; } .fa-gelb { color: #9a7400; }
.befehl pre .fa-rot, .befehl .ms .fa-rot { color: var(--fa-rot, var(--rot-hell)); }
.befehl pre .fa-blau, .befehl .ms .fa-blau { color: var(--fa-blau, var(--blau-hell)); }
.befehl pre .fa-gruen, .befehl .ms .fa-gruen { color: var(--fa-gruen, #b9f6ca); }
.befehl pre .fa-gelb, .befehl .ms .fa-gelb { color: var(--fa-gelb, #ffe57f); }
.befehl .merke { margin: 0; padding: 6px 12px; font-size: 13px; line-height: 1.4; color: var(--tinte-leise); border: 1px solid var(--tinte); border-top: 0; }
