/* Admin-grensesnitt. Mobil først; editor og forhåndsvisning side om side fra 900px.
   Berøringsmål ≥ 44px på alle knapper og lenker i navigasjon/verktøylinje. */
:root {
  --bg: #f4f8f3; --fg: #1c2a1e; --muted: #4d6350; --accent: #1f6b3a; --accent-strong: #154d29;
  --on-accent: #fff; --surface: #fff; --border: #c9dccb; --code-bg: #e6efe6; --danger: #a12626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101a12; --fg: #e4ede4; --muted: #a7bda9; --accent: #7fd39a; --accent-strong: #a9e6bb;
    --on-accent: #0f1f13; --surface: #182619; --border: #2f4532; --code-bg: #1e2f20; --danger: #ff8a8a;
  }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.5; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 0; background: var(--accent); color: var(--on-accent); padding: .5rem; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
code { overflow-wrap: anywhere; }
.topbar { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: center; padding: .4rem 1rem; border-bottom: 3px solid var(--accent); }
.topbar nav { display: flex; flex-wrap: wrap; gap: 0 .5rem; align-items: center; }
.topbar nav a, .topbar nav button.link { display: inline-block; padding: .7rem .25rem; min-height: 44px; }
.brand { font-weight: 700; color: var(--accent-strong); text-decoration: none; font-size: 1.15rem; padding: .7rem 0; }
main { max-width: 70rem; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: .5rem 0; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.grow { flex: 1 1 18rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.narrow { max-width: 28rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
.hint { font-weight: normal; color: var(--muted); font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; min-height: 44px; }
label.check input { width: 1.25rem; height: 1.25rem; margin: 0; }
p.hint { margin: -.5rem 0 0; }
fieldset { margin: 0; padding: .75rem 1rem 1rem; border: 1px solid var(--border); border-radius: 6px; min-width: 0; }
legend { font-weight: 600; padding: 0 .25rem; }
.divider { color: var(--muted); text-align: center; margin: .5rem 0; }
#passkey-login p { margin: 0; }
.penholder { justify-content: flex-start; align-items: flex-end; margin: .5rem 0 1rem; }
input, textarea, button, select { font: inherit; }
input[type=text], input:not([type]), input[type=password], input[type=number], input[type=datetime-local], textarea, select {
  padding: .6rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--fg); width: 100%; min-height: 44px;
}
button {
  padding: .55rem .9rem; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--accent-strong); cursor: pointer; min-height: 44px;
}
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.link { border: none; background: none; padding: .6rem .25rem; text-decoration: underline; color: var(--accent); }
button.danger { color: var(--danger); }
.inline { display: inline; }
.meta { color: var(--muted); font-size: .9rem; }
.badge { background: var(--accent); color: var(--on-accent); padding: .05rem .45rem; border-radius: 999px; font-size: .8rem; }
.flash { padding: .6rem .9rem; border-radius: 4px; border-left: 4px solid var(--accent); background: var(--surface); }
.flash.error { border-color: var(--danger); }
.posts, .users { list-style: none; padding: 0; max-width: 48rem; }
.posts li, .users li { padding: .6rem 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: baseline; }
.posts li a { padding: .4rem 0; display: inline-block; }

/* Editor */
.tabs { display: flex; gap: .25rem; margin-top: 1rem; position: relative; z-index: 1; margin-bottom: -1px; }
.tabs button { border-radius: 4px 4px 0 0; }
.tabs button[aria-selected=true] { background: var(--surface); border-color: var(--accent); border-bottom-color: var(--surface); font-weight: 600; }
.panes section { border: 1px solid var(--border); background: var(--surface); padding: .5rem; border-radius: 0 4px 4px 4px; display: flex; flex-direction: column; }
.panes section[hidden] { display: none; } /* display:flex over ville ellers slått ut [hidden] */
.toolbar { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .5rem; }
.toolbar button { min-width: 44px; padding: .3rem .6rem; }
textarea#body { min-height: 50vh; flex: 1; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; line-height: 1.5; }
textarea#body.dragover { outline: 3px dashed var(--accent); }
#upload-status { min-height: 1.5rem; margin: .5rem 0 0; }
.preview { flex: 1; min-height: 50vh; padding: 0 .5rem; overflow-wrap: anywhere; }
.preview:has(> .meta:only-child) { display: grid; place-items: center; }
.preview img { max-width: 100%; height: auto; }
.preview pre, .preview code { background: var(--code-bg); }
.preview pre { padding: 1rem; overflow-x: auto; }
.preview table { border-collapse: collapse; } .preview td, .preview th { border: 1px solid var(--border); padding: .3rem .5rem; }
.preview blockquote { border-left: 4px solid var(--accent); margin: 1rem 0; padding: .25rem 1rem; color: var(--muted); }
.actions { margin-top: 1rem; justify-content: flex-start; }
@media (min-width: 900px) {
  .tabs { display: none; }
  .panes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
  .panes section { border-radius: 4px; }
  .panes section[hidden] { display: flex; }
}
.editor ~ * { margin-top: 1.25rem; }
.images ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1rem; }
.images li { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; }
.images img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.danger-zone { border: 1px solid var(--danger); border-radius: 4px; padding: .5rem 1rem; }
pre.log { background: var(--code-bg); padding: 1rem; overflow-x: auto; font-size: .85rem; }
dl.meta dt { font-weight: 600; margin-top: .5rem; } dl.meta dd { margin: 0; }
.history { padding-left: 1.5rem; }
.history li { padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.history li[aria-current] { font-weight: 600; border-left: 4px solid var(--accent); }
.history li[aria-current]::marker { color: var(--accent); }
.history .meta { display: block; font-weight: normal; }
.history li a { display: inline-block; padding: .3rem 0; }
pre.diff { background: var(--code-bg); padding: 1rem; overflow-x: auto; font-size: .85rem; line-height: 1.4; }
pre.diff .add { color: #14632c; background: #d8f2df; display: inline-block; width: 100%; }
pre.diff .del { color: #9a1c1c; background: #f8dcdc; display: inline-block; width: 100%; }
pre.diff .hunk { color: var(--muted); }
@media (prefers-color-scheme: dark) {
  pre.diff .add { color: #b8f0c6; background: #163d21; }
  pre.diff .del { color: #f5b5b5; background: #4a1c1c; }
}
/* Planlagt publisering i editoren: feltet og knappen på én linje, hint under. */
.schedule { justify-content: flex-start; align-items: flex-end; }
.schedule .hint { flex-basis: 100%; margin: 0; }
