/* Bordnoter
   Tre kolonner som en rigtig note-app: menu, noteliste, dokument.
   IBM Plex med én rolle hver: Sans til betjening, Serif til det man læser og skriver, Mono til kode. */
:root {
  --ground: #f1f2f4;      /* menu */
  --paper: #ffffff;       /* liste og dokument */
  --sunk: #f6f7f9;        /* kodeblokke, felter */
  --line: #e2e4e9;
  --line-2: #cfd3da;
  --ink: #17191e;
  --ink-2: #3b3f48;
  --muted: #6a707c;
  --faint: #969ba6;
  --sel: #e7eaf0;         /* valgt række */
  --hover: #eceef2;
  --accent: #2448c9;      /* koboltblå: links, primærknap, fokus */
  --accent-ink: #ffffff;
  --accent-tint: #e9eefc;
  --danger: #b4232f;
  --warn-bg: #fdf3d9;
  --warn-line: #e8c96b;
  --os: #c2541a; --net: #0e7f91; --prog: #6a3fd4;
  --hl-kw: #8f2f9e; --hl-str: #1f7a3a; --hl-num: #a95400; --hl-com: #8b909b; --hl-fn: #2448c9; --hl-type: #a3245a; --hl-attr: #0e7f91;
  --ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side-w: 248px;
  --list-w: 344px;
  --bar-h: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #16181c; --paper: #1d2025; --sunk: #16181c;
    --line: #2b2f37; --line-2: #3a3f49;
    --ink: #e8eaee; --ink-2: #c4c8d0; --muted: #959aa6; --faint: #6f7480;
    --sel: #2a2e36; --hover: #24272e;
    --accent: #7f9cff; --accent-ink: #0d1226; --accent-tint: #232b48;
    --danger: #ff7b86; --warn-bg: #3a2f12; --warn-line: #806620;
    --os: #f08a4f; --net: #3cbacd; --prog: #a58cff;
    --hl-kw: #d39bf0; --hl-str: #8fd19a; --hl-num: #f0b46b; --hl-com: #737885; --hl-fn: #93aeff; --hl-type: #f08ab4; --hl-attr: #6fd0dd;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.45 var(--ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.boot { padding: 32px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Fagmærke: et lille kvadrat i fagets farve */
.sq { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--faint); }
.sq.os { background: var(--os); } .sq.netvaerk { background: var(--net); } .sq.programmering { background: var(--prog); }

/* ---------- knapper ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.ib { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); flex: none; }
.ib:hover { background: var(--hover); color: var(--ink); }
.ib.sm { width: 26px; height: 26px; }
.ib.sm .ic { width: 16px; height: 16px; }
.ib[aria-pressed="true"] { background: var(--sel); color: var(--ink); }
.fmt { font: 600 14px var(--ui); }
.fmt.it { font-style: italic; font-family: var(--text); }

.input { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--paper); color: var(--ink); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.err { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- appens skelet ---------- */
.app { display: grid; grid-template-columns: var(--side-w) var(--list-w) minmax(0, 1fr); height: 100%; }
.app.page-mode { grid-template-columns: var(--side-w) minmax(0, 1fr); }
.scrim { display: none; }

/* Menu */
.side { background: var(--ground); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 14px 12px 8px 16px; display: flex; flex-direction: column; gap: 12px; }
.ws { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.ws:hover { text-decoration: none; }
.ws-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--ink); display: grid; grid-template-columns: repeat(3, 4px); gap: 2px; align-content: center; justify-content: center; flex: none; }
.ws-mark i { width: 4px; height: 12px; border-radius: 1px; }
.ws-mark i:nth-child(1) { background: var(--os); } .ws-mark i:nth-child(2) { background: var(--net); } .ws-mark i:nth-child(3) { background: var(--prog); }
.ws-text { min-width: 0; }
.ws-name { font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-sub { font-size: 12px; color: var(--muted); line-height: 1.2; }
.search { position: relative; }
.search .ic { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search .input { height: 32px; padding-left: 31px; background: var(--paper); border-color: var(--line); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 11px var(--ui); color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 8px 20px; }
.nav-item { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: 6px; color: var(--ink); min-width: 0; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--sel); font-weight: 500; }
.nav-item .ic { width: 16px; height: 16px; color: var(--muted); }
.nav-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .n { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; padding-left: 8px; }
.subject { margin-top: 18px; }
.subject-head { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 2px 0 8px; }
.subject-head .name { font-size: 13px; font-weight: 600; color: var(--ink-2); flex: 1; }
.subject-head .ib { opacity: 0; }
.subject:hover .subject-head .ib, .subject-head .ib:focus-visible { opacity: 1; }
@media (hover: none) { .subject-head .ib { opacity: 1; } }
.topic-item { padding-left: 24px; }
.side-empty { padding: 2px 8px 4px 24px; color: var(--faint); font-size: 13px; }
.new-topic { padding: 2px 4px 4px 22px; }
.new-topic .input { height: 30px; }
.side-foot { border-top: 1px solid var(--line); padding: 8px 8px 8px 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--line); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex: none; }
.side-foot .who { flex: 1; min-width: 0; line-height: 1.25; }
.side-foot .who b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { font-size: 12px; color: var(--muted); }

