/* Sequenz-Werkzeug – gleicher Stil wie ER-Designer/Koordinaten (macOS-nah, Hell/Dunkel nach System) */
:root {
  --bg: #f5f5f7; --panel: #fbfbfd; --canvas: #ffffff; --text: #1d1d1f; --muted: #6e6e73;
  --line: rgba(0, 0, 0, .09); --ctrl: #ffffff; --ctrl-b: rgba(0, 0, 0, .15); --hover: rgba(0, 0, 0, .05);
  --seg: rgba(0, 0, 0, .06); --seg-on: #ffffff; --accent: #007aff; --accent-soft: rgba(0, 122, 255, .13);
  --danger: #d70015; --ok: #28a745; --warn: #c77700;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 0 0 .5px rgba(0, 0, 0, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --panel: #252527; --canvas: #1e1e20; --text: #f5f5f7; --muted: #98989d;
    --line: rgba(255, 255, 255, .09); --ctrl: #2c2c2e; --ctrl-b: rgba(255, 255, 255, .14); --hover: rgba(255, 255, 255, .07);
    --seg: rgba(255, 255, 255, .08); --seg-on: #5a5a5e; --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .22);
    --danger: #ff453a; --ok: #32d74b; --warn: #ff9f0a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 0 0 .5px rgba(255, 255, 255, .08);
  }
}
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
#app { height: calc(100vh - var(--bxnny-topbar-h, 0px)); height: calc(100dvh - var(--bxnny-topbar-h, 0px)); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; min-width: 28px; padding: 0 9px;
  border: 0; border-radius: 7px; background: transparent; cursor: pointer; white-space: nowrap; }
