/* Belmap 3 — exact dezelfde opbouw als Belmap 2.3, in een moderner thema */
:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-head: #f6f7f9;
  --sunken: #f1f3f6;
  --border: #dde2e9;
  --border-strong: #c5ccd6;
  --text: #1b1f24;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4fd7;
  --accent-soft: #e3ecff;
  --accent-text: #1d4ed8;
  --select: #dce7ff;
  --green: #15803d;
  --amber: #a16207;
  --amber-soft: #fff3c4;
  --amber-line: #e0b43a;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --folder: #f5b80b;
  --folder-line: #d99a00;
  --paper: #fffcf3;
  --paper-line: #efe3c2;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1c2026;
    --panel-head: #21262d;
    --sunken: #181b20;
    --border: #323842;
    --border-strong: #454d59;
    --text: #e7e9ec;
    --text-2: #b8bec7;
    --text-3: #8b929d;
    --accent: #4f8cff;
    --accent-hover: #6b9fff;
    --accent-soft: #1c2c4a;
    --accent-text: #93b7ff;
    --select: #213659;
    --green: #4ade80;
    --amber: #f0c050;
    --amber-soft: #3b3012;
    --amber-line: #8a6d1d;
    --red: #f87171;
    --red-soft: #3b1d1d;
    --paper: #201f1b;
    --paper-line: #3a3528;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, .paper:focus-visible { outline: none; }
h1, h2, h3, p { margin: 0; }
code, kbd { font: 12.5px var(--mono); background: var(--sunken); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.spacer { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); font-weight: 500; white-space: nowrap; box-shadow: var(--shadow);
  transition: background-color .1s, border-color .1s;
}
.btn:hover:not(:disabled) { background: var(--sunken); border-color: var(--text-3); }
.btn:active:not(:disabled) { background: var(--border); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.btn-small { height: 28px; padding: 0 9px; font-size: 13px; }
.btn-square { width: 32px; padding: 0; }
.btn-small.btn-square { width: 28px; }
.btn-primary, .btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled), .btn-accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary.done { background: var(--green); border-color: var(--green); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn-danger-outline { color: var(--red); }
.btn-danger-outline:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); font-size: 13.5px; text-decoration: underline; text-underline-offset: 2px; }
.folder-svg { fill: var(--folder); stroke: var(--folder-line); stroke-width: 1.3; }

