/* ---- Theme: change the colours here ---- */
:root {
  --bg: #f4f5f8; --panel: #ffffff; --raised: #f0f2f6; --ink: #171b24; --mute: #5c6779; --line: #e1e4ea;
  --acc: #c2410c; --acc-ink: #ffffff; --acc-bg: #fff1e7; --danger: #c92a2a; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --top: 60px; --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f15; --panel: #131822; --raised: #1a2030; --ink: #e8ebf2; --mute: #8f99ab; --line: #232a39;
    --acc: #ff8a4c; --acc-ink: #1a0d05; --acc-bg: rgba(255, 138, 76, .12); --danger: #ff6b6b; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f15; --panel: #131822; --raised: #1a2030; --ink: #e8ebf2; --mute: #8f99ab; --line: #232a39;
  --acc: #ff8a4c; --acc-ink: #1a0d05; --acc-bg: rgba(255, 138, 76, .12); --danger: #ff6b6b; --shadow: none;
  color-scheme: dark;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.65 var(--font); }
[hidden] { display: none !important; }
a { color: var(--acc); }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; text-wrap: balance; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--panel); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.loading, .empty { color: var(--mute); padding: 40px 0; text-align: center; }

/* ---- Buttons and fields ---- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; text-decoration: none;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 6px 13px; border-radius: 8px; font-weight: 500; }
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; }
.btn.danger { color: var(--danger); }
.btn.danger:hover, .btn[data-sure] { border-color: var(--danger); }
.btn[data-sure] { background: var(--danger); color: #fff; }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn.on { background: var(--acc-bg); border-color: var(--acc); color: var(--acc); }
.btn:disabled { opacity: .4; cursor: default; border-color: var(--line); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--mute); cursor: pointer; }
.icon-btn:hover { background: var(--raised); color: var(--ink); }
input[type="text"], input[type="password"], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-bg); }
textarea { min-height: 150px; resize: vertical; line-height: 1.55; display: block; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--mute); margin-bottom: 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row select { height: 38px; }
.row > .grow { flex: 1 1 180px; min-width: 0; }
.row > .fix { flex: 0 0 120px; }
.spacer { flex: 1; }

/* ---- Top bar ---- */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 16px; min-width: 0; }
.brand #brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--acc); color: var(--acc-ink); flex: none; }
.search { flex: 1; max-width: 460px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 38px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--mute); }
.search:focus-within { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-bg); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); box-shadow: none; padding: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
kbd { font: 12px var(--font); color: var(--mute); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; background: var(--panel); }
.actions, #actions { display: flex; align-items: center; gap: 8px; }
.who { font-size: 13px; color: var(--mute); white-space: nowrap; }
.menu-btn { display: none; }
:root .moon { display: none; }
:root[data-theme="dark"] .moon { display: block; }
:root[data-theme="dark"] .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .moon { display: block; }
  :root:not([data-theme="light"]) .sun { display: none; }
}

