/* Layout: blått toppfelt, søk + kategorier, responsivt kortrutenett; dialoger for detalj og nytt innspill */
:root {
  color-scheme: light;
  --blue: #00509e;
  --blue-tint: #e5eef8;
  --ink: #14202e;
  --muted: #566578;
  --paper: #f5f8fb;
  --surface: #ffffff;
  --line: #d5dee9;
  --band-bg: #00509e;
  --band-ink: #ffffff;
  --band-muted: #c9dcf0;
  --on-blue: #ffffff;
  --danger: #b3261e;
  --ok: #1d7a46;
  --shadow: 0 1px 2px rgba(10,30,60,.06), 0 4px 14px rgba(10,30,60,.06);
  --f-display: "Barlow Semi Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --f-body: "Open Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --blue: #6aaef0; --blue-tint: #17304d;
    --ink: #e6edf5; --muted: #9aabbe; --paper: #0d1520; --surface: #15202d;
    --line: #2a394b; --band-bg: #0a2c52; --band-ink: #ffffff; --band-muted: #a9c3df;
    --on-blue: #0b1a2b; --danger: #f2948d; --ok: #7fd3a1;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.55; }
img { max-width: 100%; }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Toppfelt */
.band { background: var(--band-bg); color: var(--band-ink); }
.band-inner { padding-block: 36px 32px; display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-end; justify-content: space-between; }
.eyebrow { font-family: var(--f-display); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--band-muted); margin-bottom: 6px; }
.band h1 { font-size: clamp(34px, 6vw, 52px); font-weight: 700; letter-spacing: -.01em; }
.band p { margin: 10px 0 0; max-width: 58ch; color: var(--band-muted); }
.band-actions { display: grid; gap: 10px; justify-items: end; }
.whoami { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; color: var(--band-muted); margin: 0; }
.linkbtn { background: none; border: none; padding: 0; color: var(--band-ink); text-decoration: underline; cursor: pointer; font-size: 13.5px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: var(--r); padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-light { background: #ffffff; color: #00509e; }
.btn-light:hover { background: #e5eef8; }
.btn-primary { background: var(--blue); color: var(--on-blue); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: transparent; border-color: var(--line); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }

.center-msg { padding-block: 60px; text-align: center; color: var(--muted); }
.login { max-width: 520px; margin: 48px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; display: grid; gap: 12px; justify-items: start; box-shadow: var(--shadow); }
.login h2 { font-size: 26px; }
.login p { margin: 0; color: var(--muted); }
.login form { display: grid; gap: 14px; width: 100%; justify-items: start; margin-top: 4px; }
.login .field { width: 100%; }
.login .formerr { color: var(--danger); }
.login .formerr:empty { display: none; }

/* Søk og filter */
.tools { padding-block: 24px 8px; display: grid; gap: 14px; }
.search { position: relative; }
.search input { width: 100%; padding: 12px 14px 12px 42px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: 16px; }
.search input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-tint); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.chip:hover { border-color: var(--blue); }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .8; }
.status { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13.5px; padding-block: 6px 14px; }
.status strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Kort */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; padding-bottom: 56px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-align: left; padding: 0; box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.card:hover { border-color: var(--blue); transform: translateY(-2px); }
.thumb { aspect-ratio: 16 / 10; width: 100%; background: var(--blue-tint); display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { font-family: var(--f-display); font-weight: 600; color: var(--blue); font-size: 15px; letter-spacing: .04em; text-transform: uppercase; padding: 12px; text-align: center; }
.thumb .badge { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.62); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tag { align-self: flex-start; font-family: var(--f-display); font-weight: 600; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); background: var(--blue-tint); padding: 2px 8px; border-radius: 4px; }
.card h3 { font-size: 21px; font-weight: 600; }
.card .excerpt { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.meta { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.empty { border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface); padding: 40px 24px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
.empty h2 { color: var(--ink); font-size: 24px; margin-bottom: 6px; }
.empty p { margin: 0 auto 16px; max-width: 52ch; }

/* Dialoger */
dialog { border: none; border-radius: 10px; padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(8,20,36,.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-titles { display: grid; gap: 6px; }
.dlg-head h2 { font-size: 26px; font-weight: 700; }
.x { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.x:hover { color: var(--ink); }
.dlg-body { padding: 18px 22px 22px; display: grid; gap: 16px; }

form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { form .row { grid-template-columns: 1fr; } }
.field { display: grid; gap: 5px; }
.field label, .field .lbl { font-weight: 600; font-size: 14px; }
.req { color: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); }
.field input[type=text], .field input[type=password], .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-tint); }
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: var(--paper); }
.drop:hover, .drop.over { border-color: var(--blue); color: var(--blue); }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.files li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r); font-size: 13.5px; }
.files .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .fs { color: var(--muted); font-variant-numeric: tabular-nums; }
.files .st.err { color: var(--danger); font-size: 12.5px; }
.files img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
progress { width: 100%; height: 8px; accent-color: var(--blue); }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; align-items: center; }
.formerr { color: var(--danger); font-size: 14px; margin: 0 auto 0 0; }

.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 14px; }
.detail-meta b { color: var(--ink); font-weight: 600; }
.detail-text { white-space: pre-wrap; margin: 0; font-size: 16px; max-width: 68ch; }
.media { display: grid; gap: 12px; }
.media img, .media video { width: 100%; max-height: 70vh; object-fit: contain; background: #000; border-radius: var(--r); display: block; }
.media audio { width: 100%; }
.media .missing { padding: 14px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); font-size: 13.5px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--r); font-weight: 600; z-index: 50; }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