/* Notelisten */
.list { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); background: var(--paper); }
.bar { height: var(--bar-h); flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.bar h2 { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.bar .back, .bar .menu-btn { display: none; margin-left: -8px; }
.list-scroll { flex: 1; overflow-y: auto; }
.list-intro { padding: 12px 16px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.note-row { display: block; padding: 11px 16px 12px; border-bottom: 1px solid var(--line); color: var(--ink); }
.note-row:hover { background: var(--hover); text-decoration: none; }
.note-row[aria-current="true"] { background: var(--sel); }
.note-row .t { font-weight: 600; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.note-row .x { margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-row .x mark { background: var(--warn-bg); color: inherit; border-radius: 2px; }
.note-row .m { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); }
.note-row .m .where { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.note-row .m .where span { overflow: hidden; text-overflow: ellipsis; }
.note-row .m .when { margin-left: auto; white-space: nowrap; padding-left: 8px; }
.note-row .m .ic { width: 13px; height: 13px; }
.list-empty { padding: 28px 20px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.list-empty h3 { color: var(--ink); font-size: 15px; font-weight: 600; }
.start { padding: 20px 16px 28px; display: flex; flex-direction: column; gap: 20px; }
.start h3 { font-size: 16px; font-weight: 600; }
.start p { color: var(--muted); margin-top: 4px; }
.start-group { display: flex; flex-direction: column; gap: 1px; }
.start-group .gh { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); padding: 0 0 4px; }
.start-group button { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; margin-left: -8px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; }
.start-group button:hover { background: var(--hover); }
.start-group button .ic { width: 15px; height: 15px; color: var(--muted); }

/* Dokumentet */
.doc { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); position: relative; }
.doc .bar { padding: 0 8px 0 20px; gap: 6px; }
.crumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; }
.crumb a { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.crumb .slash { color: var(--line-2); }
.save { font-size: 12.5px; color: var(--faint); white-space: nowrap; padding: 0 6px; }
.save.busy { color: var(--muted); }
.save.bad { color: var(--danger); }
.fmtbar { flex: none; display: flex; align-items: center; gap: 2px; padding: 4px 12px; border-bottom: 1px solid var(--line); background: var(--paper); overflow-x: auto; }
.fmtbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; flex: none; }
.fmtbar .help { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; padding-left: 12px; }
.doc-scroll { flex: 1; overflow-y: auto; }
.page { max-width: 740px; margin: 0 auto; padding: 44px 56px 120px; }
.doc-title { width: 100%; border: 0; padding: 0; margin: 0; background: transparent; font: 600 31px/1.2 var(--text); letter-spacing: -0.012em; color: var(--ink); }
.doc-title:focus { outline: none; }
.doc-title::placeholder { color: var(--faint); }
.doc-meta { margin: 10px 0 30px; color: var(--muted); font-size: 13px; }
.banner { margin: 0 0 24px; padding: 12px 14px; border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-family: var(--ui); }
.banner p { flex: 1 1 260px; }
.drop-hint { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent-tint) 85%, transparent); display: none; align-items: center; justify-content: center; font-weight: 600; z-index: 5; pointer-events: none; }
.doc.dragging .drop-hint { display: flex; }
.doc-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); padding: 24px; text-align: center; }

