/* ER-Designer – zurückhaltend im macOS-Stil, 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; --grid: rgba(0, 0, 0, .13); --code: #f5f5f7;
  --kw: #ad3da4; --str: #c41a16; --cm: #707f8c;
  --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, "SF Mono", 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; --grid: rgba(255, 255, 255, .1); --code: #1c1c1e;
    --kw: #ff7ab2; --str: #ff8170; --cm: #7f8c98;
    --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; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.ic { flex: none; display: block; }

/* ── Bedienelemente ── */
.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); }
.btn.danger { color: var(--danger); }
.btn.mini { height: 24px; min-width: 24px; font-size: 12px; padding: 0 7px; }
.btn.icon.mini { width: 24px; padding: 0; }
.btn:focus-visible, .seg button:focus-visible, .linkish:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }
.seg { display: inline-flex; background: var(--seg); border-radius: 8px; padding: 2px; gap: 2px; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 3px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; line-height: 20px; }
.seg button:hover:not(.on) { background: var(--hover); }
.seg button.on { background: var(--seg-on); box-shadow: var(--shadow); }
.seg.small button { padding: 1px 8px; font-size: 12px; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
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; }
textarea { resize: vertical; width: 100%; line-height: 1.4; padding: 5px 7px; }
select { padding-right: 4px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { min-height: 0; accent-color: var(--accent); margin: 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; }
.chk.dis { opacity: .45; cursor: default; }
kbd { font: 11px var(--font); background: var(--ctrl); border: 1px solid var(--ctrl-b); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.linkish { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.linkish:hover { color: var(--accent); }

/* ── Werkzeugleiste ── */
.tb { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; height: 52px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.tbl, .tbr { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tbr { justify-content: flex-end; }
.grp { display: flex; align-items: center; gap: 2px; }
.grp + .grp, .tbr > .btn { margin-left: 6px; }
.docinfo { display: flex; flex-direction: column; min-width: 0; }
.docname { border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 13.5px; padding: 1px 5px; min-height: 22px; width: 260px; max-width: 100%; border-radius: 5px; }
.docname:hover { border-color: var(--line); }
.docname:focus { background: var(--ctrl); }
.docsub { display: flex; gap: 10px; align-items: center; padding-left: 6px; font-size: 11px; color: var(--muted); min-width: 0; white-space: nowrap; }
.status { overflow: hidden; text-overflow: ellipsis; }
.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, .status.warn::before { background: var(--warn); }
.status.err::before { background: var(--danger); }
.status.busy::before { background: var(--accent); }
.status:empty::before { display: none; }
.account { display: inline-flex; align-items: center; gap: 4px; }
.notsel { display: none; }
.exp span { font-weight: 500; }

/* ── Arbeitsfläche ── */
.main { flex: 1; display: flex; min-height: 0; position: relative; }
.stage { flex: 1; position: relative; overflow: hidden; background-color: var(--canvas);
  background-image: radial-gradient(circle, var(--grid) 1px, transparent 1.3px); }
.stage.drop { box-shadow: inset 0 0 0 3px var(--accent); }
.canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
#overlay { pointer-events: none; }
.inline-edit { position: absolute; z-index: 6; box-sizing: border-box; min-height: 0; padding: 0 5px; border: 1.5px solid var(--accent); border-radius: 5px;
  background: var(--canvas); color: var(--text); font-family: var(--font); outline: 3px solid var(--accent-soft); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.canvas .rlabel { cursor: pointer; }
.canvas .areahit, .canvas .area text { cursor: move; }
.canvas .note { cursor: move; }
.inline-edit.multi { padding: 8px 10px; line-height: 17px; resize: none; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ctrl-b); cursor: pointer; padding: 0; background: var(--ctrl); }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.sw.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--ctrl); }
.agrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.abtn { justify-content: flex-start; background: var(--hover); }
.canvas rect.sym { cursor: pointer; }
.tip { position: absolute; z-index: 7; width: 432px; max-width: calc(100% - 16px); padding: 12px 12px 10px; border-radius: 12px; pointer-events: none;
  background: var(--panel); box-shadow: 0 12px 36px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .12); font-size: 12.5px; }
.tip .thead { margin-bottom: 6px; }
.tip p { margin: 0 0 4px; line-height: 1.4; }
.tip .tsent { color: var(--muted); }
.tip .tsent.main { color: var(--text); font-weight: 600; }
.tip .tmean { margin: 6px 0 10px; padding: 7px 9px; border-radius: 8px; background: var(--accent-soft); }
.tip .tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tip .tcard { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 2px; background: var(--canvas); }
.tip .tcard.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tip .tlabel { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tip svg { display: block; width: 100%; height: auto; }
.canvas rect.sym:hover { fill: var(--accent-soft); }
.canvas .ent { cursor: default; }
.canvas .rel { cursor: pointer; }
.canvas .handle { cursor: crosshair; }
.canvas.connecting, .canvas.connecting .ent { cursor: crosshair; }
.canvas.grab, .canvas.grab * { cursor: grab !important; }
.canvas.panning, .canvas.panning * { cursor: grabbing !important; }
.zoom { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px;
  background: var(--panel); box-shadow: var(--shadow); }
.zv { border: 0; background: none; font-size: 12px; min-width: 50px; font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 6px; height: 24px; }
.zv:hover { background: var(--hover); }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 24px; }
.empty > * { pointer-events: auto; }
.empty .etitle { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.empty .muted { max-width: 340px; margin: 0 0 14px; }

/* ── Suche (⌘K) ── */
.palback { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .18); display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh; }
.pal { width: min(620px, calc(100vw - 24px)); background: var(--panel); border-radius: 14px; box-shadow: 0 24px 70px rgba(0, 0, 0, .3), 0 0 0 .5px rgba(0, 0, 0, .15); overflow: hidden; animation: dlgIn .14s ease-out; }
.palin { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palin input { flex: 1; border: 0; background: none; font-size: 18px; outline: none; min-height: 30px; padding: 0; color: var(--text); }
.pallist { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palit { display: grid; grid-template-columns: 18px minmax(0, auto) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.palit.on { background: var(--accent); color: #fff; }
.palit .pt { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palit .ps { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palit .pk { font-size: 11px; color: var(--muted); }
.palit.on .ps, .palit.on .pk { color: rgba(255, 255, 255, .8); }
.palnone { padding: 14px; color: var(--muted); }
.palfoot { display: flex; justify-content: space-between; gap: 10px; padding: 7px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.minimap { position: absolute; right: 12px; bottom: 12px; border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); cursor: crosshair; }

/* ── Code neben dem Diagramm ── */
.codep { width: 36%; min-width: 300px; max-width: 620px; flex: none; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.codep[hidden] { display: none; }
.codep .chead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.codep .cstatus { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.codep .cstatus.ok::before { content: "● "; color: var(--ok); }
.codep .cstatus.err { color: var(--danger); white-space: normal; }
.codep .cnote { margin: 0; padding: 6px 12px; font-size: 11.5px; color: var(--muted); background: rgba(255, 159, 10, .1); border-bottom: 1px solid var(--line); }
.codep textarea { flex: 1; border: 0; border-radius: 0; resize: none; padding: 12px 14px; font: 12px/1.55 var(--mono); background: var(--canvas); outline: none; tab-size: 2; white-space: pre; min-height: 0; }

/* ── Inspektor ── */
.insp { width: 330px; flex: none; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
body.insp-closed .insp { display: none; }
.grab-handle { display: none; }
.ibody { overflow-y: auto; flex: 1; padding-bottom: 32px; overscroll-behavior: contain; }
.ihead { padding: 14px 16px 10px; }
.ikind { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.ititle { font-size: 17px; font-weight: 600; }
.iname { width: 100%; font-size: 17px; font-weight: 600; border-color: transparent; background: transparent; padding: 2px 6px; margin-left: -7px; min-height: 30px; }
.iname:hover { border-color: var(--line); }
.iname:focus { background: var(--ctrl); }
.isec { padding: 12px 16px; border-top: 1px solid var(--line); }
.isec h3 { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 9px; }
.isec p { margin: 0 0 8px; }
.hint { font-size: 11.5px; color: var(--muted); }
.field { display: grid; gap: 4px; margin-bottom: 11px; }
.field:last-child { margin-bottom: 0; }
.flabel { font-size: 12px; color: var(--muted); }
.fhint { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.field > select, .field > input { width: 100%; }
.field > .seg { justify-self: start; }

.attrs { display: flex; flex-direction: column; gap: 5px; }
.aline { display: flex; align-items: center; gap: 5px; }
.sym { flex: none; width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--ctrl-b); background: var(--ctrl); font: 600 14px var(--mono); cursor: pointer; padding: 0; }
.sym:hover { border-color: var(--accent); }
.sym.s-pk { color: var(--accent); }
.sym.s-opt { color: var(--muted); }
.aname { flex: 1; width: 0; min-width: 72px; }
.typewrap { display: flex; gap: 3px; flex: none; }
select.type { width: 102px; }
input.len { width: 46px; padding: 3px 4px; }
input.len.dec { width: 52px; }
.adetail { margin: 6px 0 8px 31px; padding: 10px; border-radius: 8px; background: var(--hover); display: flex; flex-direction: column; gap: 8px; }
.adetail .field { margin: 0; }
.adetail .field > input { width: 100%; }
.addattr { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 5px 2px; font-weight: 500; }
.addattr:hover { text-decoration: underline; }

.endcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 10px; background: var(--canvas); }
.endhead { margin-bottom: 8px; }
.endsel { width: 100%; font-weight: 600; }
.endgrid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; margin-top: 6px; }
.endgrid .flabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.endcard .field { margin-bottom: 0; }
.sentence { font-size: 12px; color: var(--muted); margin: 8px 0 0 !important; line-height: 1.35; }
.swaprow { display: flex; justify-content: center; margin-top: 6px; margin-bottom: -4px; }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.legend li { display: flex; align-items: center; gap: 10px; min-height: 24px; font-size: 12.5px; }
.legend svg { flex: none; }
.lkey { flex: none; min-width: 44px; text-align: center; font: 600 11.5px var(--mono); white-space: nowrap; }
.warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.warns li { padding-left: 14px; position: relative; font-size: 12.5px; line-height: 1.35; }
.warns li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.warns li.info::before { background: var(--muted); }
.rellist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.keys summary { cursor: pointer; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; margin: 10px 0 0; font-size: 12px; }
.keys dd { margin: 0; color: var(--muted); }

/* ── Dialoge ── */
dialog.dlg { border: 0; padding: 0; border-radius: 12px; width: min(880px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  background: var(--panel); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .12); overflow: hidden; }
dialog.dlg.narrow { width: min(460px, calc(100vw - 32px)); }
dialog.dlg.files { width: min(620px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .28); }
.dlg[open] { display: flex; flex-direction: column; animation: dlgIn .16s ease-out; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(6px) scale(.99); } }
.dhead { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.dhead h2 { font-size: 14px; font-weight: 600; margin: 0; }
.dbody { padding: 16px 18px 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.dbody p { margin: 0; }
.tabs { align-self: flex-start; }
.xcontent { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
pre.code { margin: 0; padding: 12px 14px; background: var(--code); border: 1px solid var(--line); border-radius: 8px; font: 12px/1.55 var(--mono);
  overflow: auto; max-height: min(56vh, 560px); white-space: pre; tab-size: 4; }
pre.code .kw { color: var(--kw); font-weight: 600; }
pre.code .str { color: var(--str); }
pre.code .cm { color: var(--cm); font-style: italic; }
.sqlin { font: 12px/1.5 var(--mono); min-height: 240px; white-space: pre; tab-size: 4; }
.sqlinfo p { margin: 0 0 4px; }
.sqlinfo .err { color: var(--danger); }
.xwarnlist { margin: 4px 0 0; padding: 6px 12px 6px 26px; border-radius: 8px; background: rgba(255, 159, 10, .12); font-size: 12.5px; }
.xwarn ul { margin: 0; padding: 8px 12px 8px 28px; border-radius: 8px; background: rgba(255, 159, 10, .12); font-size: 12.5px; }
.relschema { list-style: none; margin: 0; padding: 12px 14px; background: var(--code); border: 1px solid var(--line); border-radius: 8px; font: 12.5px/1.8 var(--mono); overflow: auto; max-height: 56vh; }
.relschema .fk { color: var(--accent); }
.sharebar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px);
  padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--panel); box-shadow: 0 6px 24px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .12); font-size: 12.5px; }
.sharebar > span:not(.grow) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sharebody { display: flex; flex-direction: column; gap: 14px; }
.shrow { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.shhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.shhead p { margin: 2px 0 0; font-size: 12px; }
.shurl { flex: 1; font: 12px var(--mono); }
.shprev { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
input.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--seg); border: 0; position: relative; cursor: pointer; flex: none; transition: background .15s; min-height: 0; }
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
input.switch:checked { background: var(--ok); }
input.switch:checked::after { transform: translateX(16px); }
@media (max-width: 760px) { .sharebar { top: auto; bottom: 64px; font-size: 12px; } .sharebar > span:not(.grow) { white-space: normal; } }
dialog.dlg.play { width: min(1240px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 48px)); }
.play .dbody { flex: 1; }
.pgrid { flex: 1; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; min-height: 0; }
.pgrid aside { overflow: auto; border-right: 1px solid var(--line); padding-right: 10px; }
.pgrid aside h3 { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 2px 0 8px; }
.ptables { list-style: none; margin: 0; padding: 0; }
.ptables button { display: flex; justify-content: space-between; width: 100%; padding: 4px 6px; border-radius: 6px; font: 12.5px var(--mono); }
.ptables button:hover { background: var(--hover); }
.pmain { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.pquery { font: 12.5px/1.55 var(--mono); min-height: 120px; height: 150px; resize: vertical; white-space: pre; tab-size: 2; }
.pres { flex: 1; overflow: auto; min-height: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--canvas); }
.pres table { border-collapse: collapse; font: 12px var(--mono); }
.pres th, .pres td { padding: 3px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.pres th { position: sticky; top: -8px; background: var(--panel); font-weight: 600; }
.pres td.null { color: var(--muted); font-style: italic; }
.pres .pok { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.pres .perr { margin: 0; color: var(--danger); font: 12.5px var(--mono); white-space: pre-wrap; }
.ptable + .ptable { margin-top: 12px; }
.pstatus { font-size: 12px; }
@media (max-width: 760px) { .pgrid { grid-template-columns: 1fr; } .pgrid aside { border-right: 0; max-height: 120px; } }
.cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.cursor { position: absolute; left: 0; top: 0; transition: transform .08s linear; }
.cursor svg { display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.cursor span { position: absolute; left: 14px; top: 16px; background: var(--c); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.peers { display: inline-flex; }
.peers:empty { display: none; }
.peer { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 8.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1.5px var(--panel); letter-spacing: -.02em; }
.peer + .peer { margin-left: -4px; }
.peer.me { opacity: .75; }
.sharebar.live { border: 1px solid rgba(52, 199, 89, .5); }
.vwrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; min-height: 0; }
.vlist { list-style: none; margin: 0; padding: 0; max-height: 56vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.vitem { display: flex; flex-direction: column; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.vitem:hover { background: var(--hover); }
.vitem.on { background: var(--accent); color: #fff; }
.vitem .vs { font-size: 11.5px; color: var(--muted); }
.vitem.on .vs { color: rgba(255, 255, 255, .8); }
.vprev { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.vprev .err { color: var(--danger); }
@media (max-width: 760px) { .sharebar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px);
  padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--panel); box-shadow: 0 6px 24px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .12); font-size: 12.5px; }
.sharebar > span:not(.grow) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sharebody { display: flex; flex-direction: column; gap: 14px; }
.shrow { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.shhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.shhead p { margin: 2px 0 0; font-size: 12px; }
.shurl { flex: 1; font: 12px var(--mono); }
.shprev { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
input.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--seg); border: 0; position: relative; cursor: pointer; flex: none; transition: background .15s; min-height: 0; }
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
input.switch:checked { background: var(--ok); }
input.switch:checked::after { transform: translateX(16px); }
@media (max-width: 760px) { .sharebar { top: auto; bottom: 64px; font-size: 12px; } .sharebar > span:not(.grow) { white-space: normal; } }
dialog.dlg.play { width: min(1240px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 48px)); }
.play .dbody { flex: 1; }
.pgrid { flex: 1; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; min-height: 0; }
.pgrid aside { overflow: auto; border-right: 1px solid var(--line); padding-right: 10px; }
.pgrid aside h3 { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 2px 0 8px; }
.ptables { list-style: none; margin: 0; padding: 0; }
.ptables button { display: flex; justify-content: space-between; width: 100%; padding: 4px 6px; border-radius: 6px; font: 12.5px var(--mono); }
.ptables button:hover { background: var(--hover); }
.pmain { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.pquery { font: 12.5px/1.55 var(--mono); min-height: 120px; height: 150px; resize: vertical; white-space: pre; tab-size: 2; }
.pres { flex: 1; overflow: auto; min-height: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--canvas); }
.pres table { border-collapse: collapse; font: 12px var(--mono); }
.pres th, .pres td { padding: 3px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.pres th { position: sticky; top: -8px; background: var(--panel); font-weight: 600; }
.pres td.null { color: var(--muted); font-style: italic; }
.pres .pok { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.pres .perr { margin: 0; color: var(--danger); font: 12.5px var(--mono); white-space: pre-wrap; }
.ptable + .ptable { margin-top: 12px; }
.pstatus { font-size: 12px; }
@media (max-width: 760px) { .pgrid { grid-template-columns: 1fr; } .pgrid aside { border-right: 0; max-height: 120px; } }
.cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.cursor { position: absolute; left: 0; top: 0; transition: transform .08s linear; }
.cursor svg { display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.cursor span { position: absolute; left: 14px; top: 16px; background: var(--c); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.peers { display: inline-flex; }
.peers:empty { display: none; }
.peer { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 8.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1.5px var(--panel); letter-spacing: -.02em; }
.peer + .peer { margin-left: -4px; }
.peer.me { opacity: .75; }
.sharebar.live { border: 1px solid rgba(52, 199, 89, .5); }
.vwrap { grid-template-columns: 1fr; } .vlist { max-height: 30vh; } }
.vsep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.imgprev { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 58vh; background: #fff; display: flex; justify-content: center; }
.imgprev img { max-width: 100%; height: auto; display: block; }
.fsec h3 { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 6px 0 6px; }
.flist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--canvas); }
.fitem { display: flex; align-items: center; gap: 6px; padding-right: 8px; }
.fitem + .fitem { border-top: 1px solid var(--line); }
.fitem.cur { background: var(--accent-soft); }
.fopen { flex: 1; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 12px; text-align: left; cursor: pointer; min-width: 0; }
.fopen:hover .fname { color: var(--accent); }
.fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fdate { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.factions { display: flex; gap: 2px; flex: none; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 8px); max-width: min(560px, calc(100vw - 32px));
  background: rgba(40, 40, 42, .94); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 50; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(180, 20, 20, .95); }

/* ── schmalere Fenster ── */
/* „…“-Menü */
.morebtn { display: none; }
.menu { position: fixed; z-index: 55; min-width: 230px; padding: 5px; border-radius: 10px; background: var(--panel); box-shadow: 0 12px 36px rgba(0, 0, 0, .2), 0 0 0 .5px rgba(0, 0, 0, .15); display: flex; flex-direction: column; animation: dlgIn .12s ease-out; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.mitem { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.mitem span { flex: 1; }
.mitem:hover, .mitem:focus-visible { background: var(--accent); color: #fff; outline: none; }
.mitem:hover kbd, .mitem:focus-visible kbd { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .5); }
@media (max-width: 1240px) {
  .sec { display: none; }
  .morebtn { display: inline-flex; }
}
@media (max-width: 1520px) {
  .notseg { display: none; }
  .notsel { display: block; width: 190px; }
}
@media (max-width: 980px) {
  .exp span { display: none; }
  .exp { width: 30px; padding: 0; }
  .docname { width: 180px; }
}
@media (max-width: 760px) {
  .tb { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l r" "c c"; height: auto; padding: 6px 8px; row-gap: 6px; }
  .tbl { grid-area: l; } .tbr { grid-area: r; } .tbc { grid-area: c; }
  .notsel { width: 100%; }
  .hide-s { display: none; }
  .docname { width: 100%; }
  .grp + .grp, .tbr > .btn { margin-left: 2px; }
  .codep { position: fixed; inset: auto 0 0 0; top: 40%; width: auto; max-width: none; z-index: 21; border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); }
  .insp { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 56vh; height: 56dvh; border-left: 0; border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); z-index: 20; transition: transform .22s ease; }
  body.insp-closed .insp { display: flex; transform: translateY(105%); }
  .grab-handle { display: block; height: 18px; flex: none; cursor: pointer; }
  .grab-handle::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--ctrl-b); margin: 7px auto 0; }
  .zoom { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  input, select, textarea { font-size: 16px; }     /* iOS zoomt sonst beim Tippen */
  .docname { font-size: 15px; }
  dialog.dlg { width: calc(100vw - 16px); max-height: calc(100dvh - 24px); }
  .fitem { flex-wrap: wrap; padding: 0 8px 8px 0; }
  .fitem .factions { padding-left: 36px; }
}