/* ---- Three columns ---- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr) 270px; max-width: 1560px; margin: 0 auto; }
.side { position: sticky; top: var(--top); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); overflow-y: auto; padding: 22px 16px 90px; }
.side-l { border-right: 1px solid var(--line); }
.side-r { border-left: 1px solid var(--line); }
main { min-width: 0; padding: 34px 40px 140px; outline: none; }
main > * { max-width: 800px; margin-left: auto; margin-right: auto; }
.label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--mute); margin: 0 0 10px; padding: 0 10px; }

/* Left: chapters */
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 2px; border-radius: 9px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.nav-item:hover { background: var(--raised); }
.nav-item .n { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--raised); color: var(--mute); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nav-item .n svg { width: 15px; height: 15px; stroke-width: 2; }
.nav-item .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.nav-item .c { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.nav-item.on { background: var(--acc-bg); color: var(--acc); font-weight: 600; }
.nav-item.on .n { background: var(--acc); color: var(--acc-ink); }
.nav-row { display: flex; align-items: center; gap: 2px; }
.nav-row .nav-item { flex: 1; min-width: 0; }
.nav-row .icon-btn { width: 24px; height: 28px; font-size: 13px; }
.nav-staff { display: none; }
.side .btn.add { width: 100%; justify-content: center; margin-top: 10px; border-style: dashed; }

/* Right: on this page + legend */
.toc-link { display: flex; gap: 8px; padding: 5px 10px; border-left: 2px solid var(--line); color: var(--mute); text-decoration: none; font-size: 13px; line-height: 1.4; }
.toc-link b { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.toc-link:hover { color: var(--ink); }
.toc-link.on { color: var(--acc); border-color: var(--acc); }
.legend { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.toc-empty + .legend, .legend:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.lg { display: flex; gap: 10px; align-items: baseline; font-size: 13px; line-height: 1.4; margin: 0 10px 8px; color: var(--mute); }
.chip { flex: none; display: inline-block; background: var(--acc-bg); color: var(--acc); border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.toc-inline { display: none; }

/* ---- Centre: content ---- */
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--acc); margin-bottom: 8px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; }
.page-head .lede { color: var(--mute); font-size: 17px; margin-top: 8px; }
.meta { color: var(--mute); font-size: 13px; margin-top: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h2 { font-size: 16px; margin-bottom: 12px; }
.hint { color: var(--mute); font-size: 13px; }

.rule { transition: border-color .3s; }
.rule.flash { border-color: var(--acc); }
.rule-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.rule-code { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--mute); text-transform: uppercase; font-variant-numeric: tabular-nums; }
.rule-top .icon-btn { width: 28px; height: 28px; opacity: 0; }
.rule-top .icon-btn svg { width: 16px; height: 16px; }
.rule:hover .rule-top .icon-btn, .rule-top .icon-btn:focus-visible { opacity: 1; }
.rule h2 { font-size: 20px; margin-bottom: 10px; }

.prose { overflow-wrap: anywhere; }
.prose p { margin: .55em 0; }
.prose ul, .prose ol { margin: .5em 0; padding-left: 22px; }
.prose li { margin: .25em 0; }
.prose li::marker { color: var(--acc); font-weight: 600; }
.prose h4 { font-size: 15px; margin: 1em 0 .3em; }
.prose blockquote { margin: .9em 0; padding: 8px 14px; border-left: 3px solid var(--acc); background: var(--acc-bg); border-radius: 0 8px 8px 0; }
.prose blockquote p { margin: .2em 0; }
.prose code { font: 13px ui-monospace, Consolas, monospace; background: var(--raised); padding: 1px 5px; border-radius: 5px; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
mark { background: var(--acc-bg); color: var(--acc); border-radius: 3px; padding: 0 1px; }

/* Home: chapter grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--acc); }
.tile small { color: var(--acc); font-weight: 700; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.tile b { font-size: 16px; line-height: 1.3; }
.tile span { color: var(--mute); font-size: 13px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--mute); margin-top: 30px; margin-bottom: 12px; }

/* Article: previous / next */
.pager { display: flex; gap: 12px; margin-top: 26px; }
.pager a { flex: 1; min-width: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--panel); }
.pager a:hover { border-color: var(--acc); }
.pager small { display: block; color: var(--mute); font-size: 12px; }
.pager .next { text-align: right; }

/* Search results */
.hit { display: block; text-decoration: none; color: var(--ink); }
.hit:hover { border-color: var(--acc); }
.hit h2 { font-size: 17px; margin: 2px 0 4px; }
.hit p { color: var(--mute); font-size: 14px; }

/* ---- Editing ---- */
.edit-card { border-style: dashed; }
.edit-tools { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 6px; }
.edit-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.preview { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.title-input { font-size: 24px; font-weight: 800; }
main > .btn.add { display: flex; width: 100%; justify-content: center; border-style: dashed; padding: 12px; }
.banner { display: flex; gap: 10px; align-items: center; background: var(--acc-bg); color: var(--acc); border-radius: 10px; padding: 9px 14px; font-size: 13px; font-weight: 500; margin-bottom: 18px; }

.bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 30; width: min(920px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .28); }
.bar-status { font-size: 13px; font-weight: 600; white-space: nowrap; padding-left: 4px; }
.bar-status.dirty { color: var(--acc); }
.bar input { flex: 1; min-width: 0; }
.review { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 29; width: min(920px, calc(100vw - 24px)); max-height: min(60vh, 520px); overflow-y: auto;
  padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .28); }
.review h2 { font-size: 15px; margin-bottom: 4px; }

/* Automatic change lists (staff panel + "Wijzigingen" above the publish bar) */
.changes { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13.5px; }
.changes li { padding: 5px 0 5px 16px; position: relative; overflow-wrap: anywhere; }
.changes li::before { content: ""; position: absolute; left: 2px; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: var(--acc); }
.changes .more { color: var(--mute); }
.changes .more::before { background: var(--line); }
.diff { margin: 6px 0 4px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 13px; line-height: 1.5; }
.diff div { padding: 2px 10px 2px 26px; position: relative; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--mute); }
.diff div::before { position: absolute; left: 9px; font-weight: 700; }
.diff .add { background: rgba(46, 160, 67, .16); color: var(--ink); }
.diff .add::before { content: "+"; color: #2ea043; }
.diff .del { background: rgba(248, 81, 73, .14); color: var(--ink); text-decoration: line-through; text-decoration-color: rgba(248, 81, 73, .6); }
.diff .del::before { content: "−"; color: #f85149; }
.diff .gap { text-align: center; padding: 0; line-height: 1.1; }
/* What a version changed: shown in full under each entry, scrolls on its own when it gets long. */
.log-detail { flex: 1 1 100%; min-width: 0; max-height: 360px; overflow-y: auto; padding: 2px 12px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.log-detail .changes { margin-top: 2px; }
.toast { position: fixed; left: 50%; top: calc(var(--top) + 14px); transform: translateX(-50%); z-index: 40; max-width: min(520px, calc(100vw - 24px));
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); }

/* ---- Staff panel and login ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--mute); font-size: 13px; }
.log { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.log:first-of-type { border-top: 0; }
.log > div:first-child { flex: 1 1 240px; min-width: 0; }
.log small { color: var(--mute); display: block; }
.login { max-width: 400px; margin-top: 30px; }
.login h1 { font-size: 22px; margin-bottom: 6px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }
.login .or { text-align: center; color: var(--mute); font-size: 12px; margin: 16px 0; }
.error { color: var(--danger); font-size: 14px; margin: 10px 0; }

/* ---- Smaller screens ---- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 270px minmax(0, 1fr); }
  .side-r { display: none; }
  .toc-inline { display: block; padding: 12px 16px; }
  .toc-inline summary { cursor: pointer; font-weight: 600; }
  .toc-inline .toc-link { margin-top: 0; }
  .toc-inline summary + * { margin-top: 10px; }
}
@media (max-width: 820px) {
  .layout { display: block; }
  .menu-btn { display: inline-grid; }
  .top { padding: 0 12px; gap: 8px; }
  .brand #brand, kbd, .who { display: none; }
  .brand { flex: none; }
  /* Logged-in staff find their buttons at the bottom of the chapter menu instead of in the top bar. */
  #actions.staff { display: none; }
  .nav-staff { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
  .nav-staff .btn { justify-content: center; }
  main { padding: 22px 16px 150px; }
  .side-l { position: fixed; z-index: 25; left: 0; top: var(--top); width: min(300px, 86vw); background: var(--panel); transform: translateX(-100%); transition: transform .2s; }
  .nav-open .side-l { transform: none; }
  .scrim { position: fixed; inset: var(--top) 0 0 0; z-index: 24; background: rgba(0, 0, 0, .5); display: none; }
  .nav-open .scrim { display: block; }
  .card { padding: 18px; }
  .stats { grid-template-columns: 1fr; }
  .bar { flex-wrap: wrap; }
  .bar-status { flex: 1 1 100%; }
  .rule-top .icon-btn { opacity: 1; }
  .pager { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .top, .side, .bar, .toast, .pager, .toc-inline, .rule-top .icon-btn { display: none !important; }
  .layout { display: block; } main { padding: 0; } .card { break-inside: avoid; box-shadow: none; }
}