/* Tekst: læsning og redigering bruger samme typografi */
.prose, .cm-editor { font: 17px/1.7 var(--text); color: var(--ink); }
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote, .prose table { margin: 0 0 1em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--text); font-weight: 600; line-height: 1.3; margin: 1.6em 0 .5em; letter-spacing: -0.005em; }
.prose h1 { font-size: 1.5em; } .prose h2 { font-size: 1.3em; } .prose h3 { font-size: 1.12em; } .prose h4 { font-size: 1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .2em 0; }
.prose li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.3em; }
.prose input[type="checkbox"] { width: 15px; height: 15px; margin: 0 8px 0 0; vertical-align: -2px; accent-color: var(--accent); }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.prose strong { font-weight: 600; }
.prose code { font: .84em var(--mono); background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; padding: .08em .32em; }
.prose pre { position: relative; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; font: 13.5px/1.6 var(--mono); white-space: pre; display: block; }
.prose pre .copy { position: absolute; top: 6px; right: 6px; opacity: 0; font-family: var(--ui); }
.prose pre:hover .copy, .prose pre .copy:focus-visible { opacity: 1; }
.prose blockquote { border-left: 2px solid var(--line-2); padding-left: 16px; color: var(--ink-2); font-style: italic; }
.prose img { display: block; max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; font: 14px/1.5 var(--ui); }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 7px 14px 7px 0; text-align: left; }
.prose th { font-weight: 600; }
.prose .empty-body { color: var(--faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-literal { color: var(--hl-kw); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--hl-str); }
.hljs-number, .hljs-symbol { color: var(--hl-num); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-com); font-style: italic; }
.hljs-title, .hljs-section { color: var(--hl-fn); }
.hljs-type, .hljs-deletion { color: var(--hl-type); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-params { color: var(--hl-attr); }

/* CodeMirror */
.cm-editor { background: transparent; }
.cm-editor.cm-focused { outline: none; }
.cm-editor .cm-scroller { font: inherit; line-height: inherit; overflow: visible; }
.cm-editor .cm-content { padding: 0 0 30vh; caret-color: var(--accent); min-height: 260px; }
.cm-editor .cm-line { padding: 0; }
.cm-editor .cm-cursor { border-left: 2px solid var(--accent); }
.cm-editor .cm-selectionBackground, .cm-editor.cm-focused .cm-selectionBackground { background: var(--accent-tint) !important; }
.cm-editor .cm-placeholder { color: var(--faint); font-style: italic; }
.md-h1 { font-size: 1.5em; font-weight: 600; } .md-h2 { font-size: 1.3em; font-weight: 600; } .md-h3 { font-size: 1.12em; font-weight: 600; } .md-h4 { font-weight: 600; }
.md-strong { font-weight: 600; } .md-em { font-style: italic; } .md-strike { text-decoration: line-through; }
.md-code { font-family: var(--mono); font-size: .84em; color: var(--ink-2); }
.md-mark { color: var(--faint); font-weight: 400; font-style: normal; }
.md-link { color: var(--accent); }
.md-label { color: var(--muted); }
.md-quote { color: var(--ink-2); font-style: italic; }

/* Vedhæftede filer */
.files { margin-top: 48px; border-top: 1px solid var(--line); padding-top: 16px; font-family: var(--ui); }
.files-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.files-head h3 { font-size: 14px; font-weight: 600; flex: 1; }
.files-head .muted { font-size: 13px; }
.file { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file:last-child { border-bottom: 0; }
.thumb { width: 44px; height: 34px; border-radius: 4px; border: 1px solid var(--line); background: var(--sunk); object-fit: cover; flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.thumb .ic { width: 16px; height: 16px; }
.thumb.ext { font: 600 10px var(--mono); letter-spacing: .02em; color: var(--muted); }
.thumb-btn { padding: 0; border: 0; background: none; border-radius: 4px; flex: none; }
.file.on { background: var(--sel); box-shadow: -10px 0 0 var(--sel), 10px 0 0 var(--sel); }
.file .info .nm[aria-current] { font-weight: 500; }
#d-read img[src^="/api/files/"] { cursor: zoom-in; }
.file .info { flex: 1; min-width: 0; }
.file .info .nm { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .info small { color: var(--faint); font-size: 12px; }
.file .acts { display: flex; gap: 2px; }
.uploading { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--muted); font-size: 13px; }
.progress { width: 140px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; flex: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.files-none { color: var(--faint); font-size: 13px; padding: 4px 0; }

/* Filvisning i højre side. Mens den er åben, gemmes notelisten, og dokumentet rykker til venstre. */
.viewer { display: none; }
.app.viewing { grid-template-columns: var(--side-w) minmax(360px, 1fr) var(--viewer-w, 560px); }
.app.viewing .list { display: none; }
.app.viewing .viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; border-left: 1px solid var(--line); background: var(--ground); }
.app.resizing { cursor: col-resize; user-select: none; }
.app.resizing iframe, .app.resizing video { pointer-events: none; }
.viewer .bar { padding: 0 6px 0 16px; gap: 2px; }
.v-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; margin-right: 6px; }
.v-title b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-title small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-pos { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
.v-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; flex: none; }
.v-grip { position: absolute; left: -5px; top: 0; bottom: 0; width: 9px; z-index: 4; cursor: col-resize; touch-action: none; }
.v-grip::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 1px; transition: background .12s; }
.v-grip:hover::after, .v-grip:focus-visible::after, .app.resizing .v-grip::after { left: 3px; width: 3px; background: var(--accent); }
.v-grip:focus-visible { outline: none; }
.v-body { flex: 1; min-height: 0; overflow: auto; }
.v-body:focus { outline: none; }
.v-msg { color: var(--muted); font-size: 13px; padding: 14px 18px; }
.v-img { display: flex; align-items: center; justify-content: center; padding: 24px; }
.v-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: var(--paper); box-shadow: 0 0 0 1px var(--line), 0 6px 24px rgba(15, 20, 30, .08); }
.v-img.can-zoom img { cursor: zoom-in; }
.v-img.zoom { display: block; padding: 0; }
.v-img.zoom img { max-width: none; max-height: none; border-radius: 0; box-shadow: none; cursor: zoom-out; }
.v-pdf { overflow: hidden; }
.v-pdf iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--paper); }
.v-video { display: flex; align-items: center; justify-content: center; padding: 24px; }
.v-video video { max-width: 100%; max-height: 100%; border-radius: 6px; background: #000; }
.v-doc, .v-code, .v-table { background: var(--paper); }
.v-doc .prose { max-width: 720px; margin: 0 auto; padding: 32px 36px 80px; font-size: 16px; }
.v-code pre { margin: 0; padding: 14px 0 48px; font: 13px/1.65 var(--mono); color: var(--ink); counter-reset: ln; tab-size: 4; min-width: max-content; }
.v-code.wrap pre { min-width: 0; }
.v-code .l { display: block; position: relative; min-height: 1.65em; padding: 0 20px 0 calc(var(--d, 3) * 1ch + 30px); white-space: pre; }
.v-code.wrap .l { white-space: pre-wrap; overflow-wrap: anywhere; }
.v-code .l::before { counter-increment: ln; content: counter(ln); position: absolute; left: 0; width: calc(var(--d, 3) * 1ch + 14px); text-align: right; color: var(--faint); user-select: none; }
.v-code .l:hover { background: var(--sunk); }
.v-table table { border-collapse: separate; border-spacing: 0; min-width: 100%; font: 13px/1.45 var(--ui); font-variant-numeric: tabular-nums; }
.v-table th, .v-table td { padding: 6px 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.v-table th { position: sticky; top: 0; z-index: 1; background: var(--ground); font-weight: 600; }
.v-table td.num { text-align: right; }
.v-table tbody tr:hover td { background: var(--sunk); }
.v-none { display: flex; align-items: center; justify-content: center; padding: 24px; }
.v-card { max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.v-card h3 { margin-top: 6px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.v-card p { color: var(--muted); }
.v-card .row { display: flex; gap: 8px; margin-top: 8px; }
.thumb.big { width: 64px; height: 78px; border-radius: 6px; background: var(--paper); font-size: 13px; }

/* Menuer og dialoger */
.menu { position: fixed; z-index: 40; min-width: 210px; padding: 4px; background: var(--paper); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 8px 28px rgba(15, 20, 30, .16); }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; text-align: left; color: var(--ink); }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button .ic { width: 16px; height: 16px; color: var(--muted); }
.menu button.danger, .menu button.danger .ic { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
dialog { padding: 0; border: 1px solid var(--line-2); border-radius: 10px; background: var(--paper); color: var(--ink); width: min(460px, calc(100vw - 32px)); box-shadow: 0 18px 50px rgba(15, 20, 30, .22); }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(12, 16, 24, .38); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.dlg-head { display: flex; align-items: center; gap: 8px; }
.dlg h2 { font-size: 17px; font-weight: 600; flex: 1; }
.dlg p { color: var(--ink-2); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; align-items: center; }
.dlg-foot .note { margin-right: auto; color: var(--muted); font-size: 13px; }
.hist { display: grid; grid-template-columns: 250px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 8px; height: min(62vh, 620px); overflow: hidden; }
.hist ul { list-style: none; margin: 0; padding: 4px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--ground); }
.hist li button { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.hist li button:hover { background: var(--hover); }
.hist li button[aria-current="true"] { background: var(--sel); }
.hist li small { color: var(--muted); font-size: 12px; }
.hist .pv { overflow-y: auto; padding: 24px 28px; }
.hist .pv .doc-title { font-size: 24px; margin-bottom: 18px; }
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 9px 14px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 6px 20px rgba(15, 20, 30, .2); max-width: min(460px, calc(100vw - 32px)); pointer-events: auto; }
.toast.bad { background: var(--danger); color: #fff; }

/* Medlemmer */
.admin { overflow-y: auto; min-width: 0; }
.admin .page { max-width: 900px; padding: 32px 40px 80px; display: flex; flex-direction: column; gap: 28px; margin: 0; }
.admin h1 { font: 600 24px/1.25 var(--ui); letter-spacing: -0.01em; }
.admin .lead { margin-top: 6px; color: var(--muted); max-width: 64ch; }
.admin h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 24px; color: var(--muted); }
.facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.add-member { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.add-member .field { flex: 1 1 240px; max-width: 340px; }
.add-member .check { height: 36px; }
.keyblock { border: 1px solid var(--accent); background: var(--accent-tint); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.keyblock .key { font: 500 21px/1.3 var(--mono); letter-spacing: .03em; color: var(--ink); user-select: all; word-break: break-all; }
.keyblock .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.keyblock p { color: var(--ink-2); }
.table-wrap { overflow-x: auto; }
table.members { width: 100%; border-collapse: collapse; }
.members th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.members td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.members .person { display: flex; align-items: center; gap: 10px; }
.members .off td { color: var(--faint); }
.members .acts { text-align: right; }
.members .hint-cell { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.role { color: var(--muted); }
.role.admin { color: var(--accent); }
.role.off { color: var(--danger); }

/* Login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--ground); }
.login form { width: min(400px, 100%); display: flex; flex-direction: column; gap: 22px; }
.login .ws-mark { width: 34px; height: 34px; border-radius: 8px; grid-template-columns: repeat(3, 5px); }
.login .ws-mark i { width: 5px; height: 15px; }
.login h1 { font: 600 27px/1.2 var(--text); letter-spacing: -0.01em; margin-top: 18px; }
.login .lead { color: var(--muted); margin-top: 6px; }
.login .input { height: 44px; font: 15px var(--mono); letter-spacing: .02em; }
.login .btn { height: 42px; }
.login .foot { color: var(--muted); font-size: 13px; }

/* ---------- mindre skærme ---------- */
@media (max-width: 1180px) {
  :root { --side-w: 224px; --list-w: 300px; }
  .page { padding: 36px 40px 100px; }
}
@media (max-width: 900px) {
  .app, .app.page-mode { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-102%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .app.nav-open .side { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(12, 16, 24, .35); }
  .app[data-pane="doc"] .list { display: none; }
  .app[data-pane="list"] .doc { display: none; }
  .list { border-right: 0; }
  .bar .back, .bar .menu-btn { display: inline-flex; }
  .page { padding: 28px 20px 96px; }
  .doc-title { font-size: 26px; }
  .prose, .cm-editor { font-size: 16.5px; }
  .fmtbar .help { display: none; }
  .admin .page { padding: 24px 20px 64px; }
  .hist { grid-template-columns: minmax(0, 1fr); grid-template-rows: 160px minmax(0, 1fr); }
  .hist ul { border-right: 0; border-bottom: 1px solid var(--line); }
}
/* Filvisningen på mindre skærme: først forsvinder menuen, på telefonen dækker panelet hele skærmen */
@media (min-width: 901px) { .app.viewing .page { padding: 36px 36px 100px; } }
.app.viewing .fmtbar .help { display: none; }
@media (max-width: 1280px) {
  .app.viewing { grid-template-columns: minmax(340px, 1fr) var(--viewer-w, 520px); }
  .app.viewing .side { display: none; }
}
@media (max-width: 900px) {
  .app.viewing { grid-template-columns: minmax(0, 1fr); }
  .app.viewing .viewer { position: fixed; inset: 0; z-index: 35; border-left: 0; }
  .v-grip { display: none; }
  .v-doc .prose { padding: 24px 20px 64px; }
}
@media (hover: none) {
  .prose pre { padding-top: 40px; }
  .prose pre .copy { opacity: 1; }
}
.admin .bar { display: none; }
@media (max-width: 900px) { .admin .bar { display: flex; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