.btn svg { flex: none; }
.btn.icon { padding: 0; width: 30px; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.on { background: var(--accent-soft); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.seg { display: inline-flex; background: var(--seg); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 3px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; line-height: 20px; font-size: 13px; }
.seg button:hover:not(.on) { background: var(--hover); }
.seg button.on { background: var(--seg-on); box-shadow: var(--shadow); }
.lbl { display: none; }
/* „Weitere Aktionen“: auf dem Desktop unsichtbarer Umschalter, die Knöpfe stehen per display:contents
 * ganz normal in der Werkzeugleiste (keine optische Änderung). Erst wenn die Leiste eng wird (siehe
 * @media weiter unten), wird daraus ein Dropdown-Menü wie das Kontextmenü (.seq-ctxmenu). */
#moreBtn { display: none; }
.more-menu { display: contents; }
input, select, textarea { background: var(--ctrl); border: 1px solid var(--ctrl-b); border-radius: 6px; padding: 3px 7px; min-height: 26px; box-sizing: border-box; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }

.tb { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 8px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; overflow-y: hidden; }
.tb .grp { display: flex; align-items: center; gap: 2px; flex: none; }
.docname { border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 13.5px; padding: 1px 5px; min-height: 22px; width: 220px; border-radius: 5px;
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.docname:hover { border-color: var(--line); }
.status { font-size: 11px; color: var(--muted); white-space: nowrap; flex: none; }
.status::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--muted); }
.status.ok::before { background: var(--ok); }
.status.dirty::before { background: var(--warn); }
.status.err::before { background: var(--danger); }

#main { flex: 1; display: flex; min-height: 0; position: relative; }
#editorPane { width: 42%; min-width: 260px; max-width: 640px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--canvas); }
#editorScroller { flex: 1; display: flex; min-height: 0; position: relative; }
#gutter { flex: none; width: 38px; overflow: hidden; background: var(--panel); border-right: 1px solid var(--line); position: relative; }
#gutter > div { position: absolute; left: 0; right: 0; top: 12px; text-align: right; padding-right: 6px; font: 12.5px/1.55 var(--mono); color: var(--muted); white-space: pre; }
#codeWrap { flex: 1; position: relative; overflow: hidden; }
#srcHighlight, #srcText { position: absolute; inset: 0; margin: 0; border: 0; border-radius: 0; font: 12.5px/1.55 var(--mono); padding: 12px; white-space: pre; overflow: auto; box-sizing: border-box; tab-size: 2; }
#srcHighlight { pointer-events: none; color: var(--text); background: transparent; }
#srcText { resize: none; background: transparent; color: transparent; caret-color: var(--text); }
#srcText::selection { background: var(--accent-soft); }
.tok-kw { color: var(--accent); font-weight: 600; }
.tok-arrow { color: var(--muted); font-weight: 700; }
.tok-str { color: #2e7d32; }
.tok-field { color: var(--muted); }
.hl-err-row { background: rgba(215,0,21,.09); display: inline-block; width: 100%; }
#errorBar { flex: none; max-height: 110px; overflow-y: auto; border-top: 1px solid var(--line); background: var(--panel); font-size: 12px; }
.err-line { padding: 4px 10px; color: var(--danger); border-bottom: 1px solid var(--line); cursor: pointer; }
.err-line:hover { background: var(--hover); }
#stageWrap { flex: 1; position: relative; min-width: 0; }
#stage { position: absolute; inset: 0; background: var(--canvas); overflow: auto; }
#stage svg { display: block; cursor: default; }
#stage svg .seq-participant:hover rect { stroke: var(--accent); }
#stage svg .seq-message:hover line, #stage svg .seq-message:hover path { stroke: var(--accent) !important; }
/* SVG-<text> reagiert sonst nur auf tatsächlich gefärbte Pixel (pointer-events: visiblePainted) – bei
 * kurzen Wörtern/dünner Schrift verfehlt ein Doppelklick/Tap knapp daneben dann die Beschriftung. Die
 * ganze (unsichtbare) Zeichenbox soll treffbar sein, wichtig besonders für Finger auf 390px. */
#stage svg .seq-edit-label { pointer-events: all; cursor: text; }
#drawHint { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); color: var(--muted); font-size: 12.5px; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 18px; box-shadow: var(--shadow); }
#drawHint .empty-hint-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
#drawHint ol { margin: 0; padding-left: 18px; }
#drawHint li { margin: 2px 0; }
#drawHint li b { color: var(--text); }
.inline-edit { position: absolute; z-index: 20; font: 12.5px/1.3 var(--font); padding: 3px 6px; min-width: 60px; }
.seq-popover { position: fixed; z-index: 30; width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.seq-popover label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 11.5px; }
.seq-popover select, .seq-popover input { color: var(--text); font-size: 12.5px; }
/* ───────── Inspektor (rechtes Blatt): Desktop als feste Spalte, Mobil als Bodenblatt ───────── */
#inspector { width: 0; min-width: 0; overflow: hidden; border-left: 1px solid var(--line); background: var(--canvas); flex: none; transition: width .15s; }
#inspector.insp-open { width: 260px; overflow-y: auto; padding: 12px; }
#inspectorBackdrop { display: none; }
.insp-field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; font-size: 12px; }
.insp-field > label { color: var(--muted); font-size: 11px; }
.insp-field textarea { min-height: 54px; resize: vertical; }
.insp-field .row { gap: 4px; }
.insp-field-key { width: 76px; flex: none; font-size: 11px; }
.insp-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin: 12px 0 6px; }
.insp-checks { display: flex; flex-direction: column; gap: 4px; max-height: 140px; overflow-y: auto; }
.insp-checks label { gap: 6px; font-size: 12.5px; }
.insp-close { position: absolute; top: 8px; right: 8px; }
#inspector h3 { margin: 4px 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(215, 0, 21, .1); }
.insp-delete { margin-top: 8px; width: 100%; justify-content: flex-start; }
@media (max-width: 760px) {
  #inspector { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto !important; max-height: 70vh; height: 0;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: var(--shadow); z-index: 21;
    transition: height .18s; }
  #inspector.insp-open { height: auto; max-height: 70vh; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
  #inspectorBackdrop { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20; display: none; }
  #main.has-inspector #inspectorBackdrop { display: block; }
}
.seq-selected { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
line.seq-selected, path.seq-selected { outline: none; filter: drop-shadow(0 0 0 2px var(--accent)); stroke-width: 2.4; }
.seq-ctxmenu { position: fixed; z-index: 40; min-width: 150px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; }
.seq-ctxmenu button { text-align: left; background: transparent; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--text); }
.seq-ctxmenu button:hover:not(:disabled) { background: var(--hover); }
.seq-ctxmenu button:disabled { color: var(--muted); cursor: default; }

