/* grandMA3-Look (onPC): schwarze Fenster, graue Titelleisten mit MA-Logo, dunkle Kacheln,
   gelbe Auswahl, rote Programmer-Werte, grünes Go. Referenz: Screenshot des Show-Files der Schule. */
:root {
  color-scheme: dark;
  --bg: #000;
  --win: #0a0a0b;
  --bar: #1d1e21;
  --bar2: #2a2b2f;
  --tile: #17181a;
  --line: #2a2b2f;
  --line2: #45474d;
  --fg: #ececee;
  --mute: #a0a2a9;
  --faint: #62646b;
  --yellow: #f2c230;
  --red: #d9242f;
  --red-d: #b3151f;
  --store: #ff4a4f;
  --go: #32c27a;
  --info: #52c4ff;
  --blue: #0f64a8;
  --teal: #11806f;
  --font: Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--fg); font: 400 15px/1.4 var(--font); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }

#app { height: 100%; display: grid; grid-template-rows: 22px minmax(0, 1fr); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }

/* Fenstertitel oben wie bei onPC */
.apptitle { display: flex; align-items: center; gap: 10px; padding: 0 8px; background: #fff; color: #111; font-size: 12px; white-space: nowrap; overflow: hidden; }
.apptitle a { color: #111; text-decoration: none; font-weight: 700; }
.apptitle .sp { flex: 1; }
.apptitle .xp { font-family: var(--mono); font-size: 11px; }
.apptitle button { border: 0; background: none; color: #111; font-size: 12px; padding: 0 6px; cursor: pointer; text-decoration: underline; }

.workspace { display: grid; grid-template-columns: 286px minmax(0, 1fr); min-height: 0; }

/* ---------- Fenster ---------- */
.ma-win { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--win); border: 1px solid var(--line); }
.wbar { flex: none; height: 24px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 3px; background: var(--bar); border-bottom: 1px solid #000; }
.wtitle { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wbody { flex: 1; min-height: 0; position: relative; }
.ma-logo { flex: none; display: inline-grid; place-items: center; width: 24px; height: 18px; background: #000; border: 1px solid var(--line2); border-radius: 2px; }
.ma-logo b { font-size: 10px; font-weight: 900; letter-spacing: .02em; line-height: 1; }
.wbtn { height: 20px; padding: 0 8px; border: 1px solid var(--line2); background: var(--bar2); font-size: 11.5px; border-radius: 2px; }
.wbtn.on { border-color: var(--yellow); color: var(--yellow); }
.cambtns { margin-left: auto; display: flex; gap: 4px; }

.ma-screen { display: flex; flex-direction: row; gap: 4px; padding: 4px; min-width: 0; min-height: 0; background: #000; }
.ma-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.lbar { flex: none; width: 50px; display: flex; flex-direction: column; gap: 2px; padding: 2px 0; background: #0a0a0b; border-right: 1px solid var(--line); }
.lb { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px; border: 0; background: none; color: var(--mute); font-size: 8.5px; line-height: 1; letter-spacing: -.02em; }
.lb:hover { color: var(--fg); background: var(--bar); }
.lb svg { display: block; }
.wsub { margin-left: 6px; font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.wsub.has { color: var(--yellow); }
.camstrip { position: absolute; left: 34px; right: 0; top: 0; display: flex; background: rgba(0, 0, 0, .6); border-bottom: 1px solid var(--line); }
.camt { position: relative; flex: 1; min-width: 0; height: 32px; padding: 8px 2px 0; border: 0; border-right: 1px solid var(--line); background: transparent; font-size: 10.5px; color: var(--fg); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.camt i { position: absolute; left: 3px; top: 1px; font-style: normal; font-size: 8.5px; color: var(--faint); }
.camt.on { outline: 2px solid var(--yellow); outline-offset: -2px; }
.camt:active { background: #2a2b2f; }
.tools3d { position: absolute; left: 0; top: 0; bottom: 0; width: 34px; display: flex; flex-direction: column; gap: 3px; padding: 3px; background: rgba(14, 14, 16, .82); border-right: 1px solid var(--line); }
.tool { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); background: var(--tile); color: var(--mute); border-radius: 2px; }
.tool.on { color: var(--yellow); border-color: var(--yellow); }

/* ---------- oberes Fenster ---------- */
.ma-top { flex: 1 1 0; min-height: 210px; display: flex; gap: 4px; min-width: 0; }
.win-main { flex: 1; }
.view { position: absolute; inset: 0; }
.v3d { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.say { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 10px; font-size: 13.5px; line-height: 1.35; background: rgba(10, 10, 11, .88); border: 1px solid var(--line2); pointer-events: none; }
.say.ok { border-color: var(--go); }
.say.err { border-color: var(--store); }
.viewbtns { flex: none; width: 78px; display: flex; flex-direction: column; gap: 4px; }
.vbtn { position: relative; flex: none; min-height: 52px; padding: 13px 4px 4px; border: 1px solid var(--line); background: var(--tile); font-size: 12px; line-height: 1.15; text-align: center; border-radius: 2px; }
.vbtn i { position: absolute; left: 3px; top: 1px; font-style: normal; font-size: 9.5px; color: var(--faint); }
.vbtn u { position: absolute; right: 3px; top: 3px; color: var(--faint); line-height: 0; }
.vbtn.on { background: var(--blue); border-color: #3b8ed0; }
.vbtn.on i, .vbtn.on u { color: #cfe6f8; }
.vbtn.locked, .locked { opacity: .32; }
.vbtn.locked, .tile.locked, .key.locked, .ptab.locked, .etab.locked { cursor: not-allowed; }

/* Sheets */
.view-sheet, .view-seq { padding: 6px; overflow: auto; background: var(--win); }
.sheetwrap { overflow: auto; }
.sheet { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sheet th { text-align: left; font-weight: 500; color: var(--mute); background: var(--bar); padding: 4px 6px; border: 1px solid #000; position: sticky; top: 0; }
.sheet td { padding: 3px 6px; border: 1px solid var(--line); }
.sheet .fid { color: var(--mute); }
.sheet tr.sel td { background: #1f2735; }
.sheet tr.sel .fid, .sheet tr.sel .fname { color: var(--yellow); font-weight: 700; }
.sheet tr.sel td.c-prog { background: var(--red-d); }
.sheet .tg { width: 18px; padding: 0 2px; text-align: center; color: var(--yellow); }
.sheet tr.grp td { background: #15161a; color: var(--mute); }
.sheet thead th { text-align: center; }
.sheet td { text-align: center; }
.sheet td.fname, .sheet td.fid { text-align: left; }
.sheet .cname { text-align: left; font-style: italic; color: var(--fg); }
.sheet tr.zero td { color: var(--faint); }
.sheet .dim { text-align: left; }
.seqtitle { font-size: 13px; color: var(--mute); margin-right: 10px; }
.sheet .c-def { color: var(--faint); }
.sheet .c-prog { color: #fff; font-weight: 700; background: var(--red-d); }
.sheet .c-inactive { color: #80828a; background: #1d1e21; }
.sheet .c-play { color: var(--go); }
.sheet td.ref { font-style: italic; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 2px 0; font-size: 12px; }
.lg { color: var(--mute); }
.lg.prog { color: #ff6a6f; } .lg.inactive { color: #80828a; } .lg.play { color: var(--go); } .lg.sel { color: var(--yellow); }
.empty { padding: 24px 10px; color: var(--mute); font-size: 14px; }
.seqtabs { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.seqt .cno { color: var(--yellow); font-weight: 700; }
.seqt tr.cur td { background: rgba(50, 194, 122, .16); }
.seqt .cvals { color: var(--mute); }
.fadebtn { min-width: 44px; height: 28px; border: 1px solid var(--line2); background: var(--bar2); font: 600 13px var(--mono); border-radius: 2px; }

/* ---------- Pools ---------- */
.ma-pools { flex: none; height: 168px; display: flex; gap: 4px; min-width: 0; }
.win-groups { width: 280px; flex: none; }
.win-presets { flex: 1; }
.win-pool .wbody { display: flex; }
.ptitle { flex: none; width: 54px; display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; padding: 4px 4px; font-size: 12px; font-weight: 500; color: #fff; }
.ptitle.blue { background: var(--blue); }
.ptitle .ma-logo { background: rgba(0, 0, 0, .35); border-color: rgba(255, 255, 255, .45); }
.ptabs { flex: none; width: 74px; display: flex; flex-direction: column; background: var(--teal); }
.ptab { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 0 5px; border: 0; border-bottom: 1px solid rgba(0, 0, 0, .35); background: transparent; color: #fff; font-size: 12px; line-height: 1.05; text-align: left; }
.ptab i { font-style: normal; font-size: 9.5px; opacity: .85; }
.ptab.on { background: rgba(255, 255, 255, .22); font-weight: 700; }
.pgrid { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 2px; background: #000; }
.pgrid-groups { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.pgrid-presets { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.tile { position: relative; min-width: 0; min-height: 0; border: 1px solid var(--line); background: #0d0d0e; border-radius: 1px; padding: 0; text-align: center; overflow: hidden; touch-action: manipulation; }
.tile i { position: absolute; left: 3px; top: 1px; font-style: normal; font-size: 10px; color: var(--faint); }
.tile .tn { position: absolute; left: 1px; right: 1px; bottom: 2px; font-size: 10.5px; line-height: 1.05; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.filled { background: var(--tile); border-color: var(--line2); }
.tile.filled::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--teal); }
.pgrid-groups .tile.filled::before { background: var(--yellow); }
.tile.sel { border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }
.tile:active { background: #26272b; }
.tile .tv { position: absolute; left: 50%; top: 11px; transform: translateX(-50%); width: 62%; height: 38%; }
.tv.sw { border-radius: 50%; width: 26px; height: 26px; top: 8px; border: 1px solid rgba(255, 255, 255, .5); }
.tv.bar { height: 8px; top: 18px; border: 1px solid var(--line2); }
.tv.pos, .tv.gob { font-size: 22px; line-height: 26px; color: var(--mute); text-align: center; top: 6px; }
.tv.beam { top: 10px; width: var(--w, 16px); height: 20px; background: linear-gradient(#ececee, transparent); clip-path: polygon(45% 0, 55% 0, 100% 100%, 0 100%); }

/* ---------- Befehlszeile ---------- */
.ma-cmd { flex: none; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px; background: var(--win); border: 1px solid var(--line); font-size: 14px; min-width: 0; overflow: hidden; }
.prompt { color: var(--mute); font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.cin { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--yellow); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chist { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chist.ok { color: var(--go); } .chist.bad { color: var(--store); }
.cprog { font-size: 12px; color: #ff6a6f; white-space: nowrap; }

/* ---------- unten ---------- */
.ma-bottom { flex: none; height: 206px; display: flex; gap: 4px; min-width: 0; }
.win-enc { flex: 1 1 0; min-width: 180px; }
.win-enc .wbody { display: flex; flex-direction: column; }
.etabs { flex: none; display: flex; }
.etab { flex: 1; min-width: 0; height: 32px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 0 2px; border: 0; border-right: 1px solid #000; background: var(--bar2); font-size: 9px; letter-spacing: -.02em; line-height: 1.05; overflow: hidden; }
.etab i { font-style: normal; font-size: 9px; color: var(--mute); }
.etab.on { background: #36373c; border-bottom: 2px solid var(--yellow); }
.ecells { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; padding: 3px 4px; min-height: 0; }
.ecell { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 4px; }
.elabel { font-size: 11px; color: var(--mute); }
.erow { display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; gap: 2px; }
.estep { height: 38px; border: 1px solid var(--line2); background: var(--bar2); font-size: 18px; line-height: 1; padding: 0; border-radius: 2px; }
.edisp { position: relative; height: 38px; display: flex; align-items: center; justify-content: center; gap: 6px; background: #1d1e21; border: 1px solid var(--line2); overflow: hidden; touch-action: none; cursor: ew-resize; }
.efill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, .07); pointer-events: none; }
.edisp b { position: relative; font-size: 14px; font-weight: 700; font-family: var(--mono); }
.edisp em { position: relative; font-style: normal; font-size: 10px; color: rgba(255, 255, 255, .85); }
.ecell.red .edisp { background: var(--red-d); border-color: var(--red); }
.ecell.red .efill { background: rgba(255, 255, 255, .13); }
.ecell.gray .edisp { background: #2f3034; }

.win-keys { flex: none; width: 270px; }
.keys { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(4, 1fr); gap: 2px; padding: 3px; }
.key { min-width: 0; overflow: hidden; border: 1px solid var(--line2); background: var(--bar2); font-size: 10px; letter-spacing: -.02em; font-weight: 500; padding: 0; border-radius: 2px; }
.key:active { background: #3a3b40; }
.key.num { font-size: 16px; font-family: var(--mono); background: #232427; }
.key.wide { grid-column: span 2; color: var(--yellow); font-weight: 700; font-size: 13px; }
.key.k-store { color: var(--store); }
.key.k-clear { color: #fff; background: #3b3c41; }
.key.pending { background: var(--yellow); color: #000; border-color: var(--yellow); }

.win-exec { flex: none; width: 258px; }
.execs { position: absolute; inset: 0; display: flex; gap: 2px; padding: 2px; }
.xcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 2px 1px; background: #0f0f10; border: 1px solid var(--line); }
.xcol.filled { background: #15161a; border-color: var(--line2); }
.xid { font-size: 10px; color: var(--mute); text-align: center; font-family: var(--mono); }
.xname { font-size: 9px; line-height: 1.1; text-align: center; height: 11px; overflow: hidden; white-space: nowrap; color: var(--fg); }
.xcue { font-size: 8.5px; text-align: center; color: var(--mute); height: 11px; white-space: nowrap; overflow: hidden; letter-spacing: -.02em; }
.xgo { flex: none; height: 32px; border: 1px solid var(--line2); background: var(--bar2); font-size: 11px; font-weight: 700; padding: 0; border-radius: 2px; }
.xcol.on .xgo { background: var(--go); border-color: var(--go); color: #00170c; }
.xoff { flex: none; height: 24px; border: 1px solid var(--line); background: #17181a; font-size: 10px; color: var(--mute); padding: 0; border-radius: 2px; }
.xfader { position: relative; flex: 1; min-height: 40px; touch-action: none; cursor: ns-resize; }
.xgroove { position: absolute; left: 50%; top: 10px; bottom: 10px; width: 4px; transform: translateX(-50%); background: #000; border: 1px solid var(--line2); }
.xcap { position: absolute; left: 3px; right: 3px; height: 20px; bottom: 0; background: linear-gradient(#cfd0d4, #8f9096); border-radius: 2px; }
.xfader { --travel: 100%; }
.xfader .xcap { margin-bottom: 0; }
.gmcol .xname { color: var(--yellow); }

/* Gesperrt: sichtbar, aber nicht bedienbar */
.ma-win.locked, .win-exec.locked, .win-enc.locked, .win-groups.locked { opacity: .35; pointer-events: none; }
.key.locked, .ptab.locked, .etab.locked, .gmcol.locked { opacity: .35; }

/* Aufmerksamkeit lenken */
.attn { outline: 2px solid var(--yellow); outline-offset: -2px; animation: attn .9s ease-in-out 3; }
@keyframes attn { 50% { outline-color: transparent; } }

/* Swipey */
.swipey { position: fixed; z-index: 80; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 4px; padding: 4px; background: #101012; border: 1px solid var(--line2); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .6); }
.sw-btn { border: 1px solid var(--line2); background: var(--bar2); color: var(--fg); font-size: 13px; border-radius: 3px; padding: 2px; line-height: 1.15; }
.sw-btn.off { opacity: .4; }
.sw-btn:active { background: var(--yellow); color: #000; }
.sw-center { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--yellow); border-radius: 3px; font-size: 11px; color: var(--yellow); }
.sw-center b { font-size: 20px; font-weight: 500; color: var(--fg); }

/* Dialoge */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .78); }
.modal-card { width: min(640px, 100%); max-height: 100%; overflow: auto; background: var(--win); border: 1px solid var(--line2); padding: 0 0 16px; }
.modal-card > *:not(.wbar) { margin-left: 16px; margin-right: 16px; }
.modal-card .wbar { margin-bottom: 14px; }
.modal-card input[type="text"] { width: calc(100% - 32px); min-height: 46px; padding: 0 12px; background: #000; border: 1px solid var(--line2); font-size: 17px; -webkit-user-select: text; user-select: text; }
.askbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { min-height: 44px; padding: 0 16px; border: 1px solid var(--line2); background: var(--bar2); font-size: 15px; font-weight: 500; border-radius: 2px; white-space: nowrap; }
.btn:active { background: #3a3b40; }
.btn.prim { background: var(--yellow); border-color: var(--yellow); color: #000; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .38; cursor: default; }

/* Hochformat */
@media (max-aspect-ratio: 1/1), (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(190px, 32%) minmax(0, 1fr); }
  .ma-top { min-height: 180px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; } }

/* Layout-Ansicht */
.view-layout { padding: 6px; background: var(--win); overflow: auto; }
.lgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.lcard { position: relative; height: 70px; border: 1px solid var(--line2); background: var(--tile); padding: 0; text-align: center; border-radius: 2px; }
.lcard i { position: absolute; left: 4px; top: 2px; font-style: normal; font-size: 11px; color: var(--mute); }
.lcard b { display: block; margin-top: 12px; font: 700 22px var(--mono); }
.lcard .lsw { position: absolute; left: 6px; right: 6px; bottom: 5px; height: 8px; border: 1px solid var(--line2); }
.lcard.sel { border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }
.lcard.sel i { color: var(--yellow); }
.xval { font: 600 10px var(--mono); text-align: center; color: var(--mute); }
.xcol .xgo { margin-top: 1px; }

.whint { margin-left: auto; font-size: 10.5px; color: var(--faint); white-space: nowrap; }

/* Befehlszeile: zuletzt ausgeführter Befehl bleibt sichtbar */
.ctext.done { color: var(--fg); }
.ctext.done.ok::before { content: "\2713  "; color: var(--go); }
.ctext.done.bad::before { content: "\2717  "; color: var(--store); }
.cin.idle .caret { display: none; }
.chist { color: var(--faint); }
