:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #667085; --line: #d9dde5;
  --accent: #c2410c; --accent-text: #fff; --hl: #dcebfc; --sel: #fde4d3; --focus: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171d; --panel: #1c2028; --text: #e6e8ee; --muted: #9aa3b2; --line: #333a46;
    --accent: #ea7a45; --accent-text: #1a1206; --hl: #1f3550; --sel: #4a2c1a; --focus: #7aa7ff; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: relative; flex-wrap: wrap; }
h1 { font-size: 20px; margin: 0; flex: 1 1 auto; }
.hdr-right { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.hdr-right label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=number], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .row:focus-visible, .node-label:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px; }
.w60 { width: 64px; text-align: right; } .w210 { width: 210px; } #search { width: 240px; }
button, .btn { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }

#searchResults { position: absolute; right: 16px; top: 100%; z-index: 20; margin: 0; padding: 4px; list-style: none;
  width: 560px; max-width: calc(100vw - 32px); max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #0003; }
#searchResults li { padding: 6px 10px; cursor: pointer; border-radius: 4px; }
#searchResults li:hover, #searchResults li.active { background: var(--sel); }
#searchResults small { color: var(--muted); display: block; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--w1, 300px) 6px var(--w2, 280px) 6px minmax(0, 1fr); }
.splitter { cursor: col-resize; background: var(--line); opacity: .5; touch-action: none; }
.splitter:hover, .splitter.drag { background: var(--accent); opacity: 1; }
.col { min-width: 0; overflow: hidden; background: var(--panel); display: flex; flex-direction: column; }
.col-head { display: flex; align-items: center; gap: 4px; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.col-head .spacer { flex: 1; }
.col-search { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.col-search input { width: 100%; }
button.mini { padding: 0 7px; line-height: 22px; }
#right { min-width: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--panel); }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; }
.tabs button.active { border-bottom-color: var(--accent); font-weight: 600; }
.pane { flex: 1; overflow: auto; min-height: 0; }
.pane[hidden] { display: none; }

/* Baum */
ul.tree, ul.tree ul { list-style: none; margin: 0; padding-left: 16px; }
ul.tree { padding: 6px 4px; }
.node-label { display: flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.node-label:hover { background: var(--bg); }
.node-label.sel { background: var(--sel); }
.node-label.cfg { background: var(--hl); }
.node-label.cfg.sel { background: var(--sel); }
.twisty { width: 14px; text-align: center; color: var(--muted); flex: none; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; background: var(--bg); text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); font-weight: 600; z-index: 1; }
td { padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--bg); }
tr.row.cfg td { background: var(--hl); }
tr.row.sel td { background: var(--sel); }
td.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }
.empty { padding: 24px; color: var(--muted); }
.badge { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.badge.on { background: #16a34a22; border-color: #16a34a; } .badge.off { background: #dc262622; border-color: #dc2626; }
.badge.mine { background: var(--sel); border-color: var(--accent); }

details.grp > summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 7px 10px; cursor: pointer; background: var(--bg); border-bottom: 1px solid var(--line); font-weight: 600; position: sticky; top: 0; z-index: 1; }
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary::before { content: "▸"; color: var(--muted); width: 12px; }
details.grp[open] > summary::before { content: "▾"; }
details.grp > summary .badge { margin-left: auto; font-weight: 400; }
details.grp .none { padding: 8px 14px; color: var(--muted); }
#filesPane .row-file { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#filesPane .row-file:hover { background: var(--bg); }
#filesPane .row-file.sel { background: var(--sel); }
#filesPane .row-file.dragging { opacity: .4; }
#filesPane .row-file .txt { flex: 1; min-width: 0; }
#filesPane .row-file b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#filesPane .row-file small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#filesPane .row-file .acts { display: flex; gap: 2px; opacity: 0; }
#filesPane .row-file:hover .acts, #filesPane .row-file:focus-within .acts { opacity: 1; }
@media (hover: none) { #filesPane .row-file .acts { opacity: 1; } }
.iconbtn { border: 0; background: none; padding: 2px 5px; border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1.2; text-decoration: none; }
.iconbtn:hover { background: var(--line); color: var(--text); }
details.grp.drop > summary { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--sel); }
.hint-bar { padding: 5px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
#jsonView { margin: 0; padding: 12px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

footer { display: flex; gap: 8px; align-items: center; padding: 6px 12px; background: var(--panel); border-top: 1px solid var(--line); }
footer .spacer { flex: 1; }
#docInfo { color: var(--muted); }
#status { min-width: 140px; }

/* Dialoge */
.backdrop { position: fixed; inset: 0; background: #0006; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.dialog { background: var(--panel); border-radius: 10px; width: 780px; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 20px 60px #0006; }
.dialog.small { width: 560px; }
.dlg-head { padding: 14px 18px 8px; font-weight: 700; font-size: 16px; }
.dlg-body { padding: 4px 18px 12px; overflow: auto; flex: 1; }
.dlg-foot { padding: 10px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.dlg-top { display: grid; grid-template-columns: 180px 1fr; gap: 12px; margin-bottom: 12px; }
.dlg-top fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.dlg-top textarea { width: 100%; height: 72px; resize: vertical; }
.dlg-mid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .dlg-top, .dlg-mid { grid-template-columns: 1fr; } main { display: flex; flex-direction: column; overflow: auto; } .splitter { display: none; } .col { max-height: 34vh; flex: none; } #right { min-height: 60vh; } }
.box { border: 1px solid var(--line); border-radius: 6px; padding: 10px; min-height: 140px; max-height: 340px; overflow: auto; }
.box.help { white-space: pre-wrap; font-size: 13px; }
.box.disabled { opacity: .5; pointer-events: none; }
.opt { margin-bottom: 12px; display: flex; flex-direction: column; gap: 3px; }
.opt input[type=text], .opt input[type=number], .opt select, .opt textarea { width: 100%; }
.opt .hint { color: var(--muted); font-size: 12px; }
.lbl { font-weight: 600; font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.grid-edit input { width: 100%; }
.err { color: #dc2626; padding: 6px 0; }
a { color: var(--focus); }