.zoombar { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: row; align-items: center; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: var(--shadow); z-index: 4; }
.zoombar #zoomLabel { width: 42px; text-align: center; font-size: 11px; }
.zoombar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
#stage { position: absolute; inset: 0; overflow: auto; }
#svgScaleWrap { position: relative; }

/* Zeichnung ist die Standardansicht (siehe README): der Text-Editor ist ein optionales Seitenblatt,
 * das über #mobileSwitch ein-/ausgeblendet wird – Zustand gemerkt in localStorage. Früher galt diese
 * Umschaltung nur auf schmalen Bildschirmen (<=760px), auf dem Desktop stand links dauerhaft ein
 * Texteingabe-Fenster – genau das wirkte „unbenutzbar“ (Nutzer-Rückmeldung). Jetzt gilt sie überall. */
#main.show-text #stageWrap, #main.show-draw #editorPane { display: none; }
@media (min-width: 761px) {
  #main.show-draw #editorPane { display: none; }
  #main.show-draw #stageWrap { width: 100% !important; max-width: none; }
}
@media (max-width: 760px) {
  #editorPane, #stageWrap { width: 100% !important; max-width: none; }
  .docname { width: 70px; }
  .status { display: none; }
  .tb { flex-wrap: nowrap; }
  .tb .grp .btn.icon { width: 26px; height: 26px; min-width: 26px; }
}
/* Eng wie auf dem Handy (390–760px): seltene Knöpfe wandern ins „Weitere Aktionen"-Menü statt abgeschnitten
 * zu werden – kein Knopf geht verloren, nur Undo/Redo/Fragment/Hilfe/Kopieren/Export/Teilen stehen nicht
 * mehr dauerhaft in der Leiste. Trefferfläche je Menüzeile ≥ 40px für Finger. */
@media (max-width: 760px) {
  #moreBtn { display: inline-flex; width: 30px; height: 30px; min-width: 30px; }
  .tb { gap: 6px; padding: 0 6px; }
  .seg button { padding: 3px 6px; }
  .more-menu { display: none; position: fixed; flex-direction: column; align-items: stretch; gap: 1px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
    padding: 4px; z-index: 40; min-width: 200px; max-width: calc(100vw - 16px); }
  .more-menu.open { display: flex; }
  .more-menu .btn { justify-content: flex-start; width: 100%; height: 40px; padding: 0 10px; gap: 0; font-size: 13px; }
  .more-menu .btn.icon { width: 100%; height: 40px; min-height: 40px; }
  .more-menu .lbl { display: inline; font-size: 13px; }
  .more-menu .btn svg { display: none; }   /* Menü wie macOS: nur Text, bündig */
  .more-menu-sep { height: 1px; background: var(--line); margin: 4px 2px; flex: none; }
}
@media (max-width: 420px) {
  .docname { width: 44px; }
  #addParticipantBtn .add-lbl { display: none; }
  #addParticipantBtn { width: 30px; min-width: 30px; padding: 0; justify-content: center; }
}

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(10px); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); color: var(--danger); }
.gallery-subject { font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin: 10px 0 4px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.gallery-card { text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--ctrl); cursor: pointer; font-size: 12.5px; }
.gallery-card:hover { border-color: var(--accent); background: var(--hover); }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 16px; width: min(480px, 90vw); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.3); }
dialog#cmdDialog { width: min(460px, 92vw); padding: 10px; }
dialog#helpDialog { width: min(680px, 94vw); max-height: 84vh; overflow-y: auto; }
dialog#helpDialog pre { background: var(--ctrl); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 11.5px; overflow-x: auto; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.help-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--canvas); }
.help-card h4 { margin: 0 0 6px; font-size: 13px; }
.help-card .help-svg { width: 100%; overflow: hidden; border-radius: 6px; background: var(--canvas); margin-bottom: 8px; }
.help-card .help-svg svg { width: 100%; height: auto; display: block; }
.help-card p { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.cmd-item, .doc-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.cmd-item:hover, .cmd-item.on, .doc-item:hover { background: var(--hover); }
.doc-item .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .muted { font-size: 11px; white-space: nowrap; }