/* Toolbar: two rows, like before */
.toolbar { flex: none; display: flex; flex-direction: column; gap: 5px; padding: 5px 8px; background: var(--panel-head); border-bottom: 1px solid var(--border); }
.toolbar-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.brand { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.toolbar .btn { height: 26px; padding: 0 7px; font-size: 12.5px; gap: 4px; border-radius: 5px; box-shadow: none; }
.toolbar .folder-svg { width: 13px; height: 13px; }
.toolbar .btn-square { width: 26px; padding: 0; }
.toolbar-row { gap: 4px; }

/* Layout */
main { --navigation-share: 32; --document-share: 68; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 8px 0; }
.navigation-panel { flex: var(--navigation-share) 1 0; min-height: 130px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.box { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.box-head { flex: none; display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 6px 4px 10px; background: var(--panel-head); border-bottom: 1px solid var(--border); }
.box-head h2 { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { font-size: 13px; color: var(--text-3); padding-right: 4px; }
.document-panel { flex: var(--document-share) 1 0; min-height: 0; }

/* Splitters: full-width bar with a grip */
.splitter { flex: none; height: 14px; position: relative; cursor: row-resize; touch-action: none; }
.splitter::before { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 8px; border-radius: 4px; background: var(--border); }
.splitter::after { content: ""; position: absolute; left: 50%; top: 5px; width: 36px; height: 4px; margin-left: -18px; border-top: 1px solid var(--text-3); border-bottom: 1px solid var(--text-3); opacity: .6; }
.splitter:hover::before, .splitter:focus-visible::before, body.resizing .splitter::before { background: var(--accent-soft); }
body.resizing { cursor: row-resize; user-select: none; }
#read-splitter { margin: 0 8px; }

/* Folder tree */
.folder-tree { flex: 1; overflow: auto; padding: 4px; }
.tree-row { display: flex; align-items: center; border: 1px solid transparent; border-radius: var(--radius-sm); }
.tree-row:hover { background: var(--sunken); }
.tree-row.selected { background: var(--select); border-color: var(--accent); }
.twisty { width: 18px; height: 34px; flex: none; display: grid; place-items: center; border: 0; background: none; padding: 0; color: var(--text-3); }
.twisty svg { width: 12px; height: 12px; }
.twisty[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 2px; border: 0; background: none; text-align: left; color: var(--text); }
.tree-label svg { width: 18px; height: 18px; fill: var(--folder); stroke: var(--folder-line); stroke-width: 1.2; }
.tree-row:first-child .tree-label svg { fill: none; stroke: var(--text-3); stroke-width: 2; width: 15px; height: 15px; margin: 0 1px; }
.tree-label .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Search + list */
.search { position: relative; flex: none; padding: 6px; border-bottom: 1px solid var(--border); }
.search svg { position: absolute; left: 15px; top: 15px; width: 15px; height: 15px; color: var(--text-3); }
.search input { width: 100%; height: 32px; padding: 0 8px 0 30px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); outline: none; }
.search input:focus { border-color: var(--text-3); }
.text-list { flex: 1; overflow: auto; padding: 4px; }
.text-item { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 36px; padding: 7px 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; text-align: left; }
.text-item:hover { background: var(--sunken); }
.text-item.selected { background: var(--select); border-color: var(--accent); }
.item-kind { flex: none; width: 48px; font-size: 12px; color: var(--text-3); }
.item-text { min-width: 0; display: flex; flex-direction: column; }
.item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.no-results { padding: 12px 8px; color: var(--text-3); font-size: 13px; }

/* Document */
#document { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.doc-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 8px 6px 12px; background: var(--panel-head); border-bottom: 1px solid var(--border); }
.doc-head h2 { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.segmented { flex: none; display: flex; gap: 6px; }
.segmented button { height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); font-weight: 500; box-shadow: var(--shadow); }
.segmented button:hover:not(.active) { background: var(--sunken); }
.segmented button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.doc-tools { flex: none; display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }

.read-pane { --preview-share: 45; --fields-share: 55; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 0 0; }
.paper { flex: 1 1 0; min-height: 70px; overflow: auto; margin: 0 8px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--paper-line); border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.6; outline: none; }
.read-pane.has-variables .paper { flex: var(--preview-share) 1 0; }
.read-pane:not(.has-variables) .paper { margin-bottom: 8px; }
.paper .filled { background: #d9f3e1; padding: 0 2px; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.paper .missing { background: var(--amber-soft); border: 1px dashed var(--amber-line); border-radius: 3px; padding: 0 2px; cursor: pointer; }
.paper .missing:hover { border-style: solid; }
.paper .heading { font-weight: 700; }
@media (prefers-color-scheme: dark) { .paper .filled { background: #1c3a27; } }

.fields { flex: var(--fields-share) 1 0; min-height: 90px; overflow: auto; margin: 0 8px 8px; padding: 10px 12px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.fields h3 { font-size: 13px; font-weight: 500; color: var(--text-3); margin-bottom: 6px; }
.fields-list { display: flex; flex-direction: column; gap: 10px; }
.var-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.var-field .label-row .state { display: none; }
.var-field textarea { width: 100%; min-height: 38px; max-height: 220px; resize: none; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); font-size: 15px; color: var(--text); line-height: 1.4; outline: none; }
.var-field textarea::placeholder { color: var(--text-3); }
.var-field textarea:focus { border-color: var(--text-3); }
.fields-foot { display: flex; justify-content: flex-end; margin-top: 12px; }

/* Edit */
.edit-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px; overflow: auto; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea { width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); font-size: 14px; font-weight: 400; color: var(--text); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grow { flex: 1; min-height: 160px; }
.field-grow textarea { flex: 1; height: auto; padding: 10px; resize: none; font-size: 14.5px; line-height: 1.55; }
.edit-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.hint { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { height: 24px; padding: 0 7px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--sunken); font: 12px var(--mono); color: var(--text-2); }
.chip:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }

/* Copy bar: hint above a full-width button, like before */
.copy-bar { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-top: 1px solid var(--border); background: var(--panel-head); }
.copy-hint { font-size: 13.5px; color: var(--text-3); }
.copy-hint.warn { color: var(--amber); }
.btn-copy { width: 100%; height: 48px; font-size: 18px; font-weight: 700; border-radius: var(--radius); }
.btn-copy svg { width: 18px; height: 18px; }

/* Empty */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }
.empty h2 { font-size: 16px; }
.empty p { color: var(--text-3); max-width: 300px; margin-bottom: 6px; }

/* Status bar */
.statusbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 32px; padding: 0 12px; font-size: 13px; color: var(--text-2); }
.status { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--green); }
.dot.busy { background: var(--amber-line); }
.dot.bad { background: var(--red); }
.footer-right { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-3); }
.divider { color: var(--border-strong); }
.cloud-link { border: 0; background: none; padding: 0; color: var(--accent-text); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.cloud-link.warn { color: var(--amber); }
.cloud-link.bad { color: var(--red); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px); padding: 9px 14px; border-radius: var(--radius); background: #1b1f24; color: #fff; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* Dialogs */
dialog { width: min(420px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 18, 22, .4); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel-head); border-radius: 10px 10px 0 0; }
.dialog-head h2 { font-size: 16px; }
.dialog-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; color: var(--text-2); }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--panel-head); border-radius: 0 0 10px 10px; }
.error { color: var(--red); font-size: 13px; }
.error:empty { display: none; }
.help p { line-height: 1.55; }
.help strong { color: var(--text); }

/* Reading focus */
body.reading-focus .navigation-panel, body.reading-focus #navigation-splitter { display: none; }

/* Wide: full tab or web app */
@media (min-width: 860px) {
  main { flex-direction: row; gap: 8px; }
  .navigation-panel { flex: none; width: 560px; }
  #navigation-splitter { display: none; }
  .document-panel { flex: 1; }
}
