:root {
  color-scheme: light dark;
  --petrol: #16373c;
  --petrol-2: #21494f;
  --petrol-3: #2f5f66;
  --on-petrol: #dbe8e4;
  --on-petrol-dim: #9fb9b6;
  --paper: #fbfcfa;
  --surface: #ffffff;
  --sunken: #eef2ef;
  --ink: #1b2a2c;
  --muted: #5a6d70;
  --line: #dbe3e0;
  --code: #16373c;
  --marker: #f4c62f;
  --marker-soft: rgba(244, 198, 47, .42);
  --danger: #b3321f;
  --add-bg: #dff3e3;
  --add-ink: #17602d;
  --del-bg: #fbe3df;
  --del-ink: #93281a;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --read: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", Georgia, serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --code: #0b1f22;
    --petrol: #0f2a2e;
    --petrol-2: #1b3f45;
    --petrol-3: #2a5a61;
    --paper: #16282b;
    --surface: #1d3236;
    --sunken: #203a3e;
    --ink: #e2ece9;
    --muted: #9db3b1;
    --line: #2f4a4e;
    --marker-soft: rgba(244, 198, 47, .3);
    --danger: #ef8a78;
    --add-bg: #1c4630;
    --add-ink: #a9e6bb;
    --del-bg: #552820;
    --del-ink: #f6bdb1;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.45 var(--ui); -webkit-text-size-adjust: 100%; }
::selection { background: var(--marker-soft); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--marker); outline-offset: 1px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.grow { flex: 1; }

/* Knapper */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.quiet { background: transparent; border-color: transparent; }
.btn.quiet:hover { background: var(--sunken); }
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn.primary:hover { background: var(--petrol-2); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn.wide { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 7px; background: transparent; }
.icon-btn:hover { background: var(--sunken); }

/* Emojis */
.tool-emoji { font-size: 17px; line-height: 1; font-weight: 400; }
.emoji-panel { position: fixed; z-index: 60; width: min(320px, calc(100vw - 16px)); padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 30px rgba(8, 28, 31, .22); }
.emoji-panel input { width: 100%; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 232px; margin-top: 6px; overflow: auto; }
.emoji-btn { display: grid; place-items: center; height: 36px; padding: 0; border: 0; border-radius: 6px; background: none; font-size: 21px; line-height: 1; }
.emoji-btn:hover, .emoji-btn:focus-visible { background: var(--sunken); }
.emoji-empty { grid-column: 1 / -1; margin: 8px 4px; color: var(--muted); font-size: 14px; }
.emoji-hint { margin: 8px 2px 0; color: var(--muted); font-size: 12px; }

/* Deling */
.tree-heading { margin: 16px 0 4px; padding: 0 10px; color: var(--on-petrol-dim); font-size: 13px; }
.tree-shared { display: inline-flex; flex: none; margin-left: 2px; }
.tree-link .tree-shared .icon { width: 13px; height: 13px; color: var(--marker); }
.share-badge { margin-right: 6px; padding: 3px 8px; border-radius: 6px; background: var(--marker-soft); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.share-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.share-add input { flex: 1 1 220px; min-width: 0; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.dialog select { min-height: 36px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }

/* Login */
#app.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--petrol); }
.auth-card { width: min(380px, 100%); padding: 28px; border-radius: 12px; background: var(--paper); }
.auth-card .brand-mark { color: var(--ink); font-size: 24px; }
.auth-lead { color: var(--muted); margin: 6px 0 20px; }
.auth-error { color: var(--danger); margin: 0 0 12px; }
.brand-mark { font-family: var(--read); font-weight: 700; font-size: 20px; letter-spacing: -.01em; text-decoration: none; color: inherit; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .user-form input { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }

/* Skal */
#app.shell { height: 100dvh; display: grid; grid-template-columns: 286px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--petrol); color: var(--on-petrol); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; min-height: 52px; }
.drawer-close { display: none; color: inherit; }
.drawer-close:hover { background: var(--petrol-2); }
.demo-note { margin: 0 14px 10px; font-size: 13px; color: var(--marker); }
.side-search { position: relative; padding: 0 14px 10px; }
.search { width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 7px; background: var(--petrol-2); color: var(--on-petrol); }
.search::placeholder { color: var(--on-petrol-dim); }
.search-results { position: absolute; z-index: 20; top: 42px; left: 14px; right: 14px; max-height: 60vh; overflow: auto; padding: 4px; border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 30px rgba(8, 28, 31, .35); }
.search-hit { display: block; padding: 8px; border-radius: 6px; text-decoration: none; }
.search-hit:hover, .search-hit:focus { background: var(--sunken); }
.search-hit strong { display: block; font-weight: 600; }
.search-hit span { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { margin: 0; padding: 10px; color: var(--muted); }
.side-actions { display: flex; gap: 8px; padding: 0 14px 12px; }
.side-actions .btn { flex: 1 1 auto; min-height: 34px; padding: 6px 8px; border: 0; color: var(--on-petrol); background: var(--petrol-2); }
.side-actions .btn:hover { background: var(--petrol-3); }
.tree { flex: 1; min-height: 0; overflow: auto; padding: 0 6px 12px; }
.tree-empty { padding: 8px 12px; color: var(--on-petrol-dim); }
.tree-row { position: relative; display: flex; align-items: center; min-height: 32px; border-radius: 6px; }
.tree-row:hover { background: var(--petrol-2); }
.tree-row.active { background: var(--petrol-2); }
.tree-row.active::before { content: ""; position: absolute; left: 0; top: 5px; bottom: 5px; width: 4px; border-radius: 2px; background: var(--marker); }
.tree-row.active .tree-title { color: #fff; font-weight: 600; }
.tree-toggle { width: 22px; height: 28px; flex: none; display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--on-petrol-dim); }
.tree-toggle .icon { width: 13px; height: 13px; transition: transform .12s; }
.tree-toggle.open .icon { transform: rotate(90deg); }
.tree-link { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; padding: 5px 2px; text-decoration: none; }
.tree-link .icon { width: 16px; height: 16px; color: var(--on-petrol-dim); }
.tree-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-more { width: 30px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 5px; background: none; color: var(--on-petrol-dim); opacity: 0; }
.tree-row:hover .tree-more, .tree-more:focus-visible { opacity: 1; }
.tree-more:hover { color: #fff; }
.drop-before { box-shadow: inset 0 2px 0 var(--marker); }
.drop-after { box-shadow: inset 0 -2px 0 var(--marker); }
.drop-inside { outline: 2px solid var(--marker); outline-offset: -2px; }
.side-foot { display: flex; gap: 2px; flex-wrap: wrap; padding: 8px; border-top: 1px solid var(--petrol-2); }
.foot-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 8px; border: 0; border-radius: 6px; background: none; color: var(--on-petrol-dim); font-size: 13px; }
.foot-btn:hover { background: var(--petrol-2); color: var(--on-petrol); }
.foot-btn.user { margin-left: auto; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.foot-btn .icon { width: 15px; height: 15px; }
.scrim { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; }
.topbar, .toolbar, .doc-layout, .page-column { flex: none; }
.topbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 8px 16px; background: var(--paper); }
.drawer-open-btn { display: none; }
.crumbs { display: flex; gap: 5px; min-width: 0; overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; }
.crumbs a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.save-status { margin-right: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.save-status[data-state="error"] { color: var(--danger); }

.toolbar { position: sticky; top: 52px; z-index: 5; display: flex; align-items: center; justify-content: center; gap: 1px; padding: 4px 12px; overflow-x: auto; background: var(--paper); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tool { display: inline-grid; place-items: center; flex: none; min-width: 34px; height: 32px; padding: 0 6px; border: 0; border-radius: 6px; background: none; font-size: 14px; font-weight: 600; }
.tool:hover { background: var(--sunken); }
.tool.on { background: var(--marker-soft); }
.tool code { font: 600 12px var(--mono); }
.tool-gap { flex: none; width: 1px; height: 18px; margin: 0 7px; background: var(--line); }

.doc-layout { display: flex; justify-content: center; gap: 32px; padding: 36px 28px 140px; }
.doc-column { width: 100%; max-width: 720px; min-width: 0; }
.doc-title { display: block; width: 100%; padding: 0; margin: 0 0 14px; border: 0; outline: 0; resize: none; overflow: hidden; background: none; font: 700 38px/1.18 var(--read); letter-spacing: -.015em; }
.doc-title::placeholder { color: var(--muted); opacity: .6; }
.outline { position: sticky; top: 112px; align-self: flex-start; width: 200px; flex: none; max-height: calc(100dvh - 140px); overflow: auto; font-size: 13px; }
.outline-title { margin: 0 0 8px; color: var(--muted); }
.outline-link { display: block; width: 100%; padding: 3px 0; border: 0; background: none; text-align: left; color: var(--muted); }
.outline-link:hover { color: var(--ink); }
.outline-link.level-2 { padding-left: 10px; }
.outline-link.level-3 { padding-left: 20px; }
@media (max-width: 1240px) { .outline { display: none; } }

/* Dokumenttekst */
.prose { font: 18px/1.68 var(--read); }
.editor { min-height: 45vh; outline: 0; caret-color: var(--ink); }
.prose > * { margin: 0 0 .85em; }
.prose h1, .prose h2, .prose h3 { line-height: 1.25; font-weight: 700; scroll-margin-top: 110px; letter-spacing: -.01em; }
.prose h1 { font-size: 30px; margin-top: 1.25em; }
.prose h2 { font-size: 24px; margin-top: 1.2em; }
.prose h3 { font-size: 20px; margin-top: 1.1em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li ul, .prose li ol, .prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul { margin: .2em 0; }
.prose blockquote { margin-left: 0; padding: .1em 0 .1em 1em; border-left: 4px solid var(--marker); color: var(--muted); }
.prose hr { height: 1px; border: 0; background: var(--line); margin: 1.6em 0; }
.prose a { color: var(--petrol-3); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { .prose a { color: #8bd0d6; } }
.prose :not(pre) > code { padding: .1em .32em; border-radius: 4px; background: var(--sunken); font: .84em var(--mono); }
.editor > p:only-child:has(> br:only-child)::before { content: "Skriv her, eller tast / for at vælge en blok"; position: absolute; color: var(--muted); opacity: .7; pointer-events: none; }

/* Kodeblokke */
.code-block, .code-view { margin: 1.1em 0; border-radius: 9px; background: var(--code); color: #e5efec; font: 14px/1.6 var(--mono); }
.code-head { display: flex; align-items: center; gap: 2px; padding: 5px 6px 5px 10px; border-bottom: 1px solid var(--petrol-2); font-family: var(--ui); font-size: 13px; }
.code-head select { margin-right: auto; padding: 3px 4px; border: 0; border-radius: 5px; background: var(--petrol-2); color: var(--on-petrol); }
.code-action { padding: 3px 8px; border: 0; border-radius: 5px; background: none; color: var(--on-petrol-dim); }
.code-action:hover { background: var(--petrol-2); color: #fff; }
.code-body { display: grid; }
.code-body > pre, .code-body > textarea { grid-area: 1 / 1; margin: 0; padding: 12px 14px; border: 0; font: inherit; line-height: inherit; tab-size: 4; letter-spacing: 0; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.code-body > pre code { font: inherit; }
.code-body > textarea { width: 100%; height: 100%; resize: none; overflow: hidden; outline: 0; background: transparent; color: transparent; caret-color: #fff; }
.code-body > textarea::selection { background: rgba(244, 198, 47, .35); color: transparent; }
.code-block:focus-within { box-shadow: 0 0 0 2px var(--marker); }
.code-view { position: relative; padding: 12px 14px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.code-view code { font: inherit; background: none; }
.t-kw { color: #f4c62f; }
.t-str { color: #a8dcaa; }
.t-com { color: #84a3a3; font-style: italic; }
.t-num { color: #f2a68c; }
.t-var { color: #9ed4e6; }
.t-fn { color: #bfd8ff; }

/* Login */
.auth-card form { margin: 0; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-card a.btn { text-decoration: none; min-height: 40px; }
.auth-card .btn.wide { min-height: 42px; }
.code-input { font: 600 26px/1 var(--mono); letter-spacing: .32em; text-align: center; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.auth-links .link-btn:disabled { opacity: .5; text-decoration: none; cursor: default; }
.demo-login { margin: -8px 0 16px; color: var(--danger); font-size: 14px; }
.admin-main span { display: block; overflow-wrap: anywhere; }
.admin-list li.blocked .admin-main { opacity: .6; }
.admin-list li { flex-wrap: wrap; }
.admin-main { flex: 1 1 220px; }

/* Tabeller */
.table-scroll { overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: .9em; line-height: 1.45; }
.prose th, .prose td { min-width: 90px; padding: 7px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--sunken); font-weight: 700; }
.prose th[contenteditable]:focus, .prose td[contenteditable]:focus { outline: 2px solid var(--marker); outline-offset: -2px; }
.table-block { position: relative; }
.table-tools { display: flex; flex-wrap: wrap; gap: 2px; padding-bottom: 4px; font: 13px var(--ui); opacity: 0; }
.table-block:hover .table-tools, .table-block:focus-within .table-tools { opacity: 1; }
@media (hover: none) { .table-tools { opacity: 1; } }
.table-tools button { padding: 3px 8px; border: 0; border-radius: 5px; background: var(--sunken); color: var(--muted); }
.table-tools button:hover { color: var(--ink); }

/* Import og eksport */
.transfer section { padding: 14px 0; border-top: 1px solid var(--line); }
.transfer section h3 { margin: 0 0 3px; font-size: 15px; }
.transfer .dialog-text { margin-bottom: 8px; font-size: 14px; }
.transfer-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.transfer-row input, .transfer-row select { flex: 1 1 200px; min-width: 0; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.transfer-status { padding: 10px 12px; border-radius: 7px; background: var(--sunken); font-size: 14px; overflow-wrap: anywhere; }
.transfer-status p { margin: 0; }
.transfer-status progress { width: 100%; margin-top: 8px; accent-color: var(--petrol-3); }
.transfer-status details { margin-top: 8px; }
.transfer-status ul { max-height: 170px; margin: 6px 0 0; padding-left: 18px; overflow: auto; }
.transfer-error { color: var(--danger); }
.foot-btn { white-space: nowrap; }

/* Miljøer og felter */
.doc-tools { position: sticky; top: 52px; z-index: 5; flex: none; background: var(--paper); border-bottom: 1px solid var(--line); }
.doc-tools .toolbar { position: static; border-bottom: 0; }
.env-bar { display: flex; align-items: center; justify-content: center; gap: 2px; padding: 4px 12px; overflow-x: auto; scrollbar-width: none; }
.env-tab { flex: none; min-height: 32px; padding: 4px 14px; border: 0; border-radius: 6px; background: none; color: var(--muted); }
.env-tab:hover { background: var(--sunken); color: var(--ink); }
.env-tab.on { background: var(--marker); color: #1b2a2c; font-weight: 600; }
.read-title { margin-bottom: 14px; }
.var-field { background: var(--marker-soft); border-radius: 3px; padding: 0 .15em; }
.var-missing { color: var(--danger); text-decoration: underline wavy; text-underline-offset: 3px; }
.code-view .var-missing { color: #ffb4a4; }
.t-field { color: #1b2a2c; background: var(--marker); border-radius: 3px; }
.env-warning { padding: 8px 12px; border-left: 4px solid var(--danger); background: var(--del-bg); color: var(--del-ink); font: 14px/1.45 var(--ui); }
.link-btn { padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; }
.read-view .code-view { padding-top: 36px; }
.read-view .code-view::before { content: attr(data-lang); position: absolute; top: 9px; left: 14px; color: var(--on-petrol-dim); font: 13px var(--ui); }
.code-copy { position: absolute; top: 5px; right: 6px; font: 13px var(--ui); }
.popover { max-height: min(340px, 70dvh); overflow: auto; }
.dialog.env-dialog { width: min(860px, 100%); }
.env-table-wrap { overflow-x: auto; }
.env-table { border-collapse: collapse; }
.env-table th, .env-table td { padding: 3px; text-align: left; font-weight: 400; vertical-align: middle; }
.env-table th:first-child { color: var(--muted); font-size: 13px; }
.env-table input { width: 100%; min-width: 136px; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.env-table thead input { font-weight: 600; }
.env-head { display: flex; align-items: center; gap: 1px; }
.add-field { margin-top: 10px; }
.env-dialog .auth-error { margin: 12px 0 0; }

/* Billeder */
.prose img { max-width: 100%; height: auto; border-radius: 6px; cursor: zoom-in; vertical-align: middle; }
.prose .image-view, .prose .image-block { margin: 1.2em 0; }
.prose .image-view img, .prose .image-block img { display: block; }
.image-block { position: relative; width: fit-content; max-width: 100%; border-radius: 6px; outline-offset: 3px; }
.image-block:focus { outline: 2px solid var(--marker); }
.image-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; padding: 3px; border-radius: 7px; background: var(--code); font: 13px var(--ui); opacity: 0; }
.image-block:hover .image-actions, .image-block:focus .image-actions, .image-block:focus-within .image-actions { opacity: 1; }
@media (hover: none) { .image-actions { opacity: 1; } }
.prose .image-block.uploading { display: grid; place-items: center; width: 100%; min-height: 110px; padding: 12px; background: var(--sunken); color: var(--muted); font: 14px var(--ui); text-align: center; }
.lightbox { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(6, 20, 22, .92); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 48px); border-radius: 4px; }
.lightbox-close { position: fixed; top: 12px; right: 12px; color: #fff; }
.lightbox-close:hover { background: rgba(255, 255, 255, .14); }

/* Skråstregs-menu og små lag */
.slash-menu, .popover { position: fixed; z-index: 60; min-width: 220px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 10px 30px rgba(8, 28, 31, .22); }
.slash-item { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 7px 9px; border-radius: 5px; cursor: pointer; }
.slash-item.active, .slash-item:hover { background: var(--marker-soft); }
.slash-item kbd { font: 12px var(--mono); color: var(--muted); }
.popover button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: none; text-align: left; }
.popover button:hover, .popover button:focus-visible { background: var(--sunken); }
.popover .danger { color: var(--danger); }
.toast { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--paper); }

/* Oversigter */
.page-column { width: 100%; max-width: 720px; margin: 0 auto; padding: 36px 28px 100px; }
.page-title { margin: 0 0 22px; font: 700 34px/1.18 var(--read); letter-spacing: -.015em; }
.item-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.item-list a { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.item-list a:hover .item-title { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 2px; }
.item-list .icon { color: var(--muted); }
.item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-list time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.empty { padding: 24px 0; color: var(--muted); }
.folder-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }

/* Dialoger */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8, 28, 31, .55); }
.dialog { width: min(420px, 100%); max-height: 90dvh; overflow: auto; padding: 22px; border-radius: 12px; background: var(--paper); }
.dialog.wide { width: min(600px, 100%); }
.dialog h2 { margin: 0 0 14px; font: 700 21px/1.25 var(--read); }
.dialog-text { margin: 0 0 8px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.admin-main { flex: 1; min-width: 0; }
.admin-main strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.admin-main span { color: var(--muted); font-size: 13px; }
.admin-empty { color: var(--muted); }
.user-form { display: grid; gap: 8px; margin-top: 18px; }
.user-form h3 { margin: 0; font-size: 15px; }
.check { display: flex; align-items: center; gap: 8px; }
.user-form input[type="checkbox"] { width: 18px; min-height: 18px; padding: 0; flex: none; }

/* Historik */
.history-overlay { padding: 24px; }
.history { display: grid; grid-template-columns: 310px minmax(0, 1fr); width: min(1120px, 100%); height: min(780px, 100%); border-radius: 12px; overflow: hidden; background: var(--paper); }
.history-list { display: flex; flex-direction: column; min-height: 0; background: var(--sunken); }
.history-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 18px; }
.history-head h2 { margin: 0; font: 700 21px var(--read); }
.timeline { flex: 1; overflow: auto; list-style: none; margin: 0; padding: 0 8px 14px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline li:first-child::before { top: 18px; }
.timeline li:last-child::before { bottom: calc(100% - 18px); }
.timeline-row { position: relative; display: flex; gap: 12px; width: 100%; padding: 9px 8px 9px 11px; border: 0; border-radius: 7px; background: none; text-align: left; }
.timeline-row:hover { background: rgba(120, 150, 150, .14); }
.timeline-row.active { background: var(--surface); }
.timeline-dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--muted); background: var(--sunken); }
.kind-manual .timeline-dot { border-color: #b98a00; background: var(--marker); }
.kind-restore .timeline-dot { border-color: var(--petrol-3); background: var(--petrol-3); }
.timeline-main { min-width: 0; }
.timeline-main > * { display: block; }
.timeline-main strong { font-weight: 600; overflow-wrap: anywhere; }
.timeline-main span, .timeline-main time { color: var(--muted); font-size: 13px; }
.history-detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.history-detail-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.history-back { display: none; }
.tabs { display: flex; gap: 2px; }
.tab { padding: 6px 11px; border: 0; border-radius: 6px; background: none; }
.tab.on { background: var(--sunken); font-weight: 600; }
.current-badge { color: var(--muted); font-size: 13px; }
.history-body { flex: 1; overflow: auto; padding: 20px 24px 40px; }
.preview-title { margin: 0 0 14px; font: 700 30px/1.2 var(--read); }
.diff { font: 13px/1.55 var(--mono); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.diff-line { display: grid; grid-template-columns: 22px minmax(0, 1fr); white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 8px; }
.diff-sign { text-align: center; user-select: none; }
.diff-line.add { background: var(--add-bg); color: var(--add-ink); }
.diff-line.del { background: var(--del-bg); color: var(--del-ink); }
.diff-skip { padding: 2px 22px; background: var(--sunken); color: var(--muted); font: 12px var(--ui); }
.diff-title { margin: 0 0 14px; }
.diff-title del { color: var(--del-ink); }
.diff-title ins { color: var(--add-ink); text-decoration: none; font-weight: 600; }
.diff-none { color: var(--muted); }

/* Telefon og tablet */
@media (max-width: 760px) {
  #app.shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(320px, 86vw); transform: translateX(-102%); transition: transform .18s ease; }
  .drawer-open .sidebar { transform: none; }
  .drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(8, 28, 31, .5); }
  .drawer-close, .drawer-open-btn { display: inline-grid; }
  .tree-more { opacity: 1; }
  .tree-row { min-height: 40px; }
  .topbar { padding: 6px 8px; }
  .crumbs { display: none; }
  .save-status { font-size: 12px; margin-right: 2px; max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
  .save-status[data-state="idle"] { display: none; }
  .share-badge { font-size: 12px; max-width: 46vw; }
  input, select, .code-block, .code-head select { font-size: 16px; }
  .topbar .btn { padding: 6px 8px; font-size: 14px; }
  .toolbar { justify-content: flex-start; top: 52px; }
  .doc-layout { padding: 22px 18px 120px; }
  .doc-title { font-size: 30px; }
  .prose { font-size: 17px; }
  .page-column { padding: 22px 18px 80px; }
  .page-title { font-size: 30px; }
  .history-overlay { padding: 0; }
  .history { display: block; position: relative; width: 100%; height: 100%; border-radius: 0; }
  .history-list, .history-detail { position: absolute; inset: 0; }
  .history-detail { display: none; background: var(--paper); }
  .history.show-detail .history-detail { display: flex; }
  .history-back { display: inline-grid; }
  .history-detail-head { padding: 8px; flex-wrap: wrap; }
  .history-body { padding: 16px; }
  .item-list time { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
