/* Koordinaten-Werkzeug – gleicher Stil wie der ER-Designer (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;
  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; }
.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.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); }
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); }
textarea { width: 100%; resize: vertical; line-height: 1.4; }
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
label.field input, label.field select { color: var(--text); font-size: 13px; width: 100%; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; }
input[type=checkbox] { min-height: 0; accent-color: var(--accent); margin: 0; }

.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; }
#lineType { flex: none; max-width: 110px; }
.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; }
#stage { flex: 1; position: relative; background: var(--canvas); overflow: hidden; touch-action: none; }
#cv { position: absolute; inset: 0; display: block; cursor: crosshair; }
#stage.mode-select #cv { cursor: default; }
#commentLayer { position: absolute; inset: 0; pointer-events: none; }
.commentInput { position: absolute; pointer-events: auto; min-width: 140px; max-width: 240px; font-size: 12px; padding: 4px 6px; }

#inspector { width: 300px; flex: none; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; padding: 12px; box-sizing: border-box; }
#inspector > div { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
#inspector > div:last-child { border-bottom: 0; }
#inspector h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin: 0 0 8px; }
.fieldrow { display: flex; gap: 8px; margin-bottom: 8px; min-width: 0; }
.fieldrow > label.field { flex: 1; min-width: 0; }
.series-item, .line-item { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.zoombar { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: var(--shadow); }

#inspectorToggle { display: none; }
#moreBtn { display: none; }
.more-menu { display: contents; }
.more-menu .lbl { display: none; }   /* Desktop: nur Symbol, Text erst im „…“-Menü */
@media (max-width: 560px) {
  #inspectorToggle { display: inline-flex; }
  #inspector { position: absolute; right: 0; top: 0; bottom: 0; width: 86vw; max-width: 320px; box-shadow: var(--shadow); z-index: 5; background: var(--panel); }
  #inspector[hidden] { display: none; }
  .tb { gap: 3px; padding: 0 4px; }
  .tb .grp { gap: 1px; }
  .docname { width: 58px; }
  .status { display: none; }
  #lineType { max-width: 84px; font-size: 12px; }
  .tb .btn.icon { width: 24px; height: 24px; min-width: 24px; }
  .tb .btn.icon svg.ic { width: 14px; height: 14px; }
  #accountBtn { font-size: 11px; padding: 0 6px; max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* seltenere Knöpfe (Bild kopieren/Teilen/Hilfe) wandern ins „Weitere Aktionen“-Menü statt
   * abgeschnitten zu werden – Rückgängig/Wiederholen und der Werkzeugwahl bleiben in der Leiste. */
  #moreBtn { display: inline-flex; width: 24px; height: 24px; min-width: 24px; }
  .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: 170px; max-width: calc(100vw - 16px); }
  .more-menu.open { display: flex; }
  .more-menu .btn { justify-content: flex-start; width: 100%; height: 38px; padding: 0 10px; gap: 0; font-size: 13px; }
  .more-menu .btn.icon { width: 100%; height: 38px; min-height: 38px; }
  .more-menu .lbl { display: inline; font-size: 13px; }
  .more-menu .btn svg { display: none; }
}
@media (max-width: 420px) {
  .docname { width: 40px; }
}

.empty-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); font-size: 13px;
  pointer-events: none; text-align: center; white-space: nowrap; }
.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#pasteDialog textarea { height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
dialog#cmdDialog { width: min(460px, 92vw); padding: 10px; }
.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; }
