:root {
  --bg: #ffffff;
  --panel: #f3f3f3;
  --border: #e0e0e0;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --hover: #e5f3ff;
  --selected: #cce8ff;
  --accent: #0067c0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1c;
    --panel: #252525;
    --border: #3a3a3a;
    --text: #e8e8e8;
    --muted: #9a9a9a;
    --hover: #2d3a46;
    --selected: #0f4a7a;
    --accent: #4cc2ff;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--text); }

.toolbar { display: flex; gap: 6px; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--border); align-items: center; }
.toolbar button { width: 30px; height: 28px; border: 1px solid transparent; background: transparent; color: var(--text); border-radius: 4px; cursor: pointer; font-size: 15px; }
.toolbar button:hover:not(:disabled) { background: var(--hover); }
.toolbar button:disabled { color: var(--muted); cursor: default; }
.address { flex: 1; display: flex; align-items: center; min-height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); overflow-x: auto; white-space: nowrap; }
.address a { color: var(--text); text-decoration: none; padding: 2px 4px; border-radius: 3px; cursor: pointer; }
.address a:hover { background: var(--hover); }
.address .sep { color: var(--muted); padding: 0 2px; }

.layout { flex: 1; display: flex; min-height: 0; }
.tree { width: 280px; min-width: 150px; overflow: auto; padding: 4px 0; background: var(--panel); }
.splitter { width: 4px; cursor: col-resize; background: var(--border); flex: none; }
.splitter:hover { background: var(--accent); }
.content { flex: 1; overflow: auto; position: relative; }

.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li > .node { display: flex; align-items: center; gap: 4px; padding: 3px 6px; cursor: pointer; white-space: nowrap; border-radius: 3px; margin: 0 4px; }
.tree .node:hover { background: var(--hover); }
.tree .node.selected { background: var(--selected); }
.tree .toggle { width: 14px; text-align: center; color: var(--muted); font-size: 10px; flex: none; }
.tree .icon { flex: none; }
.tree .node.unavailable { color: var(--muted); font-style: italic; }

.files { width: 100%; border-collapse: collapse; }
.files th { position: sticky; top: 0; background: var(--bg); text-align: left; font-weight: normal; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
.files th:hover { background: var(--hover); }
.files td { padding: 4px 10px; white-space: nowrap; }
.files tbody tr:hover { background: var(--hover); }
.files tbody tr.selected { background: var(--selected); }
.files .num { text-align: right; }
.files td.muted { color: var(--muted); }
.files .actions { text-align: right; }
.files .actions a, .files .actions button { color: var(--accent); background: none; border: none; cursor: pointer; font: inherit; padding: 0 4px; text-decoration: none; }
.files .actions a:hover, .files .actions button:hover { text-decoration: underline; }

.hint { padding: 24px; color: var(--muted); text-align: center; }
.hidden { display: none !important; }

.statusbar { padding: 4px 10px; border-top: 1px solid var(--border); background: var(--panel); color: var(--muted); min-height: 24px; }

.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 24px; }
.viewer-window { background: var(--bg); width: min(1100px, 100%); height: 100%; display: flex; flex-direction: column; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
.viewer-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.viewer-header span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { display: inline-block; padding: 4px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); text-decoration: none; cursor: pointer; font: inherit; }
.btn:hover { background: var(--hover); }
#viewerSource { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; white-space: pre; tab-size: 4; }
#viewerSource.error { color: #c42b1c; white-space: pre-wrap; }

/* ---------- Suche ---------- */
.searchbox { display: flex; align-items: center; gap: 2px; }
.searchbox input { width: 240px; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font: inherit; }
.searchbox input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.searchinfo { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 10px; background: var(--hover); border-bottom: 1px solid var(--border); }
.linkbtn { color: var(--accent); background: none; border: none; cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.files td.folder a { color: var(--muted); cursor: pointer; }
.files td.folder a:hover { color: var(--accent); text-decoration: underline; }
.files th.sorted::after { content: attr(data-dir); padding-left: 4px; }

.dialog { border: 1px solid var(--border); border-radius: 8px; padding: 0; background: var(--bg); color: var(--text); width: min(520px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog form { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; }
.dialog h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.dialog label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); flex: 1; }
.dialog label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.dialog input[type=text], .dialog input[type=date], .dialog select { height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font: inherit; }
.dialog input:disabled { opacity: .5; }
.dialog .row { display: flex; gap: 12px; }
.dialog fieldset { border: 1px solid var(--border); border-radius: 4px; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; }
.dialog legend { color: var(--muted); padding: 0 4px; }
.dialog-buttons { display: flex; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Textansicht ---------- */
.viewer-header { justify-content: flex-start; }
.viewer-header > .btn { flex: none; }
.tabs { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; flex: none; }
.tab { padding: 4px 14px; border: none; background: var(--bg); color: var(--text); cursor: pointer; font: inherit; }
.tab + .tab { border-left: 1px solid var(--border); }
.tab.active { background: var(--accent); color: #fff; }
#viewerSource { flex: 1; margin: 0; overflow: auto; }
#viewerSource code.hljs { background: transparent; padding: 12px; }
#viewerContent { display: block; padding: 12px; }

.markdown { flex: 1; overflow: auto; padding: 16px 32px; line-height: 1.6; font-size: 14px; }
.markdown h1, .markdown h2 { border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.markdown code { font-family: Consolas, "Cascadia Mono", monospace; background: var(--panel); padding: .1em .3em; border-radius: 3px; }
.markdown pre { background: var(--panel); padding: 12px; border-radius: 6px; overflow: auto; }
.markdown pre code { padding: 0; background: none; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 4px 10px; }
.markdown blockquote { margin: 0; padding: 0 1em; color: var(--muted); border-left: 4px solid var(--border); }
.markdown img { max-width: 100%; }
.markdown a { color: var(--accent); }
.dialog .help { color: var(--muted); font-size: 12px; }
.dialog .help code { font-family: Consolas, "Cascadia Mono", monospace; }
.dialog input[name=exclude] { font-family: Consolas, "Cascadia Mono", monospace; }
